123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- from subprocess import *
- import os
-
- class Modell():
- PATH_OV = 'meta/dist/designer-Release/openvibe-designer.sh'
- PATH_FILES = 'Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/'
-
- def __init__(self):
- pass
-
-
- def startCopySpelling(self):
- print("start copySpelling")
- path = self.PATH_FILES + 'p300-visual-1-acquisition.xml'
- process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
- stdout=PIPE,
- universal_newlines=True)
- while True:
- output = process.stdout.readline()
- print(output.strip())
- x = output.find("schlagwort?")
- if(x != -1):
- print("Training finished")
- process.terminate()
- break
-
- self.killProzess()
-
- def trainXDawn(self):
- print("start training Xdawn")
- 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)
- while True:
- output = process.stdout.readline()
- print(output.strip())
- x = output.find("Training finished and saved")
- if(x != -1):
- print("Training finished")
- process.terminate()
- break
-
- self.killProzess()
-
-
- def trainClassifier(self):
- print("start training Classifier")
- 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)
- while True:
- output = process.stdout.readline()
- print(output.strip())
- x = output.find("schlagwort?")
- if(x != -1):
- print("Training finished")
- process.terminate()
- break
-
- self.killProzess()
-
- def freeSpelling(self):
- print("start freeSpelling")
- path = self.PATH_FILES + 'p300-visual-4-online.xml'
- process = Popen(['bash', self.PATH_OV, '--play', path, '--no-gui'],
- stdout=PIPE,
- universal_newlines=True)
- while True:
- output = process.stdout.readline()
- print(output.strip())
- x = output.find("schlagwort?")
- if(x != -1):
- print("End Spelling")
- process.terminate()
- break
-
- self.killProzess()
-
- 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")
|