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

@@ -91,9 +91,9 @@ class Modell(Thread):
z = z.strip()
items = z.split(' ')
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")

+ 25
- 11
UIModellTaktil.py View File

@@ -7,6 +7,7 @@ from subprocess import *
from threading import Thread
import time
from UIModell import *
import re

class ModellTaktil(Modell):

@@ -62,7 +63,7 @@ class ModellTaktil(Modell):
while True:
output = process.stdout.readline()
print(output.strip())
x = output.find("schlagwort?")
x = output.find("Application terminated")
y = output.find("Error")
if(x != -1):
print("Training finished")
@@ -82,16 +83,18 @@ class ModellTaktil(Modell):
break

self.controller.stop()
#self.controller.stop()
def trainXDawn(self):
'''--------------------------------------------------------------------------------------------------
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.
'''
print("start training Xdawn")
print("Start training Xdawn")
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)
self.openVibeAktiv = True
@@ -117,7 +120,7 @@ class ModellTaktil(Modell):
print("stop")
break
self.controller.stop()
#self.controller.stop()

#self.controller.filterClassic()

@@ -134,19 +137,20 @@ class ModellTaktil(Modell):
process = Popen(command, stdout=PIPE, universal_newlines=True)

self.openVibeAktiv = True
counter = 0
counter = 0
acc = 0
while True:
output = process.stdout.readline()
print(output.strip())
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")
if(x != -1):
counter = counter +1
#counter = 18
if(counter >= 17):
print("Training finished")
self.controller.addInfoText('Training beendet\n')
self.controller.addInfoText('Training beendet (' + acc + ')\n')
process.terminate()
self.controller.stop("save")
break
@@ -156,8 +160,18 @@ class ModellTaktil(Modell):
self.controller.addInfoText("Fehler beim Classifier Training aufgetaucht\n")
process.terminate()
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:
print("stop")
break
@@ -180,7 +194,7 @@ class ModellTaktil(Modell):
output = process.stdout.readline()
print(output.strip())
y = output.find("Error")
x = output.find("Schlagwort")
x = output.find("Application terminated")
if(x != -1):
print("End Spelling")
process.terminate()

+ 8
- 6
UIViewTKinter.py View File

@@ -9,9 +9,11 @@ werden koennen
try:
from Tkinter import * #Fuer Python 2.7
import tkFileDialog as fd
print("python2.7")
except ImportError: #Fuer Python >3
from tkinter import *
from tkinter import filedialog as fd
print("python >3")

from UIController import *

@@ -29,8 +31,8 @@ class View(Tk):
self.controller = c
self.PATH_DEFAULT = path_default
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.faktor = [(0.073),(0.727), (0.2)]
#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
schliesst
'''
print("closing")
self.controller.commandStop()
self.controller.stopAcquisitionServer()
print("destroy")
try:
print("closing")
self.controller.commandStop()
self.controller.stopAcquisitionServer()
print("destroy")
self.dialog.destroy()
except:
pass

Loading…
Cancel
Save