public static HeartTimeoutMsg CreateNewMsg(Board board) { HeartTimeoutMsg heartTimeoutMsg = new HeartTimeoutMsg(); heartTimeoutMsg.IpAndPort = " "; heartTimeoutMsg.ProtocolVersion = 0x01; heartTimeoutMsg.CycleNo = 0; heartTimeoutMsg.Type = 0xEE; heartTimeoutMsg.SubType = 0xEE; heartTimeoutMsg.ErrorStatus = 0x02; heartTimeoutMsg.DataLen = 1; byte[] temp = new byte[] { 0x4E,0x6F,0x20,0x68,0x65,0x61,0x72,0x74,0x20,0x6D,0x65,0x73,0x73,0x61,0x67, 0x65, 0x20,0x72,0x65, 0x63, 0x65, 0x69,0x76,0x65,0x64}; byte[] heart = new byte[5 + temp.Length]; Array.Copy(board.EqId, 0, heart, 0, 5); Array.Copy(temp, 0, heart, 5, temp.Length); heartTimeoutMsg.Data = heart; return heartTimeoutMsg; }
//生成板卡通过状态切换事件(在Running 状态下) protected void GenBoardStatusChangeEvent(Board board) { BoardStatusEventArgs e = new BoardStatusEventArgs(); e.Board = board; EventHandler temp = OnBoardStatusChange; if (temp != null) { temp(this, e); } }
//根据消息的Equip获取板卡 public Board GetBoard(BaseMessage msg) { byte[] temp = new byte[5]; Array.Copy(msg.Data, 0, temp, 0, 5); //byte[] equipID = msg.Data; uint uID = BitConverter.ToUInt32(temp, 0); if (IDBoardDic.ContainsKey(uID)) { return IDBoardDic[uID]; } Board b = new Board(); b = new Board(); b.Name = "未知板卡"; return b; }
private void UpdateGridData(Board board) { int index = this.logList.Rows.Add();//添加一行 this.logList.Rows[index].Cells[0].Value = DateTime.Now.ToString("HH:mm:ss:fff");//第一列是时间 this.logList.Rows[index].Cells[1].Value = board.Name;//第二列是板卡 this.logList.Rows[index].Cells[2].Value = "握手失败";//第三列是状态 this.logList.Rows[index].DefaultCellStyle.ForeColor = System.Drawing.Color.Red; }