From 6b5aff7b6ea186f07477594aed7e04898fdfb766 Mon Sep 17 00:00:00 2001 From: Henry Winkel Date: Tue, 15 Aug 2023 15:57:52 +0200 Subject: [PATCH] FIX: fixed bug with the usage of the id in control and fix a issue where the data class where invalid while creating with a data put in --- include/SimCore/Messages/Protos/Control.proto | 8 +++++--- include/SimCore/data.hpp | 2 +- src/SimCore/Messages/Control.cpp | 12 +++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/SimCore/Messages/Protos/Control.proto b/include/SimCore/Messages/Protos/Control.proto index 32c15ac..8f58700 100644 --- a/include/SimCore/Messages/Protos/Control.proto +++ b/include/SimCore/Messages/Protos/Control.proto @@ -1,9 +1,11 @@ syntax = "proto3"; +import "Identifier.proto"; package messages.control; message control{ - uint32 type = 1; - string data = 2; - optional uint64 timestamp = 3; + messages.track.Identifier Identifier = 1; + uint32 type = 2; + string data = 3; + optional uint64 timestamp = 4; } \ No newline at end of file diff --git a/include/SimCore/data.hpp b/include/SimCore/data.hpp index 6b619bc..fe903bf 100644 --- a/include/SimCore/data.hpp +++ b/include/SimCore/data.hpp @@ -16,7 +16,7 @@ namespace SimCore } - Data(T val):mx(),data_(val),valid_(false),writeTime_(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()) + Data(T val):mx(),data_(val),valid_(true),writeTime_(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()) { } diff --git a/src/SimCore/Messages/Control.cpp b/src/SimCore/Messages/Control.cpp index 0565522..c5233ca 100644 --- a/src/SimCore/Messages/Control.cpp +++ b/src/SimCore/Messages/Control.cpp @@ -18,6 +18,8 @@ namespace SimCore messages::control::control control; + control.mutable_identifier()->set_uuid(ID_.getUUID()); + control.mutable_identifier()->set_external(ID_.isExternal()); control.set_type(Type); control.set_data(Data); control.set_timestamp(Timestamp); @@ -40,16 +42,16 @@ namespace SimCore { m.payload().UnpackTo(&controlMsg); - SimCore::Identifier id(msg.senderUUID_); + SimCore::Identifier id(controlMsg.mutable_identifier()); - ControlType kind = (SimCore::ControlType)controlMsg.type(); + ControlType type = (SimCore::ControlType)controlMsg.type(); std::string data = controlMsg.data(); - auto control = std::make_unique(id,kind,data); + auto control = std::make_unique(id,type,data); if (controlMsg.has_timestamp()) control->Timestamp = controlMsg.timestamp(); - + LOG_S(INFO)<Type; // SimCore::Control control(id,kind,data); - return control; + return std::move(control); } return nullptr;