Author Topic: Data Subscribe programmatically - Data Change only  (Read 888 times)

jslate

  • Newbie
  • *
  • Posts: 1
    • View Profile
Data Subscribe programmatically - Data Change only
« on: January 23, 2017, 06:33:57 AM »
Hi

Is it possible to use the DataChanged event of the datasubscriber programmatically?
My code is below.

public MainForm()
        {           
            InitializeComponent();                 
            SubscriptionID = modbusTCPCom1.Subscribe("425000", 1, 500,SubscribedDataChanged);         
        }

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
           modbusTCPCom1.Unsubscribe(SubscriptionID);
        }

        private void SubscribedDataChanged(object sender,MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs e)
        {
           string mystring = e.Values[0];
         string myaddress = e.PlcAddress;
        }

Thanks

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5271
    • View Profile
    • AdvancedHMI
Re: Data Subscribe programmatically - Data Change only
« Reply #1 on: January 23, 2017, 08:11:27 AM »
When subscribing with the driver via code, the event is fired every time data is returned, not only when it changes. The DataChanged is only a function of the DataSubscriber component.

rmac

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Data Subscribe programmatically - Data Change only
« Reply #2 on: March 07, 2017, 01:58:03 PM »
Private Sub DataSubscriber21_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataChanged

Runs as many time as elements I have in the Datasubscriber PLCAddressValueItems collection, even if their status don't change.
Is that the way it should work?

rmac

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Data Subscribe programmatically - Data Change only
« Reply #3 on: March 07, 2017, 02:07:13 PM »