Esempio n. 1
0
 private static List<int> CollectParameters(SerialConnectionBase source){
     string[] strings = Regex.Split(source.LastReadLines, "[;\r\n]");
     var values = new List<int>();
     foreach (string line in strings){
         int intValue;
         if (!int.TryParse(line, out intValue))
             continue;
         values.Add(intValue);
     }
     return values;
 }
Esempio n. 2
0
 private void GotAnswer(SerialConnectionBase source){
     if (!timer1.Enabled)
         return;
     string lines = source.LastReadLines;
     if (!Regex.IsMatch(lines, string.Format(@"{0}[\-\d{1}]+{2}",
                                             GetCorrectSymbolBy(_startSymbol),
                                             GetCorrectSymbolBy(_deviderSymbol),
                                             GetCorrectSymbolBy(_finishSymbol))))
         return;
     var values = CollectParameters(source);
     StoreParameters(values);
 }
 void terminalController_OnClear(SerialConnectionBase source) {
     _lastReadLines = new StringBuilder();
 }
 private void terminalController_OnAnswerReceived(SerialConnectionBase source){
     AppendText(source.LastReadLines);
 }
Esempio n. 5
0
 private void Comm_OnAnswerReceived(SerialConnectionBase source){
     string readLines = source.LastReadLines;
     ControlCallback.AppendTextFor(_form, _txtTerminal, readLines);
     if (OnAnswerReceived != null)
         OnAnswerReceived(source);
 }
Esempio n. 6
0
 private void comm_OnStateChanged(SerialConnectionBase connection){
     ChangeControlsState(connection);
 }
Esempio n. 7
0
 private void ChangeControlsState(SerialConnectionBase connection){
     bool connected = connection.Connected && connection.Ready;
     ControlCallback.SetTextFor(_form, _btnConnect, connected ? Lang.Res.Disconnect : Lang.Res.Connect);
     ControlCallback.SetEnabledFor(_form, _txtMessage, connected);
     ControlCallback.SetEnabledFor(_form, _btnSendMessage, connected);
     if (connected && OnClear != null)
         OnClear(connection);
     if (!connected && OnDisconnected != null)
         OnDisconnected(connection);
 }
Esempio n. 8
0
 static void con_OnAnswerReceived(SerialConnectionBase source) {
     Console.Out.WriteLine(source.LastReadLines);
 }
Esempio n. 9
0
 private void Disconnected(SerialConnectionBase source){
     Stop();
 }