17:31, EET
October 21, 2016
Hi,
I tried a Chained server-client configuration as following:
(Prosys OPC UA Simulation Server) –> (MyJavaUAClient) –> (MyJavaUAServer) –> (Client UAExpert)
I used the simulation item Counter1 value (ns = 5, s = “Counter1”) to test.
I can Read Counter1 value, and also Subscription to Counter1 value was successful.
I can write value from (MyJavaUAClient) to the (Prosys OPC UA Simulation Server).
However, i can’t find a way to write from (Client UAExpert) to (Prosys OPC UA Simulation Server) throught the chain.
Does any one has an idea about how to do it,
Thank’s
Best Regards
23:13, EET
October 21, 2016
Fortunately, i found a way to do it, and it’s working.
This is the solution i used in order to detect “the write action ” from UAExpert in my Java SDK server:
I declared three ‘Variant’ variables: CurrentValue, NewValue, FinalClientValue;
Every 100ms, i compare the Current value to the FinalClientValue (from UAExpert)
if it’s equal, then i update both of them with the NewValue obtained from the MonitoredItem (from Prosys Simulation OPC UA Server)
else : I put the FinalClientValue in the CurrentValue and write it to the Prosys Simulation OPC UA Server.
Question:
Is there a native way, to detect user write action on the node value (client side) in server Java SDK?
Thank you,
Best Regards
15:59, EET
April 17, 2013
Hello,
If I understood correctly, you are now creating a subscription from ‘MyJavaUAClient’ to ‘Prosys OPC UA Simulation Server’. When value changes in Simulation Server, you get notified about this in ‘MyJavaUAClient’ and then you write the value to ‘MyJavaUAServer’.
Why are you not doing this exact same pattern also in reverse order?
Meaning that: you make a subscription to the ‘MyJavaUAServer’ from ‘MyJavaUAClient’ and then write these value changes to the ‘Simulation Server’. Is this what you are looking for?
It seems that you want to somehow keep track of the client application which makes the change (MyJavaUAClient or UaExpert) and this is the reason why you need to have these three separate variables. However, it’s not immediately clear what is the background of this requirement. To put it more simply: why do you use three variables instead of just one?
17:13, EET
October 21, 2016
Hi Mr Tahvanainen,
sorry for my late reply.
I followed the example of ” Sample Console Client” provided in the SDK, (created subscription, monitored item and a data change Listener), and writing to (MyJavaUAServer) in the “OnDataChange” of the datachange listener
I write the value of the source node from (Prosys OPC UA Simulation Server) to the target node in (MyJavaUAServer) when the data changes as following:
@Override
public void onDataChange(MonitoredDataItem sender, DataValue prevValue, DataValue value) {
TargetNodeId = MyServer.TargetNode(MyServer.Clients.MSClient, sender.getNodeId());
if (value.getValue().getValue() != null)
{
try {
MyServer.Clients.MSClient.writeAttribute(TargetNodeId, Attributes.Value, value.getValue().getValue());
//MSClient: is writing to (MyJavaUAServer)
}
catch (ServiceException | StatusException e)
{
e.printStackTrace();
}
}
}
I deleted the three variables used before, and created a “reverse sens” subscription as you suggested.
Its sending me back notifications on data changes of the source. Is there a way to know what is the client who made the last data change on the monitored item, so i can avoid this.
thank you in advance,
Best regards
10:08, EET
December 21, 2011
The monitored items don’t have any clue what originates the data change. But, if the value is not actually changing, you should be safe in the server, even if you “re-set” the same value to the variable.
The other option is to not actually change the value in your server when you get the write request, and only change it when you get the data change back from the underlying server.
18:37, EET
October 21, 2016
Thank you Mr Jouni for your kind support, I have eliminated the return back of data change notifications, by adding a condition in the listener “MyMonitoredDataItemListener”
by comparing the “sender” current value to the current value of the node i want to write to it.
public void onDataChange(MonitoredDataItem sender, DataValue prevValue, DataValue value) {
TargetNodeId = MyServer.TargetNode(sender.getSubscription().getClient(), sender.getNodeId());
try {
TargetNodeCurrentValue = MyServer.Clients.MSClient.readAttribute(TargetNodeId, Attributes.Value);
} catch (ServiceException | StatusException e1) {
e1.printStackTrace();
}
if (value.getValue().getValue() != TargetNodeCurrentValue.getValue().getValue())
{
if (value.getValue().getValue() != null)
{
try
{
this.client.MSClient.writeAttribute(TargetNodeId, Attributes.Value, value.getValue().getValue());
}
catch (ServiceException | StatusException e)
{
e.printStackTrace();
}
}
else System.out.println(“The value is null!”);
}
}
And done the Same thing in the listener in the other side.
Thank you,
Best Regards
21:27, EET
October 21, 2016
In order to connect the chained Server i proceeded as shown in the following description:
(Prosys OPC UA Simulation Server) –> (MyJavaUAClient) –> (MyJavaUAServer) –> (Client UAExpert)
As detailed below:
(Prosys OPC UA Simulation Server) –> (Client1) (Binding) (MSClient) –> (MyJavaUAServer) –> (Client UAExpert)
(MyJavaUAClient) contains: (Client1), (MSClient) and the (Binding) method
as following:
MSClient = new UaClient(“opc.tcp://localhost:52520/OPCUA/MyServer”);
Client1 = new UaClient(“opc.tcp://localhost:53530/OPCUA/SimulationServer”);
(Binding): a method I created to bind source nodes of (Prosys OPC UA Simulation Server) to corresponding target nodes in (MyJavaUAServer) address space.
Please tell me if this correct or do i need to connect the same client (ex; Client1) to both servers instead. If yes, how?
Thanks in advance,
B/R
Most Users Ever Online: 1919
Currently Online:
23 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 737
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerleyModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1