Пример #1
0
 public void SendMessage_A(DTUSession session)
 {
     byte[] data = new byte[150];
     data[0]  = 0x05; data[1] = 0x0A; data[2] = 0x05; data[3] = 0x0A; //消息头标识
     data[4]  = 0x80;                                                 //通讯标志位
     data[5]  = 0x02; data[6] = 0x0A; data[7] = 0x00; data[8] = 0x03; //命令字
     data[9]  = 0x00; data[10] = 0x82;                                //数据长度 130 固定值
     data[11] = 0x00; data[12] = 0x01;                                //包序 固定值
     data[13] = 0x01;                                                 //最后一包  固定值
     data[20] = 0x27; data[21] = 0xDD;                                //平台心跳
     data[23] = SystemState;                                          //系统状态
     data[24] = (byte)((A1_Order_Enable) | (A2_Order_Enable << 1));
     data[25] = (byte)(A_System_Control);
     data[41] = (byte)((AGV_Assembly1_GET)
                       | (AGV_Assembly2_GET << 1)
                       | (AGV_Assembly1_PUT << 2)
                       | (AGV_Assembly2_PUT << 3));
     for (int i = 20; i < 150; i++)  //消息体校验字
     {
         data[14] += data[i];
     }
     for (int i = 0; i < 19; i++)  //消息头校验字
     {
         data[19] += data[i];
     }
     session.Send(data, 0, 150);
 }
Пример #2
0
 public void SendMessage_P(DTUSession session)
 {
     byte[] data = new byte[150];
     data[0]  = 0x05; data[1] = 0x0A; data[2] = 0x05; data[3] = 0x0A; //消息头标识
     data[4]  = 0x80;                                                 //通讯标志位
     data[5]  = 0x02; data[6] = 0x0A; data[7] = 0x00; data[8] = 0x01; //命令字
     data[9]  = 0x00; data[10] = 0x82;                                //数据长度 130 固定值
     data[11] = 0x00; data[12] = 0x01;                                //包序 固定值
     data[13] = 0x01;                                                 //最后一包  固定值
     data[20] = 0x29; data[21] = 0xFF;                                //平台心跳
     data[23] = SystemState;                                          //系统状态
     data[24] = (byte)((P_Order_Enable)
                       | (Hand_Order_Enabel << 1)
                       | (OrderControl << 3)); //订单控制
     data[39] = (byte)((Raw_Tray_Out) | (Inform_P_Raw_Tray << 1));
     data[41] = (byte)((AGV_Manual_Up_GET)
                       | (AGV_Manual_Down_GET << 1)
                       | (AGV_Process1_GET << 2)
                       | (AGV_Process2_GET << 3)
                       | (AGV_Manual_Up_PUT << 4)
                       | (AGV_Manual_Down_PUT << 5)
                       | (AGV_Process1_PUT << 6)
                       | (AGV_Process2_PUT << 7));
     data[42] = Maunal_Up_RFID;
     byte[] cmd = new byte[4];
     cmd      = DataTransform.floatToByte(Manual_Up_RFID_Para);
     data[46] = cmd[0];
     data[47] = cmd[1];
     data[48] = cmd[2];
     data[49] = cmd[3];
     for (int i = 20; i < 150; i++)  //消息体校验字
     {
         data[14] += data[i];
     }
     for (int i = 0; i < 19; i++)  //消息头校验字
     {
         data[19] += data[i];
     }
     session.Send(data, 0, 150);
 }