WIP Implement WheelchairAdapter.py
This commit is contained in:
parent
f59b74f403
commit
f3d2d2f7a2
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
build
|
build
|
||||||
dist
|
dist
|
||||||
|
*.spec
|
||||||
questions
|
questions
|
||||||
questionnaire.py
|
questionnaire.py
|
@ -1,14 +1,8 @@
|
|||||||
# TODO für python3 anpassen und in gui mit einfügen
|
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
from socket import *
|
from socket import *
|
||||||
import thread, threading, struct
|
import threading
|
||||||
import Queue
|
import queue
|
||||||
import time, datetime
|
import time
|
||||||
from time import clock
|
|
||||||
import os
|
|
||||||
import ctypes
|
|
||||||
|
|
||||||
|
|
||||||
# connect to BCI2000 in a new thread
|
# connect to BCI2000 in a new thread
|
||||||
class BCI2000ReceiverThread(threading.Thread):
|
class BCI2000ReceiverThread(threading.Thread):
|
||||||
@ -31,7 +25,7 @@ class BCI2000ReceiverThread(threading.Thread):
|
|||||||
self.UDPSock = socket(AF_INET,SOCK_DGRAM)
|
self.UDPSock = socket(AF_INET,SOCK_DGRAM)
|
||||||
self.UDPSock.bind(self.addr) # BIND to LISTEN
|
self.UDPSock.bind(self.addr) # BIND to LISTEN
|
||||||
print('%s initialized to %s at port %s' % (self.getName(), self.host, self.port))
|
print('%s initialized to %s at port %s' % (self.getName(), self.host, self.port))
|
||||||
print('Relaying SelectedTargerts to port -- %s ---' % self.UNITY_PORT)
|
print('Relaying SelectedTargets to port -- %s ---' % self.UNITY_PORT)
|
||||||
self.relay_unity = socket(AF_INET,SOCK_DGRAM) # UDP RELAY TO UNITY
|
self.relay_unity = socket(AF_INET,SOCK_DGRAM) # UDP RELAY TO UNITY
|
||||||
print('Relaying all to port -- %s ---' % self.FEATHER_PORT)
|
print('Relaying all to port -- %s ---' % self.FEATHER_PORT)
|
||||||
self.relay_feather = socket(AF_INET,SOCK_DGRAM) # UDP RELAY TO FEATHER
|
self.relay_feather = socket(AF_INET,SOCK_DGRAM) # UDP RELAY TO FEATHER
|
||||||
@ -59,7 +53,7 @@ class BCI2000ReceiverThread(threading.Thread):
|
|||||||
if "SelectedTarget 0" in self.data:
|
if "SelectedTarget 0" in self.data:
|
||||||
self.go = True
|
self.go = True
|
||||||
if "SelectedTarget" in self.data and "SelectedTarget 0" not in self.data and self.go == True:
|
if "SelectedTarget" in self.data and "SelectedTarget 0" not in self.data and self.go == True:
|
||||||
print "Relaying Command to Unity: ", self.data
|
print("Relaying Command to Unity: ", self.data)
|
||||||
self.relay_unity.sendto(self.data, (self.host, self.UNITY_PORT))
|
self.relay_unity.sendto(self.data, (self.host, self.UNITY_PORT))
|
||||||
self.go = False
|
self.go = False
|
||||||
|
|
||||||
@ -69,7 +63,7 @@ class BCI2000ReceiverThread(threading.Thread):
|
|||||||
#print (phaseInSequence)
|
#print (phaseInSequence)
|
||||||
|
|
||||||
if contains(self.data, "StimulusCode "):
|
if contains(self.data, "StimulusCode "):
|
||||||
print "Relaying Command to Feather: ", self.data
|
print("Relaying Command to TactileBCIfilter: ", self.data)
|
||||||
self.relay_feather.sendto(self.data, (self.host, self.FEATHER_PORT))
|
self.relay_feather.sendto(self.data, (self.host, self.FEATHER_PORT))
|
||||||
|
|
||||||
StimulusCode=int(self.data.replace('StimulusCode ',''))
|
StimulusCode=int(self.data.replace('StimulusCode ',''))
|
||||||
@ -93,23 +87,18 @@ class BCI2000ReceiverThread(threading.Thread):
|
|||||||
def returnProgramStatus(self):
|
def returnProgramStatus(self):
|
||||||
return self.running
|
return self.running
|
||||||
|
|
||||||
def kill(self):
|
|
||||||
self.running=False
|
|
||||||
log('%s terminated' % (self.getName()))
|
|
||||||
|
|
||||||
|
|
||||||
### M A I N P R O G R A M M ###
|
### M A I N P R O G R A M M ###
|
||||||
|
|
||||||
|
# # initialize queue
|
||||||
|
# phaseInSequenceQueue = queue.Queue()
|
||||||
|
# StimulusCodeQueue = queue.Queue()
|
||||||
|
|
||||||
# initialize queue
|
# RunApplication = True
|
||||||
phaseInSequenceQueue = Queue.Queue()
|
|
||||||
StimulusCodeQueue = Queue.Queue()
|
|
||||||
|
|
||||||
RunApplication = True
|
# #start BCI2000ReceiverThread
|
||||||
|
# BCI2000ReceiverThread1=BCI2000ReceiverThread(1, phaseInSequenceQueue, StimulusCodeQueue)
|
||||||
#start BCI2000ReceiverThread
|
# BCI2000ReceiverThread1.start()
|
||||||
BCI2000ReceiverThread1=BCI2000ReceiverThread(1, phaseInSequenceQueue, StimulusCodeQueue)
|
|
||||||
BCI2000ReceiverThread1.start()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
14
app.py
14
app.py
@ -11,13 +11,15 @@ import tkinter.filedialog
|
|||||||
import subprocess
|
import subprocess
|
||||||
import configparser
|
import configparser
|
||||||
import os
|
import os
|
||||||
|
# import queue
|
||||||
|
|
||||||
# own code:
|
# own code:
|
||||||
# from questionnaire import quest
|
# from questionnaire import quest
|
||||||
|
# from wheelchairAdapter import BCI2000ReceiverThread
|
||||||
|
|
||||||
# TODO Eventuell updatefunktion über git pull mit einbauen!
|
# TODO Eventuell updatefunktion über git pull mit einbauen!
|
||||||
|
|
||||||
__version__ = 0.3
|
__version__ = 0.4
|
||||||
|
|
||||||
class PythonBCIgui:
|
class PythonBCIgui:
|
||||||
|
|
||||||
@ -112,6 +114,7 @@ class PythonBCIgui:
|
|||||||
# 5. WHEELCHAIR SIMULATOR ###########################
|
# 5. WHEELCHAIR SIMULATOR ###########################
|
||||||
def btn_tacSimul(self):
|
def btn_tacSimul(self):
|
||||||
print('Starte Wheelchair Simulator')
|
print('Starte Wheelchair Simulator')
|
||||||
|
# BCI2000ReceiverThread1.start()
|
||||||
subprocess.Popen(config['PATH']['wheelchairsimulator'] + r'\Wheels_Occlusion_AutoLog.exe')
|
subprocess.Popen(config['PATH']['wheelchairsimulator'] + r'\Wheels_Occlusion_AutoLog.exe')
|
||||||
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileDrive.prm'])
|
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileDrive.prm'])
|
||||||
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\gUSBampSource.exe', '127.0.0.1'])
|
subprocess.Popen([config['PATH']['bci2000'] + r'\prog\gUSBampSource.exe', '127.0.0.1'])
|
||||||
@ -258,6 +261,15 @@ pathMenu.add_command(label="Wheelchair Simulator", command=setPathWheelchair)
|
|||||||
|
|
||||||
root.config(menu = leistenMenu)
|
root.config(menu = leistenMenu)
|
||||||
|
|
||||||
|
# # initialize queue for wheelchairadapter
|
||||||
|
# phaseInSequenceQueue = queue.Queue()
|
||||||
|
# StimulusCodeQueue = queue.Queue()
|
||||||
|
|
||||||
|
# RunApplication = True
|
||||||
|
|
||||||
|
# # initialize BCI2000ReceiverThread for wheelchairadapter
|
||||||
|
# BCI2000ReceiverThread1 = BCI2000ReceiverThread(1, phaseInSequenceQueue, StimulusCodeQueue)
|
||||||
|
|
||||||
app = PythonBCIgui(root)
|
app = PythonBCIgui(root)
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
#root.destroy() # optional;
|
#root.destroy() # optional;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user