Dateien hochladen nach „“

This commit is contained in:
Nicole Weber 2022-06-13 11:57:59 +00:00
parent 91a01ce030
commit 81d3df4fd4
3 changed files with 36 additions and 20 deletions

View File

@ -91,9 +91,9 @@ class Modell(Thread):
z = z.strip() z = z.strip()
items = z.split(' ') items = z.split(' ')
pid = items[0] pid = items[0]
if pid is not 0:
#kill -TERM veranlasst dem Prozess sich selbst zu beenden (nicht erzwungen) #kill -TERM veranlasst dem Prozess sich selbst zu beenden (nicht erzwungen)
Popen(["kill", "-TERM", str(pid)], stdout=PIPE).communicate() Popen(["kill", "-TERM", str(pid)], stdout=PIPE).communicate()
print("killed openvibe-acquisitionserver") print("killed openvibe-acquisitionserver")

View File

@ -7,6 +7,7 @@ from subprocess import *
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):
@ -62,7 +63,7 @@ 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")
@ -82,16 +83,18 @@ class ModellTaktil(Modell):
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
@ -117,7 +120,7 @@ class ModellTaktil(Modell):
print("stop") print("stop")
break break
self.controller.stop() #self.controller.stop()
#self.controller.filterClassic() #self.controller.filterClassic()
@ -134,19 +137,20 @@ class ModellTaktil(Modell):
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
@ -156,8 +160,18 @@ class ModellTaktil(Modell):
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): if(accuracy != -1):
print("ACCURACY" + output) #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
@ -180,7 +194,7 @@ class ModellTaktil(Modell):
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()

View File

@ -9,9 +9,11 @@ werden koennen
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 *
@ -29,8 +31,8 @@ class View(Tk):
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.h = self.winfo_screenheight()
self.w = 2000 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)
@ -80,11 +82,11 @@ class View(Tk):
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