private void PushCmd(LaserCmd lc) { lock (_obLock) { _listCmd.Enqueue(lc); } }
private void HandleCmdToLaser(LaserCmd laserCmd) { //set callback data id //_laser.SetExtra(laserCmd.nFlag); string strCmd = string.Empty; switch (laserCmd.nCmdType) { case CmdType.CHANGE_PROGRAM: strCmd = string.Format("GA,{0}\r", laserCmd.nProgramNum); break; case CmdType.CHANGE_CODE_INFO: strCmd = string.Format("C2,{0}", laserCmd.nProgramNum); foreach (var item in laserCmd.dicInfo) { strCmd += string.Format(",{0},{1}", item.Key, item.Value); } strCmd += "\r"; break; case CmdType.CHECK_STATUE: strCmd = "RE\r"; break; case CmdType.START_LASER: strCmd = "NT\r"; break; case CmdType.RESET_LASER: strCmd = "FY\r"; break; default: break; } byte[] btDatas = Encoding.ASCII.GetBytes(strCmd); _laser.Write(btDatas, 0, btDatas.Length); }