From 43fa5eef689667f1f618a840b26529f230ad6824 Mon Sep 17 00:00:00 2001 From: Julius Pfrommer Date: Wed, 11 Oct 2023 21:43:07 +0200 Subject: [PATCH] feat(pubsub): Use EventLoop time source in ua_pubsub_writer.c --- src/pubsub/ua_pubsub_writer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pubsub/ua_pubsub_writer.c b/src/pubsub/ua_pubsub_writer.c index 50bc91711ef..bde9d9588d7 100644 --- a/src/pubsub/ua_pubsub_writer.c +++ b/src/pubsub/ua_pubsub_writer.c @@ -703,7 +703,7 @@ UA_DataSetWriter_generateDataSetMessage(UA_Server *server, UA_DataSetWriter *dataSetWriter) { UA_Boolean heartbeat = false; UA_PublishedDataSet *currentDataSet = NULL; - + if(UA_NodeId_isNull(&dataSetWriter->connectedDataSet)){ heartbeat = true; } else { @@ -714,6 +714,9 @@ UA_DataSetWriter_generateDataSetMessage(UA_Server *server, } } + UA_WriterGroup *wg = UA_WriterGroup_findWGbyId(server, dataSetWriter->linkedWriterGroup); + UA_EventLoop *el = UA_PubSubConnection_getEL(server, wg->linkedConnection); + /* Reset the message */ memset(dataSetMessage, 0, sizeof(UA_DataSetMessage)); @@ -804,7 +807,7 @@ UA_DataSetWriter_generateDataSetMessage(UA_Server *server, if((u64)dsm->dataSetMessageContentMask & (u64)UA_UADPDATASETMESSAGECONTENTMASK_TIMESTAMP) { dataSetMessage->header.timestampEnabled = true; - dataSetMessage->header.timestamp = UA_DateTime_now(); + dataSetMessage->header.timestamp = el->dateTime_now(el); } /* TODO: Picoseconds resolution not supported atm */ @@ -850,7 +853,7 @@ UA_DataSetWriter_generateDataSetMessage(UA_Server *server, if((u64)jsonDsm->dataSetMessageContentMask & (u64)UA_JSONDATASETMESSAGECONTENTMASK_TIMESTAMP) { dataSetMessage->header.timestampEnabled = true; - dataSetMessage->header.timestamp = UA_DateTime_now(); + dataSetMessage->header.timestamp = el->dateTime_now(el); } /* TODO: Statuscode not supported yet */