From 8b2829034cde943f3a7989f08470b9509a0a8de9 Mon Sep 17 00:00:00 2001 From: mbay Date: Thu, 10 Dec 2020 09:46:09 +0100 Subject: [PATCH] The OPCUA Server sets the Servertimestamp in the moment of writing the node, which is from our perspective as specified by the OPCUA guidline. If the Sourcetimestamp is not set by the client, you can use the commented line with SourceTimestamp as well. --- opcua/server/address_space.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opcua/server/address_space.py b/opcua/server/address_space.py index 547e1789c..cc5af62f0 100644 --- a/opcua/server/address_space.py +++ b/opcua/server/address_space.py @@ -10,7 +10,7 @@ from opcua import ua from opcua.server.user_manager import UserManager - +import pytz class AttributeValue(object): @@ -63,6 +63,9 @@ def write(self, params, user=UserManager.User.Admin): if not ua.ua_binary.test_bit(al.Value.Value, ua.AccessLevel.CurrentWrite) or not ua.ua_binary.test_bit(ual.Value.Value, ua.AccessLevel.CurrentWrite): res.append(ua.StatusCode(ua.StatusCodes.BadUserAccessDenied)) continue + tz = pytz.timezone('Europe/Berlin') + writevalue.Value.ServerTimestamp = datetime.now(tz) + #writevalue.Value.SourceTimestamp = datetime.now(tz) res.append(self._aspace.set_attribute_value(writevalue.NodeId, writevalue.AttributeId, writevalue.Value)) return res