Web API Read Tag Trigger Scan Class Fast Rate

I have several scales and other simple devices on the shop floor that I am connecting to the gateway via serial-IP converters to allow direct communication from the Gateway. I am integrating with another application that will read these devices via http get calls to a web API that runs on the WebDev module. I would like to have a slow poll rate to monitor if the device is up and running and trigger an alarm if not. But I need a much faster rate when being actively used. When the operator is using the scale I need it be updating 2 times a second or so. A typical use case:

  • Slow poll rate with a “Lost Connection” alarm
  • An operator starts a process step that uses the scale. The shop floor execution app will fire http get commands 1/sec requesting the scale weight to the web API. The weight is displayed live on the HMI for the operator.
    • The web API triggers the fast poll-rate
    • The web API returns the tag value and quality
    • After a timeout period, the poll rate is changed back to the slow rate
  • Variant: After a machine cycle the operator requests cycle data from the machine from the shop floor execution app. Multiple values are requested from the machine and returned to the shop floor app via web API.

There are a couple ways to go about this that have come to mind:

  • Leased Scan Class
    • Pro - Has slow and fast poll rates as desired; poll rate switches tag-by-tag
    • Con - Not sure how to trigger the fast rate without a client or designer reading the tag (see below)
  • Driven Scan Class
    • Pro - Simple to setup with a trigger tag
    • Con - To not trigger all tags on the same scan class, need one scan class per device (maintenance headache)

I have tried to setup a listener to a tag in the jython scripting using the gateway context as shown here and here, but

from com.inductiveautomation.ignition.gateway import SRContext

fails with an error of ImportError: No module named gateway when testing in the Script Console. I know that setting up a listener will require removing it as well to prevent gateway problems. It appears this method is highly cautioned by IA and others for understandable reasons.

After I create a device library, I want to have this system be very low maintenance and extremely simple to add/remove these type of devices on the shop floor. Setting up a new scan class for each device seems more complex than I’d like. Not all devices will have the same number of values returned, so I am unsure how to employ UDTs and if they would help. Much prefer a solution without 3rd party software.

Initial questions:

  • Recommendations from those who have been down a similar path?
  • Ideas on how to trigger the fast poll rate on the Leased scan class type?