首页/文章/ 详情

RationalDMIS构建坐标系

1天前浏览3


DMISMN/'Created by [天永智能装备股份有限公司] on 星期二, 十月 17, 2017', 4.0

UNITS/MM, ANGDEC

WKPLAN/XYPLAN

PRCOMP/ON

TECOMP/ON

FLY/1.0

MODE/PROG, MAN

SNSET/APPRCH, 3.000000

SNSET/RETRCT, 3.000000

SNSET/DEPTH, 0.000000

SNSET/SEARCH, 10.000000

SNSET/CLRSRF, 50.000000

RECALL/D(MCS)

SNSLCT/S(20-30X2)

GEOALG/CIRCLE, LSTSQR

GEOALG/ARC, LSTSQR

GEOALG/PLANE, LSTSQR

$$

$$

MODE/MAN

F(PLN1) = FEAT/PLANE,CART, 447.9898, -851.3108, -663.7937, 0.000002,$

-0.000739, 1.000000

$$ Measurement points are created through actual points

MEAS/PLANE, F(PLN1), 4

  PTMEAS/CART,  381.124480, -783.327320, -663.743379,  0.000002, -0.000739,$

1.000000

  PTMEAS/CART,  518.325999, -783.327232, -663.743587,  0.000002, -0.000739,$

1.000000

  PTMEAS/CART,  518.331993, -919.289585, -663.844089,  0.000002, -0.000739,$

1.000000

  PTMEAS/CART,  374.176822, -919.299166, -663.843878,  0.000002, -0.000739,$

1.000000

ENDMES

D(CRD1) = DATSET/FA(PLN1), ZDIR

D(CRD1) = TRANS/ZORIG, FA(PLN1)

F(CIR1) = FEAT/CIRCLE,INNER,CART, 414.7606, -847.5162, -5.3283, 0.000000,$

0.000000, 1.000000, 35.1921

$$ Measurement points are created through actual points

MEAS/CIRCLE, F(CIR1), 4

  PTMEAS/CART,  397.235226, -849.091495, -5.328321,  0.995985, 0.089524,$

-0.000000

  PTMEAS/CART,  410.098353, -830.549086, -5.328321,  0.264961, -0.964259,$

-0.000000

  PTMEAS/CART,  431.525423, -842.171906, -5.328321,  -0.952760, -0.303723,$

-0.000000

  PTMEAS/CART,  411.759462, -864.854446, -5.328321,  0.170558, 0.985348,$

-0.000000

ENDMES

F(CIR2) = FEAT/CIRCLE,INNER,CART, 485.2421, -847.2645, -4.3219, 0.000000,$

0.000000, 1.000000, 35.2190

$$ Measurement points are created through actual points

MEAS/CIRCLE, F(CIR2), 4

  PTMEAS/CART,  481.453270, -830.067499, -4.321950,  0.215158, -0.976579,$

-0.000000

  PTMEAS/CART,  502.362259, -843.142241, -4.321950,  -0.972213, -0.234096,$

-0.000000

  PTMEAS/CART,  485.096192, -864.873422, -4.321950,  0.008285, 0.999966,$

-0.000000

  PTMEAS/CART,  467.994641, -850.816908, -4.321950,  0.979441, 0.201730,$

-0.000000

ENDMES

F(PROJPT1) = FEAT/POINT,CART, 414.7606, -847.5162, 0.0000, -0.000000,$

0.000000, -1.000000

CONST/POINT,F(PROJPT1),PROJPT,FA(CIR1),FA(PLN1)

F(PROJPT2) = FEAT/POINT,CART, 485.2421, -847.2645, 0.0000, -0.000000,$

0.000000, -1.000000

CONST/POINT,F(PROJPT2),PROJPT,FA(CIR2),FA(PLN1)


$$ CREATED BY : External-Array Software, Inc

$$ DATE : Jan 19, 2009

$$ DISLAIMER: 

$$ This Macro has been tested internally but not been tested with

$$ other DMIS compatible software. This Macro is provided as sample

$$ and can be modifed for your own use. External-Array doesn't not 

$$ guarantee the quality of this Macro.


$$ FUNCION: Create a nominal line using two actual features

$$ DI, DJ, DK are the normal vector of the plane that the line lies on


M(EASI_2PT_TO_LINE) = Macro/'FEAT1', 'FEAT2', 'FEATLINE', DI, DJ, DK

DECL/LOCAL,DOUBLE,DVALUE[6]

    DECL/LOCAL,INTGR, INDEX1, INDEX2

    

    CALL/M(EASI_GETX_INDEX), FEAT1, INDEX1

    CALL/M(EASI_GETX_INDEX), FEAT2, INDEX2

    

DVALUE[1] = OBTAIN/FA(@FEAT1),INDEX1

DVALUE[2] = OBTAIN/FA(@FEAT1),INDEX1+1

DVALUE[3] = OBTAIN/FA(@FEAT1),INDEX1+2

      

DVALUE[4] = OBTAIN/FA(@FEAT2),INDEX2

DVALUE[5] = OBTAIN/FA(@FEAT2),INDEX2+1

DVALUE[6] = OBTAIN/FA(@FEAT2),INDEX2+2

      

    F(@FEATLINE) = FEAT/LINE,BND,CART,DVALUE[1],DVALUE[2],DVALUE[3],$

                                      DVALUE[4],DVALUE[5],DVALUE[6],$

                                      DI, DJ, DK

ENDMAC


CALL/M(EASI_2PT_TO_LINE),(PROJPT1),(PROJPT2),(BFLN1), -0.000002, 0.000739,$

1.000000

CONST/LINE,F(BFLN1),BF,FA(PROJPT1),FA(PROJPT2)

D(CRD2) = ROTATE/ZAXIS, FA(BFLN1), XDIR

D(CRD3) = TRANS/XORIG, FA(PROJPT1), YORIG, FA(PROJPT1)


TEXT/OPER, '请将测头移动到安全位置!!'

GOTO/0.000000, 0.000000, 200.000000


MODE/PROG,MAN


$$ This sample DMIS Macro is provided by External-Array Software, Inc.

$$ It should be modified for your own use. There is no guarantee for

$$ the quality of this Macro. November, 2003


$$ FUNCION: Move machine CLEAR DIST above the current clear surface 

$$ plane and then move machine parallel to the clear surface

$$ plane to the project point of POINT(TARX, TARY, TARZ) on 

$$ the clear surface plane but CLEAR DIST above the plane

$$ ALL Macro parameters are in PCS and Current UNITS

$$ Last update: 3-1-04 Add mode checking. only works in PROG MODE

$$ Last update: 8-24-04 Clear position is based on the surface of

$$ ruby ball instead of the center of it.


M(EASI_CLEARPLN_GOTO) = MACRO/ISNOM, TARX, TARY, TARZ

DECL/LOCAL, REAL, CCX, CCY, CCZ, CCI, CCJ, CCK

DECL/LOCAL, REAL, CURX, CURY, CURZ, TD, CLRDIST, SDIAM

DECL/LOCAL, CHAR, 255, CLRLABEL, FLABEL, MMODE, SNAME


MMODE = VALUE/MODE

CLRLABEL = VALUE/SNSET, CLRSRF

IF/ ( (LEN(CLRLABEL) .GT. 0) .AND. (MMODE .EQ. 'PROG,MAN') )

CLRDIST = VALUE/SNSET, CLRSRF, DIST

FLABEL = ASSIGN/'FA'

IF/ ISNOM .EQ. 0

FLABEL = ASSIGN/'F'

ENDIF

CCX = OBTAIN/FLABEL(@CLRLABEL), 3

CCY = OBTAIN/FLABEL(@CLRLABEL), 4

CCZ = OBTAIN/FLABEL(@CLRLABEL), 5

CCI = OBTAIN/FLABEL(@CLRLABEL), 6

CCJ = OBTAIN/FLABEL(@CLRLABEL), 7

CCK = OBTAIN/FLABEL(@CLRLABEL), 8

SNAME = VALUE/SNSLCT

SDIAM = OBTAIN/SS(SNAME), 8

CCX = ASSIGN/CCX + CCI * SDIAM/2

CCY = ASSIGN/CCY + CCJ * SDIAM/2

CCZ = ASSIGN/CCZ + CCK * SDIAM/2


CURX = VALUE/GOTO, XAXIS

CURY = VALUE/GOTO, YAXIS

CURZ = VALUE/GOTO, ZAXIS

TD = ASSIGN/(CURX - CCX) * CCI + (CURY - CCY) * CCJ + (CURZ - CCZ) * CCK

IF/ TD .LT. CLRDIST

TD = ASSIGN/(CLRDIST - TD)

GOTO/CURX+CCI*TD, CURY+CCJ*TD, CURZ+CCK*TD

ENDIF

TD = ASSIGN/(TARX - CCX) * CCI + (TARY - CCY) * CCJ + (TARZ - CCZ) * CCK

IF/ TD .LT. CLRDIST

TD = ASSIGN/(CLRDIST - TD)

GOTO/TARX+CCI*TD, TARY+CCJ*TD, TARZ+CCK*TD

ENDIF

ENDIF

ENDMAC

SNSET/APPRCH, 3

SNSET/RETRCT, 3

SNSET/DEPTH, 0.0000

SNSET/SEARCH, 10.0000

SNSET/CLRSRF, 50

DECL/COMMON,REAL,PLN1_1_AX

PLN1_1_AX = OBTAIN/FA(PLN1)[1],2

DECL/COMMON,REAL,PLN1_1_AY

PLN1_1_AY = OBTAIN/FA(PLN1)[1],3

DECL/COMMON,REAL,PLN1_2_AX

PLN1_2_AX = OBTAIN/FA(PLN1)[2],2

DECL/COMMON,REAL,PLN1_2_AY

PLN1_2_AY = OBTAIN/FA(PLN1)[2],3

DECL/COMMON,REAL,PLN1_3_AX

PLN1_3_AX = OBTAIN/FA(PLN1)[3],2

DECL/COMMON,REAL,PLN1_3_AY

PLN1_3_AY = OBTAIN/FA(PLN1)[3],3

DECL/COMMON,REAL,PLN1_4_AX

PLN1_4_AX = OBTAIN/FA(PLN1)[4],2

DECL/COMMON,REAL,PLN1_4_AY

PLN1_4_AY = OBTAIN/FA(PLN1)[4],3

F(PT1) = FEAT/POINT,CART, PLN1_1_AX,PLN1_1_AY,0, 0,0,1

MEAS/POINT, F(PT1), 1

  PTMEAS/CART,  -33.407453, 63.818190, 0.000000,  -0.000000, -0.000000, 1.000000

ENDMES


F(PT2) = FEAT/POINT,CART, PLN1_2_AX,PLN1_2_AY,0, 0,0,1

MEAS/POINT, F(PT2), 1

  PTMEAS/CART,  103.793192, 63.328350, 0.000000,  -0.000000, -0.000000, 1.000000

ENDMES


F(PT3) = FEAT/POINT,CART, PLN1_3_AX,PLN1_3_AY,0, 0,0,1

MEAS/POINT, F(PT3), 1

  PTMEAS/CART,  103.313684, -72.633194, 0.000000,  -0.000000, -0.000000,$

1.000000

ENDMES


F(PT4) = FEAT/POINT,CART, PLN1_4_AX,PLN1_4_AY,0, 0,0,1

MEAS/POINT, F(PT4), 1

  PTMEAS/CART,  -40.840603, -72.128017, 0.000000,  -0.000000, -0.000000,$

1.000000

ENDMES

GOTO/-40.831450, -72.126086, 153.998471

F(PLN2) = FEAT/PLANE,CART, 33.2147, -4.4037, 0.0000, 0.000000, -0.000000,$

1.000000

CONST/PLANE,F(PLN2),BF,FA(PT1),FA(PT2),FA(PT3),FA(PT4)

SNSET/APPRCH, 3.0000

SNSET/RETRCT, 3.0000

SNSET/DEPTH, 0.0000

SNSET/SEARCH, 10.0000

SNSET/CLRSRF, FA(PLN2), 50.0000

F(CIR3) = FEAT/CIRCLE,INNER,CART, -0.0000, 0.0000, -5.0000, -0.000000,$

-0.000000, 1.000000, 35.2000

$$ Measurement points are created through nominal points

CALL/M(EASI_CLEARPLN_GOTO), 1, -6.653232, -11.754379, 45.000000

MEAS/CIRCLE, F(CIR3), 4

  GOTO/CART,  -6.653232, -11.754379, 45.000000

  PTMEAS/CART,  -8.620282, -15.229601, -5.000000,  0.492581, 0.870267, -0.000000

  GOTO/CART,  -10.644991, -8.313549, -5.000000

  GOTO/CART,  -13.016147, -3.607056, -5.000000

  GOTO/CART,  -13.405712, 1.648578, -5.000000

  PTMEAS/CART,  -15.229601, 8.620282, -5.000000,  0.870267, -0.492581, -0.000000

  GOTO/CART,  -8.313549, 10.644991, -5.000000

  GOTO/CART,  -3.607056, 13.016147, -5.000000

  GOTO/CART,  1.648578, 13.405712, -5.000000

  PTMEAS/CART,  8.620282, 15.229601, -5.000000,  -0.492581, -0.870267, 0.000000

  GOTO/CART,  10.644991, 8.313549, -5.000000

  GOTO/CART,  13.016147, 3.607056, -5.000000

  GOTO/CART,  13.405712, -1.648578, -5.000000

  PTMEAS/CART,  15.229601, -8.620282, -5.000000,  -0.870267, 0.492581, 0.000000

  GOTO/CART,  11.754379, -6.653232, 45.000000

ENDMES

F(CIR4) = FEAT/CIRCLE,INNER,CART, 70.5000, 0.0000, -5.0000, -0.000000,$

-0.000000, 1.000000, 35.2000

$$ Measurement points are created through nominal points

CALL/M(EASI_CLEARPLN_GOTO), 1, 11.763818, -6.651222, 50.991889

MEAS/CIRCLE, F(CIR4), 4

  GOTO/CART,  11.763818, -6.651222, 50.991889

  GOTO/CART,  84.006355, -0.096476, 45.000000

  PTMEAS/CART,  87.999554, -0.125000, -5.000000,  -0.999975, 0.007100, 0.000000

  GOTO/CART,  82.941325, -5.257791, -5.000000

  GOTO/CART,  79.982216, -9.618654, -5.000000

  GOTO/CART,  75.579526, -12.515165, -5.000000

  PTMEAS/CART,  70.375000, -17.499554, -5.000000,  0.007100, 0.999975, -0.000000

  GOTO/CART,  65.242209, -12.441325, -5.000000

  GOTO/CART,  60.881346, -9.482216, -5.000000

  GOTO/CART,  57.984835, -5.079526, -5.000000

  PTMEAS/CART,  53.000446, 0.125000, -5.000000,  0.999975, -0.007100, 0.000000

  GOTO/CART,  58.058675, 5.257791, -5.000000

  GOTO/CART,  61.017784, 9.618654, -5.000000

  GOTO/CART,  65.420474, 12.515165, -5.000000

  PTMEAS/CART,  70.625000, 17.499554, -5.000000,  -0.007100, -0.999975, 0.000000

  GOTO/CART,  70.596476, 13.506355, 45.000000

ENDMES

CALL/M(EASI_2PT_TO_LINE),(CIR3),(CIR4),(BFLN2), 0.000001, 0.000739, 1.000000

CONST/LINE,F(BFLN2),BF,FA(CIR3),FA(CIR4)

D(CRD4) = DATSET/FA(PLN2), ZDIR, FA(BFLN2), XDIR, FA(CIR3), XORIG

D(CRD4) = TRANS/ZORIG, FA(PLN2), YORIG, FA(CIR3), XORIG, -0

MODE/PROG,MAN

SNSET/APPRCH, 3.0000

SNSET/RETRCT, 3.0000

SNSET/DEPTH, 0.0000

SNSET/SEARCH, 10.0000

SNSET/CLRSRF, FA(PLN2), 50.0000

F(J-1) = FEAT/CIRCLE,INNER,CART, 0.0000, 0.0000, -5.0000, 0.000000,$

-0.000000, 1.000000, 35.2000

$$ Measurement points are created through nominal points

CALL/M(EASI_CLEARPLN_GOTO), 1, 13.506300, -0.103886, 45.000000

MEAS/CIRCLE, F(J-1), 4

  GOTO/CART,  13.506300, -0.103886, 45.000000

  PTMEAS/CART,  17.499482, -0.134600, -5.000000,  -0.999970, 0.007700, -0.000000

  GOTO/CART,  12.438439, -5.264615, -5.000000

  GOTO/CART,  9.476938, -9.623855, -5.000000

  GOTO/CART,  5.072659, -12.517949, -5.000000

  PTMEAS/CART,  -0.134600, -17.499482, -5.000000,  0.007700, 0.999970, -0.000000

  GOTO/CART,  -5.264615, -12.438439, -5.000000

  GOTO/CART,  -9.623855, -9.476938, -5.000000

  GOTO/CART,  -12.517949, -5.072659, -5.000000

  PTMEAS/CART,  -17.499482, 0.134600, -5.000000,  0.999970, -0.007700, 0.000000

  GOTO/CART,  -12.438439, 5.264615, -5.000000

  GOTO/CART,  -9.476938, 9.623855, -5.000000

  GOTO/CART,  -5.072659, 12.517949, -5.000000

  PTMEAS/CART,  0.134600, 17.499482, -5.000000,  -0.007700, -0.999970, 0.000000

  GOTO/CART,  0.103886, 13.506300, 45.000000

ENDMES

F(J-2) = FEAT/CIRCLE,INNER,CART, 70.5000, 0.0000, -5.0000, 0.000000,$

-0.000000, 1.000000, 35.2000

$$ Measurement points are created through nominal points

CALL/M(EASI_CLEARPLN_GOTO), 1, 0.112622, 13.508852, 50.993301

MEAS/CIRCLE, F(J-2), 4

  GOTO/CART,  0.112622, 13.508852, 50.993301

  GOTO/CART,  84.006300, -0.103886, 45.000000

  PTMEAS/CART,  87.999482, -0.134600, -5.000000,  -0.999970, 0.007700, -0.000000

  GOTO/CART,  82.938439, -5.264615, -5.000000

  GOTO/CART,  79.976938, -9.623855, -5.000000

  GOTO/CART,  75.572659, -12.517949, -5.000000

  PTMEAS/CART,  70.365400, -17.499482, -5.000000,  0.007700, 0.999970, -0.000000

  GOTO/CART,  65.235385, -12.438439, -5.000000

  GOTO/CART,  60.876145, -9.476938, -5.000000

  GOTO/CART,  57.982051, -5.072659, -5.000000

  PTMEAS/CART,  53.000518, 0.134600, -5.000000,  0.999970, -0.007700, 0.000000

  GOTO/CART,  58.061561, 5.264615, -5.000000

  GOTO/CART,  61.023062, 9.623855, -5.000000

  GOTO/CART,  65.427341, 12.517949, -5.000000

  PTMEAS/CART,  70.634600, 17.499482, -5.000000,  -0.007700, -0.999970, 0.000000

  GOTO/CART,  70.603886, 13.506300, 45.000000

ENDMES

F(J-3) = FEAT/CIRCLE,INNER,CART, -4.7500, -50.0000, -5.0000, 0.000000,$

-0.000000, 1.000000, 8.0000

$$ Measurement points are created through nominal points

CALL/M(EASI_CLEARPLN_GOTO), 1, -4.743301, -50.000052, 45.000000

MEAS/CIRCLE, F(J-3), 4

  GOTO/CART,  -4.743301, -50.000052, 45.000000

  PTMEAS/CART,  -0.750119, -50.030800, -5.000000,  -0.999970, 0.007700,$

-0.000000

  PTMEAS/CART,  -4.780800, -53.999881, -5.000000,  0.007700, 0.999970, -0.000000

  PTMEAS/CART,  -8.749881, -49.969200, -5.000000,  0.999970, -0.007700, 0.000000

  PTMEAS/CART,  -4.719200, -46.000119, -5.000000,  -0.007700, -0.999970,$

0.000000

  GOTO/CART,  -4.749948, -49.993301, 45.000000

ENDMES

F(J-4) = FEAT/CIRCLE,INNER,CART, 75.2500, -50.0000, -5.0000, 0.000000,$

-0.000000, 1.000000, 8.0000

$$ Measurement points are created through nominal points

CALL/M(EASI_CLEARPLN_GOTO), 1, -4.740238, -49.992304, 50.993301

MEAS/CIRCLE, F(J-4), 4

  GOTO/CART,  -4.740238, -49.992304, 50.993301

  GOTO/CART,  75.256699, -50.000052, 45.000000

  PTMEAS/CART,  79.249881, -50.030800, -5.000000,  -0.999970, 0.007700,$

-0.000000

  PTMEAS/CART,  75.219200, -53.999881, -5.000000,  0.007700, 0.999970, -0.000000

  PTMEAS/CART,  71.250119, -49.969200, -5.000000,  0.999970, -0.007700, 0.000000

  PTMEAS/CART,  75.280800, -46.000119, -5.000000,  -0.007700, -0.999970,$

0.000000

  GOTO/CART,  75.250052, -49.993301, 45.000000

ENDMES

F(J-5) = FEAT/CIRCLE,INNER,CART, -14.7500, -85.0000, -5.0000, 0.000000,$

-0.000000, 1.000000, 8.0000

$$ Measurement points are created through nominal points

CALL/M(EASI_CLEARPLN_GOTO), 1, 75.258617, -49.991418, 50.993301

MEAS/CIRCLE, F(J-5), 4

  GOTO/CART,  75.258617, -49.991418, 50.993301

  GOTO/CART,  -14.743301, -85.000052, 45.000000

  PTMEAS/CART,  -10.750119, -85.030800, -5.000000,  -0.999970, 0.007700,$

-0.000000

  PTMEAS/CART,  -14.780800, -88.999881, -5.000000,  0.007700, 0.999970,$

-0.000000

  PTMEAS/CART,  -18.749881, -84.969200, -5.000000,  0.999970, -0.007700,$

0.000000

  PTMEAS/CART,  -14.719200, -81.000119, -5.000000,  -0.007700, -0.999970,$

0.000000

  GOTO/CART,  -14.749948, -84.993301, 45.000000

ENDMES

F(J-6) = FEAT/CIRCLE,INNER,CART, 85.2500, 85.0000, -5.0000, 0.000000,$

-0.000000, 1.000000, 7.9977

$$ Measurement points are created through nominal points

CALL/M(EASI_CLEARPLN_GOTO), 1, -14.740631, -84.990851, 50.993301

MEAS/CIRCLE, F(J-6), 4

  GOTO/CART,  -14.740631, -84.990851, 50.993301

  GOTO/CART,  85.255549, 84.999957, 45.000000

  PTMEAS/CART,  89.248731, 84.969200, -5.000000,  -0.999970, 0.007700, -0.000000

  PTMEAS/CART,  85.219200, 81.001269, -5.000000,  0.007700, 0.999970, -0.000000

  PTMEAS/CART,  81.251269, 85.030800, -5.000000,  0.999970, -0.007700, 0.000000

  PTMEAS/CART,  85.280800, 88.998731, -5.000000,  -0.007700, -0.999970, 0.000000

  GOTO/CART,  85.250043, 85.005549, 45.000000

ENDMES

MODE/AUTO,PROG,MAN

BADTST/ON      

SNSET/SEARCH,6.0000       

F(ST1)=FEAT/POINT,CART,0,0,0,0,0,1

MEAS/POINT,F(ST1),1

PTMEAS/CART,0,0,0

ENDMES

$$ check to see if the point feature was successfully measured.

$$ if not sucecess  mesure the hole

IF/(BADPT())

SNSET/RETRCT,5

SNSET/APPRCH,5

F(S-CIRE1)=FEAT/CIRCLE,INNER,CART,0,0,-5,0,0,1,35.2

MEAS/CIRCLE,F(S-CIRE1),4    

ENDMES     

ENDIF

BADTST/OFF

T(TCOR1) = TOL/CORTOL,XAXIS, -0.020, 0.020

T(TCOR2) = TOL/CORTOL,YAXIS, -0.020, 0.020

OUTPUT/FA(J-1),TA(TCOR1),TA(TCOR2)

OUTPUT/FA(J-2),TA(TCOR1),TA(TCOR2)

OUTPUT/FA(J-3),TA(TCOR1),TA(TCOR2)

OUTPUT/FA(J-4),TA(TCOR1),TA(TCOR2)

OUTPUT/FA(J-5),TA(TCOR1),TA(TCOR2)

OUTPUT/FA(J-6),TA(TCOR1),TA(TCOR2)


来源:山涧果子
ACTUG3DEC
著作权归作者所有,欢迎分享,未经许可,不得转载
首次发布时间:2024-12-27
最近编辑:1天前
山涧果子
大专 签名征集中
获赞 204粉丝 51文章 254课程 0
点赞
收藏
作者推荐

Building Intelligence into your programs

The High Level section of DMIS is the part of the language that most closely resembles other computer languages. It includes statements that allow the programmer to declare and use variables, perform calculations, control program flow, etc.This section of the DMIS language differs from the rest in that it isn’t specific to the measurement process. It does however provide tools to control and manipulate the measurement process.Variables:If you have used other programming languages you will be familiar with variables. If you haven’t then you can think of a variable as a slot in the computer memory that you name and insert values into. The values can then be altered (that’s why it’s called a variable, get it?) or retrieved for use in the program. DMIS provides a number of variable types which correspond to the type of data you will store in them: BOOL = true or false.DOUBLE = decimal number (more decimal places).REAL = decimal number (less decimal places).INTGR = whole number (small number).LONG = decimal number (large number).CHAR = text. For instance, if you wanted to store a persons name you would use a CHAR variable. If you wanted to store a result you would use either a DOUBLE or a REAL. In most circumstances it doesn’t matter which you choose but it is a good idea to use the DOUBLE type for complex calculations requiring many decimal places. The same goes for INTGR or LONG. If you had a loop (more on loops later) that counts to ten then you obviously don’t need to use a LONG but if the loop counts to 1,000,000 you may have a problem with INTGR because on most 32 bit systems an INTGR can only hold a value of approximately 32,000 although this is machine dependant, if in doubt use DOUBLE and LONG. The BOOL type is a little different from the other variable types because it can only hold two values, true or false. It is most often used for making decisions based on these conditions.Once you have decided on the type of variable you must use the DECL statement to declare it so that the system can allocate a slot in memory:DECL/LOCAL, INTGR, numberOfRuns This example creates a whole number (INTGR) variable called numberOfRuns which will be LOCAL in scope. Scope dictates what part of the system has access to the variable: COMMON = system wide access.GLOBAL = access by main and sub programs.LOCAL = access only by main program.Good programming practice dictates that you do not make variables available to other programs and processes unless necessary so the use of the LOCAL type is recommended for most cases. DECL/LOCAL, CHAR, 512, operatorName This example creates a text variable (CHAR) called operatorName which will be LOCAL in scope. When it comes to text variables the system does not have any idea how much space to allocate so we have to specify the maximum number of characters using an optional numeric parameter, in this case 512 characters. DECL/GLOBAL, REAL, xValue This example creates a decimal number (REAL) variable called xValue which will be GLOBAL in scope. Assignments: Now that you have created a slot in the computer memory you need to a place a value into it. One way to do this is with the ASSIGN statement:userName= ASSIGN/'Steve' In this example I have put my name into a variable called userName. The ASSIGN statement can also be used with expressions. Expressions are a combination of conditions, functions or calculations that will return a value which will be assigned to the variable: myCos= ASSIGN/COS(DTOR(45)) In this example I am putting the cosine of 45 degrees into a variable called myCos. I have used two of DMIS’ intrinsic functions in the expression. The inner expression converts 45 degrees decimal to radians and the outer function returns the cosine of that result. The expression contains two DMIS functions COS (returns the cosine of an angle in radians) and DTOR (returns the radian equivalent of a decimal angle). Notice that one function is contained within the other, this is called nesting and the inner function will be executed first. firstName= ASSIGN/'Steve'lastName= ASSIGN/'Horsfall'fullName= ASSIGN/CONCAT(firstName,' ', lastName) This example assigns two variables called firstName and lastName as text and then combines the two variables split by a space constant using the CONCAT statement. The result of the concatenation is assigned to the fullName variable. Getting data: Another way of putting a value into a variable is to use the OBTAIN statement. The OBTAIN statement gets data from DMIS elements such as features, tolerances, etc. and places that data into a variable: xActual= OBTAIN/FA(FACE1_PNT1),3 In this example we are getting the measured X value from a feature called FACE1_PNT1 and putting it into a variable called xActual. The number at the end of the example is referred to as the ordinal value and represents the comma delimited location in the output string of the data to be retrieved: FA(FACE1_PNT1)=FEAT/POINT,CART,2.4435,0.0233,99.987,1,0,0 As the output string above shows, the variable would contain 2.4435. When using the OBTAIN statement the ordinal value will depend on the type of data you are trying to get: flatnessResult= OBTAIN/TA(FLT1),2 Whereas the previous example retrieved data directly from a feature, in this example the OBTAINstatement is getting its data from the output which resulted from the use of the FLT1 tolerance. Writing to devices: Once variables have been assigned they can be written to various devices using the DMIS WRITEstatement: WRITE/DID(_TERM),'Operator: ', userName This example writes some text defining who the operator of the machine is to a predetermined DMIS device for the system terminal. Not all devices are made available automatically and in these cases you will have to use the DEVICE statement to specify the type of device and in when you are writing to files use the OPEN statement: DID(dataFile)=DEVICE/STOR,'c:\data\part.dat'OPEN/DID(dataFile),DIRECT,OUTPUT,OVERWRWRITE/DID(dataFile),'X=',xval:10:4,' Y=',yval:10:4,' Z=',zval:10:4CLOSE/DID(dataFile),KEEP This example creates a device called dataFile which points to a file called 'c:\data\part.dat'. From this point onward, all operations on the file are carried out using the device name rather than the actual file name. The OPEN statement opens the device for DIRECT OUTPUT and the minor word OVERWR tells the system to overwrite any previous files of that name. Once the file has been opened the WRITEstatement is used to send data to the file, in this case I have included field widths and decimal place parameters so the data will be written in space delimited columns. I could have left off the field widths and put commas between each variable to make the data spread sheet friendly. Once the data has been written the file is closed using the CLOSE statement. Notice the KEEP minor word means that the file will be retained after closing. Reading from devices: $$$$ define input$$DID(plane_file)=DEVICE/STOR,'C:\DATA\PLN.DAT'$$$$ declare variables$$DECL/LOCAL,CHAR,20,pln_nameDECL/LOCAL,DOUBLE,xvalp,yvalp,zvalp,ivalp,jvalp,kvalpDECL/LOCAL,DOUBLE,xval1,yval1,zval1,ival1,jval1,kval1DECL/LOCAL,DOUBLE,xval2,yval2,zval2,ival2,jval2,kval2DECL/LOCAL,DOUBLE,xval3,yval3,zval3,ival3,jval3,kval3DECL/LOCAL,DOUBLE,xval4,yval4,zval4,ival4,jval4,kval4DECL/LOCAL,DOUBLE,xval,yval,zval,ival,jval,kval$$$$ open the input file and read data for measurement$$OPEN/DID(plane_file),DIRECT,INPUT$$$$ read plane data$$READ/DID(plane_file),pln_name,xvalp,yvalp,zvalp,ivalp,jvalp,kvalp$$$$ read point data$$READ/DID(plane_file),xval1,yval1,zval1,ival1,jval1,kval1READ/DID(plane_file),xval2,yval2,zval2,ival2,jval2,kval2READ/DID(plane_file),xval3,yval3,zval3,ival3,jval3,kval3READ/DID(plane_file),xval4,yval4,zval4,ival4,jval4,kval4$$$$ close the input file$$CLOSE/DID(plane_file),KEEP$$$$ measure plane$$MODE/AUTO,PROG,MANF(pln_name)=FEAT/PLANE,CART,xvalp,yvalp,zvalp,ivalp,jvalp,kvalpMEAS/PLANE,F(pln_name),4PTMEAS/CART,xval1,yval1,zval1,ival1,jval1,kval1PTMEAS/CART,xval2,yval2,zval2,ival2,jval2,kval2PTMEAS/CART,xval3,yval3,zval3,ival3,jval3,kval3PTMEAS/CART,xval4,yval4,zval4,ival4,jval4,kval4ENDMES$$ This example uses the OPEN statement in DIRECT INPUT mode so that we can use the READstatement to read data from a file and use it to measure PLANE. Program execution: Programs generally execute sequentially from start to finish unless you use high level to alter that course. The DMIS statements IF, ELSE or ENDIF are quite often used to alter the route a program will take: RES_PF=OBTAIN/TA(CIRC1),3$$IF/ (RES_PF.EQ.‘INTOL’)$$WRITE/DID(_TERM),’RESULT PASSED’$$ELSE$$ WRITE/DID(_TERM), ’RESULT FAILED’$$ENDIF In this example a tolerance called CIR1 is used in an output statement and the OBTAIN command is used to retrieve the result status. The IF, ELSE and ENDIF statements form a block whose first part (between the IF and the ELSE statements) contain code which will be executed if the expression in the IFstatement is true (in this case we write a pass message to the terminal). Notice the use of the .EQ.minor word which means equal to. When the result of the expression is false the second part of the IF ENDIF block is executed (in this case we write a fail message to the terminal). Another use of the IF ENDIF block is program jumps: $$$$ define variables$$DECL/LOCAL,INTGR, HOLENUM, NUMHOLESDECL/LOCAL,DOUBLE, CANGLE, HANGLEDECL/LOCAL, CHAR, 512, HOLENAME$$$$ define variables$$HOLENUM=ASSIGN/1NUMHOLES=ASSIGN/10HANGLE=ASSIGN/(360/NUMHOLES)CANGLE=ASSIGN/0$$(LOOP)$$$$ build a hole name using the loop counter$$HOLENAME=ASSIGN/CONCAT ('BPHOLE', HOLENUM)$$$$ measure a hole (name is variable not constant)$$MODE/AUTO,PROG,MANF(HOLENAME)=FEAT/CIRCLE,INNER,POL,42.5,CANGLE,0,0,0,1,5MEAS/CIRCLE,F(HOLENAME),6ENDMESOUTPUT/FA(HOLENAME),TA(RAD1),TA(ANG1),TA(DIAM_1)$$$$ increment the loop counter$$HOLENUM=ASSIGN/HOLENUM+1$$$$ check how many holes have been measured$$IF/(HOLENUM.LE.NUMHOLES)CANGLE=ASSIGN/CANGLE+HANGLEJUMPTO/(LOOP)ENDIF$$ This example builds on the concepts we have already introduced. The purpose of the code is to measure 10 holes on a bolt circle using the IF ENDIF block to increment the angle of the next hole and move the program back to the start of the code using the JUMPTO statement. When this code is reached the execution point for the program is moved to the specified label (LOOP). Notice that we use the CONCAT statement to increment the feature name and the variables for the name and angle are embedded directly in the feature definition. Although this is a common use of the IF statement a better solution would be to use a DO loop which would encapsulate all of the code and does not rely on the use of a JUMPTO statement. Although jumps are allowed in DMIS they are generally considered bad programming practice and should be used with caution. A typical DO loop would look like this: DECL/LOCAL,INTGR,LP_CNTDO/LP_CNT,1,5$$$$ program here$$ENDDO This example repeats the code between the DO statement and the ENDDO statements 5 times starting at 1. The INTGR variable LP_CNT is incremented each time the code is executed. We could have put the previous code into this block and used the LP_CNT as the feature number without using a JUMPTO. The only time this becomes difficult is if the code to be embedded is very large making the start and end of the loop hard to see. This article is designed to get you started with DMIS high level but the DMIS statements listed are just a subset of those available and you are encouraged to explore the full set by purchasing the DMIS Standard. More information and examples can also be found in my book ‘Step by Step DMIS Programming’.来源:山涧果子

未登录
还没有评论
课程
培训
服务
行家
VIP会员 学习计划 福利任务
下载APP
联系我们
帮助与反馈