1111from modules import decision_command
1212from utilities .workers import queue_proxy_wrapper
1313from utilities .workers import worker_controller
14+ from modules .common .modules import position_global
15+ from modules .common .modules .data_encoding import message_encoding_decoding
16+ from modules .common .modules .data_encoding import worker_enum
1417
1518MAVLINK_CONNECTION_ADDRESS = "tcp:localhost:14550"
1619FLIGHT_INTERFACE_TIMEOUT = 10.0 # seconds
1720FLIGHT_INTERFACE_BAUD_RATE = 57600 # symbol rate
1821FLIGHT_INTERFACE_WORKER_PERIOD = 0.1 # seconds
22+ WORK_COUNT = 4
23+ COMMUNICATIONS_WORKER_ID = worker_enum .WorkerEnum .COMMUNICATIONS_WORKER
24+
25+
26+ def simulate_communications_worker (
27+ in_queue : queue_proxy_wrapper .QueueProxyWrapper ,
28+ data_point : position_global .PositionGlobal ,
29+ ) -> None :
30+ """
31+ Encode coordinates and place into queue.
32+ """
33+ result , message = message_encoding_decoding .encode_position_global (
34+ COMMUNICATIONS_WORKER_ID , data_point
35+ )
36+ assert result
37+ assert message is not None
38+
39+ in_queue .queue .put (message )
40+
41+ return
1942
2043
2144def apply_decision_test (
@@ -105,6 +128,8 @@ def main() -> int:
105128 out_queue = queue_proxy_wrapper .QueueProxyWrapper (mp_manager )
106129 home_position_out_queue = queue_proxy_wrapper .QueueProxyWrapper (mp_manager )
107130 in_queue = queue_proxy_wrapper .QueueProxyWrapper (mp_manager )
131+ communications_in_queue = queue_proxy_wrapper .QueueProxyWrapper (mp_manager )
132+ communications_out_queue = queue_proxy_wrapper .QueueProxyWrapper (mp_manager )
108133
109134 worker = mp .Process (
110135 target = flight_interface_worker .flight_interface_worker ,
@@ -116,6 +141,7 @@ def main() -> int:
116141 in_queue , # Added input_queue
117142 out_queue ,
118143 home_position_out_queue ,
144+ communications_in_queue ,
119145 controller ,
120146 ),
121147 )
@@ -129,6 +155,27 @@ def main() -> int:
129155 home_position = home_position_out_queue .queue .get ()
130156 assert home_position is not None
131157
158+ data_points = [position_global .PositionGlobal .create (43.471468 , - 80.544205 , 335 ),
159+ position_global .PositionGlobal .create (43.6629 , - 79.3957 , 105 ),
160+ position_global .PositionGlobal .create (43.2609 , - 79.9192 , 100 ),
161+ position_global .PositionGlobal .create (43.7735 , - 79.5019 , 170 )
162+ ]
163+
164+ # Simulate communications worker
165+ for i in range (0 , WORK_COUNT ):
166+ simulate_communications_worker (communications_in_queue , home_position , data_points [i ])
167+
168+ # Test flight interface worker sending statustext messages
169+ for i in range (0 , WORK_COUNT ):
170+ try :
171+ input_data : bytes = communications_out_queue .queue .get_nowait ()
172+ assert input_data is not None
173+ except queue .Empty :
174+ print ("Output queue has no more messages to process, exiting" )
175+ break
176+
177+ assert communications_out_queue .queue .empty ()
178+
132179 # Run the apply_decision tests
133180 test_result = apply_decision_test (in_queue , out_queue )
134181 if not test_result :
0 commit comments