|
2 | 2 | import time
|
3 | 3 | import logging as log
|
4 | 4 | import time
|
5 |
| -from datetime import timedelta |
6 |
| - |
| 5 | +import socket |
7 | 6 | import socketio
|
| 7 | + |
| 8 | +from datetime import timedelta |
8 | 9 | from google.protobuf import json_format
|
9 | 10 | from google.protobuf.json_format import MessageToDict
|
10 | 11 |
|
| 12 | +from PDS.spacexPacket import spacex_packet |
11 | 13 | from PDS.UDP.PodUdpConnection import PodUdpConnection
|
12 | 14 | from PDS.helpers.heartbeat_timer import HeartbeatTimer
|
13 | 15 | from Paradigm_pb2 import Telemetry
|
|
18 | 20 | broadcast_timer = HeartbeatTimer()
|
19 | 21 | log.basicConfig(stream=sys.stdout, format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
|
20 | 22 |
|
| 23 | +# SpaceX Packet connection, only to be turned on during Competition run |
| 24 | +SEND_SPACEX_PACKET = False |
| 25 | +if SEND_SPACEX_PACKET: |
| 26 | + server = ('127.0.0.1', 3000) |
| 27 | + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
| 28 | + |
21 | 29 | # Create socket to connect to server
|
22 | 30 | sio = socketio.Client()
|
23 | 31 | connection_status = {'name': 'telemetry', 'status': 0}
|
@@ -64,6 +72,9 @@ def main():
|
64 | 72 | sio.emit('pod_telemetry', json_pod_data)
|
65 | 73 | pod_data = MessageToDict(pod_data)
|
66 | 74 | log.warning("Telemetry: {}".format(pod_data))
|
| 75 | + if SEND_SPACEX_PACKET: |
| 76 | + packet = spacex_packet(pod_data) |
| 77 | + sock.sendto(packet, server) |
67 | 78 | else:
|
68 | 79 | connection_status['status'] = 0
|
69 | 80 | sio.emit('connection_updates', json.dumps(connection_status))
|
|
0 commit comments