Example: I have an object with three Variables (boolean): Global, S1, S2.
Clients can read and write S1 and S2 and can only read Global.
I need the server to modify Global when S1 and S2 are modified by the clients.
How can I do this operation without using methods?
Re:Modify a Variable value when another one (or more) change its
Moderator: uasdkcpp
-
- Full Member
- Posts: 7
- Joined: 28 Jul 2011, 18:04
Modify a Variable value when another one (or more) change it
Last edited by JtR on 07 Feb 2013, 10:48, edited 1 time in total.
- Support Team
- Hero Member
- Posts: 3064
- Joined: 18 Mar 2011, 15:09
Re:Modify a Variable value when another one (or more) change
There are two options to implement a solution to this requirement
(1) Subscribe for data changes internally
You can subscribe for the values S1 and S2 and you can calculate und update Global if you get a data change. The following forum topic is explaining how to subscribe internally for changes:
http://www.unified-automation.com/forum ... he-sdk.htm
UaForum -> Products of Unified Automation -> C++ based OPC UA SDK
-> How do I read or subscribe for data internally in the server
(2) Do additional actions at Write
You can overwrite IOManagerUaNode::afterGetAttributeValue() to execute additional actions when a certain value was successfully written.
If you are deriving your NodeManager from NodeManagerBase, you need to implement this function in your NodeManager class.
Best regards,
Unified Automation Support Team
(1) Subscribe for data changes internally
You can subscribe for the values S1 and S2 and you can calculate und update Global if you get a data change. The following forum topic is explaining how to subscribe internally for changes:
http://www.unified-automation.com/forum ... he-sdk.htm
UaForum -> Products of Unified Automation -> C++ based OPC UA SDK
-> How do I read or subscribe for data internally in the server
(2) Do additional actions at Write
You can overwrite IOManagerUaNode::afterGetAttributeValue() to execute additional actions when a certain value was successfully written.
If you are deriving your NodeManager from NodeManagerBase, you need to implement this function in your NodeManager class.
Best regards,
Unified Automation Support Team
Last edited by Support Team on 07 Feb 2013, 10:48, edited 1 time in total.
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Full Member
- Posts: 7
- Joined: 28 Jul 2011, 18:04
Re:Modify a Variable value when another one (or more) change
Two things:
first: thanks for the answer!
second: why don't the methods BaseVariableType:: setValue() and BaseVariableType:: setAttributeValue() trigger the IOManagerUaNode:: afterSetAttributeValue()?
first: thanks for the answer!
second: why don't the methods BaseVariableType:: setValue() and BaseVariableType:: setAttributeValue() trigger the IOManagerUaNode:: afterSetAttributeValue()?
Last edited by JtR on 07 Feb 2013, 10:48, edited 1 time in total.
- Support Team
- Hero Member
- Posts: 3064
- Joined: 18 Mar 2011, 15:09
Re:Modify a Variable value when another one (or more) change
The methods in IOManagerUaNode like before/afterSetAttributeValue are used to control and act on operations executed from a client through OPC UA services like Read and Write. This allows the implementer of the IOManager / NodeManager to do things like checking user rights or to trigger internal business logic.
If you are using BaseVariableType:: setValue() and BaseVariableType:: setAttributeValue(), you are doing that from your own code and business logic. You should know what is necessary if you update one variable if the update of other variables is necessary. The mentioned methods are accessing the variable objects directly. There is no other logic in between.
If you are accessing the values through internal Read and Write operations, afterSetAttributeValue is also called.
Best regards,
Unified Automation Support Team
If you are using BaseVariableType:: setValue() and BaseVariableType:: setAttributeValue(), you are doing that from your own code and business logic. You should know what is necessary if you update one variable if the update of other variables is necessary. The mentioned methods are accessing the variable objects directly. There is no other logic in between.
If you are accessing the values through internal Read and Write operations, afterSetAttributeValue is also called.
Best regards,
Unified Automation Support Team
Last edited by Support Team on 07 Feb 2013, 10:48, edited 1 time in total.
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Full Member
- Posts: 7
- Joined: 28 Jul 2011, 18:04
Re:Modify a Variable value when another one (or more) change
Thanks for the clarification:)
Last edited by JtR on 07 Feb 2013, 10:48, edited 1 time in total.
-
- Full Member
- Posts: 7
- Joined: 28 Jul 2011, 18:04
Re:Modify a Variable value when another one (or more) change
And if the variables S1 and S2 are on other servers?
Last edited by JtR on 07 Feb 2013, 10:48, edited 1 time in total.
- Support Team
- Hero Member
- Posts: 3064
- Joined: 18 Mar 2011, 15:09
Re:Modify a Variable value when another one (or more) change
In this case you need to implement an OPC UA client in your server that is subscribing for S1 and S2 in the other server.
Best regards,
Unified Automation Support Team
Best regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team
Unified Automation Support Team