You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UIController.py 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import UIModellVisuell as modelVisuell
  2. import UIModellTaktil as modelsTaktil
  3. import UIViewTKinter as viewTkinter
  4. class Controller():
  5. def __init__(self):
  6. self.view = viewTkinter.View(self)
  7. self.modi = "visuellesBCI"
  8. self.commands = {
  9. "copySpelling": self.commandoCopySpelling,
  10. "stop": self.commandStop,
  11. "freeSpelling": self.commandFreeSpelling,
  12. "test": self.test,
  13. "wechsel": self.wechsel,
  14. "speicherort": self.speicherort
  15. }
  16. self.nexts = {
  17. "filterXdawn" : self.filterXdawn,
  18. "filterClassic": self.filterClassic
  19. }
  20. self.pagesTaktil = {
  21. "stop": "StartPage",
  22. "copySpelling": "WorkingPageTaktil",
  23. "freeSpelling": "WorkingPageTaktil",
  24. "test": "WorkingPageTaktil"
  25. }
  26. self.pagesVisuell = {
  27. "stop": "StartPage",
  28. "copySpelling": "WorkingPageVisuell",
  29. "freeSpelling": "WorkingPageVisuell",
  30. "test": "WorkingPageVisuell"
  31. }
  32. self.model = None
  33. self.view.mainloop()
  34. def actionPerformed(self, action):
  35. self.changePage(action)
  36. func = self.commands.get(action)
  37. if(func is not None):
  38. func()
  39. else:
  40. print("Kommado existiert nicht")
  41. def changePage(self,action):
  42. if(self.modi == "taktilesBCI"):
  43. page = self.pagesTaktil.get(action)
  44. elif(self.modi == "visuellesBCI"):
  45. page = self.pagesVisuell.get(action)
  46. if(page is not None):
  47. self.view.changeFrame(page)
  48. def wechsel(self):
  49. if(self.modi == "taktilesBCI"):
  50. self.view.setChangeBtnText("Wechsel zu taktilen BCI")
  51. self.view.setTitleText("visuelles BCI")
  52. self.modi = "visuellesBCI"
  53. elif(self.modi == "visuellesBCI"):
  54. self.setTitle("taktiles BCI")
  55. self.view.setChangeBtnText("Wechsel zu visuellen BCI")
  56. self.modi = "taktilesBCI"
  57. def speicherort(self):
  58. pass
  59. def test(self):
  60. if(self.modi == "taktilesBCI"):
  61. self.model = modelsTaktil.Modell(self)
  62. elif(self.modi == "visuellesBCI"):
  63. self.model = modelVisuell.Modell(self)
  64. self.model.setFunktion(self.model.trainXDawn)
  65. self.model.start()
  66. #wird durch Btn gestartet -> startet copyspelling als thread
  67. def commandoCopySpelling(self):
  68. if(self.modi == "taktilesBCI"):
  69. self.model = modelsTaktil.Modell(self)
  70. elif(self.modi == "visuellesBCI"):
  71. self.model = modelVisuell.Modell(self)
  72. self.model.setFunktion(self.model.startCopySpelling)
  73. self.model.start()
  74. #wird durch Copy-Speller Thread copystelling gestartet -> startete filtern als thread
  75. def filterXdawn(self):
  76. if(self.modi == "taktilesBCI"):
  77. self.model = modelsTaktil.Modell(self)
  78. elif(self.modi == "visuellesBCI"):
  79. self.model = modelVisuell.Modell(self)
  80. self.model.setFunktion(self.model.trainXDawn)
  81. self.model.start()
  82. #wird durch XDawn-Thread copystelling gestartet -> startete filtern als thread
  83. def filterClassic(self):
  84. if(self.modi == "taktilesBCI"):
  85. self.model = modelsTaktil.Modell(self)
  86. elif(self.modi == "visuellesBCI"):
  87. self.model = modelVisuell.Modell(self)
  88. self.model.setFunktion(self.model.trainClassifier)
  89. self.model.start()
  90. def commandFreeSpelling(self):
  91. print("freespelling")
  92. if(self.modi == "taktilesBCI"):
  93. self.model = modelsTaktil.Modell(self)
  94. elif(self.modi == "visuellesBCI"):
  95. self.model = modelVisuell.Modell(self)
  96. self.model.setFunktion(self.model.freeSpelling)
  97. self.model.start()
  98. def commandStop(self):
  99. if(self.model is not None):
  100. self.setInfos("Action: STOP-Command")
  101. self.model.stop()
  102. self.model.join()
  103. self.model.killProzess()
  104. self.mode = None
  105. def stop(self, next=None):
  106. print("Stop aus Modell")
  107. self.model.stop()
  108. self.model.join()
  109. self.model.killProzess()
  110. self.mode = None
  111. if(next is not None):
  112. func = self.nexts.get(next)
  113. func()
  114. def setInfos(self,text):
  115. self.view.setInfoText(text)
  116. def setTitle(self,text):
  117. self.view.setTitleText(text)
  118. def changeScreen(self, pageName):
  119. self.view.changeFrame(pageName=pageName)
  120. def getModi(self):
  121. return self.modi