14
14
import websocket
15
15
import rel
16
16
import threading
17
-
17
+ CONNECTION_URL = "ws://192.168.5.3:7867/remotecon"
18
18
class RemoteController (object ):
19
19
20
20
def __init__ (self , MainWindow ) -> None :
@@ -103,26 +103,31 @@ def isPrefix(self, prefix_text):
103
103
return False
104
104
return True
105
105
106
- def asyncTask (self , f_stop ):
107
- self .ws .send ("PING" )
108
- if not f_stop .is_set ():
109
- # call f() again in 60 seconds
110
- threading .Timer (5 , self .asyncTask , [f_stop ]).start ()
106
+ def phaseAlign (self ):
107
+ try :
108
+ self .ws .send ("PHASE_ALIGN" )
109
+ except Exception as e :
110
+ self .show_popup ()
111
+ with open ('last_prefix.txt' ,'w+' ) as file :
112
+ file .writelines (self .download_prefix_text .toPlainText ())
113
+ sys .exit ()
114
+
115
+
116
+
117
+ # def asyncTask(self, f_stop):
118
+ # self.ws.send("PING")
119
+ # self.ws.recv()
120
+ # if not f_stop.is_set():
121
+ # # call f() again in 60 seconds
122
+ # threading.Timer(5, self.asyncTask, [f_stop]).start()
111
123
112
124
def setupUi (self , MainWindow ):
113
125
# Setup the WEB SOCKET
114
126
#self.ws = websocket.WebSocketApp("ws://192.168.5.2:7867/remotecon")
115
127
self .ws = websocket .WebSocket ()
116
- self .ws .connect ("ws://192.168.5.2:7867/remotecon" )
117
- f_stop = threading .Event ()
118
- self .asyncTask (f_stop )
119
- # self.ws = websocket.WebSocketApp("ws://192.168.5.2:7867/remotecon")
120
- #
121
- # self.ws.run_forever(ping_interval=1)
122
- # self.ws.run_forever(dispatcher=rel, reconnect=5)
123
- # rel.signal(2, rel.abort)
124
- # rel.dispatch()
125
- # await ws.send('2')
128
+ self .ws .connect (CONNECTION_URL )
129
+ # f_stop = threading.Event()
130
+ # self.asyncTask(f_stop)
126
131
# Setup the GUI
127
132
MainWindow .setObjectName ("MainWindow" )
128
133
MainWindow .resize (800 , 800 )
@@ -131,7 +136,7 @@ def setupUi(self, MainWindow):
131
136
self .label = QtWidgets .QLabel (self .centralwidget )
132
137
self .label .setGeometry (QtCore .QRect (290 , 10 , 161 , 61 ))
133
138
font = QtGui .QFont ()
134
- font .setFamily ("Source Code Pro" )
139
+ # font.setFamily("Source Code Pro")
135
140
font .setPointSize (19 )
136
141
self .label .setFont (font )
137
142
self .label .setObjectName ("label" )
@@ -177,11 +182,17 @@ def setupUi(self, MainWindow):
177
182
self .download_btn .clicked .connect (self .downloadBtn )
178
183
179
184
self .delete_btn = QtWidgets .QPushButton (self .centralwidget )
180
- self .delete_btn .setGeometry (QtCore .QRect (280 , 520 , 161 , 50 ))
185
+ self .delete_btn .setGeometry (QtCore .QRect (450 , 520 , 161 , 50 ))
181
186
self .delete_btn .setFont (font )
182
187
self .delete_btn .setObjectName ("pushButton_6" )
183
188
self .delete_btn .clicked .connect (self .delete_all_btn )
184
189
190
+ self .phase_align_btn = QtWidgets .QPushButton (self .centralwidget )
191
+ self .phase_align_btn .setGeometry (QtCore .QRect (120 ,520 , 161 , 50 ))
192
+ self .phase_align_btn .setFont (font )
193
+ self .phase_align_btn .setObjectName ("pushButton_phase" )
194
+ self .phase_align_btn .clicked .connect (self .phaseAlign )
195
+
185
196
186
197
self .status_label = QtWidgets .QPlainTextEdit (self .centralwidget )
187
198
self .status_label .setGeometry (QtCore .QRect (173 , 280 , 381 , 91 ))
@@ -218,13 +229,13 @@ def retranslateUi(self, MainWindow):
218
229
self .download_prefix_text .setPlaceholderText (_translate ("MainWindow" , " Enter Session Prefix" ))
219
230
self .download_btn .setText (_translate ("MainWindow" , "Download" ))
220
231
self .prefix_list_btn .setText (_translate ("MainWindow" , "Prefix List" ))
232
+ self .phase_align_btn .setText (_translate ("MainWindow" , "Phase Align" ))
221
233
self .status_label .setPlaceholderText (_translate ("MainWindow" , "No status " ))
222
234
223
235
224
236
if __name__ == "__main__" :
225
237
app = QtWidgets .QApplication (sys .argv )
226
238
MainWindow = QtWidgets .QMainWindow ()
227
-
228
239
rc = RemoteController (MainWindow )
229
240
rc .setupUi (MainWindow )
230
241
0 commit comments