Author Topic: Read from an array  (Read 4413 times)

baliam

  • Newbie
  • *
  • Posts: 2
    • View Profile
Read from an array
« on: July 15, 2013, 02:08:19 PM »
I am using v3.40 of AdvancedHMI.

I have an array data structure with an array nested inside it like below:
RecipeStore[0]
     RecipeStore[0].Number
     RecipeStore[0].OD
     RecipeStore[0].Description
     RecipeStore[0].PT
          RecipeStore[0].PT.Entry
               RecipeStore[0].PT.Entry[0] - [10]
RecipeStore[1]
     RecipeStore[1].Number
     RecipeStore[1].OD
     RecipeStore[1].Description
     RecipeStore[1].PT
          RecipeStore[1].PT.Entry
               RecipeStore[1].PT.Entry[0] - [10]
and repeats to 51.

Whenever I attempt to read RecipeStore[1].OD (or anything from RecipeStore), I get the following error in VS2010.
System.OverflowException: Arithmetic operation resulted in an overflow.
   at MfgControl.AdvancedHMI.Drivers.CIP.GetTagIndex(CLXAddress TagName)
   at MfgControl.AdvancedHMI.Drivers.CIP.ReadTagValue(CLXAddress clxTag, UInt16 numberOfElements, UInt16 sequenceNumber)
   at AdvancedHMIDrivers.EthernetIPforCLXComm.ReadAny(String startAddress, Int32 numberOfElements, Boolean AsyncModeIn) in D:\Source\AdvancedHMI v340\AdvancedHMIDrivers\EthernetIPforCLXComm.vb:line 338
   at MfgControl.AdvancedHMI.RecipeForm.LoadRecipes(Int32 RecipesLoaded) in D:\Source\AdvancedHMI v340\AdvancedHMI\RecipeForm.vb:line 177

Does anyone have any thoughts or input?

dmroeder

  • Global Moderator
  • Full Member
  • *****
  • Posts: 206
    • View Profile
Re: Read from an array
« Reply #1 on: July 15, 2013, 02:19:57 PM »
Can you take a screenshot of your UDT expanded in the controller tags as well as a screenshot of the line of code you are using to read the tag?  What data types are these?
« Last Edit: July 15, 2013, 02:21:43 PM by dmroeder »

baliam

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Read from an array
« Reply #2 on: July 15, 2013, 02:39:18 PM »
I can't seem to upload any screenshots, as they keep clearing.

Visual Studio code
Code: [Select]
    Private Sub LoadRecipes(ByVal RecipesLoaded As Int32)

        Try

            For i As Int32 = RecipesLoaded To 50
                Dim plcResults As String()
                'plcResults = _syncReadPLC.ReadSynchronous("RecipeStore", 1)
                plcResults = _syncReadPLC.ReadAny("RecipeStore", 1, False)
                uxRecipeList.Items.Add(i & " - " & plcResults(0) & """ Diameter Pipe")
                RecipesLoaded += 1
            Next

            uxRecipeList.SelectedIndex = 0

        Catch ex As Exception

            Trace.WriteLine(RecipesLoaded)
            If ex.ToString().Contains("Read Failed - Status Code=-20") Then
                LoadRecipes(RecipesLoaded)
            Else
                Console.WriteLine(ex.ToString())
            End If

        End Try

    End Sub

PLC Data types
RecipeStore[0]    (RecipeStorage datatype)
     RecipeStore[0].Number    (DINT datatype)
     RecipeStore[0].OD    (Real datatype)
     RecipeStore[0].Description    (String datatype)
     RecipeStore[0].PT    (Recipe_Single datatype)
          RecipeStore[0].PT.Entry    (Real[10] datatype)
               RecipeStore[0].PT.Entry[0] - [10]    (Real datatype)

dmroeder

  • Global Moderator
  • Full Member
  • *****
  • Posts: 206
    • View Profile
Re: Read from an array
« Reply #3 on: July 15, 2013, 05:44:00 PM »
You have to write the code to read each specific tag:

Code: [Select]
plcResults = _syncReadPLC.ReadAny("RecipeStore[0].OD")
'add to your list
plcResults = _syncReadPLC.ReadAny("RecipeStore[0].Number")
'add to your list
'and so on