private void GrdData_DataSourceChanged(object sender, EventArgs e) { string triggerTime = DateTime.Now.ToString("HHmmss"); foreach (DataGridViewRow dr in grdData.Rows) { if (dr.Cells[0].Value != null) { switch (dr.Cells["KeyName"].Value.ToString()) { case "STX": dr.Cells["Values"].Value = MsgModel._startPoint; dr.ReadOnly = true; break; case "ETX": dr.Cells["Values"].Value = MsgModel._endPoint; dr.ReadOnly = true; break; case "TriggerTime": dr.Cells["Values"].Value = triggerTime; dr.ReadOnly = true; break; case "Command": dr.Cells["Values"].Value = function; dr.ReadOnly = true; break; case "EqpNo": dr.Cells["Values"].Value = Equipment.eqpID; dr.ReadOnly = true; break; case "SeqNo": dr.Cells["Values"].Value = Equipment.seqno.ToString().PadLeft(4, '0'); dr.ReadOnly = true; break; case "BCC": Dictionary <string, string> dt = new Dictionary <string, string>() { { "TriggerTime", triggerTime } }; byte[] bbc = new byte[2]; bbc = MsgModel.BCC(dt); dr.Cells["Values"].Value = bbc[0].ToString() + bbc[1].ToString(); dr.ReadOnly = true; break; case "PlatformNo": dr.Cells["Values"].Value = Equipment.eqpID; dr.ReadOnly = true; break; case "ReSent": dr.Cells["Values"].Value = "0"; //dr.ReadOnly = true; break; case "Pier": dr.Cells["Values"].Value = "0000"; //dr.ReadOnly = true; break; case "ShelfHeight": dr.Cells["Values"].Value = "0"; //dr.ReadOnly = true; break; case "ShelfWidth": dr.Cells["Values"].Value = "0"; //dr.ReadOnly = true; break; default: break; } } } }
public string[] GetData(MsgEventArg msg, ref byte[] rep) { string dtt = DateTime.Now.ToString("HHmmss"); Dictionary <string, string> time = new Dictionary <string, string>() { { "TriggerTime", dtt } }; sTX = MsgModel._startPoint; seqNo = msg._value["SeqNo"]; command = msg._cmdCode; reSent = msg._value["ReSent"]; triggerTime = dtt; eqpNo = Equipment.eqpID; status = msg._value["Status"]; eTX = MsgModel._endPoint; StringBuilder strb = new StringBuilder(); byte[] chkbbc = new byte[2]; Dictionary <string, string> dt = new Dictionary <string, string>() { { "TriggerTime", triggerTime } }; int reidx = 0; foreach (string key in MsgModel._commandType[msg._cmdCode].Keys) { for (int i = 0; i < MsgModel._commandType[msg._cmdCode][key]; i++) { switch (key) { case "STX": strb.Append(key + ":" + sTX + "\n"); rep[reidx] = Convert.ToByte(Convert.ToString(Convert.ToInt32(sTX, 16))); break; case "SeqNo": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(seqNo)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(seqNo)[i]; break; case "Command": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(command)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(command)[i]; break; case "ReSent": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(reSent)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(reSent)[i]; break; case "TriggerTime": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(triggerTime)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(triggerTime)[i]; break; case "EqpNo": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(eqpNo)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(eqpNo)[i]; break; case "Status": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(status)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(status)[i]; break; case "BCC": chkbbc = MsgModel.BCC(dt); strb.Append(key + ":" + Convert.ToString(int.Parse(chkbbc[i].ToString()), 16).ToUpper() + "\n"); //Convert.ToString(chkbbc[i]).PadLeft(2, '0') if (chkbbc[i] >= 10) { rep[reidx] = Encoding.ASCII.GetBytes(Convert.ToString(chkbbc[i], 16).ToUpper())[0]; } else { rep[reidx] = chkbbc[i]; } break; case "ETX": strb.Append(key + ":" + eTX); rep[reidx] = Convert.ToByte(Convert.ToString(Convert.ToInt32(eTX, 16))); break; } reidx++; } } string[] sp = strb.ToString().Split('\n'); return(sp); }
public string[] GetData(MsgEventArg msg, ref byte[] rep) { try { string dtt = DateTime.Now.ToString("HHmmss"); Dictionary <string, string> time = new Dictionary <string, string>() { { "TriggerTime", dtt } }; sTX = MsgModel._startPoint; seqNo = msg._value["SeqNo"]; command = msg._cmdCode; reSent = msg._value["ReSent"]; triggerTime = dtt; mCKey = msg._value["MCkey"]; eqpNo = Equipment.eqpID; cycleCmd = msg._value["CycleCmd"]; jobType = msg._value["JobType"]; shelfHeight = msg._value["ShelfHeight"]; shelfWidth = msg._value["ShelfWidth"]; Row = msg._value["Row"]; bas = msg._value["Base"]; layer = msg._value["Layer"]; platform = msg._value["Platform"]; pier = msg._value["Pier"]; eTX = MsgModel._endPoint; StringBuilder strb = new StringBuilder(); byte[] chkbbc = new byte[2]; Dictionary <string, string> dt = new Dictionary <string, string>() { { "TriggerTime", triggerTime } }; int reidx = 0; foreach (string key in MsgModel._commandType[msg._cmdCode].Keys) { for (int i = 0; i < MsgModel._commandType[msg._cmdCode][key]; i++) { switch (key) { case "STX": strb.Append(key + ":" + sTX + "\n"); rep[reidx] = Convert.ToByte(Convert.ToString(Convert.ToInt32(sTX, 16))); break; case "SeqNo": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(seqNo)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(seqNo)[i]; break; case "Command": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(command)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(command)[i]; break; case "ReSent": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(reSent)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(reSent)[i]; break; case "TriggerTime": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(triggerTime)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(triggerTime)[i]; break; case "MCkey": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(mCKey)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(mCKey)[i]; break; case "EqpNo": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(eqpNo)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(eqpNo)[i]; break; case "CycleCmd": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(cycleCmd)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(cycleCmd)[i]; break; case "JobType": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(jobType)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(jobType)[i]; break; case "ShelfHeight": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(shelfHeight)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(shelfHeight)[i]; break; case "ShelfWidth": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(shelfWidth)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(shelfWidth)[i]; break; case "Row": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(Row)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(Row)[i]; break; case "Base": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(bas)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(bas)[i]; break; case "Layer": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(layer)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(layer)[i]; break; case "Platform": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(platform)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(platform)[i]; break; case "Pier": strb.Append(key + ":" + Convert.ToString((char)Encoding.ASCII.GetBytes(pier)[i]).PadLeft(2, '0') + "\n"); rep[reidx] = Encoding.ASCII.GetBytes(pier)[i]; break; case "BCC": chkbbc = MsgModel.BCC(dt); strb.Append(key + ":" + Convert.ToString(int.Parse(chkbbc[i].ToString()), 16).ToUpper() + "\n"); //Convert.ToString(chkbbc[i]).PadLeft(2, '0') if (chkbbc[i] >= 10) { rep[reidx] = Encoding.ASCII.GetBytes(Convert.ToString(chkbbc[i], 16).ToUpper())[0]; } else { rep[reidx] = chkbbc[i]; } break; case "ETX": strb.Append(key + ":" + eTX); rep[reidx] = Convert.ToByte(Convert.ToString(Convert.ToInt32(eTX, 16))); break; } reidx++; } } string[] sp = strb.ToString().Split('\n'); return(sp); } catch (Exception ex) { throw; } }