Пример #1
0
 private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e, byte[] bits)
 {
     try
     {
         SerialMessageHandler.Handle(bits);
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message);
     }
 }
Пример #2
0
        private void SerialPortDataReceived(object sender, SerialDataReceivedEventArgs e, byte[] bits)
        {
            SerialMessageHandler.Handle(bits);
            Dispatcher.Invoke(new Action(() =>
            {
                listBox.Items.Add(SerialMessageHandler.Eight + "\r\n");

                listBox.ScrollIntoView(listBox.Items.Count);

                if (SerialMessageHandler.One)
                {
                    panelValue1.Background = Brushes.Green;
                }
                else
                {
                    panelValue1.Background = Brushes.Red;
                }
                if (SerialMessageHandler.Two)
                {
                    panelValue2.Background = Brushes.Green;
                }
                else
                {
                    panelValue2.Background = Brushes.Red;
                }
                if (SerialMessageHandler.Three)
                {
                    panelValue3.Background = Brushes.Green;
                }
                else
                {
                    panelValue3.Background = Brushes.Red;
                }
                if (SerialMessageHandler.Four)
                {
                    panelValue4.Background = Brushes.Green;
                }
                else
                {
                    panelValue4.Background = Brushes.Red;
                }
                if (SerialMessageHandler.Five)
                {
                    panelValue5.Background = Brushes.Green;
                }
                else
                {
                    panelValue5.Background = Brushes.Red;
                }
                if (SerialMessageHandler.Six)
                {
                    panelValue6.Background = Brushes.Green;
                }
                else
                {
                    panelValue6.Background = Brushes.Red;
                }
                if (SerialMessageHandler.Seven)
                {
                    panelValue7.Background = Brushes.Green;
                }
                else
                {
                    panelValue7.Background = Brushes.Red;
                }

                if (SerialMessageHandler.Eight)
                {
                    panelValue8.Background = Brushes.Green;
                }
                else
                {
                    panelValue8.Background = Brushes.Red;
                }
            }
                                         ));
        }