小编Eti*_*nne的帖子

node.js opc ua许多受监控的项目

我使用node-opcua module并且我想opc ua nodes通过订阅监视许多我看到的结果如下:用户在html UI中选择要监视的节点,然后单击Monitor按钮将这些nodeIds作为参数发送,然后为每个nodeid将设置订阅和.on("已更改" )并行处理所有这些项目.现在代码看起来像:

 var monitoredItem  = the_subscription.monitor({
       nodeId: opcua.resolveNodeId("ns=6;s=S71500ET200MP station_1.Master.111"),
       attributeId: 13
   },
   {
       samplingInterval: 100,
       discardOldest: true,
       queueSize: 10
   },
   opcua.read_service.TimestampsToReturn.Both
   );
   console.log("-------------------------------------");
   var nodes = [];

   monitoredItem.on("changed",function(dataValue){
      //console.log(" value = ",dataValue.value.value);
      //console.log(" sourceTimestamp = ",dataValue.sourceTimestamp.toISOString());
      //console.log(JSON.stringify(dataValue));
      var Node = {nodeId: "ns=6;s=S71500ET200MP station_1.Master.111", nodeName: "111" , nodeValue: dataValue.value.value , nodeTimestamp: dataValue.sourceTimestamp.toISOString()};
      var arrayNode = Object.keys(Node).map(function(k) { return Node[k] });
      //console.log(JSON.stringify(Node));
      nodes.push(arrayNode);

    //  console.log(nodes);
   });
},
Run Code Online (Sandbox Code Playgroud)

现在,如果我想设置新项目来监控它,只需添加许多变量MonitorItem1,..2,.3等.

怎么做更多的agile/dynamic …

javascript node.js opc-ua node-opcua

5
推荐指数
1
解决办法
1969
查看次数

node opc-ua - 如何在服务器中发现变量?

我正在学习节点opc-ua并且已经遵循了GitHub页面中为sample_server.js和simple_client.js提供的示例.

在sample_server中,我在构造服务器的地址空间时添加一个变量,例如:

//this code is in the server    
addressSpace.addVariable({
        componentOf: device,
        nodeId: "ns=1;s=variable_1",
        browseName: "MyVariable1",
        dataType: "Double",
        value: {
            get: function () {
                return new opcua.Variant({ dataType: opcua.DataType.Double, value: variable1 });
            }
        }
    });
Run Code Online (Sandbox Code Playgroud)

以下是整个服务器代码供参考:

var opcua = require("node-opcua");

var server = new opcua.OPCUAServer({
    port: 4334, // the port of the listening socket of the server
    resourcePath: "UA/MyLittleServer", // this path will be added to the endpoint resource name
    buildInfo: {
        productName: "MySampleServer1",
        buildNumber: "7658",
        buildDate: new Date(2014, 5, 2) …
Run Code Online (Sandbox Code Playgroud)

node.js opc-ua node-opcua

4
推荐指数
1
解决办法
4683
查看次数

标签 统计

node-opcua ×2

node.js ×2

opc-ua ×2

javascript ×1