Indigo JMF Subscriptions - An Example

Post Reply
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Indigo JMF Subscriptions - An Example

Post by gabrielp »

Overview
If you want to get some information from your Indigo/DFE, you can always send it a JMF. But if you are actively monitoring the status of the device, you're better off with a JMF subscription which will notify an HTTP endpoint when something changes. Below you'll find an example on how to implement a basic JMF subscription endpoint using Node.

Requirements
  • Node
  • NPM
Installation
Clone the GitHub repo (https://github.com/dominickp/JMF-Subscription).
"cd" to the repository directory and run the following to install the needed node modules:

Code: Select all

npm install winston
npm install xml2js
npm install request
You should then see a folder in your repo called "node_modules/". In the repo directory, create an additional folder called "logs/".

Configuration
Edit "JmfSubscriptionInitalize.js" and set the "idp_endpoint" variable to be the URI for your JMF device (this could be the press or DFE). Then, set the "jmf_subscription_server" to be the HTTP endpoint the JMF device should update with the subscription (should be something like 'your_local_ip:9090'). You can get a little fancier with the JMF you send to the device. In my example, I just have a basic "QueryStatus" JMF being sent from a string.

Usage
"cd" to the repository directory and run the following command:

Code: Select all

node JmfSubscriptionInitalize.js
If it worked correctly, you should see a big XML (JMF) response:
Image

Now that you have set your subscription, we need to launch our "jmf_subscription_server" to capture the messages as they are sent. Run the following command:

Code: Select all

node JmfSubscriptionServer.js
You'll see an immediate response that the server is listening to the specified port. In my example: "Server listening on: http://localhost:9090".

Now wait a bit and you'll start to see some updates in the JmfSubscriptionServer.js window:
Image

Thanks to winston, the responses are also logged in a log file in "logs/":
Image
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Indigo JMF Subscriptions - An Example

Post by gabrielp »

I've made several updates to this. It now scans your DFE for JMF-ready devices and subscribes all of them. The server now saves to a database. It's controlled via command line arguments.

https://github.com/dominickp/JMF-Subscription
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Indigo JMF Subscriptions - An Example

Post by gabrielp »

kevinjel wrote:I'm a starter with this, my understanding of a JMF is the response of what the machine has produced / done. Is there documentation how this works. and if i'm correct u do requests to the DFE?? You are displaying the status of the indigo press in the command line. is there also an option to ask for amount of copies printed of a specific job? amount of impressions, print time?

heck if that is possible, i'd love to dive into it.
You can query lots of different information. For example, the queue of the press or the status of a specific job. In the example above, I'm using a the generic basic status query. There's documentation and examples in HP's "HP Indigo JDF IDP Worker SDK" which can be found here: http://www.hpwsn.com . In the query in the example I provided, the "ProductionCounter" is the impression count and I'm sure there's a way to query a specific job to see the number of clicks.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
sander
Advanced member
Posts: 276
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: Indigo JMF Subscriptions - An Example

Post by sander »

Another way around; If you submit your JDF via a JMF with SubmitQueueEntry you can define a ReturnJMF URL. When your job is printed it returns a JDF ticket which includes clicks, start and end time, used substrate etc.

That way don't have to query the DFE, it just sends the information when the job is done.

Anyway, your script is really interesting Gabriel. Next year I need to get more information from the DFE's / Production Center so will look in your script for sure. Still figuring out if go all the way with the RestAPI or JDF/JMF, or mixed :geek:
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Indigo JMF Subscriptions - An Example

Post by gabrielp »

I've updated the repo readme with some example charts I was able to make with this data.
sander wrote:Anyway, your script is really interesting Gabriel. Next year I need to get more information from the DFE's / Production Center so will look in your script for sure. Still figuring out if go all the way with the RestAPI or JDF/JMF, or mixed :geek:
Do you know anything about the REST API for indigos? Is there an SDK? I've love to work with REST instead.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
sander
Advanced member
Posts: 276
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: Indigo JMF Subscriptions - An Example

Post by sander »

Hm, I thought the Rest API was supported by both Production Pro as Production Center. I just looked for the documentation but couldn't find any rest api info, my bad, it seems to be Production Center only.

Sorry for giving you bad hope :oops:
lombert
Member
Posts: 167
Joined: Fri Feb 04, 2011 2:31 pm
Location: Sweden

Re: Indigo JMF Subscriptions - An Example

Post by lombert »

gabrielp wrote:Configuration
Edit "JmfSubscriptionInitalize.js" and set the "idp_endpoint" variable to be the URI for your JMF device (this could be the press or DFE). Then, set the "jmf_subscription_server" to be the HTTP endpoint the JMF device should update with the subscription (should be something like 'your_local_ip:9090'). You can get a little fancier with the JMF you send to the device. In my example, I just have a basic "QueryStatus" JMF being sent from a string.
I don't knew if I missed something but I can't find "JmfSubscriptionInitalize.js".

Have downloaded 'GitHub repo (https://github.com/dominickp/JMF-Subscription)' Unpacked it @ my Application folder.

Downloaded 'Node v6.9.1 LT'S

Run 'npm install winston', 'npm install xml2js' and 'npm install request' all went OK.

Then run 'sudo npm install jmf-subscription -g'

But I can't still find "JmfSubscriptionInitalize.js" or run 'node JmfSubscriptionInitalize.js'

What have I missed? :)
Between jobs!
lombert
Member
Posts: 167
Joined: Fri Feb 04, 2011 2:31 pm
Location: Sweden

Re: Indigo JMF Subscriptions - An Example

Post by lombert »

And I tried this:

Code: Select all

jmf-spy --action=subscribe --idp http://hpro1-sm1:8080/prodflow/jmf/ --server http://192.168.30.214:9090
and gets this error:

Code: Select all

error: Error body=undefined
/usr/local/lib/node_modules/jmf-subscription/node_modules/nedb/lib/datastore.js:77
    if (err) { throw err; }
               ^

Error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/jmf-subscription/src/js/../../db/server.db'
    at Error (native)
Between jobs!
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Indigo JMF Subscriptions - An Example

Post by gabrielp »

Sorry about that, this repo has changed a little bit since I wrote this post.

Ah, it's a permissions error. It can't create the database. You could go find that folder in the error and make the ./db/server.db file writable or do the following:
- Navigate to the folder where you unpacked the JMF-Subscription code
- Run npm install in that directory
- Ensure that ./db/server.db exists and is writable. If it doesn't exist, creating an empty file and putting it there will probably work.
- Replace the commands in the readme that say "jdf-spy" with "node ./src/js/interface.js". For example:
---- jmf-spy --action=[action]
---- becomes
---- node ./src/js/interface.js --action=[action]
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
lombert
Member
Posts: 167
Joined: Fri Feb 04, 2011 2:31 pm
Location: Sweden

Re: Indigo JMF Subscriptions - An Example

Post by lombert »

Thanks!

Now it started.
Between jobs!
Post Reply