|
|
#include "JELOperate.h"
|
|
|
|
|
|
|
|
|
|
|
|
JELOperate::JELOperate()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
|
|
|
JELOperate::~JELOperate()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
bool JELOperate::InitJEL()
|
|
|
{
|
|
|
m_RobotComm.SetWorkMode(FALSE, 100);
|
|
|
std::string strCom = std::to_string(m_nBaud) + ",N,8,1";
|
|
|
m_nPort = 2;
|
|
|
if (m_RobotComm.Open(m_nPort, (char*)strCom.c_str()))
|
|
|
{
|
|
|
//m_RobotComm.SetWnd(gChildPCS_WaferTransfer->GetSafeHwnd());
|
|
|
m_RobotComm.SetNotify(std::bind(&JELOperate::OnRobotCommRecv, this));
|
|
|
|
|
|
CRobotCmdInfo RobotCmd;
|
|
|
RobotCmd.m_RobotCmdType = _RobotCmd_ResetErr;
|
|
|
SendRobotCmd(RobotCmd);
|
|
|
Sleep(500);
|
|
|
RobotCmd.m_RobotCmdType = _RobotCmd_Org;
|
|
|
RobotCmd.m_WaitCmdTime = 60;
|
|
|
bool issuccess = SendRobotCmd(RobotCmd);
|
|
|
if (!issuccess)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
/*if (!issuccess)
|
|
|
{
|
|
|
CRobotCmdInfo RobotCmd2;
|
|
|
RobotCmd2.m_RobotCmdType = _RobotCmd_ResetErr;
|
|
|
SendRobotCmd(RobotCmd2);
|
|
|
Sleep(500);
|
|
|
SendRobotCmd(RobotCmd2);
|
|
|
Sleep(500);
|
|
|
RobotCmd2.m_RobotCmdType = _RobotCmd_Org;
|
|
|
bool issuccess = SendRobotCmd(RobotCmd2);
|
|
|
}*/
|
|
|
|
|
|
Sleep(500);
|
|
|
//初始化准直器
|
|
|
RobotCmd.m_RobotCmdType = _RobotCmd_Init_Align;
|
|
|
issuccess = SendRobotCmd(RobotCmd);
|
|
|
if (!issuccess)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
bool JELOperate::InitAlign()
|
|
|
{
|
|
|
m_RobotComm.SetWorkMode(FALSE, 100);
|
|
|
std::string strCom = std::to_string(m_nBaud) + ",N,8,1";
|
|
|
m_nPort = 2;
|
|
|
if (m_RobotComm.Open(m_nPort, (char*)strCom.c_str()))
|
|
|
{
|
|
|
//初始化准直器
|
|
|
CRobotCmdInfo RobotCmd;
|
|
|
RobotCmd.m_RobotCmdType = _RobotCmd_Init_Align;
|
|
|
return SendRobotCmd(RobotCmd);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
bool JELOperate::SendRobotCmd(CRobotCmdInfo& RobotCmd)
|
|
|
{
|
|
|
int m_nSlot = 0;
|
|
|
//取料
|
|
|
/*CRobotCmdInfo RobotCmd;
|
|
|
RobotCmd.m_RobotCmdType = _RobotCmd_TransferWafer;
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_ImmediateReadFeedback;
|
|
|
RobotCmd.m_Slot = m_nSlot + 1;
|
|
|
RobotCmd.m_FromPos = _WaferPos_Cassette;
|
|
|
RobotCmd.m_ToPos = _WaferPos_Arm1;*/
|
|
|
|
|
|
|
|
|
eGlobalVariableType AlarmType = _GlobalVar_NULL;
|
|
|
//if (!m_RobotComm.IsOpen())
|
|
|
//{
|
|
|
// //设置报警信息
|
|
|
// RobotCmd.m_ErrStr = "Com Port Not Open";
|
|
|
// //return _GlobalVar_Alarm_Robot_ComPortNotOpen;
|
|
|
// return false;
|
|
|
//}
|
|
|
std::string InfoStr = GetRobotCmdInfoStr(RobotCmd);
|
|
|
|
|
|
//m_CurRobotCmdType = RobotCmd.m_RobotCmdType;
|
|
|
//先把串口缓冲数据读取掉
|
|
|
{
|
|
|
char Buf[256];
|
|
|
memset(Buf, 0, 256);
|
|
|
m_RobotComm.ReadBuf(Buf, 256);
|
|
|
}
|
|
|
bool m_IsbJelCommRecv = false;//是否收到串口消息
|
|
|
//获取发送指令信息
|
|
|
RobotJel_GetSendCmd(RobotCmd);
|
|
|
|
|
|
//设置报警信息
|
|
|
if (RobotCmd.m_SendCmdStr == "")
|
|
|
{
|
|
|
RobotCmd.m_ErrStr = "GetSendCmd Failed";
|
|
|
//return _GlobalVar_Alarm_Robot_CmdNak;
|
|
|
return false;
|
|
|
}
|
|
|
//robot运动时不能开关foup 门
|
|
|
/*bool bLoadPortSafetyLock = (m_CurRobotCmdType == _RobotCmd_TransferWafer || m_CurRobotCmdType == _RobotCmd_ToWaitPos || m_CurRobotCmdType == _RobotCmd_Org);
|
|
|
if (bLoadPortSafetyLock)
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("LoadPortSafety-->Lock");
|
|
|
}*/
|
|
|
//发送指令到robot(不会抛出异常)
|
|
|
AlarmType = RobotJel_SendCmdToRobotExt(RobotCmd);
|
|
|
/*if (bLoadPortSafetyLock)
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("LoadPortSafety-->Unlock");
|
|
|
}*/
|
|
|
//返回非正常状态时读取robot 和aligner的错误信息
|
|
|
if (AlarmType != _GlobalVar_NULL && RobotCmd.m_RobotCmdSendType == _RobotCmdSendType_WaitCmdEnd)
|
|
|
{
|
|
|
CheckRobotErrState(RobotCmd);
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
std::string JELOperate::GetRobotCmdInfoStr(CRobotCmdInfo &RobotCmd)
|
|
|
{
|
|
|
std::string InfoStr;
|
|
|
switch (RobotCmd.m_RobotCmdType)
|
|
|
{
|
|
|
case _RobotCmd_TransferWafer:
|
|
|
case _RobotCmd_ToWaitPos:
|
|
|
{
|
|
|
InfoStr = "TransferWafer : ";
|
|
|
//InfoStr += GetWaferPosTypeStr(RobotCmd.m_FromPos);
|
|
|
InfoStr += " -> ";
|
|
|
//InfoStr += GetWaferPosTypeStr(RobotCmd.m_ToPos);
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_Cassette || RobotCmd.m_ToPos == _WaferPos_Cassette)
|
|
|
{
|
|
|
InfoStr += " Slot: ";
|
|
|
InfoStr += std::to_string(RobotCmd.m_Slot);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case _RobotCmd_ResetErr:
|
|
|
InfoStr = "_RobotCmd_ResetErr";
|
|
|
break;
|
|
|
case _RobotCmd_Arm1Arm2MergePos:
|
|
|
InfoStr = "_RobotCmd_Arm1Arm2MergePos";
|
|
|
break;
|
|
|
case _RobotCmd_QueryState:
|
|
|
InfoStr = "_RobotCmd_QueryState";
|
|
|
break;
|
|
|
case _RobotCmd_QueryCoord1:
|
|
|
InfoStr = "_RobotCmd_QueryCoord1";
|
|
|
break;
|
|
|
case _RobotCmd_QueryCoord2:
|
|
|
InfoStr = "_RobotCmd_QueryCoord2";
|
|
|
break;
|
|
|
case _RobotCmd_QueryCoord3:
|
|
|
InfoStr = "_RobotCmd_QueryCoord3";
|
|
|
break;
|
|
|
case _RobotCmd_AlignerExt:
|
|
|
InfoStr = "_RobotCmd_AlignerExt";
|
|
|
break;
|
|
|
case _RobotCmd_AlignerOrg:
|
|
|
InfoStr = "_RobotCmd_AlignerOrg";
|
|
|
break;
|
|
|
case _RobotCmd_AlignerVacOn:
|
|
|
InfoStr = "_RobotCmd_AlignerVacOn";
|
|
|
break;
|
|
|
case _RobotCmd_AlignerVacOff:
|
|
|
InfoStr = "_RobotCmd_AlignerVacOff";
|
|
|
break;
|
|
|
case _RobotCmd_AlignerSetPar:
|
|
|
InfoStr = "_RobotCmd_AlignerSetPar";
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
return InfoStr;
|
|
|
}
|
|
|
|
|
|
void JELOperate::RobotJel_GetSendCmd(CRobotCmdInfo &RobotCmd)
|
|
|
{
|
|
|
int RobotCmdWaitTime = m_nWaitTime;
|
|
|
|
|
|
if (RobotCmd.m_RobotCmdType == _RobotCmd_RunToCassMappingPoint)
|
|
|
{
|
|
|
if (RobotCmd.LoadportId == LOADPORT_LEFT)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G300";
|
|
|
}
|
|
|
else if (RobotCmd.LoadportId == LOADPORT_CENTER)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G301";
|
|
|
}
|
|
|
else if (RobotCmd.LoadportId == LOADPORT_RIGHT)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G302";
|
|
|
}
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_ImmediateReadFeedback;//等待完成
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (RobotCmd.m_RobotCmdType == _RobotCmd_ReadMappingData)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G35";
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_ImmediateReadFeedback;//等待完成
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (RobotCmd.m_RobotCmdType == _RobotCmd_Mapping)
|
|
|
{
|
|
|
if (RobotCmd.LoadportId == LOADPORT_LEFT)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G7";
|
|
|
}
|
|
|
else if (RobotCmd.LoadportId == LOADPORT_CENTER)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G8";
|
|
|
}
|
|
|
else if (RobotCmd.LoadportId == LOADPORT_RIGHT)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G9";
|
|
|
}
|
|
|
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitCmdEnd;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = RobotCmdWaitTime;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (RobotCmd.m_RobotCmdType == _RobotCmd_Check_ARM_EXIST_WAFER)
|
|
|
{
|
|
|
if (RobotCmd.m_armPos == "up")
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1CS4";
|
|
|
}
|
|
|
else if (RobotCmd.m_armPos == "down")
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1CS8";
|
|
|
}
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_ImmediateReadFeedback;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = RobotCmdWaitTime;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (RobotCmd.m_RobotCmdType == _RObotCmd_RotateToWaferIdPos)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G310";
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitCmdEnd;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = RobotCmdWaitTime;
|
|
|
}
|
|
|
|
|
|
if (RobotCmd.m_RobotCmdType == _RobotCmd_Init_Align)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G299";
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitCmdEnd;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = RobotCmdWaitTime;
|
|
|
}
|
|
|
if (RobotCmd.m_RobotCmdType == _RObotCmd_Switch_bank)
|
|
|
{
|
|
|
if (RobotCmd.m_Slot == 1)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G5";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G4";
|
|
|
}
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = RobotCmdWaitTime;
|
|
|
}
|
|
|
|
|
|
if (RobotCmd.m_RobotCmdType == _RobotCmd_AlignerOrg)//reset err->org->取料位置
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G112";
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = RobotCmdWaitTime;
|
|
|
}
|
|
|
if (RobotCmd.m_RobotCmdType == _RobotCmd_Port1Org)//reset err->org->取料位置
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G105";
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitCmdEnd;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = RobotCmdWaitTime;
|
|
|
}
|
|
|
if (RobotCmd.m_RobotCmdType == _RobotCmd_Port2Org)//reset err->org->取料位置
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G106";
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitCmdEnd;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = RobotCmdWaitTime;
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_AlignerExt)//执行准直
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitCmdEnd;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = 20;
|
|
|
RobotCmd.m_SendCmdStr = "$1G294";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_AlignerVacOn)//aligner真空on
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//只发送
|
|
|
RobotCmd.m_SendCmdStr = "$2WUC";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_AlignerVacOff)//aligner真空off
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//只发送
|
|
|
RobotCmd.m_SendCmdStr = "$2WDF";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_AlignerSetPar)//设置aligner角度
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//只发送
|
|
|
std::string str = "$2WOP" + std::to_string(m_nAligner);
|
|
|
RobotCmd.m_SendCmdStr = str;
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_ResetErr)//Robot重置错误
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//只发送
|
|
|
RobotCmd.m_SendCmdStr = "$1RD";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_QueryState)//查询状态
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitFeedback;//发送后只等待反馈<
|
|
|
RobotCmd.m_SendCmdStr = "$1ER";
|
|
|
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_Org)//ROBOT ORG
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G3";
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitCmdEnd;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = RobotCmdWaitTime;
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_QueryCoord1)//Robot查询坐标
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_ImmediateReadFeedback;//立即读取反馈(同步)
|
|
|
RobotCmd.m_SendCmdStr = "$16X";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_QueryCoord2)//Robot查询坐标
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_ImmediateReadFeedback;//立即读取反馈(同步)
|
|
|
RobotCmd.m_SendCmdStr = "$16R";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_QueryCoord3)//Robot查询坐标
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_ImmediateReadFeedback;//立即读取反馈(同步)
|
|
|
RobotCmd.m_SendCmdStr = "$16Y";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_Arm1VacOff)//Arm1真空off
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//只发送
|
|
|
RobotCmd.m_SendCmdStr = "$1DS20";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_Arm2VacOff)//Arm2真空off
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//只发送
|
|
|
RobotCmd.m_SendCmdStr = "$1DS10";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_Arm1VacOn)//Arm1真空on
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//只发送
|
|
|
RobotCmd.m_SendCmdStr = "$1DS21";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_Arm2VacOn)//Arm2真空on
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//只发送
|
|
|
RobotCmd.m_SendCmdStr = "$1DS11";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_AdsVacOn)
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//只发送
|
|
|
RobotCmd.m_SendCmdStr = "$1G91";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_AdsVacOff)
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//只发送
|
|
|
RobotCmd.m_SendCmdStr = "$1G82";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_InitSet)
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_SendOnly;//只发送
|
|
|
RobotCmd.m_SendCmdStr = "$1G80";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_Arm_Check)
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitCmdEnd;//只发送
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_Arm1)
|
|
|
RobotCmd.m_SendCmdStr = "$1G36";
|
|
|
else
|
|
|
RobotCmd.m_SendCmdStr = "$1G37";
|
|
|
}
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_TransferWafer)//Robot传输指令
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitCmdEnd;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = RobotCmdWaitTime;
|
|
|
//上手指取_WaferPos_Cassette
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_Cassette && RobotCmd.m_ToPos == _WaferPos_Arm1)
|
|
|
{
|
|
|
//料盒1取晶圆指令:$1G10->$1G34,料盒2取晶圆指令:$1G80->$1G104
|
|
|
std::string cmdStr = "$1G";
|
|
|
int cmdIndex = 0;
|
|
|
RobotCmd.m_cassIndex == 1 ? cmdIndex = RobotCmd.m_Slot + 9 : cmdIndex = RobotCmd.m_Slot + 79;
|
|
|
cmdStr += std::to_string(cmdIndex);
|
|
|
RobotCmd.m_SendCmdStr = cmdStr;
|
|
|
|
|
|
}
|
|
|
//上手指放_WaferPos_Cassette
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_Arm1 && RobotCmd.m_ToPos == _WaferPos_Cassette)
|
|
|
{
|
|
|
//料盒1放晶圆指令:$1G40->$1G64,料盒2取晶圆指令:$1G110->$1G134
|
|
|
std::string cmdStr = "$1G";
|
|
|
int cmdIndex = 0;
|
|
|
RobotCmd.m_cassIndex == 1 ? cmdIndex = RobotCmd.m_Slot + 39 : cmdIndex = RobotCmd.m_Slot + 109;
|
|
|
cmdStr += std::to_string(cmdIndex);
|
|
|
RobotCmd.m_SendCmdStr = cmdStr;
|
|
|
|
|
|
}
|
|
|
|
|
|
//手指取放Aligner
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_Arm1 && RobotCmd.m_ToPos == _WaferPos_Aligner)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G291";
|
|
|
}
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_Aligner && RobotCmd.m_ToPos == _WaferPos_Arm1)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G290";
|
|
|
}
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_Aligner && RobotCmd.m_ToPos == _WaferPos_Arm2)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G292";
|
|
|
}
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_Arm2 && RobotCmd.m_ToPos == _WaferPos_Aligner)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G293";
|
|
|
}
|
|
|
//手指取放HotPlate
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_Arm2 && RobotCmd.m_ToPos == _WaferPos_HotPlate)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G298";
|
|
|
}
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_HotPlate && RobotCmd.m_ToPos == _WaferPos_Arm2)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G297";
|
|
|
}
|
|
|
}
|
|
|
//移动到等待位置
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_ToWaitPos)
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitCmdEnd;//等待完成
|
|
|
RobotCmd.m_WaitCmdTime = RobotCmdWaitTime;
|
|
|
//Arm2移动到取aligner 等待位
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_Aligner && RobotCmd.m_ToPos == _WaferPos_Arm2)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G287";
|
|
|
}
|
|
|
//Arm2移动到取preheater 等待位
|
|
|
if (RobotCmd.m_FromPos == _WaferPos_HotPlate && RobotCmd.m_ToPos == _WaferPos_Arm2)
|
|
|
{
|
|
|
RobotCmd.m_SendCmdStr = "$1G289";
|
|
|
}
|
|
|
}
|
|
|
//Arm1和Arm2合并位置
|
|
|
else if (RobotCmd.m_RobotCmdType == _RobotCmd_Arm1Arm2MergePos)
|
|
|
{
|
|
|
RobotCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitCmdEnd;//等待完成
|
|
|
RobotCmd.m_SendCmdStr = "$1G295";
|
|
|
RobotCmd.m_WaitCmdTime = 20;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
eGlobalVariableType JELOperate::RobotJel_SendCmdToRobotExt(CRobotCmdInfo &RobotCmd)
|
|
|
{
|
|
|
std::string RetStr;
|
|
|
std::string SendCmd = RobotCmd.m_SendCmdStr;
|
|
|
//gLogMgr->WriteDebugLog("ROBOT SEND:" + SendCmd);
|
|
|
bool bOvertime = false;
|
|
|
std::string ErrMsg;
|
|
|
{
|
|
|
int len = SendCmd.length();
|
|
|
SendCmd += " ";//增加2 字节来存放<CR><LF>
|
|
|
char *pStr = (char*)SendCmd.c_str();
|
|
|
pStr[len++] = 0x0d;//<CR>
|
|
|
pStr[len++] = 0x0a;//<LF>
|
|
|
char Buf[COM_BUF_LEN];
|
|
|
memset(Buf, 0, COM_BUF_LEN);
|
|
|
memcpy(Buf, pStr, len);
|
|
|
m_RobotComm.WriteBuf(Buf, len);
|
|
|
if (RobotCmd.m_RobotCmdSendType == _RobotCmdSendType_SendOnly)//只发送指令
|
|
|
{
|
|
|
return _GlobalVar_NULL;
|
|
|
}
|
|
|
//立即读取反馈
|
|
|
if (RobotCmd.m_RobotCmdSendType == _RobotCmdSendType_ImmediateReadFeedback)
|
|
|
{
|
|
|
m_armIsExistWafer = false;
|
|
|
Sleep(1000);
|
|
|
m_IsbJelCommRecv = false;//重置
|
|
|
memset(Buf, 0, COM_BUF_LEN);
|
|
|
m_RobotComm.ReadBuf(Buf, COM_BUF_LEN);
|
|
|
std::string RetStr(Buf);
|
|
|
|
|
|
//>$10表示有料,>$11表示无料
|
|
|
int findIndex = 0;
|
|
|
findIndex = RetStr.find(">$11");
|
|
|
findIndex >= 0 ? m_armIsExistWafer = true : m_armIsExistWafer = false;
|
|
|
|
|
|
if (RetStr.find(">") != -1)//反馈">"表示执行中
|
|
|
{
|
|
|
RobotCmd.m_RevStr = RetStr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ErrMsg = "Read Feed back Err";
|
|
|
}
|
|
|
}
|
|
|
else//异步等待读取
|
|
|
{
|
|
|
int WaitDelay = RobotCmd.m_WaitCmdTime * 1000;//总共等待的时间ms
|
|
|
int CheckDelay = 200;//每次循环延时
|
|
|
int CurDelay = 0;//当前的总延时
|
|
|
bOvertime = false;
|
|
|
ErrMsg = "";
|
|
|
while (1)
|
|
|
{
|
|
|
if (m_IsbJelCommRecv)//收到新的消息时再去读取
|
|
|
{
|
|
|
Sleep(CheckDelay);
|
|
|
m_IsbJelCommRecv = false;//重置
|
|
|
memset(Buf, 0, COM_BUF_LEN);
|
|
|
m_RobotComm.ReadBuf(Buf, COM_BUF_LEN);
|
|
|
std::string RetStr(Buf);
|
|
|
if (RetStr.find(">") != -1)//反馈">"表示执行中
|
|
|
{
|
|
|
//发送后只等待反馈<
|
|
|
if (RobotCmd.m_RobotCmdSendType == _RobotCmdSendType_WaitFeedback)
|
|
|
{
|
|
|
RobotCmd.m_RevStr = RetStr;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
//RobotCmd.m_RobotCmdSendType == _RobotCmdSendType_WaitCmdEnd
|
|
|
if (RetStr.find(RobotCmd.m_SendCmdStr) != -1)//反馈发送cmd表示执行结束
|
|
|
{
|
|
|
//gLogMgr->WriteDebugLog("REV_STR END");
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
else if (RetStr.find("ERROR") != -1)
|
|
|
{
|
|
|
//gLogMgr->WriteDebugLog("REV_STR ERROR");
|
|
|
ErrMsg = "手臂有片或无片错误";
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
CurDelay += CheckDelay;
|
|
|
if (CurDelay > WaitDelay)
|
|
|
{
|
|
|
bOvertime = true;
|
|
|
break;
|
|
|
}
|
|
|
Sleep(CheckDelay);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (bOvertime)//检测超时
|
|
|
{
|
|
|
std::string AddInfo;
|
|
|
AddInfo = "Cmd Over Time:";
|
|
|
AddInfo += RobotCmd.m_SendCmdStr;
|
|
|
//设置报警信息
|
|
|
{
|
|
|
RobotCmd.m_ErrStr = AddInfo;
|
|
|
return _GlobalVar_Alarm_Robot_CmdOverTime;
|
|
|
}
|
|
|
}
|
|
|
//ERR:code:Description
|
|
|
if (ErrMsg != "")//执行错误
|
|
|
{
|
|
|
std::string AddInfo = RobotCmd.m_SendCmdStr;
|
|
|
AddInfo += "Cmd Execute Error:";
|
|
|
AddInfo += ErrMsg;
|
|
|
//设置报警信息
|
|
|
{
|
|
|
RobotCmd.m_ErrStr = AddInfo;
|
|
|
return _GlobalVar_Alarm_Robot_StateErr;
|
|
|
}
|
|
|
}
|
|
|
return _GlobalVar_NULL;
|
|
|
}
|
|
|
|
|
|
eGlobalVariableType JELOperate::CheckRobotErrState(CRobotCmdInfo &RobotCmd)
|
|
|
{
|
|
|
eGlobalVariableType AlarmType = _GlobalVar_NULL;
|
|
|
{
|
|
|
CRobotCmdInfo TempCmd;
|
|
|
TempCmd.m_SendCmdStr = "$1ERLG";//robot 状态
|
|
|
TempCmd.m_RobotCmdSendType = _RobotCmdSendType_WaitFeedback;
|
|
|
AlarmType = RobotJel_SendCmdToRobotExt(TempCmd);
|
|
|
}
|
|
|
return _GlobalVar_NULL;
|
|
|
}
|
|
|
|
|
|
void JELOperate::OnRobotCommRecv()
|
|
|
{
|
|
|
m_IsbJelCommRecv = true;//是否收到串口消息
|
|
|
}
|