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: 960
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: 267

Currently Online:
18 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 124

pramanj: 86

ibrahim: 74

rocket science: 65

kapsl: 57

Sabari: 51

gjevremovic: 49

Xavier: 43

fred: 41

TimK: 41

Member Stats:

Guest Posters: 0

Members: 1749

Moderators: 15

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1323

Posts: 5649

Newest Members:

WalterFOUNC, datafastproxiespx01, LenkaLok, seoninet, justinevillanuev, namtrott5457, DonaldWibip, AlfredoEthix, andreidla, everangel7021

Moderators: Jouni Aro: 960, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 860, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 25, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 222, Lusetti: 0

Administrators: admin: 1