Browse Source

Dateien hochladen nach „“

master
Nicole Weber 2 years ago
parent
commit
81d3df4fd4
3 changed files with 36 additions and 20 deletions
  1. 3
    3
      UIModell.py
  2. 25
    11
      UIModellTaktil.py
  3. 8
    6
      UIViewTKinter.py

+ 3
- 3
UIModell.py View File

z = z.strip() z = z.strip()
items = z.split(' ') items = z.split(' ')
pid = items[0] pid = items[0]
#kill -TERM veranlasst dem Prozess sich selbst zu beenden (nicht erzwungen)
Popen(["kill", "-TERM", str(pid)], stdout=PIPE).communicate()
if pid is not 0:
#kill -TERM veranlasst dem Prozess sich selbst zu beenden (nicht erzwungen)
Popen(["kill", "-TERM", str(pid)], stdout=PIPE).communicate()




print("killed openvibe-acquisitionserver") print("killed openvibe-acquisitionserver")

+ 25
- 11
UIModellTaktil.py View File

from threading import Thread from threading import Thread
import time import time
from UIModell import * from UIModell import *
import re


class ModellTaktil(Modell): class ModellTaktil(Modell):


while True: while True:
output = process.stdout.readline() output = process.stdout.readline()
print(output.strip()) print(output.strip())
x = output.find("schlagwort?")
x = output.find("Application terminated")
y = output.find("Error") y = output.find("Error")
if(x != -1): if(x != -1):
print("Training finished") print("Training finished")
break break


self.controller.stop()
#self.controller.stop()
def trainXDawn(self): def trainXDawn(self):
'''-------------------------------------------------------------------------------------------------- '''--------------------------------------------------------------------------------------------------
Holt aus der shared Library die Befehle und startet das XDawnTraining. Reagiert auf Error oder Holt aus der shared Library die Befehle und startet das XDawnTraining. Reagiert auf Error oder
die Ausgabe das das Training beendet wurde. Bei Beenden startet es das ClassifierTraining, bei Error wird der Vorgang gestoppt. die Ausgabe das das Training beendet wurde. Bei Beenden startet es das ClassifierTraining, bei Error wird der Vorgang gestoppt.
''' '''
print("start training Xdawn")
print("Start training Xdawn")
self.controller.addInfoText('Starten des xDawn-Trainings -- ') self.controller.addInfoText('Starten des xDawn-Trainings -- ')
command = self.dll.getCommandXDawn_taktil().split(" ")
command = self.dll.getCommandXDawn_taktil() #.split(" ")
print("Command: " + command)
command = command.split(" ")
process = Popen(command, stdout=PIPE, universal_newlines=True) process = Popen(command, stdout=PIPE, universal_newlines=True)
self.openVibeAktiv = True self.openVibeAktiv = True
print("stop") print("stop")
break break
self.controller.stop()
#self.controller.stop()


#self.controller.filterClassic() #self.controller.filterClassic()


process = Popen(command, stdout=PIPE, universal_newlines=True) process = Popen(command, stdout=PIPE, universal_newlines=True)


self.openVibeAktiv = True self.openVibeAktiv = True
counter = 0
counter = 0
acc = 0
while True: while True:
output = process.stdout.readline() output = process.stdout.readline()
print(output.strip()) print(output.strip())
x = output.find("aka Classifier trainer") x = output.find("aka Classifier trainer")
accuracy = output.find("Training set accuracy is")
accuracy = output.find("Cross-validation test accuracy is ")
y = output.find("Error") y = output.find("Error")
if(x != -1): if(x != -1):
counter = counter +1 counter = counter +1
#counter = 18 #counter = 18
if(counter >= 17): if(counter >= 17):
print("Training finished") print("Training finished")
self.controller.addInfoText('Training beendet\n')
self.controller.addInfoText('Training beendet (' + acc + ')\n')
process.terminate() process.terminate()
self.controller.stop("save") self.controller.stop("save")
break break
self.controller.addInfoText("Fehler beim Classifier Training aufgetaucht\n") self.controller.addInfoText("Fehler beim Classifier Training aufgetaucht\n")
process.terminate() process.terminate()
break break
elif(accuracy != -1):
print("ACCURACY" + output)
if(accuracy != -1):
#print("Output:")
#print(output)
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
test = output.encode("windows-1252").decode("utf-8")
i = len("Cross-validation test")
#print(output[accuracy:accuracy+i+12])
#print(test[accuracy+i+12:accuracy+i+40].strip())
acc_s = test[accuracy+i:accuracy+i+41].strip()
acc = ansi_escape.sub('', acc_s)
print(acc)

if not self.aktiv: if not self.aktiv:
print("stop") print("stop")
break break
output = process.stdout.readline() output = process.stdout.readline()
print(output.strip()) print(output.strip())
y = output.find("Error") y = output.find("Error")
x = output.find("Schlagwort")
x = output.find("Application terminated")
if(x != -1): if(x != -1):
print("End Spelling") print("End Spelling")
process.terminate() process.terminate()

+ 8
- 6
UIViewTKinter.py View File

try: try:
from Tkinter import * #Fuer Python 2.7 from Tkinter import * #Fuer Python 2.7
import tkFileDialog as fd import tkFileDialog as fd
print("python2.7")
except ImportError: #Fuer Python >3 except ImportError: #Fuer Python >3
from tkinter import * from tkinter import *
from tkinter import filedialog as fd from tkinter import filedialog as fd
print("python >3")


from UIController import * from UIController import *


self.controller = c self.controller = c
self.PATH_DEFAULT = path_default self.PATH_DEFAULT = path_default
self.title("Visuelles Buchstabieren") self.title("Visuelles Buchstabieren")
self.h = 1000
self.w = 2000
self.h = self.winfo_screenheight()
self.w = self.winfo_screenwidth()
self.geometry('{}x{}'.format(self.w,self.h)) self.geometry('{}x{}'.format(self.w,self.h))
self.faktor = [(0.073),(0.727), (0.2)] self.faktor = [(0.073),(0.727), (0.2)]
#self.resizable(height=False, width= False) #self.resizable(height=False, width= False)
Stoppt alle laufenden Threads und schliesst OpenVibe und den Aquisitionserver bevor sich das Fenster Stoppt alle laufenden Threads und schliesst OpenVibe und den Aquisitionserver bevor sich das Fenster
schliesst schliesst
''' '''
print("closing")
self.controller.commandStop()
self.controller.stopAcquisitionServer()
print("destroy")
try: try:
print("closing")
self.controller.commandStop()
self.controller.stopAcquisitionServer()
print("destroy")
self.dialog.destroy() self.dialog.destroy()
except: except:
pass pass

Loading…
Cancel
Save