コード例 #1
0
        /// <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);
        }
コード例 #2
0
 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;
 }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     ArduinoConnection.GetInstance().DataReceived -= DataReceivedHandler;
     ArduinoConnection.Close();
     TbxLogs.Clear();
 }