How-To Guides
DeviceHub Guides

Use the Poll-Once Topic to Manually Retrieve Register Values

3min

Notes:

  • You need to follow the following guidelines for topic names: Subject-Based Messaging.
  • When publishing structured data such as JSON, you must convert to a byte array (string) first. To do this in a flow, you can use the json node.

You can use the Poll-once topic to retrieve a register value when an event occurs. The Poll-once topic will manually trigger the polling of register values.

User Scenario

You don’t need to have real-time monitoring for a PLC, and you only need to get register values when a specific event is triggered, thereby reducing unnecessary network traffic. You therefore use the Poll-once topic to retrieve these event-triggered register values.

Set Up and Use the Poll-Once Topic

To set up and use the Poll-once topic:

  1. Follow the steps to Connect a Device. For this user scenario, a Simulator Generator device is used.
  2. Follow the steps to Add Tags and create one tag with the following parameters.
    • Name: S - Random value generator
    • Value Type: int64
    • Polling Interval: 0
    • Tag Name: Enter a name for the tag.
    • Address: 1
  3. Click the Copy icon for the tag's RAW Topic. You will refer to this later.

    Copy RAW Topic icon
    Copy RAW Topic icon
    
  4. Click the Action menu for the tag and select View Poll Topic. The Poll Once dialog box displays.

    The View Poll Topic option
    The View Poll Topic option
    
  5. Click the Copy icon for the tag. You will refer to this later.

    Document image
    
  6. Navigate to Flows Manager.
  7. For a Flows Manager, click the Go To Flow Definition icon. The Flow canvas opens in a new browser tab.

    Go To Flow Definition icon
    Go To Flow Definition icon
    
  8. On the Flow canvas, drag the inject node and DataHub Publish node onto the canvas. Then, connect the two nodes.

    The inject and DataHub Publish nodes
    The inject and DataHub Publish nodes
    
  9. Double-click the DataHub Publish node. The Edit DataHub Publish node dialog box displays.
    • In the Topic field, paste the Poll-once topic you copied in step 5.
    • If needed, configure the Datahub Subscribe connection. See the Step 3: Configure Connector Nodes section in Create a Flow to learn more.
    • Click Done.
  10. Drag the DataHub Subscribe node and debug node onto the canvas.

    The DataHub Subscribe and debug nodes
    The DataHub Subscribe and debug nodes
    
  11. Double-click the DataHub Subscribe node. The Edit DataHub Subscribe node dialog box displays.
    • In the Topic field, paste the Raw Topic you copied in step 2.
    • Click Done, and then Deploy.
  12. Expand the message window beneath the flow.

    The message window
    The message window
    
  13. Click the Debug icon to view messages from the debug node.

    The debug icon
    The debug icon
    
  14. Click the Inject button. This triggers the timestamp message, which will then trigger the poll once tag to be activated.

    The nject button
    The nject button
    
  15. Confirm the Debug node is activated.

    The Activate Debug button
    The Activate Debug button
    
  16. The debug window displays a "success" :true message, which means the poll-once tag successfully polled the device and displayed the data for the tag.

    Document image
    

The rest of the payload displays the following information for the tag:

  • Data Type: The data type configured for the tag you created in step 1.
  • Timestamp: Date and time data for the poll-once message.
  • Register ID: The register ID for the tag generated in Manufacturing Connect Edge.
  • Value: The value generated for the tag when the poll was triggered. Since the tag was configured with S - Random value generator, a random value is generated.
  • Device ID: The device ID for the DataHub device generated in Manufacturing Connect Edge.
  • Tag Name: The name you configured for the tag.
  • Device Name: The name you configured for the device.
  • Description: The description you entered for the tag. Since no description was entered for the tag in this use case, no value was displayed.
  • Metadata: The meta data configured for the tag. Since no meta data was configured for the tag in this use case, no value was displayed.