1
Open Discussion / Re: Micrologix 1400: Read multiples tags
« on: May 17, 2019, 12:49:31 PM »
Great contribution bachphi, regards!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Private MyEthernetIPforSLCMicroCom As AdvancedHMIDrivers.EthernetIPforSLCMicroCom = New AdvancedHMIDrivers.EthernetIPforSLCMicroCom
Private SubscriptionID As Integer
Private LastValue As String
Public Sub New()
InitializeComponent()
MyEthernetIPforSLCMicroCom.IPAddress = "10.0.0.39"
End Sub
Private Sub fm_sis_opc_test_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MyEthernetIPforSLCMicroCom.Subscribe("N150:10", 1, 500, AddressOf DataReturned)
End Sub
Private Sub DataReturned(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
Dim PlcIp As String
Dim PlcTag As String
Dim PlcValue As String
Try
Dim DriverComm As AdvancedHMIDrivers.EthernetIPforSLCMicroCom = CType(sender, AdvancedHMIDrivers.EthernetIPforSLCMicroCom)
PlcIp = DriverComm.IPAddress
PlcTag = e.PlcAddress
PlcValue = e.Values(0).ToString()
lb_estado.Text = PlcValue.ToString
Catch ex As Exception
lb_estado.Text = ex.Message
End Try
End Sub
Private Sub MainFormX_FormClosing(sender As Object, e As Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
MyEthernetIPforSLCMicroCom.UnSubscribe(SubscriptionID)
End Sub
Private MicroGuardian As AdvancedHMIDrivers.EthernetIPforSLCMicroCom = New AdvancedHMIDrivers.EthernetIPforSLCMicroCom
Private MicroTags As AdvancedHMIDrivers.EthernetIPforSLCMicroCom = New AdvancedHMIDrivers.EthernetIPforSLCMicroCom
Sub CapturarDatos()
Dim conexion As New CConexion
Dim datos As New CDatos
Dim ComandoSQL As String = ""
Dim Valores As String = ""
For Each row As DataRow In tb_det.Rows
If row.Item("habilitado") = True Then
Dim Valortag As String = MicroTags.Read(row.Item("tag"))
If Valores = "" Then
Valores = "'" & Valortag & "'"
Else
Valores = Valores & ", '" & Valortag & "'"
End If
End If
Next
ComandoSQL = "INSERT INTO " & ObjetoDB & " (" & Columnas & ") values (" & Valores & ")"
datos.ComandoSQL_opc = ComandoSQL
datos.cadena_siscon = CadenaDB
Dim resultado As Boolean = conexion.sis_opc_RegistroSQL(datos)
End Sub