Visual Basic - Lectura BD

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

Lectura BD

Publicado por Aaron (3 intervenciones) el 09/12/2021 15:37:14
Buenas tardes:

Desde mi programa de Visual 10, me conecto a una PLC1200 con la librería libdonave.
Pretendo visualizar la lectura de un DB desde mi textbox del programa.
Llevo unos días realizando pruebas con los ejemplos que encuentro en la red, pero ninguno me ayuda lo suficiente.
Si alguno sabe como hacerlo, agradecería su ayuda.

Un saludo y gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

Lectura BD

Publicado por Aaron (3 intervenciones) el 10/12/2021 14:22:57
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
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar