小编bul*_*lho的帖子

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 ×1

node.js ×1

opc-ua ×1