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
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: 1009
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: 518

Currently Online:
26 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: 680

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6260

Newest Members:

sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com, aytule

Moderators: Jouni Aro: 1009, 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