PROC IndexToStn1() //检测变位机状态 并设置要运行到的角度位置 并对不同的GetNextPartAdv返回值情况 进行处理 VAR bool bActive;VAR jointtarget jtCurrent; //声明一个位置变量IF (NOT bInterchCalib1) CalibIntch1; ! reset inpos signals used in vcReset soLS_1_INPOS;Reset soLS_2_INPOS; //复位变位机的输出bActive:=IsMechUnitActive(INTERCH); //是否变位机激活IF (NOT bActive) ActInterch1; //激活变位机jtCurrent:=CJointT(); // 得到当前角度! get parts for stationsGetNextPartAdv 1,padvTmp1\statusCode:=retCode1;//得到存储的partdata类型的数据的值, 并将GetNextPartAdv 返回状态赋值给retCode1GetNextPartAdv 2,padvTmp2\statusCode:=retCode2;IF (retCode1=0) THENjtCurrent.extax.eax_e:=padvTmp1.procAngle.eax_e; //如果返回成功,将partdata类型数据的eax_e的值赋值给当前jtCurrentELSEjtCurrent.extax.eax_e:=0; //否则赋值0 并进行处理text_res_no:=TextResTabGet("CellText");sHeader:=TextResGet(text_res_no,218);IF (retcode1=-1) THENsMsgArr{1}:=TextResGet(text_res_no,202)+" 1";sMsgArr{2}:=TextResGet(text_res_no,214);sMsgArr{3}:="";sMsgArr{4}:="";ErrWrite\W,sHeader,sMsgArr{1}\RL2:=sMsgArr{2}\RL3:=sMsgArr{3}\RL4:=sMsgArr{4};ELSEIF (retcode1=-2) THENsMsgArr{1}:=TextResGet(text_res_no,204)+" 1";sMsgArr{2}:=TextResGet(text_res_no,205)+" 1";sMsgArr{3}:=TextResGet(text_res_no,214);sMsgArr{4}:="";ErrWrite\W,sHeader,sMsgArr{1}\RL2:=sMsgArr{2}\RL3:=sMsgArr{3}\RL4:=sMsgArr{4};ENDIFENDIFIF (retCode2=0) THENjtCurrent.extax.eax_f:=padvTmp2.loadAngle.eax_f;ELSEjtCurrent.extax.eax_f:=0;text_res_no:=TextResTabGet("CellText");sHeader:=TextResGet(text_res_no,218);IF (retcode2=-1) THENsMsgArr{1}:=TextResGet(text_res_no,202)+" 2";sMsgArr{2}:=TextResGet(text_res_no,213);sMsgArr{3}:="";sMsgArr{4}:="";ErrWrite\W,sHeader,sMsgArr{1}\RL2:=sMsgArr{2}\RL3:=sMsgArr{3}\RL4:=sMsgArr{4};ELSEIF (retcode2=-2) THENsMsgArr{1}:=TextResGet(text_res_no,204)+" 2";sMsgArr{2}:=TextResGet(text_res_no,205)+" 2";sMsgArr{3}:=TextResGet(text_res_no,213);sMsgArr{4}:="";ErrWrite\W,sHeader,sMsgArr{1}\RL2:=sMsgArr{2}\RL3:=sMsgArr{3}\RL4:=sMsgArr{4};ENDIFENDIF! apply interchange positionjtCurrent.extax.eax_d:=nInterchStn1; //将存储的变位机水平轴位置赋值给当前IF (TaskRunRob()) THEN //判定程序运行于哪个平台MoveAbsJ jtCurrent,sdInterch1,fine,tool0; ELSE%"MoveExtJ"% jtCurrent,sdInterch1,fine; //如果是外部轴 则运动到指定位置ENDIFIF (NOT RobOS()) Set soLS_1_INPOS; //并设置相应的变位机状态给PLCWaitTime nTorqueTime; IF (NOT bActive) DeactInterch1; //如果在运行这段程序之前 变位机没有激活 则 运行这段程序之后也保持运行之前的状态 ENDPROC