Author Topic: Copying 2 dimensional array from plc to another plc  (Read 874 times)

cjmcc

  • Newbie
  • *
  • Posts: 4
    • View Profile
Copying 2 dimensional array from plc to another plc
« on: October 01, 2021, 12:27:24 PM »
I am trying to send data from one plc to another plc, eventually it will be multiple. This is the code I have now, but I know that there has to be a better way to process this much data, hopefully a faster way as well. I have seen subscriptions used, but am unsure how to implement. Any ideas would be appreciated.

Code: [Select]
  Private Sub SendDataToController1()
        loading.Show()
        Dim i1, i2, As Integer
        Try
            For i1 = 1 To 15
                For i2 = 1 To 8
                    Group00SchDataFromMain(15, 8) = MainShopController.Read("Group00ScheduleData[" & i1 & "," & i2 & "]")
                    Group01SchDataFromMain(15, 8) = MainShopController.Read("Group01ScheduleData[" & i1 & "," & i2 & "]")
                    Group02SchDataFromMain(15, 8) = MainShopController.Read("Group02ScheduleData[" & i1 & "," & i2 & "]")
                    Group03SchDataFromMain(15, 8) = MainShopController.Read("Group03ScheduleData[" & i1 & "," & i2 & "]")
                    Group04SchDataFromMain(15, 8) = MainShopController.Read("Group04ScheduleData[" & i1 & "," & i2 & "]")
                    Group05SchDataFromMain(15, 8) = MainShopController.Read("Group05ScheduleData[" & i1 & "," & i2 & "]")
                    Group06SchDataFromMain(15, 8) = MainShopController.Read("Group06ScheduleData[" & i1 & "," & i2 & "]")
                    Group07SchDataFromMain(15, 8) = MainShopController.Read("Group07ScheduleData[" & i1 & "," & i2 & "]")
                    Group08SchDataFromMain(15, 8) = MainShopController.Read("Group08ScheduleData[" & i1 & "," & i2 & "]")
                    Group09SchDataFromMain(15, 8) = MainShopController.Read("Group09ScheduleData[" & i1 & "," & i2 & "]")
                    Group10SchDataFromMain(15, 8) = MainShopController.Read("Group10ScheduleData[" & i1 & "," & i2 & "]")
                    Group11SchDataFromMain(15, 8) = MainShopController.Read("Group11ScheduleData[" & i1 & "," & i2 & "]")
                    Group12SchDataFromMain(15, 8) = MainShopController.Read("Group12ScheduleData[" & i1 & "," & i2 & "]")
                    Group13SchDataFromMain(15, 8) = MainShopController.Read("Group13ScheduleData[" & i1 & "," & i2 & "]")
                    Group14SchDataFromMain(15, 8) = MainShopController.Read("Group14ScheduleData[" & i1 & "," & i2 & "]")
                    Group15SchDataFromMain(15, 8) = MainShopController.Read("Group15ScheduleData[" & i1 & "," & i2 & "]")
                    Controller1.Write("Group00ScheduleData[" & i1 & "," & i2 & "]", Group00SchDataFromMain(15, 8))
                    Controller1.Write("Group01ScheduleData[" & i1 & "," & i2 & "]", Group01SchDataFromMain(15, 8))
                    Controller1.Write("Group02ScheduleData[" & i1 & "," & i2 & "]", Group02SchDataFromMain(15, 8))
                    Controller1.Write("Group03ScheduleData[" & i1 & "," & i2 & "]", Group03SchDataFromMain(15, 8))
                    Controller1.Write("Group04ScheduleData[" & i1 & "," & i2 & "]", Group04SchDataFromMain(15, 8))
                    Controller1.Write("Group05ScheduleData[" & i1 & "," & i2 & "]", Group05SchDataFromMain(15, 8))
                    Controller1.Write("Group06ScheduleData[" & i1 & "," & i2 & "]", Group06SchDataFromMain(15, 8))
                    Controller1.Write("Group07ScheduleData[" & i1 & "," & i2 & "]", Group07SchDataFromMain(15, 8))
                    Controller1.Write("Group08ScheduleData[" & i1 & "," & i2 & "]", Group08SchDataFromMain(15, 8))
                    Controller1.Write("Group09ScheduleData[" & i1 & "," & i2 & "]", Group09SchDataFromMain(15, 8))
                    Controller1.Write("Group10ScheduleData[" & i1 & "," & i2 & "]", Group10SchDataFromMain(15, 8))
                    Controller1.Write("Group11ScheduleData[" & i1 & "," & i2 & "]", Group11SchDataFromMain(15, 8))
                    Controller1.Write("Group12ScheduleData[" & i1 & "," & i2 & "]", Group12SchDataFromMain(15, 8))
                    Controller1.Write("Group13ScheduleData[" & i1 & "," & i2 & "]", Group13SchDataFromMain(15, 8))
                    Controller1.Write("Group14ScheduleData[" & i1 & "," & i2 & "]", Group14SchDataFromMain(15, 8))
                    Controller1.Write("Group15ScheduleData[" & i1 & "," & i2 & "]", Group15SchDataFromMain(15, 8))
                Next
            Next
        Catch ex As Exception
            MsgBox("Failed to read or write PLC Data")
        End Try
        loading.Close()
    End Sub   
« Last Edit: October 01, 2021, 12:32:37 PM by cjmcc »