Author Topic: EthernetIPforCLXCom1.DataReceived Event  (Read 1323 times)

Conor_Hyland

  • Newbie
  • *
  • Posts: 12
    • View Profile
EthernetIPforCLXCom1.DataReceived Event
« on: September 18, 2019, 06:12:49 PM »
Hello Everyone,

I have been testing my graph code using a timer on my development machine and it worked perfect.
I have since copied the code to the EthernetIPforCLXCom1.DataReceived event and i am getting strange results on a virtual machine.

(1) Does the EthernetIPforCLXCom1.DataReceived event fire only on the poll rate override interval of the driver, regardless of whether it is reading from 1 tag or 5 tags? i.e. will it fire once only for all 5 tags together, or will it fire 5 times one for each tag?

(2) I am experiencing weird behaviour using a virtual machine over a network - my code worked perfect locally using a timer to fire the plotting of the lines, but since i changed the plotting to the DataReceived event, weird stuff is happening that i can't explain - would you recommend using my analysis program for short term monitoring on a VM? It may very well be a bug in my code somewhere also, but it's pretty much the same code in the timer tick event as in the DataReceived event.

(3) See my 2 starred (*****) comments below in the code. Can you do this in each case:

Code: [Select]
Private Sub EthernetIPforCLXCom1_DataReceived(sender As Object, e As PlcComEventArgs) Handles EthernetIPforCLXCom1.DataReceived

  If Recording Then

            TimeNowAsDate = Now
            Dim TimeNow As String = TimeNowAsDate.ToString("HH:mm:ss")

‘Currently reading value from SevenSegments
          Chart1.Series(0).Points.AddXY(TimeNow, SevenSegment1.Value)
              Chart1.Series(1).Points.AddXY(TimeNow, SevenSegment2.Value)
              Chart1.Series(2).Points.AddXY(TimeNow, SevenSegment3.Value)
            Chart1.Series(3).Points.AddXY(TimeNow, SevenSegment4.Value)
            Chart1.Series(4).Points.AddXY(TimeNow, SevenSegment5.Value)

‘*****Can you do this, i.e. is e.values() an array?
Chart1.Series(0).Points.AddXY(TimeNow, e.values(0))
              Chart1.Series(1).Points.AddXY(TimeNow, e.values(1))
              Chart1.Series(2).Points.AddXY(TimeNow, e.values(2))
            Chart1.Series(3).Points.AddXY(TimeNow, e.values(3))
            Chart1.Series(4).Points.AddXY(TimeNow, e.values(4))

‘*****Or this?
Chart1.Series(0).Points.AddXY(TimeNow, EthernetIPforCLXCom1.Read(“Tag Address 1”))
              Chart1.Series(1).Points.AddXY(TimeNow, EthernetIPforCLXCom1.Read(“Tag Address 2”))
              Chart1.Series(2).Points.AddXY(TimeNow, EthernetIPforCLXCom1.Read(“Tag Address 3”))
            Chart1.Series(3).Points.AddXY(TimeNow, EthernetIPforCLXCom1.Read(“Tag Address 4”))
            Chart1.Series(4).Points.AddXY(TimeNow, EthernetIPforCLXCom1.Read(“Tag Address 5”))
           
    End If
End Sub

Thanks Folks,
Regards,
Conor

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforCLXCom1.DataReceived Event
« Reply #1 on: September 18, 2019, 09:27:33 PM »
The DataReceived event will try to fire at the PollrateOverride interval and one time for each subscription. It is synchronized with the UI thread, so with it firing too frequently or having more code than it can process before the next fire can cause issues on the UI.

Conor_Hyland

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: EthernetIPforCLXCom1.DataReceived Event
« Reply #2 on: September 24, 2019, 01:50:46 PM »
Hi Archie,

We have eliminated the need for a virtual machine now which is good.

1) OK, so if there is a way I can check what the sender object is I could possibly do something like the following?:

Code: [Select]
Private Sub EthernetIPforCLXCom1_DataReceived(sender As Object, e As PlcComEventArgs) Handles EthernetIPforCLXCom1.DataReceived

    If sender is Xxxxx then
        Chart1.Series(0).Points.AddXY(TimeNow, e.values(0))
    ElseIf sender is Yyyyy then
        Chart1.Series(1).Points.AddXY(TimeNow, e.values(0))
    ElseIf sender is Zzzzz then
        Chart1.Series(2).Points.AddXY(TimeNow, e.values(0))
    EndIf

End Sub

2) What does the SubscriptionDataReceived event do so?

I can't check this on the machine, so I must have it pretty much bug free before i can connect to the PLC and start gathering data.

Thanks,
Conor

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforCLXCom1.DataReceived Event
« Reply #3 on: September 24, 2019, 02:39:17 PM »
The sender object is the driver instance. If you are routing all of your driver instance events to a single event handler, you would use your driver instance names:
Code: [Select]
If sender is EthernetIPForCLXCom1 then
        Chart1.Series(0).Points.AddXY(TimeNow, e.values(0))
    ElseIf sender is EthernetIPForCLXCom2 then
        Chart1.Series(1).Points.AddXY(TimeNow, e.values(0))
    ElseIf sender is EthernetIPForCLXCom3 then

Maybe your intention is to return particular addresses to each chart:
Code: [Select]
If e.PLCAddress="MyTag" then
        Chart1.Series(0).Points.AddXY(TimeNow, e.values(0))
    ElseIf e.PLCAddress="MyTag2" then
        Chart1.Series(1).Points.AddXY(TimeNow, e.values(0))
    ElseIf e.PLCAddress="MyTag3" then
The SubscriptionDataReceived only returns data from subscriptions and not from the Read method.