Imports System.Windows.Forms
Imports System.Threading
Imports System
Imports System.IO
Imports System.Collections
Public Class Form1
' PRUEBAS LECTURA DE DB DESDE PLC1200
Public BufferLectura(1000) As String
Dim Respuesta As Integer
Private fds As libnodave.daveOSserialType
Private di As libnodave.daveInterface
Private dc As libnodave.daveConnection
' Mas pruebas diferenes
Dim conexionDB As Libnodave_WinAC
' Conexion automata
Dim LND_WinAC As Libnodave_WinAC 'Libreria con las funciones de comunicacion,
' Bits de estado para el automata
Dim PLC_CYCLE As Byte
Dim PLC_NUM_MODEL As Byte
Dim PLC_TRIGGER_VISION As Byte
Dim PLC_STATUS_VISION As Byte
Dim PLC_RESET_VISION As Byte
Dim PLC_TRIGER_CODE_QR As Byte
'Variables anulaciones
Dim Anulaciones(9) As Char
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If LND_WinAC Is Nothing Then
LND_WinAC = New Libnodave_WinAC
End If
' Conecta con PLC sería ( puerto , IP , y Rack y Slot)
LND_WinAC.Conectar(102, "192.168.0.1", 0, 1)
If LND_WinAC.Conectado Then
TextBox1.BackColor = Color.Green
Timer1.Enabled = True
LND_WinAC.BufferEscritura(0) = 1
LND_WinAC.BufferEscritura(1) = 0
LND_WinAC.BufferEscritura(2) = 1
LND_WinAC.BufferEscritura(3) = 0
LND_WinAC.EscribirBytesDB(23, 10, 190)
' coger el DB del PLC y escribir las lineas que se quiera NO me lo hace
Else
MsgBox("No hay conexion con el automata", MsgBoxStyle.Information, "")
End If
' Quiero que cuando leea y este bien,OK y si no NOK
If TextBox1.BackColor = Color.Green Then
PictureBox2.Image = Aaron_1200_QR.My.Resources.OOK
Else
PictureBox2.Image = Aaron_1200_QR.My.Resources.NOKK
End If
End Sub
Private Function UnicodeStringToBytes(ByVal str As String) As Byte()
' Convierte string en array de bits
Return System.Text.Encoding.Unicode.GetBytes(str)
End Function
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
' Dim LeerBytesDB As String
' LND_WinAC.BufferLectura(0) = 1
'LND_WinAC.BufferLectura(1) = 0
'LND_WinAC.BufferLectura(2) = 1
'LND_WinAC.BufferLectura(3) = 0
'LND_WinAC.LeerBytesDB(23, 10, 190)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'del DB (EL QUE SEA) del PLC lo que vamos a leer
conexionDB = New Libnodave_WinAC
conexionDB.LeerBytesDB(23, 0, 1)
TextBox2.Text = conexionDB.BufferLectura(1)
End Sub
End Class