From 6f27401882237acf048f3335cee778378ca09509 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Wed, 2 Jun 2021 22:45:23 +0200 Subject: [PATCH] added timestamp to target_velocity.py --- components/orchestration/orchestrator.py | 4 +++- components/shared/dse_shared_libs/target_velocity.py | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/orchestration/orchestrator.py b/components/orchestration/orchestrator.py index 7e8054e..35910a2 100644 --- a/components/orchestration/orchestrator.py +++ b/components/orchestration/orchestrator.py @@ -1,3 +1,4 @@ +import datetime import pickle import sys from random import randrange @@ -69,7 +70,8 @@ class Orchestrator: target_vel = randrange(0, 130) print('Target velocity: {}'.format(target_vel)) response_channel.send(pickle.dumps( - TargetVelocity(vin=received_daf_object.vehicle_identification_number, target_velocity=target_vel))) + TargetVelocity(vin=received_daf_object.vehicle_identification_number, target_velocity=target_vel, + timestamp=datetime.datetime.now()))) def handle_tl_state_receive(self, msg): """ diff --git a/components/shared/dse_shared_libs/target_velocity.py b/components/shared/dse_shared_libs/target_velocity.py index 8936573..620c53b 100644 --- a/components/shared/dse_shared_libs/target_velocity.py +++ b/components/shared/dse_shared_libs/target_velocity.py @@ -1,10 +1,15 @@ from dataclasses import dataclass +from datetime import datetime @dataclass class TargetVelocity: vin: str target_velocity: float + timestamp: datetime def to_dict(self): - return self.__dict__ + return {'vin': self.vin, + 'target_velocity': self.target_velocity, + 'timestamp': self.timestamp.timestamp() + }