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
Aggregating server, relaying subscriptions to source server
October 5, 2016
17:04, EEST
Avatar
Karri Kumara
Member
Members
Forum Posts: 3
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

I am using an aggregating server. The code is largely based on the samples provided in the package. The package itself is old (2.02 – 275) but that probably does not matter in this case.

To relay variable subscriptions on the aggregating server to the original source servers, the NodeManagerListener needs a structure for finding the source server. This structure is the clientMap.

Creating the NodeManagerListener:

private static NodeManagerListener myNodeManagerListener = new ASNodeManagerListener();

In the NodeManagerListener, creating the clientMap:

private HashMap clientMap = new HashMap(100);

In the NodeManagerListener, creating a monitored data item:

@Override
public void onCreateMonitoredDataItem(ServiceContext serviceContext,
Subscription subscription, UaNode node,
UnsignedInteger attributeId, NumericRange indexRange,
MonitoringParameters params, MonitoringFilter filter,
AggregateFilterResult filterResult) throws StatusException {
// Notification of a monitored item creation request
int ns = node.getNodeId().getNamespaceIndex();

// THIS SHOWS IF THE CLIENTMAP IS EMPTY OR NOT
System.out.println(clientMap.toString());

TargetServer ts = clientMap.get(ns);

System.out.println(“### onCreateMonitoredDataItem called for node ” + node + ” ###”);

if (ts != null) {
NodeId remoteId = ts.getNodeManager().getIdMap().get(node.getNodeId());
if (remoteId != null) {
ts.client.relaySubscription(remoteId, attributeId);
ts.client.storeMonitoredIdPair(remoteId, node.getNodeId());
if (node.supportsAttribute(Attributes.AccessLevel)) {
nodeAccessLevels.put(node, ((UaVariable)node).getAccessLevel());
((UaVariable) node).setAccessLevel(AccessLevel.READWRITE);
}
}
} else
System.out.println(” The TargetServer was null!”);
}

public void updateIdMap(TargetServer ts) {
System.out.println(” clientMap is updated!”);
int ns = ts.getNodeManager().getNamespaceIndex();
if (clientMap.get(ns) == null) {
clientMap.put(ns, ts);
}
System.out.println(clientMap.toString());
}

The updateIdMap method is supposed to update the clientMap, and the Print at the end shows that the clientMap is at least seemingly updated. However, when testing with a console client and in UA Expert, the clientMap is actually always empty.
I realize this might be more about Java itself than the SDK, but I haven’t been able to find a solution yet. Could the problem have something to do with the static keyword?

October 7, 2016
15:55, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1010
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Sorry for the late response.

I don’t think the static keyword is a real problem. The aggregating server is not a simple task in general and the mapping of namespaces is one of the main problems, since each server has several namespaces that need to be mapped to the namespaces of the aggregating server.

But it is not possible to say what goes wrong here, based on the code examples. I am afraid you will just need to debug your implementation and try to track down where the data goes and why the mapping is not working as you expect.

The solution based on a single NodeManager per source server may not be easy to get working, because of the 1 to many mapping between the namespaces per server.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
14 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:

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

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