-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubSystemEmulator.py
More file actions
33 lines (27 loc) · 898 Bytes
/
SubSystemEmulator.py
File metadata and controls
33 lines (27 loc) · 898 Bytes
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
# Generic Sub-System Emulator
from PQ9Client import PQ9Client, PQ9ClientConnectionClosed
import time
import configparser
from threading import Thread
class SubSystemEmulator:
def __init__(self, pq9_connection, address):
self.pq9Handler = pq9_connection
self.address = address
self.running = False
def start(self):
self.running = True
self.processThread = Thread(target=self.task, args=())
self.processThread.start()
def close(self):
self.running = False
self.processThread.join()
def task(self):
try:
while self.running:
success, msg = self.pq9Handler.getFrame()
if success == True:
self.checkMessage(msg)
except PQ9ClientConnectionClosed:
pass
def checkMessage(self, msg):
print(msg)