private ACK_MODE RcvCheck(ref string sRcvData) { ACK_MODE _AckMode = ACK_MODE.NONE; if (IsReceived("\r\n") == true) { byte[] bRcv = GetReceiveDataByte(); sRcvData = GetReceiveDataEx_EndCut(); //실제받아오는곳 LogTextOut(string.Format("RecvData:{0}", sRcvData)); if (bRcv[0] == (byte)RCV_CHAR.ACK) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.ACK; } else if (bRcv[0] == (byte)RCV_CHAR.DATA) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; } else if (bRcv[0] == (byte)RCV_CHAR.COMPLETE) { Flush(); _WorkStatus = WORK_STATUS.IDLE; _AckMode = ACK_MODE.COMPLETE; } else if (sRcvData.Contains("ERR") == true) { Flush(); _WorkStatus = WORK_STATUS.ERROR; //ERR:201[CR][LF] Test.GlobalFunction.Instance.SetErr(sRcvData, Test.GlobalDefine.Eidentify_error.CyborgRobot_HTR); //이벤트연결됨 -> 이벤트발생시 -> TBDB_CTC 프로젝트에서 참조후 에러메시지 띄움 _ErrMsg = sRcvData; _AckMode = ACK_MODE.ERROR; } else if (sRcvData.Contains("WAR") == true) { //WAR:1001[CR][LF] Flush(); _WorkStatus = WORK_STATUS.WARING; Test.GlobalFunction.Instance.SetErr(sRcvData, Test.GlobalDefine.Eidentify_error.CyborgRobot_HTR); _WarMsg = sRcvData; _AckMode = ACK_MODE.WARNING; } } return(_AckMode); }
private ACK_MODE RcvCheck(ref string sRcvData) { ACK_MODE _AckMode = ACK_MODE.NONE; if (IsReceived("\n>") == true) { byte[] bRcv = GetReceiveDataByteEx_EndCut(); sRcvData = GetReceiveDataEx_EndCut(); LogTextOut(string.Format("RecvData:{0}", sRcvData)); if (sRcvData.Contains("#ST") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.ACK; } else if (sRcvData.Contains("#OK") == true) { FlushEx_EndCheckCut(); _WorkStatus = WORK_STATUS.IDLE; _AckMode = ACK_MODE.COMPLETE; } else if (sRcvData.Contains("#BU") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.BEFORE_CMD_PROC; } else if (sRcvData.Contains("#??") == true) { FlushEx_EndCheckCut(); _WorkStatus = WORK_STATUS.IDLE; _AckMode = ACK_MODE.NAK; } else if (sRcvData.Contains("#ER") == true) { FlushEx_EndCheckCut(); _WorkStatus = WORK_STATUS.ERROR; _ErrMsg = sRcvData; _AckMode = ACK_MODE.ERROR; } else { //위의것이 아니면, 거의 체크 데이터로 본다. 그냥.. FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; } } return(_AckMode); }
public int Seq_Wait_Command_Test(string strCmd, ACK_MODE _CheckMode) { int nSeqNo = m_nSeqNo; int nRet = 0; switch (nSeqNo) { case 0: //상태 체크 { nSeqNo = 100; _WorkStatus = WORK_STATUS.ACK_CHECK; m_RetryCount = 0; } break; case 100: //명령 전송 { if (SendData(strCmd + "\n") == true) { nSeqNo = 200; m_TimeOut = DateTime.Now; } else { //알람 Flush(); nSeqNo = 0; nRet = -1; _ErrMsg = "Send Fail."; _WorkStatus = WORK_STATUS.ERROR; } } break; case 200: //ACK Check. { string strRcv = ""; ACK_MODE _AckMode = RcvCheck(ref strRcv); if ((int)_AckMode > 0) { if (_AckMode == _CheckMode) { //원하는 데이터 받을때 까지..돈다.. m_TimeOut = DateTime.Now; nSeqNo = 1000; } else { m_TimeOut = DateTime.Now; } } else if ((int)_AckMode < 0) { if (_AckMode == ACK_MODE.BEFORE_CMD_PROC) { //이미 명령 나가있는놈이 있어서, 방금보낸 명령이 안먹음...리트라이 해야한다. if (m_RetryCount < MaxRetryCount) { m_RetryCount += 1; nSeqNo = 100; m_TimeOut = DateTime.Now; LogTextOut(string.Format("{0}/Retry Count:{1})", strCmd, m_RetryCount)); } else { nRet = nSeqNo * -1; nSeqNo = 0; LogTextOut(string.Format("{0}/RetryCount Over.", strCmd)); } } else { _WorkStatus = WORK_STATUS.ERROR; nRet = nSeqNo * -1; nSeqNo = 0; } } else { if (strCmd == "OPEN" || strCmd == "CLOSE") { if (GetElapseTime(m_TimeOut) > READ_END_DELAY * 20) { _ErrMsg = "Receive Time Out."; _WorkStatus = WORK_STATUS.ERROR; nRet = nSeqNo * -1; nSeqNo = 0; Flush(); } } else { if (GetElapseTime(m_TimeOut) > READ_END_DELAY) { _ErrMsg = "Receive Time Out."; _WorkStatus = WORK_STATUS.ERROR; nRet = nSeqNo * -1; nSeqNo = 0; Flush(); } } } } break; case 1000: { nRet = 1; nSeqNo = 0; _WorkStatus = WORK_STATUS.IDLE; } break; default: { _ErrMsg = "Seq No Error."; _WorkStatus = WORK_STATUS.ERROR; nSeqNo = 0; nRet = -1; Flush(); } break; } m_nSeqNo = nSeqNo; return(nRet); }
private ACK_MODE RcvCheck(ref string sRcvData) { ACK_MODE _AckMode = ACK_MODE.NONE; if (IsReceived("\n") == true) { byte[] byRcv = GetReceiveDataByteEx_EndCut(); sRcvData = GetReceiveDataEx_EndCut(); LogTextOut(string.Format("RecvData:{0}", sRcvData)); if (byRcv[0] == 'A') { //정상적으로 수행 FlushEx_EndCheckCut(); _AckMode = ACK_MODE.ACK; } else if (byRcv[0] == 'N') { //정상적인 커맨드가 아님. FlushEx_EndCheckCut(); _ErrMsg = "NAK."; Test.GlobalFunction.Instance.SetErr(_ErrMsg, Test.GlobalDefine.Eidentify_error.Nano300); _AckMode = ACK_MODE.NAK; } else if (byRcv[0] == 'B') { //이미 명령 수행 중. FlushEx_EndCheckCut(); _ErrMsg = "Before Comand Processing."; Test.GlobalFunction.Instance.SetErr(_ErrMsg, Test.GlobalDefine.Eidentify_error.Nano300); _AckMode = ACK_MODE.BEFORE_CMD_PROC; } else if (byRcv[0] == 'E') { //Alarm이 발생하여 Error Code 전송. FlushEx_EndCheckCut(); _ErrMsg = Encoding.ASCII.GetString(byRcv, 0, byRcv.Length); Test.GlobalFunction.Instance.SetErr(_ErrMsg, Test.GlobalDefine.Eidentify_error.Nano300); _AckMode = ACK_MODE.ERROR; } else if (byRcv[0] == 'C') { //EVENT 정보 전송. FlushEx_EndCheckCut(); _AckMode = ACK_MODE.EVENT_DATA; #region Event Data 처리 string strRcv = sRcvData; strRcv = strRcv.Trim(); strRcv = strRcv.Trim('C'); strRcv = strRcv.Replace("\n", ""); int nDec = 0; int.TryParse(strRcv, System.Globalization.NumberStyles.HexNumber, null, out nDec); for (int nBit = 0; nBit < (int)EVENT_DATA.MAX_COUNT; nBit++) { LPM_Data.EventData[nBit] = (byte)((nDec >> nBit) & 0x00000001); } #endregion } else if (byRcv[0] == 'S') { //상태조회 커맨드 FlushEx_EndCheckCut(); _AckMode = ACK_MODE.STATUS_DATA; #region Status Data 처리 string strRcv = sRcvData; strRcv = strRcv.Trim(); strRcv = strRcv.Trim('S'); strRcv = strRcv.Replace("\n", ""); int nDec = 0; int.TryParse(strRcv, System.Globalization.NumberStyles.HexNumber, null, out nDec); for (int nBit = 0; nBit < (int)STATUS_DATA.MAX_COUNT; nBit++) { LPM_Data.StatusData[nBit] = (byte)((nDec >> nBit) & 0x00000001); } #endregion } else if (byRcv[0] == 'M') { //맵핑 데이터 커맨드 FlushEx_EndCheckCut(); Mapping_Proc(sRcvData); _AckMode = ACK_MODE.MAPPING_DATA; } else { //위의것이 아니면, 거의 체크 데이터로 본다. 그냥.. FlushEx_EndCheckCut(); _AckMode = ACK_MODE.CHECK_DATA; } } return(_AckMode); }
public int Seq_ReadCommand_Test(string strCmd, ref string sRcvData) { int nSeqNo = m_nSeqNo; int nRet = 0; char STX = '#'; switch (nSeqNo) { case 0: //상태 체크 { nSeqNo = 100; _WorkStatus = WORK_STATUS.READING; } break; case 100: //명령 전송 { if (SendData(STX + strCmd + "\r") == true) { nSeqNo = 200; m_TimeOut = DateTime.Now; } else { //알람 Flush(); nSeqNo = 0; nRet = -1; } } break; case 200: //ACK Check. { ACK_MODE _AckMode = RcvCheck(ref sRcvData); if ((int)_AckMode > 0) { if (_AckMode == ACK_MODE.DATA) { m_strBeforeRcvData = sRcvData; _WorkStatus = WORK_STATUS.IDLE; nRet = 1; nSeqNo = 0; } } else if ((int)_AckMode < 0) { nRet = nSeqNo * -1; nSeqNo = 0; } else { if (GetElapseTime(m_TimeOut) > READ_END_DELAY) { nRet = nSeqNo * -1; nSeqNo = 0; Flush(); } } } break; default: { nSeqNo = 0; nRet = -1; Flush(); } break; } m_nSeqNo = nSeqNo; return(nRet); }
private int Seq_SendCommand_WaitComplete(string strCmd) { int nSeqNo = m_nSeqNo; int nRet = 0; char STX = '#'; switch (nSeqNo) { case 0: //상태 체크 { nSeqNo = 100; _WorkStatus = WORK_STATUS.MOVING; } break; case 100: //명령 전송 { if (SendData(STX + strCmd + "\r") == true) { nSeqNo = 200; m_TimeOut = DateTime.Now; } else { //알람 Flush(); nSeqNo = 0; nRet = -1; } } break; case 200: //ACK Check. { string strRcvData = ""; ACK_MODE _AckMode = RcvCheck(ref strRcvData); if ((int)_AckMode > 0) { m_TimeOut = DateTime.Now; if (_AckMode == ACK_MODE.COMPLETE) { _WorkStatus = WORK_STATUS.IDLE; nRet = 1; nSeqNo = 0; } } else if ((int)_AckMode < 0) { nRet = nSeqNo * -1; nSeqNo = 0; } else { //if (GetElapseTime(m_TimeOut) > MOVING_COMPLETE_DELAY) //{ // nRet = nSeqNo * -1; // nSeqNo = 0; // Flush(); //} } } break; default: { nSeqNo = 0; nRet = -1; Flush(); } break; } m_nSeqNo = nSeqNo; return(nRet); }
private ACK_MODE RcvCheck(ref string sRcvData) { ACK_MODE _AckMode = ACK_MODE.NONE; if (IsReceived("\n>") == true) { byte[] bRcv = GetReceiveDataByteEx_EndCut(); sRcvData = GetReceiveDataEx_EndCut(); LogTextOut(string.Format("RecvData:{0}", sRcvData)); if (sRcvData.Contains("#ST") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.ACK; } else if (sRcvData.Contains("#OK") == true) { FlushEx_EndCheckCut(); _WorkStatus = WORK_STATUS.IDLE; _AckMode = ACK_MODE.COMPLETE; } else if (sRcvData.Contains("#BU") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.BEFORE_CMD_PROC; } else if (sRcvData.Contains("#??") == true) { FlushEx_EndCheckCut(); _WorkStatus = WORK_STATUS.IDLE; _AckMode = ACK_MODE.NAK; } else if (sRcvData.Contains("#ER") == true) { SendData("#ERST" + "\r"); bError = true; FlushEx_EndCheckCut(); _WorkStatus = WORK_STATUS.ERROR; _ErrMsg = sRcvData; _AckMode = ACK_MODE.ERROR; } else if (bError) { string[] temp = sRcvData.Split('#'); if (!(temp[1] == null)) { bError = false; Test.GlobalFunction.Instance.SetErr(temp[1], Test.GlobalDefine.Eidentify_error.Aligner_PA300C); } } else { //위의것이 아니면, 거의 체크 데이터로 본다. 그냥.. FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; } } //수정 BeforeAck = _AckMode; return(_AckMode); }
private int Seq_ReadCommand(string strCmd, ref string sRcvData) { int nSeqNo = m_nReadSeqNo; int nRet = 0; switch (nSeqNo) { case 0: //상태 체크 { nSeqNo = 100; _WorkStatus = WORK_STATUS.READING; //Console.WriteLine("Send 1->" + strCmd); } break; case 100: //명령 전송 { if (SendData(strCmd + "\r\n") == true) { //Console.WriteLine("Send 2->" + strCmd); nSeqNo = 200; m_TimeOut = DateTime.Now; } else { //알람 Flush(); nSeqNo = 0; nRet = -1; } } break; case 200: //ACK Check. { ACK_MODE _AckMode = RcvCheck(ref sRcvData); if ((int)_AckMode > 0) { switch (_AckMode) { case ACK_MODE.ACK: { //Ack 받고. m_TimeOut = DateTime.Now; //Console.WriteLine("Ack->" + sRcvData); } break; case ACK_MODE.DATA: { //데이터 받고.. m_TimeOut = DateTime.Now; sRcvData = sRcvData.Replace("\r\n", ""); sRcvData = sRcvData.Replace("*", ""); sRcvData = sRcvData.Replace(" ", ""); m_strBeforeRcvData = sRcvData; //Console.WriteLine("Data->" + sRcvData); } break; case ACK_MODE.COMPLETE: { //데이터 받는거 완료 되었다..진짜끝임. m_TimeOut = DateTime.Now; sRcvData = m_strBeforeRcvData; nRet = 1; nSeqNo = 0; //Console.WriteLine("Rcv Compl->" + strCmd); } break; } } else if ((int)_AckMode < 0) { nRet = nSeqNo * -1; nSeqNo = 0; } else { if (GetElapseTime(m_TimeOut) > READ_END_DELAY) { nRet = nSeqNo * -1; nSeqNo = 0; Flush(); //Console.WriteLine("Time Out"); } } } break; default: { Console.WriteLine("Error"); nSeqNo = 0; nRet = -1; Flush(); } break; } m_nReadSeqNo = nSeqNo; return(nRet); }
private int Seq_SendCommand(string strCmd) { int nSeqNo = m_nSeqNo; int nRet = 0; switch (nSeqNo) { case 0: //상태 체크 { nSeqNo = 100; _WorkStatus = WORK_STATUS.MOVING; } break; case 100: //명령 전송 { if (SendData(strCmd + "\r\n") == true) { nSeqNo = 200; m_TimeOut = DateTime.Now; } else { //알람 Flush(); nSeqNo = 0; nRet = -1; } } break; case 200: //ACK Check. { string strRcvData = ""; ACK_MODE _AckMode = RcvCheck(ref strRcvData); if ((int)_AckMode > 0) { nRet = 1; nSeqNo = 0; } else if ((int)_AckMode < 0) { nRet = nSeqNo * -1; nSeqNo = 0; } else { if (GetElapseTime(m_TimeOut) > READ_END_DELAY) { nRet = nSeqNo * -1; nSeqNo = 0; Flush(); } } } break; default: { nSeqNo = 0; nRet = -1; Flush(); } break; } m_nSeqNo = nSeqNo; return(nRet); }
private ACK_MODE RcvCheck(ref string sRcvData) { ACK_MODE _AckMode = ACK_MODE.NONE; if (IsReceived("\r") == true) { byte[] byRcv = GetReceiveDataByteEx_EndCut(); sRcvData = GetReceiveDataEx_EndCut(); LogTextOut(string.Format("RecvData:{0}", sRcvData)); if (sRcvData.Contains("_ACK") == true) { //정상적으로 수행 FlushEx_EndCheckCut(); _AckMode = ACK_MODE.ACK; _WorkStatus = WORK_STATUS.MOVING; } else if (sRcvData.Contains("_RDY") == true) { //동작완료. FlushEx_EndCheckCut(); _AckMode = ACK_MODE.COMPLETE; _WorkStatus = WORK_STATUS.IDLE; } else if (sRcvData.Contains("_NAK") == true) { //명령이 잘못됨. FlushEx_EndCheckCut(); _AckMode = ACK_MODE.ERROR; _WorkStatus = WORK_STATUS.ERROR; Test.GlobalFunction.Instance.SetErr(_ErrMsg, Test.GlobalDefine.Eidentify_error.CyMechsRobot); } else if (sRcvData.Contains("_ERR") == true || sRcvData.Contains("ERR") == true) { //Alarm이 발생하여 Error Code 전송. FlushEx_EndCheckCut(); _ErrMsg = Encoding.ASCII.GetString(byRcv, 0, byRcv.Length); Test.GlobalFunction.Instance.SetErr(_ErrMsg, Test.GlobalDefine.Eidentify_error.CyMechsRobot); _AckMode = ACK_MODE.ERROR; _WorkStatus = WORK_STATUS.ERROR; } else if (sRcvData.Contains("POWER OFF") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.PowerStatus = ONOFF.OFF; } else if (sRcvData.Contains("POWER ON") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.PowerStatus = ONOFF.ON; } else if (sRcvData.Contains("WAFER A Y") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.Wafer_A_Status = WAFER_STS.PRESENT; } else if (sRcvData.Contains("WAFER A N") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.Wafer_A_Status = WAFER_STS.ABSENT; } else if (sRcvData.Contains("WAFER A ERR") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.Wafer_A_Status = WAFER_STS.UNKNOWN; } else if (sRcvData.Contains("WAFER B Y") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.Wafer_B_Status = WAFER_STS.PRESENT; } else if (sRcvData.Contains("WAFER B N") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.Wafer_B_Status = WAFER_STS.ABSENT; } else if (sRcvData.Contains("WAFER B ERR") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.Wafer_B_Status = WAFER_STS.UNKNOWN; } else if (sRcvData.Contains("VAC A N") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.Vaccum_A_Status = ONOFF.OFF; } else if (sRcvData.Contains("VAC A Y") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.Vaccum_A_Status = ONOFF.ON; } else if (sRcvData.Contains("VAC B N") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.Vaccum_B_Status = ONOFF.OFF; } else if (sRcvData.Contains("VAC B Y") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.Vaccum_B_Status = ONOFF.ON; } else if (sRcvData.Contains("CDM") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.HostControlMode = CONTROL_MODE.CDM; } else if (sRcvData.Contains("HOST") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.HostControlMode = CONTROL_MODE.HOST; } else if (sRcvData.Contains("VER") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.Version = sRcvData; } else if (sRcvData.Contains("ENC A") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.nEncA = Convert.ToInt32(sRcvData.Substring(4)); } else if (sRcvData.Contains("ENC B") == true) { FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; RobotData.nEncB = Convert.ToInt32(sRcvData.Substring(4)); } else { //위의것이 아니면, 거의 체크 데이터로 본다. 그냥.. FlushEx_EndCheckCut(); _AckMode = ACK_MODE.DATA; } } return(_AckMode); }