Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Write value in a chained UA Server-Clients
February 21, 2017
17:31, EET
Avatar
hbbend
Member
Members
Forum Posts: 9
Member Since:
October 21, 2016
sp_UserOfflineSmall Offline

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

February 21, 2017
23:13, EET
Avatar
hbbend
Member
Members
Forum Posts: 9
Member Since:
October 21, 2016
sp_UserOfflineSmall Offline

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

February 22, 2017
15:59, EET
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

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?

March 2, 2017
17:13, EET
Avatar
hbbend
Member
Members
Forum Posts: 9
Member Since:
October 21, 2016
sp_UserOfflineSmall Offline

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

March 3, 2017
10:08, EET
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1010
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

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.

March 6, 2017
18:37, EET
Avatar
hbbend
Member
Members
Forum Posts: 9
Member Since:
October 21, 2016
sp_UserOfflineSmall Offline

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

March 16, 2017
21:27, EET
Avatar
hbbend
Member
Members
Forum Posts: 9
Member Since:
October 21, 2016
sp_UserOfflineSmall Offline

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

March 17, 2017
14:55, EET
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1010
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

You can use one UaClient instance to connect to one server only. So this looks correct (if I could follow your design properly).

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online: Manfred Hausmann
16 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 683

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

Reallywo, digitechroshni, LouieWreve, Kickbiche, karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1