Author Topic: Datasubscriber 2 doesn't change with datachange event  (Read 1498 times)

lonconao

  • Newbie
  • *
  • Posts: 11
    • View Profile
Datasubscriber 2 doesn't change with datachange event
« on: August 12, 2021, 03:58:27 PM »
Hello guys

Waiting for you to be well, I write to ask for your help.

I have been doing some tests for a program that I am doing based on Arduino and I have the following problem

When using Datasubscriber 2 with the DataChange event manipulator it seems to me that the values ​​change only once, although according to the microcontroller screen is constantly changing. I use a label to corroborate if it is true and apparently it is so. I have also used the system debugger and the same. I attach the code and some screenshots waiting for some help from you. I can not know if it is a problem of the label or it is that the values ​​are updated only once.

Code: [Select]
    Private Sub DataSubscriber21_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataChanged

        Dim p(12) As Double

        If e.Values IsNot Nothing Then
            Me.Label5.Text = ""
            For i = 0 To 11
                p(i) &= CType(e.Values(i), Double) / 10.0
                Me.Label5.Text &= p(i) & Environment.NewLine
                'Me.Label5.Refresh()
            Next
        End If
    End Sub

https://ibb.co/PDfztWQ
https://ibb.co/XV7GHqZ
https://ibb.co/jTHNhGs

lonconao

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Datasubscriber 2 doesn't change with datachange event
« Reply #1 on: August 12, 2021, 04:10:32 PM »
Oh boy, i found the solution. Event handler is datareturned not datachange.

Even so, I ask, DataChange manipulates the information that goes from the master to the slave stations?

Thanks

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Datasubscriber 2 doesn't change with datachange event
« Reply #2 on: August 14, 2021, 02:54:09 AM »
The DataReturned event is set to fire continuously, whenever values from the PLC are returned, while the DataChanged event only fires when those returned values have changed, something like this:

Returned Values     DataReturned     DataChanged

0, 0, 0, 0, 0, 0       fires                   fires
0, 0, 0, 0, 0, 0       fires
0, 0, 0, 0, 0, 0       fires
0, 0, 0, 0, 0, 0       fires
0, 0, 1, 0, 1, 0       fires                   fires
0, 0, 1, 0, 1, 0       fires
0, 0, 1, 0, 1, 0       fires
0, 0, 1, 0, 1, 0       fires
0, 0, 1, 0, 1, 0       fires

With the DataChanged event, the GUI gets updated only when the values have changed which gives the GUI time to do other things.
« Last Edit: August 14, 2021, 02:56:57 AM by Godra »