11 context = zmq.Context(1)
12 socket = context.socket(zmq.REQ)
15 def connect(endpoint="tcp://127.0.0.1:5555
") :
16 socket.setsockopt(zmq.LINGER, 0)
17 socket.connect(endpoint)
21 socket.send(b
"@@ping")
23 poller.register(socket, zmq.POLLIN)
24 if poller.poll(1*1000) :
25 output = socket.recv()
26 print (
"@@ G4ZMQ server connected.")
28 raise ConnectionError(
"*** connection timeout")
32 socket.send(b
"@@debug")
34 socket.send(b
"@@nodebug")
35 output = socket.recv()
36 print(output.decode(charset))
39 cmd_str= command.encode(charset)
41 output = socket.recv()
42 print(output.decode(charset))
49 output = socket.recv()
50 print(output.decode(charset))
54 output = socket.recv()
55 print(output.decode(charset))
59 socket.send(cmd.encode(charset))
60 output = socket.recv()
61 print(output.decode(charset))
65 socket.send(cmd.encode(charset))
66 output = socket.recv()
67 print(output.decode(charset))
71 socket.send(cmd.encode(charset))
72 output = socket.recv()
73 print(output.decode(charset))
77 raise SyntaxWarning(
"*** no command specified.")
79 cmd =
"help " + target
80 socket.send(cmd.encode(charset))
81 output = socket.recv()
82 print(output.decode(charset))
85 socket.send(b
"history")
86 output = socket.recv()
87 print(output.decode(charset))
90 cmd =
"/run/beamOn " + str(nevent)
95 socket.send(cmd.encode(charset))
96 output = socket.recv()
97 print(output.decode(charset))
101 output = socket.recv()
102 print(output.decode(charset))
105 if __name__ ==
'__main__' :