17:04, EEST
May 1, 2016
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?
15:55, EEST
December 21, 2011
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.
Most Users Ever Online: 1919
Currently Online:
18 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: 731
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
PromotionToold, HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachusModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1