コード例 #1
0
 /// <summary>
 /// 数据接收处理,添加、删除记录
 /// </summary>
 /// <param name="buf"></param>
 private void ReceivedDataHandle(byte[] buf)
 {
     byte[] databuffer = buf;
     if (CallDataCheck(databuffer, databuffer.Length - 2) == VERIFY_NOERROR)
     {
         if (databuffer[1] == 0x41)//叫料
         {
             if (Add(databuffer[2], databuffer[3]))
             {
                 buf_callret[0] = 0x10;
                 buf_callret[1] = 0x43;
                 buf_callret[2] = buf[2];
                 buf_callret[3] = buf[3];
                 buf_callret[4] = DrvWlConGetBCC(buf_callret, buf_callctl.Length - 2);
                 buf_callret[5] = 0x03;
                 SPComCall.Write(buf_callret, 0, buf_callret.Length);
             }
         }
         else if (databuffer[1] == 0x42)//取消叫料
         {
             if (Delete(databuffer[2], databuffer[3]))
             {
                 buf_callret[0] = 0x10;
                 buf_callret[1] = 0x45;
                 buf_callret[2] = buf[2];
                 buf_callret[3] = buf[3];
                 buf_callret[4] = DrvWlConGetBCC(buf_callret, buf_callctl.Length - 2);
                 buf_callret[5] = 0x03;
                 SPComCall.Write(buf_callret, 0, buf_callret.Length);
             }
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// 地址设置按钮消息响应
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_Set_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrEmpty(tbOldAd.Text.Trim()) || String.IsNullOrEmpty(tbNewAd.Text.Trim()))
     {
         MessageBox.Show("请输入地址!");
         return;
     }
     try
     {
         buf_callsend[2] = Byte.Parse(tbOldAd.Text, System.Globalization.NumberStyles.HexNumber);
         buf_callsend[3] = Byte.Parse(tbNewAd.Text, System.Globalization.NumberStyles.HexNumber);
         buf_callsend[4] = COM.SerialPortWrapper.GetXORCheckCode(buf_callsend, buf_callsend.Length - 2);
         SPComCall.Write(buf_callsend, 0, buf_callsend.Length);
     }
     catch (FormatException)
     {
         MessageBox.Show("您输入的地址格式不正确,请重新输入!");
         return;
     }
 }