|
|
@@ -10,9 +10,11 @@ class Modell(Thread): |
|
|
|
Thread.__init__(self) |
|
|
|
self.controller = c |
|
|
|
self.aktiv= True |
|
|
|
self.openVibeAktiv = False |
|
|
|
self.infoText = '' |
|
|
|
|
|
|
|
def stop(self): |
|
|
|
print("stop") |
|
|
|
print("stop thread") |
|
|
|
self.aktiv = False |
|
|
|
|
|
|
|
def setFunktion(self, func, args=None, kwargs=None): |
|
|
@@ -21,6 +23,7 @@ class Modell(Thread): |
|
|
|
self.kwargs = kwargs or {} |
|
|
|
|
|
|
|
def run(self): |
|
|
|
print("start thread") |
|
|
|
#self.aktiv = True |
|
|
|
t = Thread(target=self.func, args=self.args, kwargs=self.kwargs) |
|
|
|
t.setDaemon(True) |
|
|
@@ -32,98 +35,157 @@ class Modell(Thread): |
|
|
|
|
|
|
|
def startCopySpelling(self): |
|
|
|
print("start copySpelling") |
|
|
|
self.infoText = 'start copyspelling -- ' |
|
|
|
self.controller.setInfos(self.infoText) |
|
|
|
self.controller.setTitle("Copy Spelling") |
|
|
|
path = self.PATH_FILES + 'p300-visual-1-acquisition.xml' |
|
|
|
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'], |
|
|
|
stdout=PIPE, |
|
|
|
universal_newlines=True) |
|
|
|
universal_newlines=True) |
|
|
|
self.openVibeAktiv = True |
|
|
|
while True: |
|
|
|
output = process.stdout.readline() |
|
|
|
print(output.strip()) |
|
|
|
x = output.find("schlagwort?") |
|
|
|
y = output.find("Error") |
|
|
|
if(x != -1): |
|
|
|
print("Training finished") |
|
|
|
process.terminate() |
|
|
|
self.infoText = self.infoText + 'finished Copyspelling\n' |
|
|
|
self.controller.setInfos(self.infoText) |
|
|
|
self.controller.stop("filterXdawn") |
|
|
|
break |
|
|
|
|
|
|
|
self.killProzess() |
|
|
|
self.controller.filterXdawn() |
|
|
|
elif(y != -1 ): |
|
|
|
print("Error occured") |
|
|
|
self.controller.changeScreen("StartPage") |
|
|
|
self.controller.setInfos(self.infoText + "Fehler beim Copyspelling aufgetaucht\n") |
|
|
|
process.terminate() |
|
|
|
self.controller.stop() |
|
|
|
break |
|
|
|
|
|
|
|
self.controller.stop() |
|
|
|
#self.killProzess() |
|
|
|
#self.controller.filterXdawn() |
|
|
|
|
|
|
|
def trainXDawn(self): |
|
|
|
print("start training Xdawn") |
|
|
|
self.controller.setTitle("start training with Xdawn") |
|
|
|
self.controller.setInfos("This may take a while") |
|
|
|
print("test") |
|
|
|
self.infoText = self.infoText + 'start training XDawn -- ' |
|
|
|
self.controller.setInfos(self.infoText) |
|
|
|
path = self.PATH_FILES + 'p300-visual-2-train-xDAWN.xml' |
|
|
|
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'], |
|
|
|
stdout=PIPE, |
|
|
|
universal_newlines=True) |
|
|
|
universal_newlines=True) |
|
|
|
self.openVibeAktiv = True |
|
|
|
while self.aktiv: |
|
|
|
output = process.stdout.readline() |
|
|
|
print(output.strip()) |
|
|
|
x = output.find("Training finished and saved") |
|
|
|
y = output.find("Error") |
|
|
|
if(x != -1): |
|
|
|
print("Training finished") |
|
|
|
process.terminate() |
|
|
|
self.infoText = self.infoText + 'finished Training\n' |
|
|
|
self.controller.setInfos(self.infoText) |
|
|
|
self.controller.stop("filterClassic") |
|
|
|
break |
|
|
|
elif(y != -1 ): |
|
|
|
print("Error occured") |
|
|
|
self.controller.changeScreen("StartPage") |
|
|
|
self.controller.setInfos(self.infoText + "Fehler beim XDawn Training aufgetaucht\n") |
|
|
|
self.controller.stop() |
|
|
|
process.terminate() |
|
|
|
break |
|
|
|
|
|
|
|
self.controller.stop() |
|
|
|
|
|
|
|
self.controller.setInfos("finished Training with xDawn") |
|
|
|
self.killProzess() |
|
|
|
#self.controller.filterClassic() |
|
|
|
|
|
|
|
|
|
|
|
def trainClassifier(self): |
|
|
|
print("start training Classifier") |
|
|
|
self.infoText = self.infoText + "start training with Classifier -- " |
|
|
|
self.controller.setInfos(self.infoText) |
|
|
|
|
|
|
|
path = self.PATH_FILES + 'p300-visual-3-train-classifier.xml' |
|
|
|
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'], |
|
|
|
stdout=PIPE, |
|
|
|
universal_newlines=True) |
|
|
|
universal_newlines=True) |
|
|
|
self.openVibeAktiv = True |
|
|
|
while True: |
|
|
|
output = process.stdout.readline() |
|
|
|
print(output.strip()) |
|
|
|
x = output.find("schlagwort?") |
|
|
|
y = output.find("Error") |
|
|
|
if(x != -1): |
|
|
|
print("Training finished") |
|
|
|
self.infoText = self.infoText + 'finished Training\n' |
|
|
|
self.controller.setInfos(self.infoText) |
|
|
|
process.terminate() |
|
|
|
break |
|
|
|
elif(y != -1 ): |
|
|
|
print("Error occured") |
|
|
|
self.controller.changeScreen("StartPage") |
|
|
|
self.controller.setInfos(self.infoText + "Fehler beim Classifier Training aufgetaucht\n") |
|
|
|
process.terminate() |
|
|
|
break |
|
|
|
|
|
|
|
self.killProzess() |
|
|
|
self.controller.changeScreen("StartPage") |
|
|
|
self.controller.stop() |
|
|
|
|
|
|
|
def freeSpelling(self): |
|
|
|
#bei error auch abrechen? |
|
|
|
print("start freeSpelling") |
|
|
|
self.infoText = 'start free spelling -- ' |
|
|
|
self.controller.setInfos(self.infoText) |
|
|
|
path = self.PATH_FILES + 'p300-visual-4-online.xml' |
|
|
|
process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'], |
|
|
|
stdout=PIPE, |
|
|
|
universal_newlines=True) |
|
|
|
universal_newlines=True) |
|
|
|
self.openVibeAktiv = True |
|
|
|
while True: |
|
|
|
output = process.stdout.readline() |
|
|
|
print(output.strip()) |
|
|
|
x = output.find("schlagwort?") |
|
|
|
y = output.find("Error") |
|
|
|
x = output.find("Schlagwort") |
|
|
|
if(x != -1): |
|
|
|
print("End Spelling") |
|
|
|
process.terminate() |
|
|
|
self.infoText = self.infoText + 'finished freespelling\n' |
|
|
|
self.controller.setInfos(self.infoText) |
|
|
|
self.controller.changeScreen("StartPage") |
|
|
|
self.controller.stop() |
|
|
|
break |
|
|
|
elif(y != -1 ): |
|
|
|
print("Error occured") |
|
|
|
self.controller.changeScreen("StartPage") |
|
|
|
self.controller.setInfos(self.infoText + "Fehler beim Freespelling aufgetaucht\n") |
|
|
|
process.terminate() |
|
|
|
self.controller.stop() |
|
|
|
break |
|
|
|
|
|
|
|
self.killProzess() |
|
|
|
self.controller.changeScreen("StartPage") |
|
|
|
self.controller.stop() |
|
|
|
|
|
|
|
def killProzess(self): |
|
|
|
print('start killing') |
|
|
|
pidOV = 0 |
|
|
|
pidP = 0 |
|
|
|
items = [] |
|
|
|
|
|
|
|
prozesse = Popen(["ps", "-e"], stdout=PIPE).communicate()[0].strip() |
|
|
|
zeilen = prozesse.split('\n') |
|
|
|
for z in zeilen: |
|
|
|
if(z.find("openvibe-design") != -1): |
|
|
|
z = z.strip() |
|
|
|
items = z.split(' ') |
|
|
|
pidOV = items[0] |
|
|
|
|
|
|
|
#kill -TERM veranlasst dem Prozess sich selbst zu beenden (nicht erzwungen) |
|
|
|
Popen(["kill", "-TERM", pidOV], stdout=PIPE).communicate() |
|
|
|
|
|
|
|
|
|
|
|
print("killed openvibe-designer") |
|
|
|
if(self.openVibeAktiv): |
|
|
|
self.openVibeAktiv = False |
|
|
|
print('start killing') |
|
|
|
pidOV = 0 |
|
|
|
items = [] |
|
|
|
|
|
|
|
prozesse = Popen(["ps", "-e"], stdout=PIPE).communicate()[0].strip() |
|
|
|
zeilen = prozesse.split('\n') |
|
|
|
for z in zeilen: |
|
|
|
if(z.find("openvibe-design") != -1): |
|
|
|
z = z.strip() |
|
|
|
items = z.split(' ') |
|
|
|
pidOV = items[0] |
|
|
|
|
|
|
|
#kill -TERM veranlasst dem Prozess sich selbst zu beenden (nicht erzwungen) |
|
|
|
Popen(["kill", "-TERM", str(pidOV)], stdout=PIPE).communicate() |
|
|
|
|
|
|
|
|
|
|
|
print("killed openvibe-designer") |
|
|
|
|
|
|
|
|
|
|
|
|