-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmlooptest.py
78 lines (65 loc) · 2.71 KB
/
mlooptest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from networking.networker import PyServer
from sequences.translator import translate
import json
import time
import os
try:
from PyQt4.QtCore import QThread, pyqtSignal, QEvent, QRegExp, QTimer
from PyQt4.QtGui import (QApplication, QPushButton, QWidget, QLabel,
QAction, QGridLayout, QMainWindow, QMessageBox, QLineEdit, QIcon,
QFileDialog, QDoubleValidator, QIntValidator, QComboBox, QMenu,
QActionGroup, QTabWidget, QVBoxLayout, QFont, QRegExpValidator,
QInputDialog)
except ImportError:
from PyQt5.QtCore import QThread, pyqtSignal, QEvent, QRegExp, QTimer
from PyQt5.QtGui import (QIcon, QDoubleValidator, QIntValidator,
QFont, QRegExpValidator)
from PyQt5.QtWidgets import (QApplication, QPushButton, QWidget,
QTabWidget, QAction, QMainWindow, QLabel, QInputDialog, QGridLayout,
QMessageBox, QLineEdit, QFileDialog, QComboBox, QActionGroup, QMenu,
QVBoxLayout)
try:
from PyQt4.QtGui import QWidget
except ImportError:
from PyQt5.QtWidgets import QWidget
import sys
app = QApplication.instance()
standalone = app is None # false if there is already an app instance
if standalone: # if there isn't an instance, make one
app = QApplication(sys.argv)
import threading as th
keep_going = True
def key_capture_thread():
global keep_going
keystroke = input()
if keystroke == 'c':
keep_going = False
print('Stopping...')
def look_for_exp_input(mloopdict):
th.Thread(target=key_capture_thread, args=(), name='key_capture_thread', daemon=True).start()
print('Looping... type c then enter to close program')
while keep_going:
if os.path.exists(mloopinputpath+r'\exp_input.txt'):
time.sleep(0.01) #Catch for file write
#print('Mloop file found')
t.mloopmodify(mloopdict,mloopinputpath)
ps.add_message(25,t.write_to_str())
#print(t.write_to_str())
#ps.add_message(4,'run')
time.sleep(2)
basesequencepath = r"sequences\SequenceFiles\0_17 September 2019_09 30 18.xml"
mloopdictpath = r"sequences\mloopdict.json"
mloopdict = json.loads(open(mloopdictpath,'r').read() )
t = translate()
t.load_xml(r'.\\sequences\\SequenceFiles\\0_17 September 2019_09 30 18.xml')
mloopinputpath= r"C:\Users\xxxg38\Documents\MATLAB\storage\mloop"
loop = True
ps = PyServer('localhost')
ps.start()
print('server started')
ps.add_message(24,'Communication Established Press Enter on communicator to continue')
# Function which waits for mloop to write a text file, then sends data on to labview via tcp
look_for_exp_input (mloopdict)
ps.add_message(24,'python mode off') # Command to unlock dexter.
time.sleep(3)
ps.close()