Last active
August 10, 2019 09:59
-
-
Save erossignon/84e9ec090909da037401d4c29b51b85b to your computer and use it in GitHub Desktop.
Revisions
-
erossignon revised this gist
Aug 10, 2019 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ { "name": "655", "version": "1.0.0", "description": "", "main": "issue65.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "async": "^3.1.0", "node-opcua": "^2.1.2" } } -
erossignon renamed this gist
Aug 10, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
erossignon revised this gist
Aug 10, 2019 . 1 changed file with 3560 additions and 0 deletions.There are no files selected for viewing
-
erossignon renamed this gist
Aug 10, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
erossignon created this gist
Aug 10, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,91 @@ const { OPCUAClient , NodeCrawler} = require("node-opcua"); const async = require("async"); const util = require("util"); const client = OPCUAClient.create({ endpoint_must_exist: false }); // UA Automation Ansi Demo Server const endpointUrl = "opc.tcp://localhost:48020"; const nodeToExplore = "ns=4;s=Demo.Massfolder_Dynamic"; const tree = { } function main(callback) { async.series([ function (cb3) { client.connect(endpointUrl, function (err) { if (err) { console.log(" cannot connect to endpoint :", endpointUrl); } else { console.log("connected !"); } cb3(err); }); }, function (cb3) { client.createSession(function (err, session) { if (err) { console.log("Failed to Create the Browse Session"); } else { console.log("Browse Session Creates Session Successfully!"); the_session = session; } cb3(err); }); }, function (cb3) { var crawler = new NodeCrawler(the_session); var nodeId = nodeToExplore console.log("Browsing Data in the server from "+ nodeToExplore.toString()); crawler.read(nodeId, function (err, obj) { if (err) { console.log("Failed to Read Data"); } else { console.log("Data read from PLC is Successful"); } cb3(err); }); crawler.on("browsed", function (element) { const parentNode = (element.parent && element.parent.$node )? element.parent.$node : tree; const key = element.browseName.toString() + " " + element.nodeId.toString(); // xxelement.nodeId.toString(); if (!parentNode[key]) { parentNode[key] = { }; } const n = parentNode[key]; element.$node = n; console.log("element name:" + element.browseName.toString()); }); } ], function (err) { console.log(util.inspect(tree,{ depth: 100})); if (err) { console.log("Failure in opcua browsing!", err); callback(err) } else { console.log("No Error :)"); callback(); } console.log("disconnected"); client.disconnect(function () { }); }); } main((err)=>{ console.log("done",err); });