13:15, EET
March 20, 2014
Hello,
I am evaluating the Prosys JAVA SDK and I try to retrieve the Current Time of the My Ignition OPC Server …
Using the Prosys OPC Client, I can select the Node “Objects/Server/ServerStatus/CurrentTime” and I can see in the “attribute and reference” list the field Value (which is in fact a node) and finally the Value representing the currenttime.
However, I can”t get that currenttime value from java code …. When I reading the Attribute Value … I got this error:
com.prosysopc.ua.StatusException: Bad_AttributeIdInvalid (0x80350000) “The attribute is not supported for the specified Node.”
What’s wrong?
NodeId nodeId = Identifiers.RootFolder;
List<RelativePathElement> browsePath = new ArrayList<RelativePathElement>();
for (String s : browsePathString.split("/")) {
final QualifiedName targetName = QualifiedName.parseQualifiedName(s);
browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, targetName));
}
// The result may always contain several targets (if there are nodes with the same browseName), although normally only one is expected
BrowsePathTarget[] pathTargets;
try {
pathTargets = client.getAddressSpace().translateBrowsePathToNodeId(nodeId,browsePath.toArray(new RelativePathElement[0]));
for (BrowsePathTarget pathTarget : pathTargets) {
String targetStr = "Target: " + pathTarget.getTargetId();
if (!pathTarget.getRemainingPathIndex().equals(UnsignedInteger.MAX_VALUE))
targetStr = targetStr + " – RemainingPathIndex: "+ pathTarget.getRemainingPathIndex();
// !!!This call will generate an exception!!!
DataValue data = client.readAttribute(nodeId, Attributes.Value);
String currentTime = data.getValue().toString();
}
catch (Exception e} {
printException(e);
}
Thanks a lot for your help!
13:55, EET
December 21, 2011
You are not using the nodeId that you get from the pathTarget. Since that is an ExpandedNodeId, you need to convert it with client.getNamespaceTable().toNodeId().
But in general, it is easier to use the known NodeId (which are all defined in Identifiers) directly, so you can just call:
Most Users Ever Online: 1919
Currently Online:
64 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: 738
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6451
Newest Members:
jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettingerModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1