Loading Noto/Misc/NotoScripts/src/Makefile +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ TCL_SCRIPTS_L = # # Python stuff (public and local) # ---------------------------- PY_SCRIPTS = subr PY_SCRIPTS = subr subrOff PY_SCRIPTS_L = PY_MODULES = Loading Noto/Misc/NotoScripts/src/subr.py +59 −9 Original line number Diff line number Diff line Loading @@ -20,7 +20,34 @@ import time import socket import struct from math import * import os import thread offsets=[0.0,0.0,0.0,0.0,0.0] exitFlag=False def readPipe(pipeName): print "Opening pipe......" pipeIn=os.open(pipeName,os.O_RDONLY|os.O_NONBLOCK) print "Pipe openened for reading......" while not exitFlag: try: pipeString=os.read(pipeIn,64) if len(pipeString)>0: print "receieved offsets %s"%pipeString info=pipeString.split(',') print info offsets[0]=float(info[0]) offsets[1]=float(info[1]) offsets[2]=float(info[2]) offsets[3]=float(info[2]) offsets[4]=float(info[2]) print offsets except Exception, ex: print ex finally: time.sleep(1) os.close(pipeIn) def usage(): print "subr [-h|--help] [-c|--code=]" Loading Loading @@ -48,6 +75,7 @@ def main(): polZ1=[0.0,0.0,0.0] polZ2=[0.0,0.0,0.0] polZ3=[0.0,0.0,0.0] pipeName="/tmp/subrPipe" for o, a in opts: if o in ("-h", "--help"): Loading Loading @@ -83,7 +111,6 @@ def main(): maxZ2=100 minZ2=-100 polZ3[0]=0.00168640 polZ3[1]=-0.271430 polZ3[2]=-57.40 Loading Loading @@ -125,6 +152,20 @@ def main(): print "Unknown code" sys.exit(1); print "Preparing pipe....." if not os.path.exists(pipeName): print "Creating pipe" os.mkfifo(pipeName,0777) print "Created" else: print "pipe already exists" try: pipeThread=thread.start_new_thread(readPipe,(pipeName, ) ) except Exception,ex: print ex sys.exit(1) #get the link to the SRTmountcomponent simpleClient = PySimpleClient() compName="" Loading @@ -145,6 +186,7 @@ def main(): print "socket connected" time.sleep(2) try: while 1: ctime=getTimeStamp().value Loading @@ -159,6 +201,11 @@ def main(): posZ1=polZ1[0]*delev*delev+polZ1[1]*delev+polZ1[2] posZ2=polZ2[0]*delev*delev+polZ2[1]*delev+polZ2[2] posZ3=polZ3[0]*delev*delev+polZ3[1]*delev+polZ3[2] posX=posX+offsets[0] posY=posX+offsets[1] posZ1=posX+offsets[2] posZ2=posX+offsets[3] posZ3=posX+offsets[4] if posX>maxX: posX=maxX if posX<minX: Loading Loading @@ -187,13 +234,16 @@ def main(): time.sleep(1) data=client_socket.recv(128) print "risposta ", data time.sleep(10) time.sleep(2) finally: exitFlag=True pipeThread.join(timeout=5) if not (compName==""): simpleClient.releaseComponent(compName) simpleClient.disconnect() if __name__=="__main__": main() Loading Noto/Misc/NotoScripts/src/subrOff.py 0 → 100644 +76 −0 Original line number Diff line number Diff line #!/usr/bin/env python # This is a python test program that rchanges the current offsets of Noto SCU #who when what #Andrea Orlati(a.orlati@ira.inaf.it) 24/01/2017 Creation import getopt, sys import string import math import time import socket import struct from math import * import os def usage(): print "subrOff [-h|--help] [-x val] [-y val] [-z val]" print "" print "[-h|--help] displays this help" print "[-x val] offset for x axis" print "[-y val] offset for y axis" print "[-z val] offset for z axis" def main(): try: opts, args = getopt.getopt(sys.argv[1:],"hx:y:z:",["help"]) except getopt.GetoptError, err: print str(err) usage() sys.exit(1) pipeName="/tmp/subrPipe" X=0.0 Y=0.0 Z=0.0 for o, a in opts: if o in ("-h", "--help"): usage() sys.exit() elif o in ("-x"): X = float(a) elif o in ("-y"): Y = float(a) elif o in ("-z"): Z = float(a) print "The offsets are X: %lf, Y: %lf, Z, %lf" % (X,Y,Z) print "Preparing pipe....." if not os.path.exists(pipeName): print "Creating pipe" os.mkfifo(pipeName,0777) print "Created" else: print "pipe already exists" print "Opening pipe......" pipeOut=open(pipeName,'w', 0) print "Pipe openened for writing......" try: pipeString="%lf,%lf,%lf"%(X,Y,Z) pipeOut.write(pipeString) print "command sent!" except Exception, ex: print ex if __name__=="__main__": main() Loading
Noto/Misc/NotoScripts/src/Makefile +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ TCL_SCRIPTS_L = # # Python stuff (public and local) # ---------------------------- PY_SCRIPTS = subr PY_SCRIPTS = subr subrOff PY_SCRIPTS_L = PY_MODULES = Loading
Noto/Misc/NotoScripts/src/subr.py +59 −9 Original line number Diff line number Diff line Loading @@ -20,7 +20,34 @@ import time import socket import struct from math import * import os import thread offsets=[0.0,0.0,0.0,0.0,0.0] exitFlag=False def readPipe(pipeName): print "Opening pipe......" pipeIn=os.open(pipeName,os.O_RDONLY|os.O_NONBLOCK) print "Pipe openened for reading......" while not exitFlag: try: pipeString=os.read(pipeIn,64) if len(pipeString)>0: print "receieved offsets %s"%pipeString info=pipeString.split(',') print info offsets[0]=float(info[0]) offsets[1]=float(info[1]) offsets[2]=float(info[2]) offsets[3]=float(info[2]) offsets[4]=float(info[2]) print offsets except Exception, ex: print ex finally: time.sleep(1) os.close(pipeIn) def usage(): print "subr [-h|--help] [-c|--code=]" Loading Loading @@ -48,6 +75,7 @@ def main(): polZ1=[0.0,0.0,0.0] polZ2=[0.0,0.0,0.0] polZ3=[0.0,0.0,0.0] pipeName="/tmp/subrPipe" for o, a in opts: if o in ("-h", "--help"): Loading Loading @@ -83,7 +111,6 @@ def main(): maxZ2=100 minZ2=-100 polZ3[0]=0.00168640 polZ3[1]=-0.271430 polZ3[2]=-57.40 Loading Loading @@ -125,6 +152,20 @@ def main(): print "Unknown code" sys.exit(1); print "Preparing pipe....." if not os.path.exists(pipeName): print "Creating pipe" os.mkfifo(pipeName,0777) print "Created" else: print "pipe already exists" try: pipeThread=thread.start_new_thread(readPipe,(pipeName, ) ) except Exception,ex: print ex sys.exit(1) #get the link to the SRTmountcomponent simpleClient = PySimpleClient() compName="" Loading @@ -145,6 +186,7 @@ def main(): print "socket connected" time.sleep(2) try: while 1: ctime=getTimeStamp().value Loading @@ -159,6 +201,11 @@ def main(): posZ1=polZ1[0]*delev*delev+polZ1[1]*delev+polZ1[2] posZ2=polZ2[0]*delev*delev+polZ2[1]*delev+polZ2[2] posZ3=polZ3[0]*delev*delev+polZ3[1]*delev+polZ3[2] posX=posX+offsets[0] posY=posX+offsets[1] posZ1=posX+offsets[2] posZ2=posX+offsets[3] posZ3=posX+offsets[4] if posX>maxX: posX=maxX if posX<minX: Loading Loading @@ -187,13 +234,16 @@ def main(): time.sleep(1) data=client_socket.recv(128) print "risposta ", data time.sleep(10) time.sleep(2) finally: exitFlag=True pipeThread.join(timeout=5) if not (compName==""): simpleClient.releaseComponent(compName) simpleClient.disconnect() if __name__=="__main__": main() Loading
Noto/Misc/NotoScripts/src/subrOff.py 0 → 100644 +76 −0 Original line number Diff line number Diff line #!/usr/bin/env python # This is a python test program that rchanges the current offsets of Noto SCU #who when what #Andrea Orlati(a.orlati@ira.inaf.it) 24/01/2017 Creation import getopt, sys import string import math import time import socket import struct from math import * import os def usage(): print "subrOff [-h|--help] [-x val] [-y val] [-z val]" print "" print "[-h|--help] displays this help" print "[-x val] offset for x axis" print "[-y val] offset for y axis" print "[-z val] offset for z axis" def main(): try: opts, args = getopt.getopt(sys.argv[1:],"hx:y:z:",["help"]) except getopt.GetoptError, err: print str(err) usage() sys.exit(1) pipeName="/tmp/subrPipe" X=0.0 Y=0.0 Z=0.0 for o, a in opts: if o in ("-h", "--help"): usage() sys.exit() elif o in ("-x"): X = float(a) elif o in ("-y"): Y = float(a) elif o in ("-z"): Z = float(a) print "The offsets are X: %lf, Y: %lf, Z, %lf" % (X,Y,Z) print "Preparing pipe....." if not os.path.exists(pipeName): print "Creating pipe" os.mkfifo(pipeName,0777) print "Created" else: print "pipe already exists" print "Opening pipe......" pipeOut=open(pipeName,'w', 0) print "Pipe openened for writing......" try: pipeString="%lf,%lf,%lf"%(X,Y,Z) pipeOut.write(pipeString) print "command sent!" except Exception, ex: print ex if __name__=="__main__": main()