Hello,
I activated the logging but always get the output in UTC-Time olso if I call LibT::setLocalTimeOutput(true).
In uatrace.cpp is the same format for both cases (true/false).
It would be nice to have a UaDateTime::toDateStringLocal() , UaDateTime::toTimeStringLocal() and a UaDateTime::toStringLocal() to fix this.
Or is there a other possibility?
Thanks Frank
LibT::setLocalTimeOutput(true) has no effect, new meber funktions for UaDateTime
Moderator: uasdkcpp
-
- Jr. Member
- Posts: 4
- Joined: 03 Sep 2012, 10:50
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re:LibT::setLocalTimeOutput(true) has no effect, new meber funktions for UaDateTime
Hi Frank,
The class UaDateTime was changed a while ago to use the date time functionality provided by the OPC UA stack. This avoids duplicated development effort for the platform/operating system specific code. The problem is that only UTC time handling is covered by the stack. The trace was not changed for this simplification but there was no special handling added for local time.
Adding the missing feature to the trace class is easy since only the current time is printed and no calculations are necessary. We added this handling. Attached you can find some code snippets to fix UaTrace::traceOutput(). The changes will be included in the next SDK update.
Adding the requested feature to UaDateTime has more implications since the class holds a UTC time and calculations with time zone and daylight saving time must be added in a platform independent way. We added a feature request for this but are not sure when it will be added to the SDK.
Best Regards,
Unified Automation Support Team
The class UaDateTime was changed a while ago to use the date time functionality provided by the OPC UA stack. This avoids duplicated development effort for the platform/operating system specific code. The problem is that only UTC time handling is covered by the stack. The trace was not changed for this simplification but there was no special handling added for local time.
Adding the missing feature to the trace class is easy since only the current time is printed and no calculations are necessary. We added this handling. Attached you can find some code snippets to fix UaTrace::traceOutput(). The changes will be included in the next SDK update.
Adding the requested feature to UaDateTime has more implications since the class holds a UTC time and calculations with time zone and daylight saving time must be added in a platform independent way. We added a feature request for this but are not sure when it will be added to the SDK.
Best Regards,
Unified Automation Support Team
Code: Select all
#include <sys/timeb.h>
#include <time.h>
// Get local time if requested for trace
if(s_IsLocalTimeTrace)
{
timeb tb;
ftime(&tb);
tm *time;
time = localtime(&tb.time);
// Trace output with local time
OpcUa_StringA_snprintf(strTemp, 2000, (OpcUa_StringA)"%02d:%02d:%02d.%03d|%d|%04X* %sn",
time->tm_hour,
time->tm_min,
time->tm_sec,
tb.millitm,
traceLevel,
OpcUa_Thread_GetCurrentThreadId(),
sContent);
Best regards
Unified Automation Support Team
Unified Automation Support Team