Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The OPCUA Server sets the Servertimestamp in the moment of writing th… #1197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion opcua/server/address_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from opcua import ua
from opcua.server.user_manager import UserManager

import pytz

class AttributeValue(object):

Expand Down Expand Up @@ -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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a fixed timezone "to Europe/Berlin" wouldn't be a good way. Either the servers local time should be passed or handled in another way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree!

writevalue.Value.ServerTimestamp = datetime.now(tz)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datetime.now(tz.utc) would be better, since every time thing on server side is based on UTC. Clients shall provide any conversions between UTC and local time.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

#writevalue.Value.SourceTimestamp = datetime.now(tz)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No comment is left behind in a PR. ;) You can delte that line, if it is unused.

res.append(self._aspace.set_attribute_value(writevalue.NodeId, writevalue.AttributeId, writevalue.Value))
return res

Expand Down