void ICommandReport.On_Command_Error(string Device_ID, ReturnMsg Msg, Command Cmd, Job Job) { if (AlarmList.ContainsKey(Msg.GetDAT())) { Alarm alm; if (AlarmList.TryGetValue(Msg.GetDAT(), out alm)) { MessageBox.Show(Device_ID + "錯誤發生\n錯誤類型:" + alm.Error_Type + "\n錯誤名稱:" + alm.Error_Name + "\n錯誤描述:" + alm.Error_Cause, "錯誤碼:" + alm.Error_Code); } } else { MessageBox.Show(Device_ID + "錯誤發生,錯誤碼:" + Msg.GetDAT()); } }
void ICommandReport.On_Command_Finished(string Device_ID, ReturnMsg Msg, Command Cmd, Job Job) { string[] reply; switch (Msg.GetCMD()) { case "PNSTS": reply = Msg.GetDAT().Split(','); string arm = reply[0]; string vac = reply[1]; string pre = reply[2]; switch (arm) { case "1": //R status.R_ArmVacuumNo1 = Convert.ToBoolean(Convert.ToInt16(vac[0])); status.R_ArmVacuumNo2 = Convert.ToBoolean(Convert.ToInt16(vac[1])); status.R_ArmVacuumNo3 = Convert.ToBoolean(Convert.ToInt16(vac[2])); status.R_ArmVacuumNo4 = Convert.ToBoolean(Convert.ToInt16(vac[3])); status.R_ArmPresentNo1 = Convert.ToBoolean(Convert.ToInt16(pre[0])); status.R_ArmPresentNo2 = Convert.ToBoolean(Convert.ToInt16(pre[1])); status.R_ArmPresentNo3 = Convert.ToBoolean(Convert.ToInt16(pre[2])); status.R_ArmPresentNo4 = Convert.ToBoolean(Convert.ToInt16(pre[3])); break; case "2": //L status.L_ArmVacuumNo1 = Convert.ToBoolean(Convert.ToInt16(vac[0])); status.L_ArmVacuumNo2 = Convert.ToBoolean(Convert.ToInt16(vac[1])); status.L_ArmVacuumNo3 = Convert.ToBoolean(Convert.ToInt16(vac[2])); status.L_ArmVacuumNo4 = Convert.ToBoolean(Convert.ToInt16(vac[3])); status.L_ArmPresentNo1 = Convert.ToBoolean(Convert.ToInt16(pre[0])); status.L_ArmPresentNo2 = Convert.ToBoolean(Convert.ToInt16(pre[1])); status.L_ArmPresentNo3 = Convert.ToBoolean(Convert.ToInt16(pre[2])); status.L_ArmPresentNo4 = Convert.ToBoolean(Convert.ToInt16(pre[3])); break; } break; case "POS__": reply = Msg.GetDAT().Split(','); status.R_EncoderPosition = reply[0]; status.L_EncoderPosition = reply[1]; status.S_EncoderPosition = reply[2]; status.Z_EncoderPosition = reply[3]; status.X_EncoderPosition = reply[4]; status.R1_EncoderPosition = reply[5]; break; } RunIdx++; if (RunIdx < cmdList.Count) { _Controller.SendCommand(cmdList[RunIdx]); } else { RefreshStatus(); RunIdx = 0; _Controller.SendCommand(cmdList[RunIdx]); } }
void IConnectionReport.OnSocketMessage(string Msg) { try { string[] MsgList = Msg.Split('\n'); foreach (string each in MsgList) { //logger.Debug("OnSocketMessage:" + each); if (each.Trim().Equals("")) { continue; } ReturnMsg eachMsg = new ReturnMsg(each); timeOutTimer.Enabled = false; switch (eachMsg.GetFLG()) { case "ACK": if (LastSendCommand.GetFLG().Equals("CMD")) //如果送出的指令不是CMD,就做下一步,否則必須等待FIN才能繼續 { SetStatus(Runing); actionTimeOutTimer.Enabled = true; tObj.On_Command_Excuted(ControllerName, eachMsg, LastSendCommand, LastJob); } else { SetStatus(Idle); tObj.On_Command_Excuted(ControllerName, eachMsg, LastSendCommand, LastJob); } break; case "NAK": SetStatus(Idle); tObj.On_Command_Error(ControllerName, eachMsg, LastSendCommand, LastJob); //錯誤發生 logger.Error("Error happen:error code=" + eachMsg.GetDAT()); break; case "FIN": actionTimeOutTimer.Enabled = false; SetStatus(Idle); //下一步 if (eachMsg.GetDAT().Equals("00000000")) { tObj.On_Command_Finished(ControllerName, eachMsg, LastSendCommand, LastJob); } else { //錯誤發生 tObj.On_Command_Error(ControllerName, eachMsg, LastSendCommand, LastJob); logger.Error("Error happen:error code=" + eachMsg.GetDAT()); } break; } } } catch (Exception ex) { logger.Error("OnSocketMessage:" + ex.Message + "\n" + ex.StackTrace); } }