Author Topic: write CLX tag from BasicDataLogger2  (Read 1306 times)

hayen

  • Newbie
  • *
  • Posts: 5
    • View Profile
write CLX tag from BasicDataLogger2
« on: December 07, 2022, 06:00:29 AM »
I have been testing the software for logging events from a CLX PLC.
It works ell enough, but some of the targeted events are too quick to be captured.
I have setup buffering on the PLC side using FiFo instructions, and I am looking for a way to set a flag on the PLC after each logging event. This flag will allow the PLC to extract a buffered event and make it available for data polling.

I was thinking of setting up a public event on the main form and add an event trigger from the BasicDataLogger2.
(The trigger would be inserted in the "StoreValue" method below.
Is there a simpler method that I am missing?

Code: [Select]
Private Sub StoreValue()
        Try
            If Not m_PauseLogging Then
                Dim StringToWrite As String = m_Prefix
                If m_TimeStampFormat IsNot Nothing AndAlso (String.Compare(m_TimeStampFormat, "") <> 0) Then StringToWrite &= Date.Now.ToString(m_TimeStampFormat)


                For Each item In PLCAddressValueItems
                    If item.ScaleFactor = 1 Then
                        StringToWrite &= "," & item.LastValue '& item.Name & ":"
                    Else
                        Try
                            StringToWrite &= "," & item.LastValue * item.ScaleFactor ' & item.Name & ":"
                        Catch ex As Exception
                            StringToWrite &= "," & "INVALID-Check scale factor-" & item.LastValue
                        End Try
                    End If
                Next
                sw.WriteLine(StringToWrite)
                sw.Flush()
                ' set the read flag complete on the PLC tag

            End If
        Catch ex As Exception
        End Try
    End Sub

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: write CLX tag from BasicDataLogger2
« Reply #1 on: December 07, 2022, 08:50:53 AM »
What is too fast to be captured? You can use the PollRateOverride to get faster updates from the PLC if the PLC is fast enough and there is enough network bandwidth. In the ideal scenario you can get up to 2ms updates.

hayen

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: write CLX tag from BasicDataLogger2
« Reply #2 on: December 08, 2022, 05:20:38 AM »
Hi Archie,
I did try lowering the polling rate, this was not sufficent to reliably capture the targetted events.
In particular, one of of them is an immediate output that stays on for a single scan time.
I sould add that the network load will increase with an upcoming project as different modules will become interconnected.

What I am looking for is a way to access the  EthernetIPforCLXCom component (placed on the main form as "EthernetIPforCLXCom1" from outside the main form (in this case either the datalogger2 of a function called from the datalogger2), in order to excecute the following write:
EthernetIPforCLXCom1.Write("EventReadConfirmation", "1").

Regards,

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: write CLX tag from BasicDataLogger2
« Reply #3 on: December 08, 2022, 09:03:26 AM »
What I am looking for is a way to access the  EthernetIPforCLXCom component (placed on the main form as "EthernetIPforCLXCom1" from outside the main form (in this case either the datalogger2 of a function called from the datalogger2), in order to excecute the following write:
EthernetIPforCLXCom1.Write("EventReadConfirmation", "1").
If you want to access the driver from another form you would use

MainForm.EthernetIPforCLXCom1.Write("EventReadConfirmation", "1")

If you want to access the driver from inside a component, there is a property ComComponent (m_ComComponent) that references the driver.

hayen

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: write CLX tag from BasicDataLogger2
« Reply #4 on: December 08, 2022, 11:04:51 AM »
Archie,

I can see the m_ComComponent variable being used in the "DataSubscriber2" class and the "Datalogger2" inherits from it.
I assume it depend s on the following: "Imports System.ComponentModel" at the top of the "DataSubsriber2" class.

Below is what I have in the "Datalogger2" class, with the write statement below the comment   ' set the read flag complete on the PLC tag

Code: [Select]
Private Sub StoreValue()
        Try
            If Not m_PauseLogging Then
                Dim StringToWrite As String = m_Prefix
                If m_TimeStampFormat IsNot Nothing AndAlso (String.Compare(m_TimeStampFormat, "") <> 0) Then StringToWrite &= Date.Now.ToString(m_TimeStampFormat)


                For Each item In PLCAddressValueItems
                    If item.ScaleFactor = 1 Then
                        StringToWrite &= "," & item.LastValue '& item.Name & ":"
                    Else
                        Try
                            StringToWrite &= "," & item.LastValue * item.ScaleFactor ' & item.Name & ":"
                        Catch ex As Exception
                            StringToWrite &= "," & "INVALID-Check scale factor-" & item.LastValue
                        End Try
                    End If
                Next
                sw.WriteLine(StringToWrite)
                sw.Flush()
                ' set the read flag complete on the PLC tag
                If m_ComComponent IsNot Nothing Then
                    'MainForm.EthernetIPforCLXCom1.Write("EventReadConfirmation", "1")
                    'm_CommComponent.Write("EventReadConfirmation", "1")
                    m_ComComponent.Write("EventReadConfirmation", "1")
                End If
            End If
        Catch ex As Exception
        End Try
    End Sub

The "m_ComComponent" generates the following ompile error:
'AdvancedHMIControls.DataSubsriber2.m_ComComponent' is not accessible in this context because it is private

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: write CLX tag from BasicDataLogger2
« Reply #5 on: December 08, 2022, 11:15:12 AM »
Use the property name and not the field directly

                    ComComponent.Write("EventReadConfirmation", "1")

hayen

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: write CLX tag from BasicDataLogger2
« Reply #6 on: December 08, 2022, 11:32:20 AM »
That will compile.
Many thanks!

I was searching for such a property before posting and was unable to find it.
Where is it defined?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: write CLX tag from BasicDataLogger2
« Reply #7 on: December 08, 2022, 11:37:58 AM »
It's in the DataSubscriber2. All AdvancedHMI controls that use data from the PLC have that property to tell it which driver to use. That is the property that allows you to have multiple drivers on one form and different controls to get data from multiple PLCs.

hayen

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: write CLX tag from BasicDataLogger2
« Reply #8 on: December 08, 2022, 11:41:00 AM »
I had missed the "PLC related properties" region...
Thanks again for your help and also for this project.