Jump to content

foxxs

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by foxxs

  1. I'm actually not familiar with plc.readwrite, are their any examples on the forms somewhere, or maybe an API i could work with. im trying to get listen mode to work as well (cant seem to get my program to actually LISTEN on a port)? i was not able to find any detailed documentation on ether subject for .net, though admittedly i may be looking in the wrong places.

    thank you for your help!

  2. I've created a fairly workable application to retrieve data from the data tables of the PLC's (PL-570) i'm working with, however I would like to also be able to gather all of the operands (MB, MI, SI, etc) as well, and format them into organized datagridviews in vb.net. I'd like to use a similar method as I've used for the tables if possible:

       Public Sub ReadDataTables(IP As String, port As Integer, protocal As EthProtocol, retries As Integer, timeoutMs As Integer)
           Dim frmClockTables As New Form
           Dim Tabs As New TabControl
           frmClockTables.Controls.Add(Tabs)
           Tabs.Dock = DockStyle.Fill
           Try
               ethernet1 = New Ethernet(IP, port, protocal, retries, timeoutMs)
               plc1 = PLCFactory.GetPLC(ethernet1, 0)
               dtTables = New DataTables(plc1, DataTablesReadOptions.StructureAndValues)
           Catch ex As Exception
               MessageBox.Show("Could not connect to " & IP & " on port " & port)
           End Try
           Try
               ethernet1 = New Ethernet(IP, port, protocal, retries, timeoutMs)
               plc1 = PLCFactory.GetPLC(ethernet1, 0)
               dtTables = New DataTables(plc1, DataTablesReadOptions.StructureAndValues)
           Catch ex As Exception
               MessageBox.Show("Could not connect to " & IP & " on port " & port)
           End Try
    
           Dim colcount As Integer = 0
           Dim rowcount As Integer = 0
           For Each item In dtTables.Tables
               Dim data As New DataGridView
               Dim tab As New TabPage
               tab.Text = item.Name.ToString
               tab.Controls.Add(data)
               data.Dock = DockStyle.Fill
               Tabs.TabPages.Add(tab)
               colcount = item.Columns.Count
               rowcount = item.Rows.Count
    
               Dim i As Integer = 0
               For Each column In item.Columns
                   data.ColumnCount = colcount
                   data.RowCount = rowcount
                   data.Columns(i).Name = column.Name.ToString
                   For Each Cell In column.Cells
                       Dim cellvalue As String = ""
                       For Each Field In Cell.Fields
                           If Not cellvalue = "" Then
                               cellvalue &= ";"
                           End If
                           cellvalue &= Field.Value
                       Next
                       data.Rows(Cell.RowIndex).Cells(Cell.ColumnIndex).Value = cellvalue
                   Next
                   i += 1
               Next
               NumberAllRows(data)
           Next
           frmClockTables.Show()
       End Sub

    how can this be done, or can it be done at all?

×
×
  • Create New...