Add station_id field to published DemodData
Signed-off-by: Alfredos-Panagiotis Damkalis <fredy@fredy.gr>spacecruft
parent
afda478ccc
commit
8adda93204
|
@ -227,15 +227,15 @@ class TelemetryViewSet( # pylint: disable=R0901
|
|||
"""
|
||||
data = {}
|
||||
|
||||
norad_cat_id = request.data.get('noradID')
|
||||
norad_id = request.data.get('noradID')
|
||||
|
||||
if not Satellite.objects.filter(norad_cat_id=norad_cat_id).exists():
|
||||
if not Satellite.objects.filter(norad_cat_id=norad_id).exists():
|
||||
try:
|
||||
update_satellite(norad_cat_id, update_name=True)
|
||||
update_satellite(norad_id, update_name=True)
|
||||
except LookupError:
|
||||
return Response(status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
data['satellite'] = Satellite.objects.get(norad_cat_id=norad_cat_id).id
|
||||
data['satellite'] = Satellite.objects.get(norad_cat_id=norad_id).id
|
||||
data['station'] = request.data.get('source')
|
||||
timestamp = request.data.get('timestamp')
|
||||
data['timestamp'] = timestamp
|
||||
|
@ -245,6 +245,7 @@ class TelemetryViewSet( # pylint: disable=R0901
|
|||
if request.data.get('observation_id'):
|
||||
observation_id = request.data.get('observation_id')
|
||||
data['observation_id'] = observation_id
|
||||
station_id = ''
|
||||
if request.data.get('station_id'):
|
||||
station_id = request.data.get('station_id')
|
||||
data['station_id'] = station_id
|
||||
|
@ -280,11 +281,15 @@ class TelemetryViewSet( # pylint: disable=R0901
|
|||
self.perform_create(serializer)
|
||||
|
||||
# Run task to decode the current frame
|
||||
decode_current_frame.delay(norad_cat_id, serializer.instance.pk)
|
||||
decode_current_frame.delay(norad_id, serializer.instance.pk)
|
||||
|
||||
# Run task to publish the current frame via ZeroMQ
|
||||
publish_current_frame.delay(
|
||||
norad_cat_id, timestamp, request.data.get('frame'), observer, observation_id
|
||||
timestamp, request.data.get('frame'), observer, {
|
||||
'norad_id': norad_id,
|
||||
'observation_id': observation_id,
|
||||
'station_id': station_id
|
||||
}
|
||||
)
|
||||
|
||||
return Response(status=status.HTTP_201_CREATED)
|
||||
|
|
|
@ -265,7 +265,7 @@ def decode_current_frame(norad_id, demoddata_id):
|
|||
|
||||
|
||||
@shared_task
|
||||
def publish_current_frame(norad_id, timestamp, frame, observer, observation_id):
|
||||
def publish_current_frame(timestamp, frame, observer, ids):
|
||||
"""Task to publish a current frame for a satellite."""
|
||||
# Initialize ZeroMQ socket
|
||||
publisher = CONTEXT.socket(zmq.XPUB)
|
||||
|
@ -282,11 +282,12 @@ def publish_current_frame(norad_id, timestamp, frame, observer, observation_id):
|
|||
else:
|
||||
publisher.send_multipart(
|
||||
[
|
||||
bytes(str(norad_id), 'utf-8'),
|
||||
bytes(ids['norad_id'], 'utf-8'),
|
||||
bytes(timestamp, 'utf-8'),
|
||||
bytes(frame, 'utf-8'),
|
||||
bytes(observer, 'utf-8'),
|
||||
bytes(observation_id, 'utf-8')
|
||||
bytes(ids['observation_id'], 'utf-8'),
|
||||
bytes(ids['station_id'], 'utf-8')
|
||||
]
|
||||
)
|
||||
finally:
|
||||
|
|
Loading…
Reference in New Issue