diff --git a/Helical1.pbi b/Helical1.pbi new file mode 100644 index 0000000..152a1f6 --- /dev/null +++ b/Helical1.pbi @@ -0,0 +1,113 @@ +[ + [ + "StatusGblListCtrl", + [], + "name=g;caption=global;state=67377148;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=200;besth=369;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=41;floaty=486;floatw=208;floath=377;notebookid=-1;transparent=255" + ], + [ + "MotorListCtrl", + [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "name=p;caption=motor pos;state=67377148;dir=4;layer=0;row=0;pos=1;prop=100000;bestw=200;besth=350;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1;notebookid=-1;transparent=255" + ], + [ + "WatchListCtrl", + [ + [ + "EncTable[1].PrevEnc", + null + ], + [ + "EncTable[9].PrevEnc", + null + ], + [ + "Motor[1].idCmd", + null + ], + [ + "Motor[1].Ctrl", + null + ], + [ + "Motor[1].pos", + null + ], + [ + "Motor[1].ServoOut", + null + ], + [ + "P1000", + null + ], + [ + "Gather.Samples", + null + ], + [ + "Gather.MaxLines", + null + ] + ], + "name=w;caption=watch;state=67377148;dir=4;layer=0;row=1;pos=0;prop=100000;bestw=200;besth=369;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=221;floaty=858;floatw=208;floath=377;notebookid=-1;transparent=255" + ], + [ + "StatusMotorListCtrl", + [ + 1 + ], + "name=m1;caption=motor1;state=67377148;dir=4;layer=0;row=4;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=485;floaty=810;floatw=208;floath=677;notebookid=-1;transparent=255" + ], + [ + "StatusMotorListCtrl", + [ + 2 + ], + "name=m2;caption=motor2;state=67377148;dir=4;layer=0;row=4;pos=1;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=520;floaty=734;floatw=208;floath=677;notebookid=-1;transparent=255" + ], + [ + "StatusCoordListCtrl", + [ + 1 + ], + "name=c1;caption=coord1;state=67377148;dir=4;layer=0;row=2;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=350;floaty=493;floatw=208;floath=677;notebookid=-1;transparent=255" + ], + [ + "StatusMotorListCtrl", + [ + 3 + ], + "name=m3;caption=motor3;state=67377148;dir=4;layer=0;row=5;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1490;floaty=556;floatw=208;floath=677;notebookid=-1;transparent=255" + ], + [ + "StatusMotorListCtrl", + [ + 4 + ], + "name=m4;caption=motor4;state=67377148;dir=4;layer=0;row=5;pos=1;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1528;floaty=501;floatw=208;floath=677;notebookid=-1;transparent=255" + ], + [ + "StatusMotorListCtrl", + [ + 5 + ], + "name=m5;caption=motor5;state=67377148;dir=4;layer=0;row=6;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1588;floaty=238;floatw=208;floath=677;notebookid=-1;transparent=255" + ] +] \ No newline at end of file diff --git a/PBInspect1.pbi b/PBInspect1.pbi index 0764276..a94c14f 100644 --- a/PBInspect1.pbi +++ b/PBInspect1.pbi @@ -27,25 +27,95 @@ [ "Motor[1].idCmd", "lambda v: '%.8g'%float(v)" -], - [ "Motor[1].iqCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[1].idCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[2].iqCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[2].idCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[3].iqCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[3].idCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[4].iqCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[4].idCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[5].iqCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[5].idCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[6].iqCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[6].idCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[7].iqCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[7].idCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[8].iqCmd", "lambda v: '%.8g'%float(v)" ], - [ "Motor[8].idCmd", "lambda v: '%.8g'%float(v)" ], - [ "P2000", null ], - [ "P3000", null ] + ], + [ + "Motor[1].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[1].ServoOut", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].ServoOut", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].ServoOut", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[4].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[4].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[4].ServoOut", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[5].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[5].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[5].ServoOut", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[6].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[6].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[6].ServoOut", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[7].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[7].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[7].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "P1000", + null + ], + [ + "P2000", + null + ] ], "name=w;caption=watch;state=67377148;dir=4;layer=0;row=1;pos=0;prop=100000;bestw=200;besth=369;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=221;floaty=858;floatw=208;floath=377;notebookid=-1;transparent=255" ], @@ -54,7 +124,7 @@ [ 3 ], - "name=m3;caption=motor3;state=67377148;dir=4;layer=0;row=5;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=694;floaty=941;floatw=208;floath=677;notebookid=-1;transparent=255" + "name=m3;caption=motor3;state=67377148;dir=4;layer=0;row=6;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=694;floaty=941;floatw=208;floath=677;notebookid=-1;transparent=255" ], [ "StatusGblListCtrl", @@ -66,48 +136,48 @@ [ 2 ], - "name=m2;caption=motor2;state=67377148;dir=4;layer=0;row=4;pos=1;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=2588;floaty=946;floatw=208;floath=677;notebookid=-1;transparent=255" + "name=m2;caption=motor2;state=67377148;dir=4;layer=0;row=5;pos=1;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=2588;floaty=946;floatw=208;floath=677;notebookid=-1;transparent=255" ], [ "StatusMotorListCtrl", [ 4 ], - "name=m4;caption=motor4;state=67377148;dir=4;layer=0;row=6;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=905;floaty=792;floatw=208;floath=677;notebookid=-1;transparent=255" + "name=m4;caption=motor4;state=67377148;dir=4;layer=0;row=7;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=905;floaty=792;floatw=208;floath=677;notebookid=-1;transparent=255" ], [ "StatusMotorListCtrl", [ 5 ], - "name=m5;caption=motor5;state=67377148;dir=4;layer=0;row=6;pos=1;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1139;floaty=836;floatw=208;floath=677;notebookid=-1;transparent=255" + "name=m5;caption=motor5;state=67377148;dir=4;layer=0;row=7;pos=1;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1139;floaty=836;floatw=208;floath=677;notebookid=-1;transparent=255" ], [ "StatusMotorListCtrl", [ 7 ], - "name=m7;caption=motor7;state=67377148;dir=4;layer=0;row=7;pos=1;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1353;floaty=657;floatw=208;floath=677;notebookid=-1;transparent=255" + "name=m7;caption=motor7;state=67377148;dir=4;layer=0;row=8;pos=1;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1353;floaty=657;floatw=208;floath=677;notebookid=-1;transparent=255" ], [ "StatusMotorListCtrl", [ 6 ], - "name=m6;caption=motor6;state=67377148;dir=4;layer=0;row=7;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1276;floaty=771;floatw=208;floath=677;notebookid=-1;transparent=255" - ], - [ - "StatusCoordListCtrl", - [ - 0 - ], - "name=c0;caption=coord0;state=67377148;dir=4;layer=0;row=2;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=457;floaty=774;floatw=208;floath=677;notebookid=-1;transparent=255" + "name=m6;caption=motor6;state=67377148;dir=4;layer=0;row=8;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1276;floaty=771;floatw=208;floath=677;notebookid=-1;transparent=255" ], [ "StatusMotorListCtrl", [ 1 ], - "name=m1;caption=motor1;state=67377148;dir=4;layer=0;row=4;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=669;floaty=892;floatw=208;floath=677;notebookid=-1;transparent=255" + "name=m1;caption=motor1;state=67377148;dir=4;layer=0;row=5;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=669;floaty=892;floatw=208;floath=677;notebookid=-1;transparent=255" + ], + [ + "StatusCoordListCtrl", + [ + 1 + ], + "name=c1;caption=coord1;state=67377148;dir=4;layer=0;row=2;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=527;floaty=439;floatw=208;floath=677;notebookid=-1;transparent=255" ] ] \ No newline at end of file diff --git a/PBInspect2.pbi b/PBInspect2.pbi index 421d2c1..c3ec8b9 100644 --- a/PBInspect2.pbi +++ b/PBInspect2.pbi @@ -29,34 +29,74 @@ [ "WatchListCtrl", [ - [ - "EncTable[1].PrevEnc", - null - ], - [ - "EncTable[9].PrevEnc", - null - ], [ "Motor[1].idCmd", - null + "lambda v: '%.8g'%float(v)" ], [ - "Motor[1].Ctrl", - null - ], - [ - "Motor[1].pos", - null + "Motor[1].iqCmd", + "lambda v: '%.8g'%float(v)" ], [ "Motor[1].ServoOut", - null + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].ServoOut", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].ServoOut", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[4].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[4].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[4].ServoOut", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[5].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[5].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[5].ServoOut", + "lambda v: '%.8g'%float(v)" ], [ "P1000", null ], + [ + "P2000", + null + ], [ "Gather.Samples", null @@ -92,15 +132,22 @@ [ "StatusMotorListCtrl", [ - 7 + 4 ], - "name=m7;caption=motor7;state=67377148;dir=4;layer=0;row=3;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1220;floaty=261;floatw=208;floath=677;notebookid=-1;transparent=255" + "name=m4;caption=motor4;state=67377148;dir=4;layer=0;row=5;pos=1;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=991;floaty=738;floatw=208;floath=677;notebookid=-1;transparent=255" ], [ "StatusMotorListCtrl", [ - 8 + 5 ], - "name=m8;caption=motor8;state=67377148;dir=4;layer=0;row=3;pos=1;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1257;floaty=494;floatw=208;floath=677;notebookid=-1;transparent=255" + "name=m5;caption=motor5;state=67377148;dir=4;layer=0;row=6;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1181;floaty=512;floatw=208;floath=677;notebookid=-1;transparent=255" + ], + [ + "StatusMotorListCtrl", + [ + 3 + ], + "name=m3;caption=motor3;state=67377148;dir=4;layer=0;row=5;pos=0;prop=100000;bestw=200;besth=669;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=1168;floaty=473;floatw=208;floath=677;notebookid=-1;transparent=255" ] ] \ No newline at end of file diff --git a/Readme.md b/Readme.md index efe2c93..0d44709 100644 --- a/Readme.md +++ b/Readme.md @@ -155,7 +155,7 @@ HelicalScan PPMAC=MOTTEST-CPPM-CRM0485 cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX -PBInspect --host $PPMAC --cfg PBInspect2.pbi +PBInspect --host $PPMAC --cfg PBInspect1.pbi cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/cfg gpasciiCommander --host $PPMAC sim_8_motors.cfg -i @@ -263,7 +263,7 @@ ssh x06mx-cons-1 export CAQTDM_DISPLAY_PATH=/net/slsfs-crtl/export/sf/common/config/qt/:/net/slsfs-crtl/export/sf/controls/config/qt/ - +export EPICS_CA_ADDR_LIST="129.129.126.255" caqtdm -macro "P=SAR-EXPMX" ESB_MX_exp.ui ``` @@ -289,3 +289,44 @@ To see the differences compare: When using segmented mode (SegMoveTime>0) the velocities are not needed. With SegMoveTime=0 these velocities are needed and will result in a non optimal trajectory (with the current buggy calculation). ``` + + +Testing Helicalscan with real motors 8.1.18 +------------------------------------------- +``` +PPMAC=SAR-CPPM-EXPMX1 +cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/cfg +gpasciiCommander --host $PPMAC -i + +$$$*** +!common() +!SAR-EXPMX1() +enable plc 1 + +export EPICS_CA_ADDR_LIST=$PPMAC +caQtDM -macro 'P=SAR-EXPMX' ESB_MX_exp + +do homing (or call plc 1) +cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python +./helicalscan.py +``` + + +Testing Wedge mover +------------------- +``` +PPMAC=SAR-CPPM-EXPMX2 +cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX +PBInspect --host $PPMAC --cfg PBInspect2.pbi + +cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/cfg +gpasciiCommander --host $PPMAC -i +$$$*** +!common() +!SAR-EXPMX2() +Motor[1].pLimits=0 +Motor[2].pLimits=0 +Motor[3].pLimits=0 +Motor[4].pLimits=0 + +``` diff --git a/SAR-EXPMX2.subs b/SAR-EXPMX2.subs index c71bfee..8460b3f 100644 --- a/SAR-EXPMX2.subs +++ b/SAR-EXPMX2.subs @@ -17,13 +17,13 @@ file asyn.template {{P="$(P_M)2", PORT=$(PORT_M)}} file PPMACMotor.template { pattern{ DESC , P , M , PORT , ADDR, DIR, VELO, HVEL, ACCL, JAR, MRES , PREC, EGU , DHLM, DLLM} - { "Wedge 1" , "$(P_M)", "MOT_WEDGE1", "$(PORT_M)", 1 , 0 , .3 , .3 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } - { "Wedge 2" , "$(P_M)", "MOT_WEDGE2", "$(PORT_M)", 2 , 0 , .3 , .3 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } - { "Wedge 3" , "$(P_M)", "MOT_WEDGE3", "$(PORT_M)", 3 , 0 , .3 , .3 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } - { "Wedge 4" , "$(P_M)", "MOT_WEDGE4", "$(PORT_M)", 4 , 0 , .3 , .3 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } - { "Wedge X" , "$(P_M)", "MOT_WEDGEX", "$(PORT_M)", 9 , 0 , .3 , .3 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } - { "Wedge Y" , "$(P_M)", "MOT_WEDGEY", "$(PORT_M)", 10 , 0 , .3 , .3 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } - { "Wedge A" , "$(P_M)", "MOT_WEDGEA", "$(PORT_M)", 11 , 0 , .3 , .3 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } - { "Wedge B" , "$(P_M)", "MOT_WEDGEB", "$(PORT_M)", 12 , 0 , .3 , .3 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } + { "Wedge 1" , "$(P_M)", "MOT_WEDGE1", "$(PORT_M)", 1 , 0 , 1. , .5 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } + { "Wedge 2" , "$(P_M)", "MOT_WEDGE2", "$(PORT_M)", 2 , 0 , 1. , .5 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } + { "Wedge 3" , "$(P_M)", "MOT_WEDGE3", "$(PORT_M)", 3 , 0 , 1. , .5 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } + { "Wedge 4" , "$(P_M)", "MOT_WEDGE4", "$(PORT_M)", 4 , 0 , 1. , .5 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } + { "Wedge X" , "$(P_M)", "MOT_WEDGEX", "$(PORT_M)", 9 , 0 , 1. , .5 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } + { "Wedge Y" , "$(P_M)", "MOT_WEDGEY", "$(PORT_M)", 10 , 0 , 1. , .5 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } + { "Wedge A" , "$(P_M)", "MOT_WEDGEA", "$(PORT_M)", 11 , 0 , 1. , .5 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } + { "Wedge B" , "$(P_M)", "MOT_WEDGEB", "$(PORT_M)", 12 , 0 , 1. , .5 , 0.1 , 20 , -0.001, 3 , "mm" , 0 , 0 } { "Backlight", "$(P_M)", "MOT_BLGT" , "$(PORT_M)", 5 , 1 , 40E3, 20E3, 0.1 , 20 , -1 , 0 , "usr", 0 , 0 } } diff --git a/cfg/MX1_home.cfg b/cfg/MX1_home.cfg index fc38312..8874966 100644 --- a/cfg/MX1_home.cfg +++ b/cfg/MX1_home.cfg @@ -108,6 +108,8 @@ open plc PLC_Homing //Motor[1].PhasePos=560 // 555 581 593 558 //Motor[2].PhasePos=1540 //1549 1531 1543 1537 + homez6,7 + goto 1 N0: //ERROR_END diff --git a/cfg/MX1_setup.cfg b/cfg/MX1_setup.cfg index 5024ef8..86d5dcd 100644 --- a/cfg/MX1_setup.cfg +++ b/cfg/MX1_setup.cfg @@ -95,8 +95,8 @@ Motor[3].pPhaseEnc=Acc84B[0].Chan[2].SerialEncDataA.a //Interferometer 1,2 //------------------ -!encoder_inc(enc=6,tbl=6,mot=6)# ,posSf=13000./650000) -!encoder_inc(enc=7,tbl=7,mot=7)# ,posSf=13000./650000) +!encoder_inc(enc=6,tbl=6,mot=6 ,posSf=.01) //1 incr=10nm -> posSf=.01 to scale to um +!encoder_inc(enc=7,tbl=7,mot=7 ,posSf=-.01) //1 incr=10nm,inverse direction -> posSf=.01 to scale to um #3,4,5hmz diff --git a/cfg/MX2_setup.cfg b/cfg/MX2_setup.cfg index 8723fc7..a66cbce 100644 --- a/cfg/MX2_setup.cfg +++ b/cfg/MX2_setup.cfg @@ -1,18 +1,40 @@ //Wedge Movers --------------- -!encoder_inc(enc=1,posSf=1./20) -!motor(mot=1,current=120,JogSpeed=1,HomeVel=.5,servoSf=12.28878*20,homing='enc-index',invDir=True,HomeOffset=2855,InPosBand=1) +//-------------- +//Nanotec 2 ph motor 42.3mm 1.8deg, Planetgetriebe 1.5Nm I=1:12, Spindel 2mm steigung +//ST4118L1804-B 42 mm 17 50 Ncm 1.8 deg/step 1.8 A/Wicklung 49 mm €34.10 -!encoder_inc(enc=2,posSf=1./20) -!motor(mot=2,current=120,JogSpeed=1,HomeVel=.5,servoSf=12.28878*20,homing='enc-index',invDir=True,HomeOffset=2844,InPosBand=1) +//102400*12=1228800 == 2mm +//#1j:1228800 -> 1 rev = 2mm = 2000inc +//posSf = userUnits/encoder_steps =1 +//servoSf=motor_u_steps/userUnits = 1228800/2000. = 614.4 -!encoder_inc(enc=3,posSf=1./20) -!motor(mot=3,current=120,JogSpeed=1,HomeVel=.5,servoSf=12.28878*20,homing='enc-index',invDir=True,HomeOffset=204,InPosBand=1) +//#1 = wedge 1a +//#2 = wedge 1b +//#3 = wedge 2a +//#4 = wedge 2b -!encoder_inc(enc=4,posSf=1./20) -!motor(mot=4,current=120,JogSpeed=1,HomeVel=.5,servoSf=12.28878*20,homing='enc-index',invDir=True,HomeOffset=2094,InPosBand=1) +//steigung Keil: 11.4212deg = arctan(0.2)=11.31deg -> Steigung 1:5 +//on 146mm from 35 to 21.5mm 146/(35-21.5)=10.81 +//on 280mm from 61mm to 38 mm 280/(61-38)= + +//!encoder_sim(enc=1) +//!encoder_inc(enc=1,tbl=9,mot=9,posSf=1) +//!motor(mot=1,dirCur=120,JogSpeed=102.4*1,invDir=False) +//Motor[1].pLimits=0 + +!encoder_inc(enc=1,posSf=1.) +!motor(mot=1,dirCur=1000,JogSpeed=1.,HomeVel=.5,servoSf=614.4,homing='enc-index',invDir=False,HomeOffset=0,InPosBand=1) + +!encoder_inc(enc=2,posSf=1.) +!motor(mot=2,dirCur=1000,JogSpeed=1.,HomeVel=.5,servoSf=614.4,homing='enc-index',invDir=False,HomeOffset=0,InPosBand=1) + +!encoder_inc(enc=3,posSf=1.) +!motor(mot=3,dirCur=1000,JogSpeed=1.,HomeVel=.5,servoSf=614.4,homing='enc-index',invDir=False,HomeOffset=0,InPosBand=1) + +!encoder_inc(enc=4,posSf=1.) +!motor(mot=4,dirCur=1000,JogSpeed=1.,HomeVel=.5,servoSf=614.4,homing='enc-index',invDir=False,HomeOffset=0,InPosBand=1) //Backlight @@ -22,4 +44,4 @@ !motor(mot=5,dirCur=1800,JogSpeed=40,invDir=False) -!holding_current(m5=[1400,1800]) +!holding_current(m1=[0,1000],m2=[0,1000],m3=[0,1000],m4=[0,1000],m5=[1400,1800]) diff --git a/python/helicalscan.py b/python/helicalscan.py index 6522d80..7f20487 100755 --- a/python/helicalscan.py +++ b/python/helicalscan.py @@ -30,7 +30,7 @@ verbose bits: ''' -import os, sys, json +import os, sys, json,re import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt @@ -275,7 +275,7 @@ class HelicalScan: param=self.param # param[i]=(z_i, y_i, x_i, r_i,phi_i) ctr=param[:,0:3].mean(0)[::-1] - self.axSetCenter(ctr,10) + self.axSetCenter(ctr,param[0,3]+param[1,3]) axCx=plt.axes([0.1, 0.01, 0.8, 0.02]) axCz=plt.axes([0.1, 0.04, 0.8, 0.02]) @@ -348,7 +348,7 @@ class HelicalScan: # param[i]=(z_i, y_i, x_i, r_i,phi_i) ctr=(0,0,0) - self.axSetCenter(ctr,10) + self.axSetCenter(ctr,param[0,3]+param[1,3]) axDx=plt.axes([0.1, 0.01, 0.8, 0.02]) axDz=plt.axes([0.1, 0.04, 0.8, 0.02]) @@ -404,7 +404,7 @@ class HelicalScan: # param[i]=(z_i, y_i, x_i, r_i,phi_i) ctr=(0,0,0) - self.axSetCenter(ctr,10) + self.axSetCenter(ctr,param[0,3]+param[1,3]) axFrm=plt.axes([0.1, 0.01, 0.8, 0.02]) @@ -704,7 +704,7 @@ open forward p0_z=z_0+r_0*cos(phi_0+qW) p1_z=z_1+r_1*cos(phi_1+qW) - scale=(qFY-y_0)/(y_1-y_0) + scale=(qFY-(y_0))/(y_1-(y_0)) p0_x=p0_x+scale*(p1_x-p0_x) p0_y=p0_y+scale*(p1_y-p0_y) p0_z=p0_z+scale*(p1_z-p0_z) @@ -727,10 +727,11 @@ open inverse define( qCX='L4', qCZ='L5', qW='L3', qFY='L1') define(vqCX='R4', vqCZ='R5', vqW='R3', vqFY='R1') - define(qCX='L4', qCZ='L5', qW='L3', qFY='L1') define(p0_x='L10', p0_y='L11', p0_z='L12') define(p1_x='L13', p1_y='L14', p1_z='L15') - define(scale='L16') + define(p_x='L16', p_y='L17', p_z='L18') + define(sclY='L19') + define(scl='L20') if(D0>0) send 1"inv_inp(%f) %f:%f %f:%f %f:%f %f:%f\\n",D0,DX,vDX,DZ,vDZ,W,vW,Y,vY else @@ -750,20 +751,26 @@ open inverse p0_z=z_0+r_0*cos(phi_0+W) p1_z=z_1+r_1*cos(phi_1+W) - scale=(Y-y_0)/(y_1-y_0) - p0_x=p0_x+scale*(p1_x-p0_x) - p0_y=p0_y+scale*(p1_y-p0_y) - p0_z=p0_z+scale*(p1_z-p0_z) - qCX=DX+p0_x - qCZ=DZ+p0_z + sclY=(Y-(y_0))/(y_1-(y_0)) + p_x=p0_x+sclY*(p1_x-p0_x) + p_y=p0_y+sclY*(p1_y-p0_y) + p_z=p0_z+sclY*(p1_z-p0_z) + qCX=DX+p_x + qCZ=DZ+p_z qFY=Y if(D0>0) - { // calculate velocities for PVT motion - vqCX=vDX - vqCZ=vDZ - vqW=vW + { // calculate velocities for PVT motion''') + prg.append(" vW=vW*%g"%(d2r/1000.)) #scale from 1000*deg to rad + prg.append(''' p_x=sclY*(p1_x-p0_x) + p_z=sclY*(p1_z-p0_z) vqFY=vY - send 1"inv_res %f:%f %f:%f %f:%f %f:%f\\n",qCX,vqCX,qCZ,vqCZ,qW,vqW,qFY,vqFY + vqCX=vDX + (p1_x-p0_x)/(p1_y-p0_y)*vY //+ vqW*p_z + vqCZ=vDZ + (p1_z-p0_z)/(p1_y-p0_y)*vY //+ vqW*p_x + //vqW=vqW+(vqCX+(p1_x-p0_x)/(p1_y-p0_y)*vY)*p_z+(vqCZ+(p1_z-p0_z)/(p1_y-p0_y)*vY)*p_x + vqW=vW//+((p1_x-p0_x)/(p1_y-p0_y)*vY)*p_z+((p1_z-p0_z)/(p1_y-p0_y)*vY*p_x + ''') + prg.append(" vqW=vqW*%g"%(1000./d2r)) #scale from rad to 1000*deg + prg.append(''' send 1"inv_res %f:%f %f:%f %f:%f %f:%f\\n",qCX,vqCX,qCZ,vqCZ,qW,vqW,qFY,vqFY } else send 1"inv_res %f %f %f %f\\n",qCX,qCZ,qW,qFY @@ -771,6 +778,11 @@ open inverse close ''') +# vqCX=vDX + (p1_x-p0_x)/(p1_y-p0_y)*vY + vqW*p_x +# vDX is in same direction, so add as it is +# (p1_x-p0_x)/(p1_y-p0_y)*vY velocity part in vqCX direction, when moving in vY +# vqW*p_x velocity part of the rotation (vqW is in rad) + self.download(prg,mode=0,file='/tmp/coordTrf.cfg') @@ -845,7 +857,7 @@ close cntHor = kwargs.get('cntHor', 4) hRng = kwargs.get('hRng', (-.2,.2)) wRng = kwargs.get('wRng', (0,360000)) - yRng = kwargs.get('yRng', (2.3,6.2)) + yRng = kwargs.get('yRng', self.param[:,1]) numPt=cntVert*cntHor pt=np.zeros((numPt,4)) @@ -881,7 +893,7 @@ close cntHor = kwargs.get('cntHor', 4) hRng = kwargs.get('hRng', (-.2,.2)) wRng = kwargs.get('wRng', (0,360000)) - yRng = kwargs.get('yRng', (2.3,6.2)) + yRng = kwargs.get('yRng', self.param[:,1]) pt2pt_time = kwargs.get('pt2pt_time', 100) smt = kwargs.get('smt', 1) # SegMoveTime, default = 1ms -> velocity calc not yet 100% correct (smt=0 not 100% working) numPt=cntVert*cntHor @@ -1001,6 +1013,18 @@ close stderr=sprc.PIPE) res = p.wait() self.rec = np.genfromtxt(fnLoc, delimiter=' ') + com=GpasciiCommunicator().connect(host,prompt='# ') + ack=GpasciiCommunicator.gpascii_ack + + channels=["Motor[4].HomePos","Motor[5].HomePos","Motor[3].HomePos","Motor[1].HomePos"] + ofs=np.ndarray(len(channels)) + for i,v in enumerate(channels): + com.write(v+'\n') + val=com.read_until(ack) + #print val + #regexp: https://docs.python.org/2/library/re.html -> %e, %E, %f, %g + ofs[i]=float(re.search('=([-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)',val).group(1)) + self.rec-=ofs self.save_rec() @@ -1062,19 +1086,45 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n ' hs=HelicalScan(args) hs.args.verbose = 255 - hs.args.host='MOTTEST-CPPM-CRM0485' + #hs.args.host='MOTTEST-CPPM-CRM0485' + hs.args.host='SAR-CPPM-EXPMX1' #SAR-CPPM-EXPMX1 MOTTEST-CPPM-CRM0485 #hs.sequencer() #hs.test_find_rot_ctr() #hs.test_find_rot_ctr(n=5. ,per=1.,bias=2.31,ampl=4.12,phi=24.6) hs.calcParam() + #hs.param[0]=(15,2,0,3,0)#(z_i, y_i, x_i, r_i,phi_i) + #hs.param[1]=(15,4,0,3,0)#(z_i, y_i, x_i, r_i,phi_i) + #hs.param[0]=(-100, 10,0,50,0)#(z_i, y_i, x_i, r_i,phi_i) + #hs.param[1]=(-100,-10,0,70,0)#(z_i, y_i, x_i, r_i,phi_i) + hs.test_coord_trf() #hs.interactive_cx_cz_w_fy() #hs.interactive_dx_dz_w_y() - hs.download(file='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/cfg/sim_8_motors.cfg') - hs.gen_coord_trf_code() + #mode bits: + #0:1 config simulated motors + #1:2 config real motors + #2:4 config coord trf + mode=6#6#5#4#0 + os.chdir(os.path.join(os.path.dirname(__file__),'../cfg')) + if mode&1: + hs.download(file='sim_8_motors.cfg') + if mode&2: + hs.download(['$$$***','!common()','!SAR-EXPMX1()','#1..7j/','enable plc 1','Motor[1].MaxSpeed=25','Motor[2].MaxSpeed=25']) + raw_input('press return when homed') + if mode&4: + hs.download(['disable plc 0',]) + time.sleep(.5) + hs.gen_coord_trf_code() + print ('gen_coord_trf_code') + time.sleep(.5) + hs.download(['enable plc 0',]) + time.sleep(.5) + hs.download(['#1..7j/',]) + time.sleep(.5) + #hs.gen_prog(mode=-1) #hs.gen_prog(mode=0,cntHor=1,cntVert=3,wRng=(120000,120000)) #hs.gen_prog(mode=0,cntHor=1) @@ -1083,9 +1133,14 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n ' #hs.gen_prog(mode=1,cntHor=1,cntVert=5,wRng=(120000,120000),pt2pt_time=100) #hs.gen_prog(mode=1,cntHor=1,cntVert=5,wRng=(120000,120000),pt2pt_time=100,smt=0) #hs.gen_prog(mode=1,cntHor=1,cntVert=5,wRng=(0,360000)) - #hs.gen_prog(mode=1,cntHor=1,cntVert=5,wRng=(0,360000),smt=0) + #hs.gen_prog(mode=1,cntHor=1,cntVert=5,hRng=(-.3,.3),wRng=(0,360000),smt=1) + #hs.gen_prog(mode=1,cntHor=7,cntVert=2,hRng=(-3,3),wRng=(120000,120000),smt=0) + hs.gen_prog(mode=1,cntHor=3,cntVert=6,hRng=(-5,5),wRng=(00,120000),smt=0,pt2pt_time=10) + #hs.gen_prog(mode=1, cntHor=1, cntVert=2, wRng=(0, 360000), smt=0) #hs.gen_prog(mode=1) - hs.gen_prog(mode=1,pt2pt_time=100,cnt=1,cntVert=35,cntHor=7,hRng=(-.3,.3),wRng=(0,360000*3),yRng=(6.2,2.3)) + #hs.gen_prog(mode=1,pt2pt_time=100,cnt=1,cntVert=35,cntHor=7,hRng=(-.3,.3),wRng=(0,360000*3),yRng=(6.2,2.3)) + #hs.gen_prog(mode=1,pt2pt_time=100,cnt=1,cntVert=10,cntHor=3,hRng=(-30,30),wRng=(0,36000),yRng=(-50,-100)) + #hs.gen_prog(mode=1,cntHor=7,cntVert=2,hRng=(-100,50),wRng=(000,10000),smt=0) hs.load_rec() hs.show_pos();hs.show_vel() hs.interactive_anim() diff --git a/python/helicalscan1.svg b/python/helicalscan1.svg index 4e4303e..a52383b 100644 --- a/python/helicalscan1.svg +++ b/python/helicalscan1.svg @@ -18,6 +18,34 @@ sodipodi:docname="helicalscan1.svg"> + + + + + + + φφs + id="tspan5158">0 pe + id="tspan5192">1 ps + id="tspan5198">0 φe + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:64.99999762%;font-family:MathJax_Size1;-inkscape-font-specification:MathJax_Size1;baseline-shift:sub">1 ys + id="tspan5210">0 ye + id="tspan5216">1 v crystal + y="484.16422">crystal rs + id="tspan5226">0 re + id="tspan5232">1 xe + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:64.99999762%;font-family:MathJax_Size1;-inkscape-font-specification:MathJax_Size1;baseline-shift:sub">1 xs + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:64.99999762%;font-family:MathJax_Size1;-inkscape-font-specification:MathJax_Size1;baseline-shift:sub">0 - coord transformation:input ω,y,dx,dzinput ω,y,dx,dzoutput: ω,x,y,z,output: qω,qcx,qfy,qcz,dx,dz are translation from the vector v after rotationdx,dz are translation from the vector v after rotationq vaiables are 'real motor' variables known values after fft: yknown values after fft: ys, r0, rs, x0, xs, φ0, φs, y0, ye, r1, re, x1, xe, φ1, φe + style="font-size:64.99999762%;baseline-shift:sub">1 φe - - v=pe-ps - - - - ps(ω)= + id="tspan3936">n(ω)= xs+rn+rs·cos(φn·sin(φs+ω) + style="font-size:64.99999762%;baseline-shift:sub">n+ω) yzn+rs+rn·cos(φs·sin(φs+ω) + id="tspan4413">n+ω) ys + style="font-size:64.99999762%;baseline-shift:sub">n output:output:ω=ωqω=ωx=psx+vqcx=px(y)+dxy=yqfy=yz=psy+vqcz=pz(y)+dz + x="347.44675" + y="763.10614" /> - - v ·(ye-ys) - - v·(y-ys) - - - - - - + + + @@ -850,9 +796,13 @@ y="827.30298" x="70.195465" id="tspan3792" - sodipodi:role="line">vpx(y) + style="font-size:64.99999762%;baseline-shift:sub">0x+scl·(p1x-p0x) @@ -875,9 +825,13 @@ sodipodi:role="line" id="tspan3822" x="70.195465" - y="846.34308">vy(y) + y="846.34308">p0y+scl·(p1y-p0y) vz(y) + sodipodi:role="line">p0z+scl·(p1z-p0z) v(y)= - = + sodipodi:role="line">p(y)= + id="flowPara3858" /> + scl= + y-y0y1-y0 + + + + + + + + p1x-p0x + diff --git a/python/plot_interfero.py b/python/plot_interfero.py index 6305f77..16e0e9e 100755 --- a/python/plot_interfero.py +++ b/python/plot_interfero.py @@ -11,33 +11,39 @@ zamofing_t@ganymede:~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/cfg$ gpasciiCommander --host $PPMAC -i $$$*** !common() -!mx-stage() +!SAR-EXPMX1() +enable plc 1 +Motor[1].MaxSpeed=25 +Motor[2].MaxSpeed=25 +X -12000 ..12000 +Y -12000 .. 12000 Gather.Enable=0 Gather.Items=6 Gather.MaxSamples=1000000 Gather.Period=10 -Gather.Addr[0]=Motor[2].DesPos.a -Gather.Addr[1]=Motor[3].DesPos.a -Gather.Addr[2]=Motor[2].ActPos.a -Gather.Addr[3]=Motor[3].ActPos.a -Gather.Addr[4]=Motor[4].ActPos.a -Gather.Addr[5]=Motor[5].ActPos.a +Gather.Addr[0]=Motor[1].DesPos.a +Gather.Addr[1]=Motor[2].DesPos.a +Gather.Addr[2]=Motor[1].ActPos.a +Gather.Addr[3]=Motor[2].ActPos.a +Gather.Addr[4]=Motor[6].ActPos.a +Gather.Addr[5]=Motor[7].ActPos.a open prog 2 linear abs - X1000 Y1000 + X-12000 Y-12000 dwell 10 Gather.Enable=2 - X28000 Y1000 + X-12000 Y12000 dwell 100 - X1000 Y1000 + X-12000 Y-12000 dwell 100 - X1000 Y28000 + X12000 Y-12000 dwell 100 - X1000 Y1000 + X-12000 Y-12000 dwell 1000 Gather.Enable=0 close +#1..7j/ &1 b2r @@ -57,43 +63,217 @@ b2r ''' -import os, sys, json +import os, sys, json, time import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import subprocess as sprc import telnetlib -if __name__=='__main__': - def plot_gather(base): - #rec=Motor[1].ActPos,Motor[2].ActPos,Motor[3].ActPos,Motor[1].DesPos,Motor[2].DesPos,Motor[3].DesPos - #res=rot.ActPos,y.ActPos,x.ActPos,rot.DesPos,y.DesPos,x.DesPos +class Interferometer(): + def __init__(self,**kwargs): + for k,v in kwargs.iteritems(): + setattr(self,k,v) + + + def gen_prog(self,prgId=2,mode=0,**kwargs): + ''' + kwargs: + acq_per : acquire period: acquire data all acq_per servo loops (default=1) + mode=0: test motion + xrng: + yrng: + spd: + ''' + prg=[] + acq_per=kwargs.get('acq_per',10) + gather={"MaxSamples":1000000, "Period":acq_per} + #Sys.ServoPeriod is dependent of !common() macro + ServoPeriod= .2 #0.2ms + #ServoPeriod = .05 + self.meta = {'timebase': ServoPeriod*gather['Period']} + channels=["Motor[1].DesPos","Motor[2].DesPos","Motor[1].ActPos","Motor[2].ActPos","Motor[6].ActPos","Motor[7].ActPos"] + prg.append('Gather.Enable=0') + prg.append('Gather.Items=%d'%len(channels)) + for k,v in gather.iteritems(): + prg.append('Gather.%s=%d'%(k,v)) + for i,c in enumerate(channels): + prg.append('Gather.Addr[%d]=%s.a'%(i,c)) + + + prg.append('open prog %d'%(prgId)) + prg.append(' P1000=0') + # this uses Coord[1].Tm and limits with MaxSpeed + + #******** mode -1 ******** + if mode==0: #### jog all motors 10000um (or 10000 mdeg) + xRng = kwargs.get('xRng', (-12000,12000)) + yRng = kwargs.get('yRng', (-12000,12000)) + spd = kwargs.get('spd', 10) + prg.append('Motor[1].MaxSpeed=%f'%spd) + prg.append('Motor[2].MaxSpeed=%f'%spd) + prg.append(''' + linear abs + X%g Y%g + dwell 10 + Gather.Enable=2 + X%g Y%g + dwell 100 + X%g Y%g + dwell 100 + X%g Y%g + dwell 100 + X%g Y%g + dwell 100 + Gather.Enable=0 +'''%(xRng[0],yRng[0],xRng[0],yRng[1],xRng[0],yRng[0],xRng[1],yRng[0],xRng[0],yRng[0])) + + prg.append(' P1000=1') + prg.append('close') + prg.append('&1\nb%dr\n'%prgId) + + self.download(prg,mode=3,file='/tmp/prg.cfg') + + + def download(self,prg=None,mode=0,file='/tmp/interfero.cfg'): + ''' + mode bits: + bit 0 (1): wait execution finished (P1000==1) + bit 1 (2): gather and save data + bit 2 (4): ... + ''' + host=self.host + if prg is not None and self.verbose & 4: + for ln in prg: + print(ln) + + if file is not None and prg is not None: + fh=open(file,'w') + fh.write('\n'.join(prg)) + fh.close() + if host is not None: + # ***download and start the program*** + cmd ='gpasciiCommander --host '+host+' '+ file + print(cmd) + p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT) + #res=p.stdout.readlines(); print res + retval = p.wait() + + if mode &1: + # ***wait program finished P1000=1*** + com=GpasciiCommunicator().connect(host,prompt='# ') + ack=GpasciiCommunicator.gpascii_ack + sys.stdout.write('wait execution...');sys.stdout.flush() + while(True): + #Gather.MaxLines calculates maximum numbewr of gathering into memory + com.write('P1000\n') + val=com.read_until(ack) + #print val + val=int(val[val.find('=')+1:].rstrip(ack)) + if val==1:break + #com.write('Gather.Index\n') + #val=com.read_until(ack) + #print val + time.sleep(.2) + sys.stdout.write('.');sys.stdout.flush() + if mode &2: + fnRmt = '/var/ftp/gather/out.txt' + fnLoc = '/tmp/gather.txt' + print('\ngather data to %s...' % fnRmt) + p = sprc.Popen(('ssh', 'root@' + host, 'gather ', '-u', fnRmt), shell=False, stdin=sprc.PIPE, stdout=sprc.PIPE, + stderr=sprc.PIPE) + res = p.wait() + if res: + print('ssh failed. ssh root@%s to open a session' % host) + return + + print('transfer data to %s...' % fnLoc) + p = sprc.Popen(('scp', 'root@' + host + ':' + fnRmt, fnLoc), shell=False, stdin=sprc.PIPE, stdout=sprc.PIPE, + stderr=sprc.PIPE) + res = p.wait() + self.rec = np.genfromtxt(fnLoc, delimiter=' ') + + def show_pos(self): + rec=self.rec + #"M1.DesPos","M2.DesPos","M1.ActPos","M2.ActPos","M6.ActPos","M7.ActPos"] #idx 0 1 2 3 4 5 f1=plt.figure() - #f2 = plt.figure() ax1 = f1.add_subplot(1,1,1) - #ax2 = f2.add_subplot(1, 1, 1) - for fn in sorted(os.listdir(base)): - print fn - rec = np.genfromtxt(base+'/'+fn, delimiter=' ') - print rec.shape + x=range(len(rec[:,0])) - x=range(len(rec[:,0])) - #hl=ax[0].plot(x, y, color=col) - - hl=ax1.plot(x,-(rec[:,0]-rec[0,0]),'k') - hl=ax1.plot(x,-(rec[:,2]-rec[0,2]),'r') - hl=ax1.plot(x,-(rec[:,4]-rec[0,4])/100,'m') - hl=ax1.plot(x,rec[:,1]-rec[0,1],'k') - hl=ax1.plot(x,rec[:,3]-rec[0,3],'b') - hl=ax1.plot(x,-(rec[:,5]-rec[0,5])/100,'c') + hl=ax1.plot(x,-(rec[:,0]-rec[0,0]),'k') + hl=ax1.plot(x,-(rec[:,2]-rec[0,2]),'r') + hl=ax1.plot(x,-(rec[:,4]-rec[0,4])/100,'m') + hl=ax1.plot(x,rec[:,1]-rec[0,1],'k') + hl=ax1.plot(x,rec[:,3]-rec[0,3],'b') + hl=ax1.plot(x,-(rec[:,5]-rec[0,5])/100,'c') + #hl=ax1.plot(x,-(rec[:,0]-rec[0,0]),'k') + #hl=ax1.plot(x,-(rec[:,2]-rec[0,2]),'r') + #hl=ax1.plot(x,-(rec[:,4]-rec[0,4])/100,'m') + #hl=ax1.plot(x,rec[:,1]-rec[0,1],'k') + #hl=ax1.plot(x,rec[:,3]-rec[0,3],'b') + #hl=ax1.plot(x,-(rec[:,5]-rec[0,5])/100,'c') plt.show() -#plot_gather(base='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/gather5/') -#plot_gather(base='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/gather50/') -#plot_gather(base='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/tmp/') -#plot_gather(base='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/data_interfero_spd10') -#plot_gather(base='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/data_interfero_spd20') -plot_gather(base='data_interfero_spd10') + def show_poserr(self): + rec=self.rec + #"M1.DesPos","M2.DesPos","M1.ActPos","M2.ActPos","M6.ActPos","M7.ActPos"] + #idx 0 1 2 3 4 5 + f1=plt.figure() + ax1 = f1.add_subplot(1,1,1) + + t=range(len(rec[:,0])) + actYerr=(rec[:,2]-rec[:,0]);actYerr-=actYerr[0] + actXerr=(rec[:,3]-rec[:,1]);actXerr-=actXerr[0] + infYerr=(rec[:,4]-rec[:,0]);infYerr-=infYerr[0] + infXerr=(rec[:,5]-rec[:,1]);infXerr-=infXerr[0] + + hl=ax1.plot(t,actYerr,'r',label='actYerr') + hl=ax1.plot(t,actXerr,'b',label='actXerr') + hl=ax1.plot(t,infYerr,'m',label='infYerr') + hl=ax1.plot(t,infXerr,'c',label='infXerr') + + #plt.legend(handles=h) + ax1.legend() + plt.show() + +class GpasciiCommunicator(): + '''Communicates with the Delta Tau gpascii programm + ''' + gpascii_ack="\x06\r\n" + gpascii_inp='Input\r\n' + + def connect(self, host, username='root', password='deltatau',prompt='ppmac# ',verbose=0): + p=telnetlib.Telnet(host) + s=p.read_until('login: ') + if verbose: print(s) + p.write(username+'\n') + s =p.read_until('Password: ') + if verbose: print(s) + p.write(password+'\n') + s =p.read_until(prompt) # command prompt + if verbose: print(s) + p.write('gpascii -2\n') # execute gpascii command + s=p.read_until(self.gpascii_inp) + if verbose: print(s) + return p + + +if __name__=='__main__': + + ifm=Interferometer(verbose = 255,host='SAR-CPPM-EXPMX1') + os.chdir(os.path.join(os.path.dirname(__file__), '../cfg')) + ifm.download(['$$$***','!common()','!SAR-EXPMX1()','#1..7j/','enable plc 1','Motor[1].MaxSpeed=25','Motor[2].MaxSpeed=25']) + raw_input('press return when homed') + #ifm.gen_prog(mode=0) + #ifm.show_poserr() + #ifm.gen_prog(mode=0,xRng=(-10000,10000),yRng=(-10000,10000),spd=10) + ifm.gen_prog(mode=0,xRng=(-5000,5000),yRng=(-5000,5000),spd=5) + ifm.show_poserr() + #ifm.gen_prog(mode=0,xRng=(-2000,2000),yRng=(4000,8000),spd=5) + #ifm.show_poserr() + + #ifm.rec = np.genfromtxt('/scratch/gather.txt', delimiter=' ') + #ifm.show_pos() diff --git a/qt/ESB_MX_exp.ui b/qt/ESB_MX_exp.ui index e80461c..4250d32 100644 --- a/qt/ESB_MX_exp.ui +++ b/qt/ESB_MX_exp.ui @@ -296,7 +296,7 @@ P=$(P),M=MOT_GIRDER5 Home BkLight - $(P):MOTOR_BLGT.HOMF + $(P):MOT_BLGT.HOMF 1