'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'
' Lee las Entradas Digitales de los Expandores
'
Public Sub Lee_Entradas_Expansores
Private Dire As Byte ' Direccion
Private Regi(1) As Byte ' Numero de Registro
Private Valor(1) As Byte ' Valor del Registro
Private Algun_Cambio As Boolean = False ' Algun Cambio en las Entradas Digitales
Private Que_Cambio As Int = 0
Private R As Byte = 0 ' Auxiliar Escritura Bus.
Private Meno_E02 As Boolean
Private Meno_E10 As Boolean
Private Meno_E11 As Boolean
Private Meno_E15 As Boolean
' Si Esta en el Menu 54.
If DISPLAY.Menu_Display = 54 Then
Meno_E02 = E02
Meno_E10 = E10
Meno_E11 = E11
Meno_E15 = E15
End If
'
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' Primer Expansor, Entradas
Dire = 32 ' 01000000 ' Direccion
Regi(0) = 0 ' 00000000 ' Registro
' Si el Estado del Expansor 32 es Correcto Intenta Leerlo
If Estado32 = True Then
' Lee el Primer Expansor, Todo Entradas
R = Bus.WriteTo(Dire,Regi)
' Lee el Valor del Registro 0
Private V32() As Byte = Bus.RequestFrom(Dire, 1)
' Si la Lectura Fue Correcta V32 Mide de largo un BYTE
If V32.Length > 0 Then
' Asigna Valor de la Lectrura
Valor(0) = V32(0)
' Revisa si hay Cambio en las entradas digitales
If EB(0) <> Valor(0) Then
Algun_Cambio = True
Que_Cambio = Que_Cambio + 1
' Asigna Valor a las entradas digitales
EB(0) = Valor(0)
If Bit.Get(Valor(0),0) = 0 Then E00 = False Else E00 = True
If Bit.Get(Valor(0),1) = 0 Then E01 = False Else E01 = True
If Bit.Get(Valor(0),2) = 0 Then E02 = False Else E02 = True
If Bit.Get(Valor(0),3) = 0 Then E03 = False Else E03 = True
If Bit.Get(Valor(0),4) = 0 Then E04 = False Else E04 = True
If Bit.Get(Valor(0),5) = 0 Then E05 = False Else E05 = True
If Bit.Get(Valor(0),6) = 0 Then E06 = False Else E06 = True
If Bit.Get(Valor(0),7) = 0 Then E07 = False Else E07 = True
End If
Else
If Error_Leer_IO = False Then
Error_Leer_IO = True
DISPLAY.Presenta_Estado_Expansores
End If
If Estado32 = True Then
Estado32 = False ' Error en el Expansor Add = 32
End If
End If
End If
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' Segundo Expansor, Entradas
Dire = 33 ' 01000010 ' Direccion
Regi(0) = 0 ' 00000000 ' Registro
' Si el Estado del Expansor 33 es Correcto Intenta Leerlo
If Estado33 = True Then
' Lee el Segundo Expansor, Todo Entradas
R = Bus.WriteTo(Dire,Regi)
' Lee el Valor del Registro 0
Private V33() As Byte = Bus.RequestFrom(Dire, 1)
' Si la Lectura Fue Correcta V33 Mide de largo un BYTE
If V33.Length > 0 Then
' Asigna Valor de la Lectrura
Valor(0) = V33(0)
' Revisa si hay Cambio en las entradas digitales
If EB(1) <> Valor(0) Then
Algun_Cambio = True
Que_Cambio = Que_Cambio + 2
EB(1) = Valor(0)
' Asigna Valor a las entradas digitales
If Bit.Get(Valor(0),0) = 0 Then E10 = False Else E10 = True
If Bit.Get(Valor(0),1) = 0 Then E11 = False Else E11 = True
If Bit.Get(Valor(0),2) = 0 Then E12 = False Else E12 = True
If Bit.Get(Valor(0),3) = 0 Then E13 = False Else E13 = True
If Bit.Get(Valor(0),4) = 0 Then E14 = False Else E14 = True
If Bit.Get(Valor(0),5) = 0 Then E15 = False Else E15 = True
If Bit.Get(Valor(0),6) = 0 Then E16 = False Else E16 = True
If Bit.Get(Valor(0),7) = 0 Then E17 = False Else E17 = True
End If
Else
If Error_Leer_IO = False Then
Error_Leer_IO = True
DISPLAY.Presenta_Estado_Expansores
End If
If Estado33 = True Then
Estado33 = False ' Error en el Expansor Add = 33
End If
End If
End If
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' Tercer Expansor, Entradas
Dire = 34 ' 01000010 ' Direccion
Regi(0) = 0 ' 00000000 ' Registro
' Si el Estado del Expansor 34 es Correcto Intenta Leerlo
If Estado34 = True Then
' Lee el Tercer Expansor, Todo Entradas
R = Bus.WriteTo(Dire,Regi)
' Lee el Valor del Registro 0
Private V34() As Byte = Bus.RequestFrom(Dire, 1)
' Si la Lectura Fue Correcta V34 Mide de largo un BYTE
If V34.Length > 0 Then
' Asigna Valor de la Lectrura
Valor(0) = V34(0)
' Revisa si hay Cambio en las entradas digitales
If EB(2) <> Valor(0) Then
Algun_Cambio = True
Que_Cambio = Que_Cambio + 4
' Asigna Valor a las entradas digitales
EB(2) = Valor(0)
If Bit.Get(Valor(0),0) = 0 Then E20 = False Else E20 = True
If Bit.Get(Valor(0),1) = 0 Then E21 = False Else E21 = True
If Bit.Get(Valor(0),2) = 0 Then E22 = False Else E22 = True
If Bit.Get(Valor(0),3) = 0 Then E23 = False Else E23 = True
If Bit.Get(Valor(0),4) = 0 Then E24 = False Else E24 = True
If Bit.Get(Valor(0),5) = 0 Then E25 = False Else E25 = True
If Bit.Get(Valor(0),6) = 0 Then E26 = False Else E26 = True
If Bit.Get(Valor(0),7) = 0 Then E27 = False Else E27 = True
End If
Else
If Error_Leer_IO = False Then
Error_Leer_IO = True
DISPLAY.Presenta_Estado_Expansores
End If
If Estado34 = True Then
Estado34 = False ' Error en el Expansor Add = 34
End If
End If
End If
' Si Hay algun Cambio en las entradas Digitales
If Algun_Cambio= True Then
' Si esta en la Pantalla 22. Ver Entradas Digitales
If DISPLAY.Menu_Display = 22 Then
' Actualiza Display
DISPLAY.Menu_22(Que_Cambio)
End If
End If
' Si Esta en el Menu 54 y Hay algun Cambio lo Actualiza
If DISPLAY.Menu_Display = 54 Then
If Meno_E02 <> E02 Then Cambio_E02 = True
If Meno_E10 <> E10 Then Cambio_E10 = True
If Meno_E11 <> E11 Then Cambio_E11 = True
If Meno_E15 <> E15 Then Cambio_E15 = True
End If
End Sub