private void DisplayRxMessage(object sender, EventArgs e)
 {
     canTrans.RxMsgsEventArgs RxMsgs = (canTrans.RxMsgsEventArgs)e;
     byte[] Rxdata = StringToHex(RxMsgs.ToString());
     autoResponse(Rxdata);
     {
         EventHandler TextBoxDisplayUpdate = delegate
         {
         };
         try { Invoke(TextBoxDisplayUpdate); } catch { };
     }
 }
Exemple #2
0
 void trans_init()
 {
     /* 使用事件委托传参 */
     driverTrans.EventTxFarms += new EventHandler(
         (sender1, e1) =>
     {
         canTrans.FarmsEventArgs args      = (canTrans.FarmsEventArgs)e1;
         EventHandler TextBoxDisplayUpdate = delegate
         {
             richTextBoxDisplay.AppendText(args.ToString() + "\r\n");
         };
         try { Invoke(TextBoxDisplayUpdate); } catch { };
     }
         );
     driverTrans.EventRxFarms += new EventHandler(
         (sender1, e1) =>
     {
         canTrans.FarmsEventArgs args      = (canTrans.FarmsEventArgs)e1;
         EventHandler TextBoxDisplayUpdate = delegate
         {
             richTextBoxDisplay.AppendText(args.ToString() + "\r\n");
         };
         try { Invoke(TextBoxDisplayUpdate); } catch { };
     }
         );
     driverTrans.EventRxMsgs += new EventHandler(
         (sender1, e1) =>
     {
         canTrans.RxMsgsEventArgs RxMsgs = (canTrans.RxMsgsEventArgs)e1;
         autoResponse(StringToHex(RxMsgs.ToString()));
     }
         );
     driverTrans.EventError += new EventHandler(
         (sender1, e1) =>
     {
         canTrans.ErrorEventArgs args      = (canTrans.ErrorEventArgs)e1;
         EventHandler TextBoxDisplayUpdate = delegate
         {
             richTextBoxDisplay.AppendText(args.ToString() + "\r\n");
         };
         try { Invoke(TextBoxDisplayUpdate); } catch { };
     }
         );
     driverTrans.CanRead  += driver.ReadData;
     driverTrans.CanWrite += driver.WriteData;
 }