#!/usr/bin/python
import os
import cburealtimesettings

if (not os.path.exists(cburealtimesettings.realtimepath())):
	os.mkdir(cburealtimesettings.realtimepath());
if (not os.path.exists(cburealtimesettings.incomingmetapath())):
	os.mkdir(cburealtimesettings.incomingmetapath());

while (1):
	lastseriesfn=os.path.join(cburealtimesettings.incomingmetapath(),"lastseries.txt");
	try:
		f=open(lastseriesfn,"r");
		ind=int(f.readline());
		f.close();
	except:
		ind=1;
	
	fileexists=1;
	while(fileexists):
		fn=os.path.join(cburealtimesettings.incomingmetapath(),"series%06d.txt"%ind);
		if (os.path.exists(fn)):
			ind=ind+1;
		else:
			break;
				
	print "Next file %s"%fn
	
	firstwrite=1;
	nccmdfile=os.popen("nc -l -p %d"%cburealtimesettings.incomingport_scanner());
	while (1):
Exemple #2
0
#!/usr/bin/python
import os
import cburealtimesettings

if (not os.path.exists(cburealtimesettings.realtimepath())):
    os.mkdir(cburealtimesettings.realtimepath())
if (not os.path.exists(cburealtimesettings.incomingmetapath())):
    os.mkdir(cburealtimesettings.incomingmetapath())

while (1):
    lastseriesfn = os.path.join(cburealtimesettings.incomingmetapath(),
                                "lastseries.txt")
    try:
        f = open(lastseriesfn, "r")
        ind = int(f.readline())
        f.close()
    except:
        ind = 1

    fileexists = 1
    while (fileexists):
        fn = os.path.join(cburealtimesettings.incomingmetapath(),
                          "series%06d.txt" % ind)
        if (os.path.exists(fn)):
            ind = ind + 1
        else:
            break

    print "Next file %s" % fn

    firstwrite = 1
#!/usr/bin/python
import os
import cburealtimesettings

# Load up the last stim_ip received
fin=open(os.path.join(cburealtimesettings.incomingmetapath(),'stim_ip.txt'));
stim_ip=fin.readline();
fin.close();

# Communicates with stimulus delivery machine
while (1):
	nccmdfile=os.popen("nc -l -p %d"%cburealtimesettings.inport_stim());
	while (1):
		ncresp=nccmdfile.readline();
		if (len(ncresp)==0):
			break;
		f=ncresp.split(' ');

		print "Received " + ncresp,

		if (f[0]=="HELLO_REALTIME"):
			stim_ip=f[1].strip();

			if (stim_ip.find(".")==-1):
				stim_ip=stim_ip + ".mrc-cbu.cam.ac.uk";

			fout=open(os.path.join(cburealtimesettings.incomingmetapath(),'stim_ip.txt'),'w');
			fout.writelines(stim_ip);
			fout.close();		
				
			# Handshake!
Exemple #4
0
#!/usr/bin/python
import os
import cburealtimesettings

# Load up the last stim_ip received
fin = open(os.path.join(cburealtimesettings.incomingmetapath(), 'stim_ip.txt'))
stim_ip = fin.readline()
fin.close()

# Communicates with stimulus delivery machine
while (1):
    nccmdfile = os.popen("nc -l -p %d" % cburealtimesettings.inport_stim())
    while (1):
        ncresp = nccmdfile.readline()
        if (len(ncresp) == 0):
            break
        f = ncresp.split(' ')

        print "Received " + ncresp,

        if (f[0] == "HELLO_REALTIME"):
            stim_ip = f[1].strip()

            if (stim_ip.find(".") == -1):
                stim_ip = stim_ip + ".mrc-cbu.cam.ac.uk"

            fout = open(
                os.path.join(cburealtimesettings.incomingmetapath(),
                             'stim_ip.txt'), 'w')
            fout.writelines(stim_ip)
            fout.close()