Author Topic: Ethernet CLX not working on multi-form applications.  (Read 4325 times)

therobotguyllc

  • Newbie
  • *
  • Posts: 1
    • View Profile
Ethernet CLX not working on multi-form applications.
« on: March 20, 2014, 01:25:14 PM »
Greetings,

I've been using Advanced HMI for some time now and I love it. However, I'm struggling with an issue. I have a 5 form application in VB and I have a tool on each page that uses the GetTagList function, but it only works the first time I use it. Basically, no matter which for I am using, the GetTagList command doesn't work once I've used it once (on any page).

Here is the code I am using currently.
Try
            Dim tags() As MfgControl.AdvancedHMI.Drivers.CLXTag = Me.EthernetIPforCLXCom1.GetTagList
            Dim TagIndex As Integer = 0

            For Each TagID In tags
                Me.ListBox1.Items.Add(tags(TagIndex).TagName & "  " & tags(TagIndex).Instance)
                TagIndex = TagIndex + 1
            Next
            Me.ListBox1.Sorted = True
            Me.ListBox1.SelectionMode = SelectionMode.MultiExtended
            ListBox1.TopIndex = 0

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Any suggestions would be helpful. I can still use the EthernetIPforCLXCom1.Read() on all the pages without issues. But not the GetTagList. So it appears as though the driver is still working. Maybe the issue is me haha.

thanks!
Justin

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Ethernet CLX not working on multi-form applications.
« Reply #1 on: March 20, 2014, 01:35:14 PM »
Just a quick shot in the dark, but try this to see what happens:

Dim tags() As MfgControl.AdvancedHMI.Drivers.CLXTag = MainForm.EthernetIPforCLXCom1.GetTagList

shsobsidianlilly

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Ethernet CLX not working on multi-form applications.
« Reply #2 on: March 26, 2014, 12:37:05 AM »
I also have Multiple forms with no additional code and i keep getting the error "Index was outside the bounds of the array". When I goto the error list it point me to the I/P address for the form   Me.EthernetIPforCLXCom1.IPAddress = "10.16.109.131".
Any help would be nice.

Thanks Dave

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Ethernet CLX not working on multi-form applications.
« Reply #3 on: September 10, 2015, 08:54:45 AM »
I take it the Taglist is still not working. the latest version 3.99 now gives me an error "Object reference not set to an instance of an object".
Does the Taglist only get Controller tags supposedly?  Ingear has a similar UploadTags , but it also get ProgramList first.
Code: [Select]
Try
Dim MyPLC As New Controller()
Dim MyTag As Tag
MyPLC.IPAddress = "192.168.1.40"
' connect to plc
If MyPLC.Connect()<> ResultCode.E_SUCCESS Then
MessageBox.Show(MyPLC.ErrorString)
Return
End If
' upload tags
If MyPLC.UploadTags()<> ResultCode.E_SUCCESS
MessageBox.Show(MyPLC.ErrorString)
Return
End If
' get program list
Dim programList As ReadOnlyCollection(Of Logix.Program) = MyPLC.ProgramList
' iterate through program
For Each program As Logix.Program in programList
' get list of TagTemplates
Dim templateList As ReadOnlyCollection(Of TagTemplate) = program.TagsItems()
' iterate through all templates in program
For Each item As TagTemplate In templateList
If item.Name = "SomeTag" Then
MyTag = item.ToTag()
End If
Next
Next
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Ethernet CLX not working on multi-form applications.
« Reply #4 on: September 10, 2015, 09:07:05 AM »
I didn't realize this was broken by one of the upgrades. If you edit AdvancedHMiDriver\AllenBradley\EthernetIPforCLXCom.vb, and go to line 526, you can edit the code to this:
Code: [Select]
    Public Function GetTagList() As MfgControl.AdvancedHMI.Drivers.CLXTag()
        '* We must get the sequence number from the DLL
        '* and save the read information because it can comeback before this
        '* information gets put in the PLCAddressByTNS array
        Dim SequenceNumber As Integer = DLL(MyDLLInstance).GetNextTransactionNumber(32767) ' TNS1.GetNextNumber("c", MyObjectID)

        Dim SequenceByte As Integer = SequenceNumber And 255
        Requests(SequenceByte) = New List(Of CLXAddressRead)
        Requests(SequenceByte).Add(New AdvancedHMIDrivers.CLXAddressRead)
        Requests(SequenceByte)(0).TransactionNumber = CUShort(SequenceNumber)
        'Requests(SequenceNumber And 255).Responded = False

        Dim d() As MfgControl.AdvancedHMI.Drivers.CLXTag = DLL(MyDLLInstance).GetCLXTags(10, SequenceNumber, MyObjectID)

        Return d
    End Function

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Ethernet CLX not working on multi-form applications.
« Reply #5 on: September 10, 2015, 09:20:26 AM »
And to answer your question about the tags, yes it will only get Controller scope tags.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Ethernet CLX not working on multi-form applications.
« Reply #6 on: September 11, 2015, 10:19:24 PM »
Just to make sure AdvancedHMI has comparable features, the next release will be able to read Program scope tags.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Ethernet CLX not working on multi-form applications.
« Reply #7 on: September 11, 2015, 11:47:13 PM »
Good news! they ( and others) also have a property IsConnected to check for PLC connected before writing tag.  You have  ConnectionEstablished event. Right now I used that and set boolean PLCIsConnected to true.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Ethernet CLX not working on multi-form applications.
« Reply #8 on: September 12, 2015, 06:48:18 AM »
Good news! they ( and others) also have a property IsConnected to check for PLC connected before writing tag.  You have  ConnectionEstablished event. Right now I used that and set boolean PLCIsConnected to true.
A connection check is not necessary because the diver does that automatically. There is no need to connect/disconnect explicitly