diff --git a/UIController.py b/UIController.py index f76f2e4..0c1eab6 100644 --- a/UIController.py +++ b/UIController.py @@ -28,11 +28,11 @@ class Controller(): self.getSharedLibrary() - self.view = viewTkinter.View(self, self.dll.getDefaultPath()) + self.view = viewTkinter.View(self, self.dll.getDefaultPath_visuell()) self.modi = "visuellesBCI" - self.pathOVFile = self.dll.getPathOVFile() - self.pathSpatialCfg = self.dll.getSpatialCFGFile() - self.pathClassifierCfg = self.dll.getClassifierCFGFile() + self.pathOVFile = self.dll.getPathOVFile_visuell() + self.pathSpatialCfg = self.dll.getSpatialCFGFile_visuell() + self.pathClassifierCfg = self.dll.getClassifierCFGFile_visuell() self.infotext = "" self.commands = { @@ -90,23 +90,41 @@ class Controller(): self.dll.getCommandCopyspellingVisuell.argtypes = [] self.dll.getCommandCopyspellingVisuell.restype = ctypes.c_char_p - self.dll.getCommandXDawn.argtypes = [] - self.dll.getCommandXDawn.restype = ctypes.c_char_p + self.dll.getCommandXDawn_taktil.argtypes = [] + self.dll.getCommandXDawn_taktil.restype = ctypes.c_char_p - self.dll.getCommandClassifier.argtypes = [] - self.dll.getCommandClassifier.restype = ctypes.c_char_p + self.dll.getCommandXDawn_visuell.argtypes = [] + self.dll.getCommandXDawn_visuell.restype = ctypes.c_char_p - self.dll.getDefaultPath.argtypes = [] - self.dll.getDefaultPath.restype = ctypes.c_char_p + self.dll.getCommandClassifier_visuell.argtypes = [] + self.dll.getCommandClassifier_visuell.restype = ctypes.c_char_p - self.dll.getPathOVFile.argtypes = [] - self.dll.getPathOVFile.restype = ctypes.c_char_p + self.dll.getCommandClassifier_taktil.argtypes = [] + self.dll.getCommandClassifier_taktil.restype = ctypes.c_char_p - self.dll.getSpatialCFGFile.argtypes = [] - self.dll.getSpatialCFGFile.restype = ctypes.c_char_p + self.dll.getDefaultPath_visuell.argtypes = [] + self.dll.getDefaultPath_visuell.restype = ctypes.c_char_p - self.dll.getClassifierCFGFile.argtypes = [] - self.dll.getClassifierCFGFile.restype = ctypes.c_char_p + self.dll.getDefaultPath_taktil.argtypes = [] + self.dll.getDefaultPath_taktil.restype = ctypes.c_char_p + + self.dll.getPathOVFile_visuell.argtypes = [] + self.dll.getPathOVFile_visuell.restype = ctypes.c_char_p + + self.dll.getSpatialCFGFile_visuell.argtypes = [] + self.dll.getSpatialCFGFile_visuell.restype = ctypes.c_char_p + + self.dll.getClassifierCFGFile_visuell.argtypes = [] + self.dll.getClassifierCFGFile_visuell.restype = ctypes.c_char_p + + self.dll.getPathOVFile_taktil.argtypes = [] + self.dll.getPathOVFile_taktil.restype = ctypes.c_char_p + + self.dll.getSpatialCFGFile_taktil.argtypes = [] + self.dll.getSpatialCFGFile_taktil.restype = ctypes.c_char_p + + self.dll.getClassifierCFGFile_taktil.argtypes = [] + self.dll.getClassifierCFGFile_taktil.restype = ctypes.c_char_p self.dll.getCommandStartAquisitionServer.argtypes = [] self.dll.getCommandStartAquisitionServer.restype = ctypes.c_char_p @@ -149,10 +167,18 @@ class Controller(): if(self.modi == "taktilesBCI"): self.view.setChangeBtnText("Wechsel zu taktilen BCI") self.view.setTitleText("visuelles BCI") + self.view.setDefaultPath(self.dll.getDefaultPath_visuell()) + self.pathOVFile = self.dll.getPathOVFile_visuell() + self.pathSpatialCfg = self.dll.getSpatialCFGFile_visuell() + self.pathClassifierCfg = self.dll.getClassifierCFGFile_visuell() self.modi = "visuellesBCI" elif(self.modi == "visuellesBCI"): self.setTitle("taktiles BCI") self.view.setChangeBtnText("Wechsel zu visuellen BCI") + self.view.setDefaultPath(self.dll.getDefaultPath_taktil()) + self.pathOVFile = self.dll.getPathOVFile_taktil() + self.pathSpatialCfg = self.dll.getSpatialCFGFile_taktil() + self.pathClassifierCfg = self.dll.getClassifierCFGFile_taktil() self.modi = "taktilesBCI" def speichern(self): @@ -214,7 +240,9 @@ class Controller(): Funktion CopySpelling aus. ''' self.file = path - if self.file is "-1": + print(path) + if self.file == "-1": + print("kein gueltiger Pfad") self.view.changeFrame("StartPage") else: if(self.modi == "taktilesBCI"): diff --git a/UIController.pyc b/UIController.pyc index 61b96f7..58c3cd6 100644 Binary files a/UIController.pyc and b/UIController.pyc differ diff --git a/UIModellTaktil.py b/UIModellTaktil.py index ce30761..1b2e8da 100644 --- a/UIModellTaktil.py +++ b/UIModellTaktil.py @@ -91,7 +91,7 @@ class ModellTaktil(Modell): ''' print("start training Xdawn") self.controller.addInfoText('Starten des xDawn-Trainings -- ') - command = self.dll.getCommandXDawn().split(" ") + command = self.dll.getCommandXDawn_taktil().split(" ") process = Popen(command, stdout=PIPE, universal_newlines=True) self.openVibeAktiv = True @@ -130,7 +130,7 @@ class ModellTaktil(Modell): print("start training Classifier") self.controller.addInfoText("Starten des Classifier-Trainings -- ") - command = self.dll.getCommandClassifier().split(" ") + command = self.dll.getCommandClassifier_taktil().split(" ") process = Popen(command, stdout=PIPE, universal_newlines=True) self.openVibeAktiv = True diff --git a/UIModellTaktil.pyc b/UIModellTaktil.pyc index be5b006..b3ce8da 100644 Binary files a/UIModellTaktil.pyc and b/UIModellTaktil.pyc differ diff --git a/UIModellVisuell.py b/UIModellVisuell.py index 299ff0d..3111b0f 100644 --- a/UIModellVisuell.py +++ b/UIModellVisuell.py @@ -94,7 +94,7 @@ class ModellVisuell(Modell): ''' print("start training Xdawn") self.controller.addInfoText('Starten des XDawn/Trainings -- ') - command = self.dll.getCommandXDawn().split(" ") + command = self.dll.getCommandXDawn_visuell().split(" ") process = Popen(command, stdout=PIPE, universal_newlines=True) self.openVibeAktiv = True @@ -129,7 +129,7 @@ class ModellVisuell(Modell): ''' print("start training Classifier") self.controller.addInfoText("Starten Classifier-Trainings -- ") - command = self.dll.getCommandClassifier().split(" ") + command = self.dll.getCommandClassifier_visuell().split(" ") process = Popen(command, stdout=PIPE, universal_newlines=True) self.openVibeAktiv = True diff --git a/UIModellVisuell.pyc b/UIModellVisuell.pyc index e91a99f..d34f42c 100644 Binary files a/UIModellVisuell.pyc and b/UIModellVisuell.pyc differ diff --git a/UIViewTKinter.py b/UIViewTKinter.py index 29cfc5b..7bb4337 100644 --- a/UIViewTKinter.py +++ b/UIViewTKinter.py @@ -82,6 +82,10 @@ class View(Tk): self.controller.commandStop() self.controller.stopAcquisitionServer() print("destroy") + try: + self.dialog.destroy() + except: + pass self.destroy() @@ -150,6 +154,9 @@ class View(Tk): def setChangeBtnText(self,text): self.changeBtn["text"] = text + def setDefaultPath(self, path): + self.PATH_DEFAULT = path + def openfiledialog(self): path = self.PATH_DEFAULT #file = fd.askopenfilename(initialdir=path) @@ -158,6 +165,12 @@ class View(Tk): def savefiledialog(self): self.dialog = Tk() + + self.dialog.title("Visuelles Buchstabieren") + h = 100 + w = 400 + self.dialog.geometry('{}x{}'.format(w,h)) + self.dialog.geometry("+{}+{}".format(100,200)) l = Label(self.dialog, text="Bitte geben Sie einen Speichernamen ein:") eingabefeld = Entry(self.dialog) okBtn = Button(self.dialog, text="OK", command=lambda:self.okBtn(eingabefeld.get())) diff --git a/UIViewTKinter.pyc b/UIViewTKinter.pyc index 28a60d0..b633b7f 100644 Binary files a/UIViewTKinter.pyc and b/UIViewTKinter.pyc differ diff --git a/dll.cpp b/dll.cpp index 651cbe4..77c5974 100644 --- a/dll.cpp +++ b/dll.cpp @@ -4,21 +4,38 @@ using namespace std; extern "C"{ +//allgemein +//------------------------------------------------------------------------------------------------------------------------------------- string PATH_OV = "meta/dist/Release/openvibe-designer.sh"; string PATH_AquisitionServer = "meta/dist/Release/openvibe-acquisition-server.sh"; - string PATH_FILES = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/"; - string pathOVFile = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/signals/p300-xdawn-train2.ov"; - string pathClassifierCFG = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/cfg/p300-classifier.cfg"; - string pathSpatialCFG = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/cfg/p300-spatial-filter.cfg"; - string PATH_DEFAULT = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/datasets"; - string fileCopySpellingTaktil = "p300-visual-1-acquisition.xml"; - string fileCopySpellingVisuell = "p300-visual-1-acquisition.xml"; string fileXDawnTraining = "p300-visual-2-train-xDAWN.xml"; string fileClassifierTraining = "p300-visual-3-train-classifier.xml"; - string filefreeSpellingTaktil = "p300-visual-4-online.xml"; + +//visuell +//------------------------------------------------------------------------------------------------------------------------------------- + string PATH_FILES_Visual = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/"; + string pathOVFile_visuell = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/signals/p300-xdawn-train2.ov"; + string pathClassifierCFG_visuell = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/cfg/p300-classifier.cfg"; + string pathSpatialCFG_visuell = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/cfg/p300-spatial-filter.cfg"; + string PATH_DEFAULT_visuell = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/datasets"; + + string fileCopySpellingVisuell = "p300-visual-1-acquisition.xml"; string filefreeSpellingVisuell = "p300-visual-4-online.xml"; +//taktil +//------------------------------------------------------------------------------------------------------------------------------------ + string fileCopySpellingTaktil = "p300-visual-1-acquisition.xml"; + string filefreeSpellingTaktil = "p300-visual-4-online.xml"; + + string PATH_FILES_taktil = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/"; + string pathOVFile_taktil = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/signals/p300-xdawn-train2.ov"; + string pathClassifierCFG_taktil = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/cfg/p300-classifier.cfg"; + string pathSpatialCFG_taktil = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/cfg/p300-spatial-filter.cfg"; + string PATH_DEFAULT_taktil = "Projekte/OpenViBE_visual_BCI-master/openvibe_visual_bci/datasets"; + +//Befehle +//------------------------------------------------------------------------------------------------------------------------------------- string command = "bash"; string nogui = "--no-gui"; string play = "--play"; @@ -36,7 +53,7 @@ extern "C"{ char* getCommandFreespellingTaktil() { string s = ""; - s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES).append(filefreeSpellingTaktil).append(" ").append(nogui); + s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES_taktil).append(filefreeSpellingTaktil).append(" ").append(nogui); char char_array[s.length()+1]; strcpy(char_array, s.c_str()); char* s_convert = char_array; @@ -46,7 +63,7 @@ extern "C"{ char* getCommandFreespellingVisuell() { string s = ""; - s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES).append(filefreeSpellingVisuell).append(" ").append(nogui); + s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES_Visual).append(filefreeSpellingVisuell).append(" ").append(nogui); char char_array[s.length()+1]; strcpy(char_array, s.c_str()); char* s_convert = char_array; @@ -56,7 +73,7 @@ extern "C"{ char* getCommandCopyspellingTaktil() { string s = ""; - s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES).append(fileCopySpellingTaktil).append(" ").append(nogui); + s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES_taktil).append(fileCopySpellingTaktil).append(" ").append(nogui); char char_array[s.length()+1]; strcpy(char_array, s.c_str()); char* s_convert = char_array; @@ -66,27 +83,47 @@ extern "C"{ char* getCommandCopyspellingVisuell() { string s = ""; - s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES).append(fileCopySpellingVisuell).append(" ").append(nogui); + s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES_Visual).append(fileCopySpellingVisuell).append(" ").append(nogui); char char_array[s.length()+1]; strcpy(char_array, s.c_str()); char* s_convert = char_array; return s_convert; } - char* getCommandXDawn() + char* getCommandXDawn_taktil() { string s = ""; - s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES).append(fileXDawnTraining).append(" ").append(nogui); + s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES_taktil).append(fileXDawnTraining).append(" ").append(nogui); char char_array[s.length()+1]; strcpy(char_array, s.c_str()); char* s_convert = char_array; return s_convert; } - char* getCommandClassifier() + char* getCommandXDawn_visuell() { string s = ""; - s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES).append(fileClassifierTraining).append(" ").append(nogui); + s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES_Visual).append(fileXDawnTraining).append(" ").append(nogui); + char char_array[s.length()+1]; + strcpy(char_array, s.c_str()); + char* s_convert = char_array; + return s_convert; + } + + char* getCommandClassifier_visuell() + { + string s = ""; + s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES_Visual).append(fileClassifierTraining).append(" ").append(nogui); + char char_array[s.length()+1]; + strcpy(char_array, s.c_str()); + char* s_convert = char_array; + return s_convert; + } + + char* getCommandClassifier_taktil() + { + string s = ""; + s = s.append(command).append(" ").append(PATH_OV).append(" ").append( play).append(" ").append(PATH_FILES_taktil).append(fileClassifierTraining).append(" ").append(nogui); char char_array[s.length()+1]; strcpy(char_array, s.c_str()); char* s_convert = char_array; @@ -103,36 +140,72 @@ extern "C"{ return s_convert; } - char* getDefaultPath() + char* getDefaultPath_visuell() { - string s = PATH_DEFAULT; + string s = PATH_DEFAULT_visuell; char char_array[s.length()+1]; strcpy(char_array, s.c_str()); char* s_convert = char_array; return s_convert; } - char* getPathOVFile() + char* getDefaultPath_taktil() { - string s = pathOVFile; + string s = PATH_DEFAULT_taktil; char char_array[s.length()+1]; strcpy(char_array, s.c_str()); char* s_convert = char_array; return s_convert; } - char* getSpatialCFGFile() + char* getPathOVFile_visuell() { - string s = pathSpatialCFG; + string s = pathOVFile_visuell; char char_array[s.length()+1]; strcpy(char_array, s.c_str()); char* s_convert = char_array; return s_convert; } - char* getClassifierCFGFile() + char* getSpatialCFGFile_visuell() { - string s = pathClassifierCFG; + string s = pathSpatialCFG_visuell; + char char_array[s.length()+1]; + strcpy(char_array, s.c_str()); + char* s_convert = char_array; + return s_convert; + } + + char* getClassifierCFGFile_visuell() + { + string s = pathClassifierCFG_visuell; + char char_array[s.length()+1]; + strcpy(char_array, s.c_str()); + char* s_convert = char_array; + return s_convert; + } + + char* getPathOVFile_taktil() + { + string s = pathOVFile_taktil; + char char_array[s.length()+1]; + strcpy(char_array, s.c_str()); + char* s_convert = char_array; + return s_convert; + } + + char* getSpatialCFGFile_taktil() + { + string s = pathSpatialCFG_taktil; + char char_array[s.length()+1]; + strcpy(char_array, s.c_str()); + char* s_convert = char_array; + return s_convert; + } + + char* getClassifierCFGFile_taktil() + { + string s = pathClassifierCFG_taktil; char char_array[s.length()+1]; strcpy(char_array, s.c_str()); char* s_convert = char_array; diff --git a/dll.so b/dll.so index 8a57b16..d9b04e7 100755 Binary files a/dll.so and b/dll.so differ diff --git a/gui b/gui index 5d5d671..07b6364 100755 Binary files a/gui and b/gui differ