From 4aed383ed06777e54ed05aba35a4547297294de2 Mon Sep 17 00:00:00 2001 From: Alfredos-Panagiotis Damkalis Date: Tue, 19 Jan 2021 19:58:29 +0200 Subject: [PATCH] Add observer field to ZeroMQ sent data Signed-off-by: Alfredos-Panagiotis Damkalis --- db/api/views.py | 2 +- db/base/tasks.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/db/api/views.py b/db/api/views.py index ce3098b..77c664c 100644 --- a/db/api/views.py +++ b/db/api/views.py @@ -276,7 +276,7 @@ class TelemetryViewSet( # pylint: disable=R0901 decode_current_frame.delay(norad_cat_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')) + publish_current_frame.delay(norad_cat_id, timestamp, request.data.get('frame'), observer) return Response(status=status.HTTP_201_CREATED) diff --git a/db/base/tasks.py b/db/base/tasks.py index ddd6fcc..d52fbae 100644 --- a/db/base/tasks.py +++ b/db/base/tasks.py @@ -265,7 +265,7 @@ def decode_current_frame(norad_id, demoddata_id): @shared_task -def publish_current_frame(norad_id, timestamp, frame): +def publish_current_frame(norad_id, timestamp, frame, observer): """Task to publish a current frame for a satellite.""" # Initialize ZeroMQ socket publisher = CONTEXT.socket(zmq.XPUB) @@ -281,9 +281,12 @@ def publish_current_frame(norad_id, timestamp, frame): raise else: publisher.send_multipart( - [bytes(str(norad_id), 'utf-8'), - bytes(frame, 'utf-8'), - bytes(timestamp, 'utf-8')] + [ + bytes(str(norad_id), 'utf-8'), + bytes(timestamp, 'utf-8'), + bytes(frame, 'utf-8'), + bytes(observer, 'utf-8') + ] ) finally: publisher.close()