Ejemplo n.º 1
0
 public void OnBiasReceived(BiasReceivedEventArgs e)
 {
     ElementStatusUpdateEventArgs eStatus = new ElementStatusUpdateEventArgs();
     eStatus.Status = string.Format("PID Bias of {0} for channel {1} Received at {2}", e.Bias.ToString(),_ctrl_chnl.ToString(), DateTime.Now.ToString("HH:mm:ss.fff"));
     ElementStatusUpdateEvent(this, eStatus);
 }
Ejemplo n.º 2
0
 public void OnPacketReceived(Serial_parser sender,PacketEventArgs e){
     Serial_parser.msg_type_tx received_msg_type = (Serial_parser.msg_type_tx)e.packet[e.packet_config.padding_len + 1];
     if (received_msg_type != Serial_parser.msg_type_tx.probe)//Probe fills output windows
     {
         Debug.WriteLine(string.Format("MSG CTRL OnPacketReceived {0} at {1}", received_msg_type.ToString(), DateTime.Now.ToLongTimeString()));
     }
     switch (received_msg_type)
     {
         case Serial_parser.msg_type_tx.heart_beat:
             if (HeartBeatReceived != null)
             {
                 HeartBeatReceived(this, new EventArgs());
             }
             break;
         case Serial_parser.msg_type_tx.settings_tx:
             //serial_driver.main_form.settings.push_setting_data(packet); //TODO
             throw new NotImplementedException();
             break;
         case Serial_parser.msg_type_tx.probe:
             ProbeReceivedEventArgs eProbe=new ProbeReceivedEventArgs();
             eProbe.payload=e.payload;
             if (ProbeReceived != null)
             {
                 ProbeReceived(eProbe);
             }
             else
             {
                 Debug.WriteLine(string.Format("Unhandeled {0} at {1}", received_msg_type.ToString(), DateTime.Now.ToLongTimeString()));
             }
             break;
         case Serial_parser.msg_type_tx.msg_tx:
             throw new NotImplementedException();
             //TODO
             break;
         case Serial_parser.msg_type_tx.acknowledgement:
             switch ((ACK_type)e.payload[0])
             {
                 case ACK_type.AckCommand:
                     if (AckCommandReceived != null)
                     {
                         AckReceivedEventArgs eAck = new AckReceivedEventArgs();
                         eAck.ID = e.payload[1];
                         AckCommandReceived(this,eAck);
                     }
                     else
                     {
                         Debug.WriteLine(string.Format("Unhandeled {0} at {1}", received_msg_type.ToString(), DateTime.Now.ToLongTimeString()));
                     }
                     break;
                 case ACK_type.AckSettingUpdate:
                     if (AckSettingUpdateReceived!=null)
                     {
                         AckReceivedEventArgs eAck = new AckReceivedEventArgs();
                         eAck.ID = e.payload[1];
                         AckSettingUpdateReceived(this,eAck);
                     }
                     else
                     {
                         Debug.WriteLine(string.Format("Unhandeled {0} at {1}", received_msg_type.ToString(), DateTime.Now.ToLongTimeString()));
                     }
                     break;
                 default:
                     throw new NotImplementedException();
                     break;
             }
             break;
         case Serial_parser.msg_type_tx.dbg_txt:
             DebugTextReceivedEventArgs eDebugText = new DebugTextReceivedEventArgs();
             eDebugText.DebugText=System.Text.Encoding.Default.GetString(e.payload.ToArray());
             if (DebugTextReceived != null)
             {
                 DebugTextReceived(eDebugText);
             }
             else
             {
                 Debug.WriteLine(string.Format("Unhandeled {0} at {1}", received_msg_type.ToString(), DateTime.Now.ToLongTimeString()));
             }
             break;
         case Serial_parser.msg_type_tx.chnl_bias:
             BiasReceivedEventArgs eBias = new BiasReceivedEventArgs();
             eBias.Bias = BitConverter.ToSingle(e.payload.ToArray(), 0);
             eBias.CtrlChnl = (commander.ctrl_channel)BitConverter.ToSingle(e.payload.ToArray(), 4);
             BiasReceived(this,eBias);
             break;
         case Serial_parser.msg_type_tx.mrft_bag:
             MRFTBagReceivedEventArgs eMRFTBag = new MRFTBagReceivedEventArgs();
             eMRFTBag.Amplitude = BitConverter.ToSingle(e.payload.ToArray(), 0);
             eMRFTBag.Duration = BitConverter.ToUInt32(e.payload.ToArray(), 4);
             if (MRFTBagReceived != null)
             {
                 MRFTBagReceived(eMRFTBag);
             }
             else
             {
                 Debug.WriteLine(string.Format("Unhandeled {0} at {1}", received_msg_type.ToString(), DateTime.Now.ToLongTimeString()));
             }
             break;
         default:
             throw new NotImplementedException();
             break;
     }
 }
Ejemplo n.º 3
0
 private void OnBiasReceived(object sender, BiasReceivedEventArgs e)
 {
     if (e.CtrlChnl == _ctrl_chnl)
     {
         _organizer.MWMsgCtrl.BiasReceived -= OnBiasReceived;
         _bias_result = Convert.ToInt32(e.Bias);
         IsDone = true;
     }
 }