示例#1
0
import socket
socket.setdefaulttimeout(20)
import sys

try:
    table = bindpyrame.init_ports_table("/opt/pyrame/ports.txt")
    port = bindpyrame.get_port("TEST_PORT",table)
except Exception as e:
    print e
    sys.exit(1)

# SENDCMD
try:
    retcode,res=bindpyrame.sendcmd("localhost",port,"twoargs_test","arg1","arg2")
except Exception as e:
    print e
    sys.exit(1)
print("sendcmd: retcode=%d res=%s"%(retcode,res))

print("");

# EXECCMD
try:
    sockid = bindpyrame.open_socket("localhost",port)
    retcode,res=bindpyrame.execcmd(sockid,"twoargs_test","arg1","arg2")
except Exception as e:
    print e
    sys.exit(1)
print("execcmd: retcode=%d res=%s"%(retcode,res))
sys.exit(0)
示例#2
0
    if sleep_time == 0:
        print("sendcmd:{0}: Time per set_voltage_ps: {1:.06f} s".format(i,(time()-start)/repetitions))

# EXECCMD
print("Starting execcmd loop. Press any key to stop...")
sockid=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sockid.connect(('localhost',port))
for i in range(duration):
    if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
        raw_input()
        break
    if sleep_time == 0:
        start = time()
    for voltage in voltages:
        sleep(sleep_time)
        retcode,res=bindpyrame.execcmd(sockid,"set_voltage_ps",psid,str(voltage),channel)
        attempts += 1
        if retcode==0:
            print("execcmd:{0}:{1} Error setting voltage".format(i,voltage))
            errors += 1
    if sleep_time == 0:
        print("execcmd:{0}: Time per set_voltage_ps: {1:.06f} s".format(i,(time()-start)/repetitions))

# Wrap up
print ("Number of errors = {0}/{1} ({2}%)".format(errors,attempts,float(errors)/attempts))
retcode,res=bindpyrame.execcmd(sockid,"deinit_ps",psid)
sockid.close()
if retcode==0:
    print("Error deinitializing PS")
    sys.exit(1)