-
Notifications
You must be signed in to change notification settings - Fork 0
/
startExperiment.py
43 lines (38 loc) · 1.36 KB
/
startExperiment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'''
Simple simultaneous network control of Bonsai and OpenEphys.
Dependencies:
1. pyOSC
2. SimpleOSC
'''
import argparse
from simpleOSC import initOSCClient, sendOSCMsg
import zmq
import random
import sys
import time
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--bonsaiIP", default="127.0.0.1", help="The IP of Bonsai machine")
parser.add_argument("--bonsaiPort", type=int, default=2323, help="The port Bonsai is listening on")
parser.add_argument("--oeIP", default="10.153.170.52", help="The IP of OpenEphys machine")
parser.add_argument("--oePort", default='5556', help="The port OpenEphys is listening on")
parser.add_argument("--mode", default='start', help="start or stop")
args = parser.parse_args()
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://%s:%s" % (args.oeIP, args.oePort))
if args.mode == 'start':
initOSCClient(args.bonsaiIP,args.bonsaiPort)
sendOSCMsg("/number", [1])
socket.send("StartRecord CreateNewDir=1")
socket.recv_string()
elif args.mode == 'stop':
initOSCClient(args.bonsaiIP,args.bonsaiPort)
sendOSCMsg("/number", [2])
socket.send("StopRecord")
socket.recv_string()
elif args.mode == 'event':
initOSCClient(args.bonsaiIP,args.bonsaiPort)
sendOSCMsg("/number", [3])
socket.send("Event")
socket.recv_string()