This commit is contained in:
2022-05-20 08:24:44 +02:00
parent 399282cba9
commit 8e5b15e0ac
3 changed files with 155 additions and 27 deletions

View File

@@ -39,6 +39,29 @@ Mot 5: Stage Z Stada Stepper 670mA 200 poles 1 rev = 100*2
Enc 6: Interferometer Y
Enc 7: Interferometer X
tunnel PowerBrick port locally
------------------------------
Port 22 on PowerBrick is the ssh server port
Port 2332 on PowerBrick is the gather port of gather_server
PPMAC=SAR-CPPM-EXPMX1
ssh -L 10001:localhost:22 root@$PPMAC 'uname -a'
ssh -L 10002:localhost:2332 root@$PPMAC 'uname -a'
-> this tunnels port 22 and 2332 of $PPMAC to 10001 and 10002 of localhost
('uname -a' is just to execute a command and return, because the port remains open)
Tests:
nc localhost 10001
nc localhost 10002
list close ssh tunnel
---------------------
lsof -i -n | egrep 'ssh'
lsof -i -n | grep '127.0.0.1:1000'
'''
from __future__ import print_function
#from __future__ import absolute_import,division,generators,nested_scopes,print_function,unicode_literals,with_statement
@@ -52,6 +75,7 @@ import matplotlib.pyplot as plt
import subprocess as sprc
sys.path.insert(0,os.path.expanduser('~/Documents/prj/SwissFEL/PBTools/'))
sys.path.insert(0,os.path.expanduser('/tmp/zamofing_t/PBTools/'))
from pbtools.misc.pp_comm import PPComm
from pbtools.misc.gather import Gather
from MXMotion import MotionBase
@@ -638,12 +662,13 @@ class ShapePath(MotionBase):
#1-> Y
#2-> X
#3-> A
#4->0
#5->0
#6->0
#7->0
#8->0
#1..8j/
&0#4->0
&0#5->0
&0#6->0
&0#7->0
#1..3j/
//#8->0
//#1..8j/
'''
gpascii.send_block(prg)
@@ -800,18 +825,29 @@ if __name__=='__main__':
def run_test(args):
#dp=DebugPlot();dp.plot_gather();return
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # create an INET, STREAMing socket
s.settimeout(.1)
try:
port=22 #ssh port
s.connect((args.host, port)) # try to connect to port
s.close()
except (socket.error, socket.gaierror) as e:
comm=gather=None
else:
comm = PPComm(host=args.host)
gather = Gather(comm)
#import socket
#s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # create an INET, STREAMing socket
#s.settimeout(.1)
#try:
# port=22 #ssh port
# s.connect((args.host, port)) # try to connect to port
# s.close()
#except (socket.error, socket.gaierror) as e:
# comm=gather=None
#else:
# comm = PPComm(host=args.host)
# gather = Gather(comm)
hpp=args.host.split(':')
param={'host':hpp[0]}
if len(hpp)>1:
param['port']=int(hpp[1])
if len(hpp)>2:
param['fast_gather_port']=int(hpp[2])
print(' -> ssh-tunneling PPComm({host}:{port} {host}:{fast_gather_port})'.format(**param))
comm=PPComm(**param)
gather = Gather(comm)
#real start and frame trigger with sync
#sp = ShapePath(comm, gather, args.verbose)
@@ -819,7 +855,7 @@ if __name__=='__main__':
#sp = ShapePath(comm, gather, args.verbose,sync_mode=0,pt2pt_time=10)
#simulated start and frame trigger no sync
#sp = ShapePath(comm, gather, args.verbose,sync_mode=1,sync_flag=3)
sp = ShapePath(comm, gather, args.verbose,sync_mode=1,sync_flag=3)
#simulated start and frame trigger with sync
#sp = ShapePath(comm, gather, args.verbose,sync_mode=2,sync_flag=3)
@@ -828,7 +864,7 @@ if __name__=='__main__':
#sp = ShapePath(comm, gather, args.verbose,sync_mode=1,sync_flag=1)
#simulated start real frame trigger with sync
sp = ShapePath(comm, gather, args.verbose,sync_mode=2,sync_flag=1)
#sp = ShapePath(comm, gather, args.verbose,sync_mode=2,sync_flag=1)
fn='/tmp/shapepath'
#fn =unique_filename('ShapePathAnalyser/records/19_01_24/spiral')
@@ -855,11 +891,12 @@ if __name__=='__main__':
#sp.gen_swissmx_points(width=1000,ofs=(-500,0))
#sp.gen_swissfel_points(width=1000,ofs=(-500,0))
#sp.gen_rand_points(n=20, scale=100,ofs=(-950,+2780));sp.sort_points(xy=False)
sp.gen_rand_points(n=200, scale=100,ofs=(0,+2000));sp.sort_points(xy=False)
#sp.gen_rand_points(n=200, scale=100,ofs=(0,+2000));sp.sort_points(xy=False)
#sp.gen_swissmx_points(width=1000, ofs=(-500, 0));
#sp.gen_spiral_points(rStart=100,rInc=10,numSeg=4,numCir=60, ofs=(0, 0))
#sp.gen_spiral_points(rStart=100,rInc=130,numSeg=4,numCir=2, ofs=(0, 0))
#sp.gen_grid_points(w=10,h=10,pitch=100,rnd=0,ofs=(0,0));sp.sort_points(False);
#sp.gen_grid_points(w=20,h=20,pitch=100,rnd=0,ofs=(0,+2000));sp.sort_points(False);
sp.gen_grid_points(w=5,h=10,pitch=100,rnd=0,ofs=(0,+2000));sp.sort_points(False,10);
#sp.gen_grid_points(w=1,h=10,pitch=100,rnd=0,ofs=(0,0))
#sp.gen_spiral_points(rStart=100,rInc=20,numSeg=8,numCir=32, ofs=(0, 0))
#sp.gen_spiral_points(rStart=100,rInc=10,numSeg=2,numCir=32, phase=45, ofs=(0, 0))
@@ -869,7 +906,7 @@ if __name__=='__main__':
gtMaxLn=116508;ovhdTime=100
acq_per=int(np.ceil((sp.meta['pt2pt_time']*sp.points.shape[0]+ovhdTime)/(gtMaxLn*sp.meta['srv_per'])))
sp.setup_gather(acq_per=acq_per)
sp.setup_sync(verbose=args.verbose&32,timeOfs=0.55)
sp.setup_sync(verbose=args.verbose&32,timeOfs=0.05)
sp.setup_coord_trf() # reset to shape path system
#sp.meta['pt2pt_time']=10 #put between setup_sync and setup_motion to have more motion points than FEL syncs
sp.setup_motion(fnPrg=fn+'.prg', mode=3, scale=1.,dwell=10)
@@ -917,8 +954,8 @@ if __name__=='__main__':
'main command line interpreter function'
#usage: gpasciiCommunicator.py --host=PPMACZT84 myPowerBRICK.cfg
(h, t)=os.path.split(sys.argv[0]);cmd='\n '+(t if len(h)>3 else sys.argv[0])+' '
exampleCmd=('-n',
'-v15'
exampleCmd=('-v15',
'--host=localhost:10001:10002'
)
epilog=__doc__+'''
Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
@@ -928,6 +965,7 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
parser.add_option('-v', '--verbose', type="int", dest='verbose', help='verbosity bits (see below)', default=0)
parser.add_option('--host', help='hostname', default='SAR-CPPM-EXPMX1')
#parser.add_option('--host', help='hostname', default='localhost:10001:10002')
#parser.add_option('--host', help='hostname')
(args, other)=parser.parse_args()