-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathState_thread.py
52 lines (38 loc) · 1.69 KB
/
State_thread.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
"""
This file is part of HDCS.
HDCS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
HDCS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with HDCS. If not, see <http://www.gnu.org/licenses/>.
"""
from time import time
from ADCS_Link import ADCS_Link
from PyQt5 import QtCore
class Thread(QtCore.QThread):
compare = ['F1','F2']
state_emitter = QtCore.pyqtSignal(dict)
ADCS = ADCS_Link()
lasttime=time()
def get_gui(self,gui):
""" Obtain a link to the GUI object for the command variable """
self.GUI = gui
def run(self):
""" Operate the state thread: check for changes, emit if there are """
INIT = True
while True:
new_state = self.ADCS.tranceive_and_parse(self.GUI.Command,
self.GUI.State)
if new_state:
self.compare = [key for key,value in new_state.items()
if new_state[key]!=self.GUI.State[key]]
# Can't do new_state!=State b/c ADCS doesn't have the same keys
if len(self.compare) or INIT:
self.state_emitter.emit(new_state)
INIT = 0
self.lasttime=time()