Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
console.log(chalk.yellow(" session created"));
console.log(" sessionId : ", the_session.sessionId.toString());
client.on("backoff", (retry: number, delay: number) => {
console.log(chalk.bgWhite.yellow("backoff attempt #"), retry, " retrying in ", delay / 1000.0, " seconds");
});
client.on("start_reconnection", () => {
console.log(chalk.bgWhite.red(" !!!!!!!!!!!!!!!!!!!!!!!! Starting Reconnection !!!!!!!!!!!!!!!!!!!"));
});
// -----------------------------------------------------------------------------------------------------------
// NAMESPACE
// display namespace array
// -----------------------------------------------------------------------------------------------------------
const server_NamespaceArray_Id = makeNodeId(VariableIds.Server_NamespaceArray); // ns=0;i=2006
const dataValue = await the_session.readVariableValue(server_NamespaceArray_Id);
console.log(" --- NAMESPACE ARRAY ---");
const namespaceArray = dataValue.value.value;
for (const namespace of namespaceArray) {
console.log(" Namespace ", namespace.index, " : ", namespace);
}
console.log(" -----------------------");
// -----------------------------------------------------------------------------------------------------------
// enumerate all EVENT TYPES
// -----------------------------------------------------------------------------------------------------------
const result = getAllEventTypes(the_session);
console.log(chalk.cyan("---------------------------------------------------- All Event Types "));
console.log(treeify.asTree(result, true));
function (callback) {
const server_NamespaceArray_Id = opcua.makeNodeId(VariableIds.Server_NamespaceArray); // ns=0;i=2006
the_session.readVariableValue(server_NamespaceArray_Id, function (err, dataValue) {
console.log(" --- NAMESPACE ARRAY ---");
if (!err) {
const namespaceArray = dataValue.value.value;
for (let i = 0; i < namespaceArray.length; i++) {
console.log(" Namespace ", i, " : ", namespaceArray[i]);
}
}
console.log(" -----------------------");
callback(err);
});
},
function (callback) {
const server_NamespaceArray_Id = opcua.makeNodeId(VariableIds.Server_NamespaceArray); // ns=0;i=2006
the_session.readVariableValue(server_NamespaceArray_Id, function (err, dataValue) {
console.log(" --- NAMESPACE ARRAY ---");
if (!err) {
const namespaceArray = dataValue.value.value;
for (let i = 0; i < namespaceArray.length; i++) {
console.log(" Namespace ", i, " : ", namespaceArray[i]);
}
}
console.log(" -----------------------");
callback(err);
});
},
.argv;
const securityMode = coerceMessageSecurityMode(argv.securityMode!);
if (securityMode === MessageSecurityMode.Invalid) {
throw new Error("Invalid Security mode");
}
const securityPolicy = coerceSecurityPolicy(argv.securityPolicy!);
if (securityPolicy === SecurityPolicy.Invalid) {
throw new Error("Invalid securityPolicy");
}
const timeout = argv.timeout as number * 1000 || 20000;
const monitored_node: NodeId = coerceNodeId(argv.node as string ||
makeNodeId(VariableIds.Server_ServerStatus_CurrentTime));
console.log(chalk.cyan("securityMode = "), securityMode.toString());
console.log(chalk.cyan("securityPolicy = "), securityPolicy.toString());
console.log(chalk.cyan("timeout = "), timeout ? timeout : " Infinity ");
console.log(" monitoring node id = ", monitored_node);
const endpointUrl = argv.endpoint as string;
if (!endpointUrl) {
yargs.showHelp();
process.exit(0);
}
const discoveryUrl = argv.discovery ? argv.discovery as string : endpointUrl;
const doCrawling = !!argv.crawl;
const doHistory = !!argv.history;
function get_root_folder(callback) {
if(!rootFolder) {
rl.pause();
proxyManager.getObject(opcua.makeNodeId(opcua.ObjectIds.RootFolder),function(err,data) {
if (!err) {
rootFolder = data;
assert(rootFolder,"expecting rootFolder");
setRootNode(rootFolder);
rl.resume();
}
callback();
});
} else {
setCurrentNode(rootFolder);
callback();
}
}
async function getAllEventTypes(session: ClientSession) {
const baseNodeId = makeNodeId(ObjectTypeIds.BaseEventType);
const result = {};
await _getAllEventTypes(session, baseNodeId, result);
return result;
}