'###################################################################################
'########### Send commands from MLServer to Serial(RF) OR Gateway ##################
'###################################################################################
Sub TcpStreams_NewText(Text As String)'data from MLS (port 20000)
'split cmd
Dim A() As String = Regex.Split(";", s.Mid(Text,2,s.Len(Text)-1))'remove $
Log(A(1) & " " & A(2) & " " & A(3) & " " & A(4))
'update LOG
Ser_text.Text = Ser_text.Text & Text & Chr(13) & Chr(10)
' Ser_text.ScrollTopPosition = Ser_text.Text.Length
Ser_text.SetSelection(Ser_text.Text.Length, Ser_text.Text.Length)
'CHECK If COMMND To BE RUN ON GATEWAY OR TO BE SENT TO SERIAL
Select Case s.mid(Text,1,1)
Case "#" ' cmd from MLS not to be sent to serial
Log("MLS --> Gateway")
eval_MLSCMD(s.Mid(Text,2,s.Len(Text)-1))
Case Else
Try
update_switchStatus(A(1),A(2),A(3),A(4),"","")
ast.Write (s.Trim(Text) & Chr(13) & Chr(10))
Log("Sending " & Text & " from MLS --> Serial OK")
Log("Updating_switchStatus")
' update_switchStatus(A(1),A(2),A(3),A(4),"","")
Catch
Log("Sending " & Text & " to Serial FAILED")
Log(LastException)
End Try
End Select
End Sub