Avatar
Please consider registering
guest
sp_LogInOut Log Insp_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 RSSsp_TopicIcon
Read commands problem
March 24, 2014
13:15, EET
Avatar
lvboque
Member
Members
Forum Posts: 8
Member Since:
March 20, 2014
sp_UserOfflineSmall Offline

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?

String browsePathString = "Objects/Server/ServerStatus/CurrentTime";
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!

March 24, 2014
13:55, EET
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1029
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

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:

DataValue data = client.readValue(Identifiers.Server_ServerStatus_CurrentTime);
Forum Timezone: Europe/Helsinki
Most Users Ever Online: 1919
Currently Online: msaala
Guest(s) 36
Currently Browsing this Page:
2 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 90
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 732
Moderators: 8
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1545
Posts: 6515
Newest Members:
mood edibles, LouieWreve, daniellabdx, janessan21, sammiebeak359, gena7127517, thorstenbouldin, Brett.Rollason, steven014223542, Roberthat
Moderators: Jouni Aro: 1029, Pyry: 1, Petri: 1, Bjarne Boström: 1045, Jimmy Ni: 26, Matti Siponen: 353, Lusetti: 0, Elias: 0
Administrators: admin: 1