Subscribing to PLC data via code

From AdvancedHMI
Revision as of 18:59, 19 January 2017 by Arj3090 (talk | contribs) (Created page with "The AdvancedHMI drivers support a subscription that will automatically poll data and return the values. The DataSubscriber provides a non-code method of using this service. Ho...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The AdvancedHMI drivers support a subscription that will automatically poll data and return the values. The DataSubscriber provides a non-code method of using this service. However, there are times when it is desired or more efficient to subscribe using code. This is an example on how to do this:


   Private SubscriptionID1 As Integer
   Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click
       SubscriptionID1 = EthernetIPforCLXCom1.Subscribe("MyTag", 1, 500, AddressOf Subscription_DataReceived)
   End Sub
   Private Sub Subscription_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs)
       Label1.Text = e.Values(0)
   End Sub
   Private Sub MainForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
       EthernetIPforCLXCom1.UnSubscribe(SubscriptionID1)
   End Sub


The rate at which date is polled is determined by the value of the PollRateOverride property.

Each driver is highly optimized for communications using subscriptions. All of the visual controls (e.g. Gauge) use the subscription mechanism to receive their data.