Skip to content

Commit

Permalink
add AttributeIds
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Feb 12, 2014
1 parent 70afa81 commit aee56c3
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
40 changes: 38 additions & 2 deletions bin/interactive_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var rl = readline.createInterface({
completer: completer
});

var the_sesssion = {};
var the_sesssion = null;

var client = new OPCUAClient();

Expand Down Expand Up @@ -60,6 +60,15 @@ client.on("receive_response",function(message){
});


var variables = require("./../lib/opcua_node_ids").Variable;

function get_variable_nodeid(value1,value2) {
if(variables.hasOwnProperty(value1)) {
return get_variable_nodeid(variables[value1],0);
}
return ec.makeNodeId(parseInt(value1),parseInt(value2));
}


if (rl.history) {
rl.history.push("open opc.tcp://localhost:51210/UA/SampleServer");
Expand Down Expand Up @@ -138,7 +147,7 @@ rl.on('line', function (line) {
rl.pause();
nodes = [];
nodes.push( {
nodeId: ec.makeNodeId(parseInt(args[1]),parseInt(args[2])),
nodeId: get_variable_nodeid(args[1],args[2]),
includeSubtypes: true,
browseDirection: browseService.BrowseDirection.Both
});
Expand All @@ -164,6 +173,33 @@ rl.on('line', function (line) {

}
break;

case 'r':
case 'read':
if (the_sesssion) {
rl.pause();
nodes = [];
nodes.push( {
nodeId: get_variable_nodeid(args[1],args[2]),
attributeId: 13,
indexRange: null
});
console.log(treeify.asTree(nodes,true));

the_sesssion.read(nodes,function(err,dataValues) {
console.log(" done ...");
if (err ) {
console.log(err);
console.log(dataValues);
} else {
console.log(dataValues[0]);

}
});
rl.resume();
}
break;

default:
console.log('Say what? I might have heard `' + cmd.trim() + '`');
break;
Expand Down
29 changes: 28 additions & 1 deletion lib/read_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,38 @@ var TimestampsToReturn_Schema = {
};
var TimestampsToReturn = exports.TimestampsToReturn = factories.registerObject(TimestampsToReturn_Schema);


var AttributeIds = {
NodeId:1,
NodeClass:2,
BrowseName:3,
DisplayName:4,
Description:5,
WriteMask:6,
UserWriteMask:7,
IsAbstract:8,
Symmetric:9,
InverseName:10,
ContainsNoLoops:11,
EventNotifier:12,
Value:13,
DataType:14,
ValueRank:15,
ArrayDimensions:16,
AccessLevel:17,
UserAccessLevel:18,
MinimumSamplingInterval:19,
Historizing:20,
Executable:21,
UserExecutable:22
};


var ReadValueId_Schema = {
name: "ReadValueId",
fields: [
{ name: "nodeId" , fieldType: "NodeId"},
{ name: "attributeId" , fieldType: "IntegerId"},
{ name: "attributeId" , fieldType: "IntegerId"}, // see AttributeIds
{ name: "indexRange" , fieldType: "NumericRange" , defaultValue: function() { return null; }},
{ name: "dataEncoding", fieldType: "QualifiedName" , defaultValue: function() { return null; }}
]
Expand Down

0 comments on commit aee56c3

Please sign in to comment.