import UIModellVisuell as modelVisuell import UIModellTaktil as modelsTaktil import UIViewTKinter as viewTkinter class Controller(): def __init__(self): self.view = viewTkinter.View(self) self.modi = "visuellesBCI" self.commands = { "copySpelling": self.commandoCopySpelling, "stop": self.commandStop, "freeSpelling": self.commandFreeSpelling, "test": self.test, "wechsel": self.wechsel, "speicherort": self.speicherort } self.nexts = { "filterXdawn" : self.filterXdawn, "filterClassic": self.filterClassic } 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 speicherort(self): pass def test(self): if(self.modi == "taktilesBCI"): self.model = modelsTaktil.Modell(self) elif(self.modi == "visuellesBCI"): self.model = modelVisuell.Modell(self) self.model.setFunktion(self.model.trainXDawn) self.model.start() #wird durch Btn gestartet -> startet copyspelling als thread def commandoCopySpelling(self): if(self.modi == "taktilesBCI"): self.model = modelsTaktil.Modell(self) elif(self.modi == "visuellesBCI"): self.model = modelVisuell.Modell(self) 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 = modelsTaktil.Modell(self) elif(self.modi == "visuellesBCI"): self.model = modelVisuell.Modell(self) 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 = modelsTaktil.Modell(self) elif(self.modi == "visuellesBCI"): self.model = modelVisuell.Modell(self) self.model.setFunktion(self.model.trainClassifier) self.model.start() def commandFreeSpelling(self): print("freespelling") if(self.modi == "taktilesBCI"): self.model = modelsTaktil.Modell(self) elif(self.modi == "visuellesBCI"): self.model = modelVisuell.Modell(self) self.model.setFunktion(self.model.freeSpelling) self.model.start() def commandStop(self): if(self.model is not None): self.setInfos("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 setInfos(self,text): self.view.setInfoText(text) def setTitle(self,text): self.view.setTitleText(text) def changeScreen(self, pageName): self.view.changeFrame(pageName=pageName) def getModi(self): return self.modi