Skip to content
Snippets Groups Projects
Commit cca187ca authored by 488_MP-4's avatar 488_MP-4
Browse files

new thread for output

parent 7fe8cf40
No related branches found
No related tags found
5 merge requests!106Adding Pycrocart 2.1,!104adding cflib to this branch,!103Updating develop to current state of master branch,!98Pycrocart 2.1 will,!94Merge cflib adapter into main
No preview for this file type
No preview for this file type
from ast import While
from email import message
from queue import Queue
from threading import Thread
......@@ -11,12 +12,19 @@ class main():
self.outputQueue = Queue()
def processCommands(self):
def start(self):
gs = GroundstationSocket()
self.inThread = Thread(target = gs.groundstation_connect, args = (self.inputQueue,))
self.inThread.start()
cfConnect = CrazyflieConnection()
self.cfConnect = CrazyflieConnection()
self.commandThread = Thread(target = self.processCommands)
self.commandThread.start()
while True:
if self.outputQueue.not_empty:
message = self.outputQueue.get()
gs.WriteToBackend(message)
def processCommands(self):
while True:
if self.inputQueue.not_empty:
command = self.inputQueue.get()
......@@ -24,40 +32,39 @@ class main():
msg_type = command["msg_type"]
print(msg_type)
if msg_type == MessageTypeID.GETPACKETLOGS_ID.value:
cfConnect.GetPacketLogs()
self.cfConnect.GetPacketLogs()
elif msg_type == MessageTypeID.UPDATE_ID.value:
cfConnect.Update()
self.cfConnect.Update()
elif msg_type == MessageTypeID.BEGINUPDATE_ID.value:
cfConnect.BeginUpdate()
self.cfConnect.BeginUpdate()
elif msg_type == MessageTypeID.OUTPUT_OVERRIDE_ID.value:
cfConnect.OverrideOuput()
self.cfConnect.OverrideOuput()
elif msg_type == MessageTypeID.GETNODES_ID.value:
cfConnect.GetNodes()
self.cfConnect.GetNodes()
elif msg_type == MessageTypeID.SETPARAM_ID.value:
cfConnect.SetParam()
self.cfConnect.SetParam()
elif msg_type == MessageTypeID.GETPARAM_ID.value:
cfConnect.GetParam()
self.cfConnect.GetParam()
elif msg_type == MessageTypeID.SETSOURCE_ID.value:
cfConnect.SetSource()
self.cfConnect.SetSource()
elif msg_type == MessageTypeID.GETSOURCE_ID.value:
cfConnect.GetSource()
self.cfConnect.GetSource()
elif msg_type == MessageTypeID.RESPSOURCE_ID.value:
cfConnect.RespSource()
self.cfConnect.RespSource()
elif msg_type == MessageTypeID.GETOUTPUT_ID.value:
cfConnect.GetOutput()
self.cfConnect.GetOutput()
elif msg_type == MessageTypeID.GETNODES_ID.value:
cfConnect.GetNodes()
self.cfConnect.GetNodes()
elif msg_type == MessageTypeID.ADDNODE_ID.value:
cfConnect.AddNode()
self.cfConnect.AddNode()
elif msg_type == MessageTypeID.LOG_ID.value:
cfConnect.GetLogFile()
self.cfConnect.GetLogFile()
elif msg_type == MessageTypeID.LOG_END_ID.value:
cfConnect.LogBlockCommand()
self.cfConnect.LogBlockCommand()
if self.outputQueue.not_empty:
message = self.outputQueue.get()
gs.WriteToBackend(message)
......@@ -65,6 +72,6 @@ class main():
if __name__ == '__main__':
main().processCommands()
main().start()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment