Sub Process_Globals
Private server As ServerSocket
Dim output As String
Dim monitor1 As String
Private rp As RuntimePermissions
End Sub
Sub Globals
Private astream As AsyncStreams
Private ser As B4RSerializator
Public connected As Boolean
Dim ImgToggleButtonLED1 As BitmapDrawable
Private Button1 As Button
Private Button2 As Button
Private Button3 As Button
Private ToggleButton1 As ToggleButton
Private LabelAlertaImage As Label
Private LabelAlertaText As Label
Private LabelAlertaText1 As Label
Private TabHost1 As TabHost
Private LabelMONITOR As Label
Private RadioButton1 As RadioButton
Private RadioButton2 As RadioButton
Private Panel3 As Panel
Private PanelPAG3 As Panel
Private LabelPARADA As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Titulo")
ser.Initialize
TabHost1.AddTab("MONITORIZAR", "MONITORIZAR.Bal")
TabHost1.AddTab("PARAR", "Parada.Bal")
TabHost1.AddTab("LLAMAR", "LLamada.Bal")
ImgToggleButtonLED1.Initialize(LoadBitmap(File.DirAssets, "setaOFF.png"))
ImgToggleButtonLED1.Gravity = Gravity.FILL
ToggleButton1.Background = ImgToggleButtonLED1
server.Initialize(51042, "server")
server.Listen
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
'
End Sub
private Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
' Log($"NewConnection: ${Successful}"$)
If Successful Then
connected = True
If astream.IsInitialized Then astream.Close
astream.Initialize(NewSocket.InputStream, NewSocket.OutputStream, "astream")
End If
End Sub
Private Sub AStream_NewData (Buffer() As Byte)
Dim objects() As Object = ser.ConvertBytesToArray(Buffer)
For Each o As Object In objects
' Log(o)
Select Case o
Case "paro1T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 1"
LabelAlertaText1.Text= "CERRADURA"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text= "1"
monitor1 = "666332938"
RadioButton1.Checked=True
LabelPARADA.Visible=True
Case "paro2T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 1"
LabelAlertaText1.Text= "SETA MOTOR"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="1"
monitor1 = "666332938"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro3T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 1"
LabelAlertaText1.Text= "POCAYOKE ANTIPIN"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="1"
monitor1 = "666332938"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro4T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 1"
LabelAlertaText1.Text= "TORNILLO MASA"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="1"
monitor1 = "666332938"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro5T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 1"
LabelAlertaText1.Text= "PRISIONERO DERECHA"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="1"
monitor1 = "666332938"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro6T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 1"
LabelAlertaText1.Text= "SETA LEBOMAT TRASERA DERECHA"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="1"
monitor1 = "666332938"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro7T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 1"
LabelAlertaText1.Text= "FINAL DE CARRERA DELANTERA IZQUIERDA"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="1"
monitor1 = "666332938"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro8T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 2"
LabelAlertaText1.Text= "ASIENTO TRASERO"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="2"
monitor1 = "651422831"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro9T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 2"
LabelAlertaText1.Text= "ASIENTO DELANTERO"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="2"
monitor1 = "651422831"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro10T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 2"
LabelAlertaText1.Text= "ROBOT"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="2"
monitor1 = "651422831"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro11T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 2"
LabelAlertaText1.Text= "FINAL DE CARRERA MANIPULADOR IZQUIERDA"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="2"
monitor1 = "651422831"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro12T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 2"
LabelAlertaText1.Text= "POKAYOKE TAPONES"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="2"
monitor1 = "651422831"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro13T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 2"
LabelAlertaText1.Text= "STRAIKER DERECHA"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="2"
monitor1 = "651422831"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "paro14T"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO ZONA 2"
LabelAlertaText1.Text= "MASA CAPO"
LabelAlertaText.TextColor = Colors.Red
LabelAlertaText1.TextColor = Colors.Red
LabelMONITOR.Text="2"
monitor1 = "651422831"
RadioButton2.Checked=True
LabelPARADA.Visible=True
Case "SETA"
LabelAlertaImage.Text=Chr(0xE002)
LabelAlertaImage.TextColor = Colors.Red
LabelAlertaText.Text= "PARO SETA APP"
LabelAlertaText1.Text= ""
LabelAlertaText.TextColor = Colors.Red
LabelMONITOR.Text=""
monitor1 = ""
RadioButton1.Checked=False
RadioButton2.Checked=False
LabelPARADA.Visible=True
Case "ACTIVADA"
LabelAlertaImage.Text=Chr(0xE5CA)
LabelAlertaImage.TextColor = Colors.Green
LabelAlertaText.Text = "ACTIVADA"
LabelAlertaText1.Text= ""
LabelAlertaText.TextColor=Colors.Green
LabelPARADA.Visible=False
End Select
Next
astream.Write(ser.ConvertArrayToBytes(Array(output)))
End Sub
Sub ToggleButton1_CheckedChange(Checked As Boolean)
If Checked = False Then
ImgToggleButtonLED1.Initialize(LoadBitmap(File.DirAssets, "setaOFF.png"))
ImgToggleButtonLED1.Gravity = Gravity.FILL
ToggleButton1.Background = ImgToggleButtonLED1
output = "out1 T"
ToastMessageShow ("SETA OFF", False)
Else
ImgToggleButtonLED1.Initialize(LoadBitmap(File.DirAssets, "setaON.png"))
ImgToggleButtonLED1.Gravity = Gravity.FILL
ToggleButton1.Background = ImgToggleButtonLED1
output = "out1 F"
ToastMessageShow ("SETA ON", False)
End If
End Sub
Sub Button1_Click
server.Listen
End Sub
Sub Button2_Click
rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then Return
' PERMISSION_CALL_PHONE includes phone state
Dim pc As PhoneCalls
StartActivity(pc.Call(monitor1))
End Sub
Sub Button3_Click
Panel3.Visible=True
End Sub
Sub RadioButton1_CheckedChange(Checked As Boolean)
monitor1 = "666332938"
LabelMONITOR.Text = "1"
Panel3.Visible=False
End Sub
Sub RadioButton2_CheckedChange(Checked As Boolean)
monitor1 = "651422831"
LabelMONITOR.Text = "2"
Panel3.Visible=False
End Sub
Sub PanelPAG3_Click
Panel3.Visible=False
End Sub
Private Sub Astream_Error
' Log("Disconnected")
connected = False
End Sub
Private Sub Astream_Terminated
Astream_Error
End Sub