$$DMISLAYER/'SCR200Calibration.dms'
DECL/REAL,PORTX,PORTY,PORTZ,IT,JT,I,J,K,SNLENG,FPORTX,FPORTY,DirFac,PortPos
DECL/INTGR,10,L,PORTDIR
DECL/CHAR,10,CalibFile,HomeDir
$$ENDLAYER
PortPos=0
TEXT/OPER,'Latch all port lids in their open position.'
UNITS/MM,ANGDEC
WKPLAN/XYPLAN
MODE/MAN
RECALL/D(MCS)
$$S(DEFAULT)=SNSDEF/PROBE,INDEX,POL,0.0000,0.0000,$
0.000000,0.000000,-1.000000,126.9744,1.9797
SNLENG=OBTAIN/SA(DEFAULT),9
SNSLCT/S(DEFAULT)
PRCOMP/OFF
CALL/EXTERN,DME, 'V3DHOME',HomeDir
CalibFile = CONCAT(HomeDir,'\Users\Sensor\SCR200calib.data')
DID(PORTDATA)=DEVICE/STOR,CalibFile
OPEN/DID(PORTDATA),DIRECT,OUTPUT,OVERWR
F(P1)=FEAT/POINT,CART, 100.000000, 100.000000, 100.000000, 0.000000, $
-1.000000, 0.000000
MEAS/POINT,F(P1),1
PTMEAS/CART,100.000000,100.000000,100.000000,0.000000,-1.000000,0.000000
ENDMES
F(P2)=FEAT/POINT,CART, 200.000000, 100.000000, 100.000000, 0.000000, $
-1.000000, 0.000000
MEAS/POINT,F(P2),1
PTMEAS/CART,200.000000,100.000000,100.000000,0.000000,-1.000000,0.000000
ENDMES
F(RACKLN)=FEAT/LINE,UNBND,CART, 150.000000, 100.000000, 100.000000, 1.000000, $
0.000000, 0.000000, 0.000000, -1.000000, 0.000000
CONST/LINE,F(RACKLN),BF,FA(P2),FA(P1)
I = OBTAIN/FA(RACKLN),7
J = OBTAIN/FA(RACKLN),8
K = OBTAIN/FA(RACKLN),9
WRITE/DID(PORTDATA),I,',',J,',',K
IT=ABS(I)
JT=ABS(J)
IF/IT > JT
PORTDIR=1
ELSE
IF/J > 0
PORTDIR=2
ELSE
PORTDIR=3
ENDIF
ENDIF
$$
F(P3)=FEAT/POINT,CART, 100.000000, 150.000000, 100.000000, 0.000000, $
-1.000000, 0.000000
MEAS/POINT,F(P3),1
PTMEAS/CART,100.000000,150.000000,100.000000,0.000000,-1.000000,0.000000
ENDMES
F(P4)=FEAT/POINT,CART, 100.000000, 150.000000, 100.000000, 0.000000, $
0.000000, 1.000000
MEAS/POINT,F(P4),1
PTMEAS/CART,100.000000,150.000000,100.000000,0.000000,0.000000,1.000000
ENDMES
PORTZ = OBTAIN/FA(P4),5
$$
M(MEASPT)=MACRO/PTNum
DECL/LOCAL,CHAR,80,StrPtNo1,StrPtNo2
DECL/LOCAL,INTGR,PTSNo
PTSNo = PTNum
StrPtNo1 = STR(PTSNO)
StrPtNo1 = CONCAT('P',StrPtNo1)
F(StrPtNo1)=FEAT/POINT,CART, 245.841504, 178.573487, 76.230209, 0.999889, $
0.006672, 0.013345
MEAS/POINT,F(StrPtNo1),1
PTMEAS/CART,245.841504,178.573487,76.230209,0.999889,0.006672,0.013345
ENDMES
PTSNo = PTSNo + 1
StrPtNo2 = STR(PTSNO)
StrPtNo2 = CONCAT('P',StrPtNo2)
F(StrPtNo2)=FEAT/POINT,CART, 257.767601, 178.603847, 76.309317, -0.999932, $
0.005586, -0.010241
MEAS/POINT,F(StrPtNo2),1
PTMEAS/CART,257.767601,178.603847,76.309317,-0.999932,0.005586,-0.010241
ENDMES
F(MIDDLEPT)=FEAT/POINT,CART, 251.804552, 178.588667, 76.269763, 0.000000, $
0.000000, 1.000000
CONST/POINT,F(MIDDLEPT),MIDPT,FA(StrPtNo2),FA(StrPtNo1)
ENDMAC
$$
M(LPWRT)=MACRO/DirFactor
DirFac = DirFactor
IF/DirFac.EQ.-1
PortPos=60
ELSE
IF/DirFac.EQ.-2
PortPos=-60
ENDIF
ENDIF
DO/L,0,2,1
IF/(PORTDIR.EQ.1)
PORTX=FPORTX+(30*L)-PortPos
ENDIF
IF/(PORTDIR.EQ.2)
PORTY=FPORTY+(30*L)-PortPos
ENDIF
IF/(PORTDIR.EQ.3)
PORTY=FPORTY-(30*L)-PortPos
ENDIF
WRITE/DID(PORTDATA),PORTX,',',PORTY,',',PORTZ
ENDDO
ENDMAC
$$
IF/(PORTDIR.EQ.1)
PORTY = OBTAIN/FA(P3),4
PORTY = PORTY+15
CALL/M(MEASPT),5
FPORTX = OBTAIN/FA(MIDDLEPT),3
CALL/M(LPWRT),1
CALL/M(MEASPT),7
FPORTX = OBTAIN/FA(MIDDLEPT),3
CALL/M(LPWRT),-1
ENDIF
IF/(PORTDIR.EQ.2)
PORTX = OBTAIN/FA(P3),3
PORTX = PORTX-15
CALL/M(MEASPT),5
FPORTY = OBTAIN/FA(MIDDLEPT),4
CALL/M(LPWRT),1
CALL/M(MEASPT),7
FPORTY = OBTAIN/FA(MIDDLEPT),4
CALL/M(LPWRT),-1
ENDIF
IF/(PORTDIR.EQ.3)
PORTX = OBTAIN/FA(P3),3
PORTX = PORTX+15
CALL/M(MEASPT),5
FPORTY = OBTAIN/FA(MIDDLEPT),4
CALL/M(LPWRT),1
CALL/M(MEASPT),7
FPORTY = OBTAIN/FA(MIDDLEPT),4
CALL/M(LPWRT),-2
ENDIF
WRITE/DID(PORTDATA),SNLENG,',','0',',','39.6'
CLOSE/DID(PORTDATA),KEEP
dmesw/COMAND,'configscr:CalibFile'
PRCOMP/ON
MODE/PROG,MAN
TEXT/OPER,'Calibration completed!'
ENDFIL