/// <summary> /// Split string to object 'request' /// </summary> /// <param name="s"></param> /// <returns>List of Request</returns> public List <Request> ComStringSplitter(string s) { List <Request> array = new List <Request>(); var requests = ArduinoConnection.GetRequests(s); foreach (var request in requests) { Request r = new Request { FullRequest = request }; if (request.StartsWith(Request.TypeInfo)) { r.Type = Request.TypeInfo; r.Content = request.Replace(Request.TypeInfo, string.Empty); } else if (request.StartsWith(Request.TypeHeatingPower)) { r.Type = Request.TypeHeatingPower; r.Content = request.Replace(Request.TypeHeatingPower, string.Empty); } else if (request.StartsWith(Request.TypeState)) { r.Type = Request.TypeState; r.Content = request.Replace(Request.TypeState, string.Empty); } array.Add(r); } return(array); }
private void btn_closeCOM_Click(object sender, RoutedEventArgs e) { ArduinoConnection.GetInstance().DataReceived -= DataReceivedHandler; ArduinoConnection.Close(); LbxCom.UnselectAll(); AddLog($"Connection to {ArduinoConnection.GetInstance().PortName} is closed\r\n"); BtnCloseCom.IsEnabled = false; BtnRefreshCom.IsEnabled = true; }
private void lbxCom_SelectionChanged(object sender, SelectionChangedEventArgs e) { var lbx = (ListBox)sender; if (lbx.SelectedItem != null) { BtnCloseCom.IsEnabled = true; ArduinoConnection.SetCom(lbx.SelectedItem.ToString()); ArduinoConnection.GetInstance().DataReceived += DataReceivedHandler; ArduinoConnection.Go(); AddLog($"Connection to {ArduinoConnection.GetInstance().PortName} is open\r\n"); BtnRefreshCom.IsEnabled = false; } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { ArduinoConnection.GetInstance().DataReceived -= DataReceivedHandler; ArduinoConnection.Close(); TbxLogs.Clear(); }