|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- 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
-
-
-
|