|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- from UIModellVisuell import *
- from UIModellTaktil import *
- import UIViewTKinter as viewTkinter
- from shutil import copyfile
-
-
-
- class Controller():
-
- def __init__(self, pathOVFile, path_ov, path_files, path_default):
- self.view = viewTkinter.View(self, path_default)
- self.modi = "visuellesBCI"
- self.pathOVFile = pathOVFile
- self.PATH_OV = path_ov
- self.PATH_FILES = path_files
- self.infotext = ""
-
- self.commands = {
- "copySpelling": self.commandoCopySpelling,
- "stop": self.commandStop,
- "freeSpelling": self.commandFreeSpelling,
- "test": self.test,
- "wechsel": self.wechsel,
- "speicherort": self.setDataset
- }
-
- self.nexts = {
- "filterXdawn" : self.filterXdawn,
- "filterClassic": self.filterClassic,
- "save": self.speichern
- }
-
- self.pagesTaktil = {
- "stop": "StartPage",
- "copySpelling": "WorkingPageTaktil",
- "freeSpelling": "WorkingPageTaktil",
- "test": "WorkingPageTaktil"
- }
- self.pagesVisuell = {
- "stop": "StartPage",
- "copySpelling": "WorkingPageVisuell",
- "freeSpelling": "WorkingPageVisuell",
- "test": "WorkingPageVisuell"
- }
-
- self.model = None
- self.view.mainloop()
-
- def actionPerformed(self, action):
- self.changePage(action)
- func = self.commands.get(action)
- if(func is not None):
- func()
- else:
- print("Kommado existiert nicht")
-
- def changePage(self,action):
- if(self.modi == "taktilesBCI"):
- page = self.pagesTaktil.get(action)
- elif(self.modi == "visuellesBCI"):
- page = self.pagesVisuell.get(action)
- if(page is not None):
- self.view.changeFrame(page)
-
- def wechsel(self):
- if(self.modi == "taktilesBCI"):
- self.view.setChangeBtnText("Wechsel zu taktilen BCI")
- self.view.setTitleText("visuelles BCI")
- self.modi = "visuellesBCI"
- elif(self.modi == "visuellesBCI"):
- self.setTitle("taktiles BCI")
- self.view.setChangeBtnText("Wechsel zu visuellen BCI")
- self.modi = "taktilesBCI"
-
- def speichern(self):
- print("saveFile")
- copyfile(self.pathOVFile, self.file)
-
- def setDataset(self):
- file = self.view.openfiledialog()
- copyfile(file, self.pathOVFile)
-
-
- def test(self):
- self.file = self.view.savefiledialog()
- if(self.modi == "taktilesBCI"):
- self.model = ModellTaktil(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
- elif(self.modi == "visuellesBCI"):
- self.model = ModellVisuell(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
- self.model.positionWindow()
- self.model.setFunktion(self.model.trainXDawn)
- self.model.start()
-
- #wird durch Btn gestartet -> startet copyspelling als thread
- def commandoCopySpelling(self):
- self.file = self.view.savefiledialog()
- if(self.modi == "taktilesBCI"):
- self.model = ModellTaktil(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
- elif(self.modi == "visuellesBCI"):
- self.model = ModellVisuell(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
- self.model.setFunktion(self.model.startCopySpelling)
- self.model.start()
-
- #wird durch Copy-Speller Thread copystelling gestartet -> startete filtern als thread
- def filterXdawn(self):
- if(self.modi == "taktilesBCI"):
- self.model = ModellTaktil(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
- elif(self.modi == "visuellesBCI"):
- self.model = ModellVisuell(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
- self.model.setFunktion(self.model.trainXDawn)
- self.model.start()
-
- #wird durch XDawn-Thread copystelling gestartet -> startete filtern als thread
- def filterClassic(self):
- if(self.modi == "taktilesBCI"):
- self.model = ModellTaktil(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
- elif(self.modi == "visuellesBCI"):
- self.model = ModellVisuell(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
- self.model.setFunktion(self.model.trainClassifier)
- self.model.start()
-
- def commandFreeSpelling(self):
- print("freespelling")
- if(self.modi == "taktilesBCI"):
- self.model = ModellTaktil(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
- elif(self.modi == "visuellesBCI"):
- self.model = ModellVisuell(self, path_files= self.PATH_FILES, path_ov= self.PATH_OV)
- self.model.setFunktion(self.model.freeSpelling)
- self.model.start()
-
- def commandStop(self):
- if(self.model is not None):
- self.addInfoText("Action: STOP-Command")
- self.model.stop()
- self.model.join()
- self.model.killProzess()
- self.mode = None
-
-
- def stop(self, next=None):
- print("Stop aus Modell")
- self.model.stop()
- self.model.join()
- self.model.killProzess()
- self.mode = None
- if(next is not None):
- func = self.nexts.get(next)
- func()
-
- def addInfoText(self,text):
- self.infotext = self.infotext + text
- self.view.setInfoText(self.infotext)
-
- def resetInfo(self):
- self.infotext = ""
-
- def setTitle(self,text):
- self.view.setTitleText(text)
-
- def changeScreen(self, pageName):
- self.view.changeFrame(pageName=pageName)
-
- def getModi(self):
- return self.modi
-
- def getWindowSize(self):
- return self.view.getWindowSize()
-
-
-
-
|