• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript node-opcua.OPCUAServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中node-opcua.OPCUAServer的典型用法代码示例。如果您正苦于以下问题:TypeScript OPCUAServer类的具体用法?TypeScript OPCUAServer怎么用?TypeScript OPCUAServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了OPCUAServer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: before

    before(done => {
        port += 1;

        const options = { port };
        server = new OPCUAServer(options);

        server.on("post_initialize", () => {
            const addressSpace = server.engine.addressSpace!;

            const group = addressSpace.getOwnNamespace().addObject({
                browseName: "Group",
                organizedBy: addressSpace.rootFolder.objects
            });

            for (let i = 0; i < 27; i++) {
                addressSpace.getOwnNamespace().addObject({
                    browseName: "Object" + i,
                    organizedBy: group
                });
            }
            groupNodeId = group.nodeId;
        });
        server.start((err?: Error) => {
            if (err) {
                return done(err);
            }
            endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl;
            if (err) {
                return done(err);
            }
            done();
        });
    });
开发者ID:node-opcua,项目名称:node-opcua,代码行数:33,代码来源:test_e2e_#519_Nodecrawler_is_not_browsing_some_nodes.ts


示例2: main

async function main() {

    try {

        const server = new OPCUAServer({
            nodeset_filename: [
                nodesets.standard_nodeset_file
            ]
        });

        await server.initialize();

        // post-initialize
        const addressSpace = server.engine.addressSpace!;

        const object = installObjectWithMethod(addressSpace);

        console.log("object = ", object.toString());
        await callMethodFromServer(addressSpace, object.nodeId);

        await server.start();
        console.log(" Server started ", server.endpoints[0].endpointDescriptions()[0].endpointUrl);
    } catch (err) {
        console.log(" Error: ", err.message);
        console.log(err.stack);
    }
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:27,代码来源:test_server_with_method.ts


示例3: startServer

// openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout example.pem \
//        -outform der -out example.der -subj "/CN=example.com" -days 3650
async function startServer(): Promise<OPCUAServer> {

    server = new OPCUAServer({
        maxAllowedSessionNumber: 10,
        nodeset_filename: empty_nodeset_filename,
        port,
    });
    await server.start();
    endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl!;
    return server;
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:13,代码来源:test_e2e_session_with_X509IdentityToken.ts


示例4: main

async function main() {

    const server = new OPCUAServer(server_options);

    server.on("post_initialize", () => {
        /* empty */
    });

    console.log(chalk.yellow("  server PID          :"), process.pid);
    console.log(chalk.yellow("  silent              :"), argv.silent);

    await server.start();

    const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl!;
    console.log(chalk.yellow("  server on port      :"), chalk.cyan(server.endpoints[0].port.toString()));
    console.log(chalk.yellow("  endpointUrl         :"), chalk.cyan(endpointUrl));

    console.log(chalk.yellow("\n  server now waiting for connections. CTRL+C to stop"));

    if (argv.silent) {
        console.log("silent");
        console.log = (...args: [any?, ... any[]]) => {
            /* silent */
        };
    }

    server.on("create_session", (session: ServerSession) => {
        console.log(" SESSION CREATED");
        console.log(chalk.cyan("    client application URI: "), session.clientDescription!.applicationUri);
        console.log(chalk.cyan("        client product URI: "), session.clientDescription!.productUri);
        console.log(chalk.cyan("   client application name: "), session.clientDescription!.applicationName.toString());
        console.log(chalk.cyan("   client application type: "), session.clientDescription!.applicationType.toString());
        console.log(chalk.cyan("              session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
        console.log(chalk.cyan("           session timeout: "), session.sessionTimeout);
        console.log(chalk.cyan("                session id: "), session.nodeId);
    });

    server.on("session_closed", (session: ServerSession, reason: string) => {
        console.log(" SESSION CLOSED :", reason);
        console.log(chalk.cyan("              session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
    });

    process.on("SIGINT", async () => {
        // only work on linux apparently
        console.error(chalk.red.bold(" Received server interruption from user "));
        console.error(chalk.red.bold(" shutting down ..."));
        await server.shutdown(1000);
        console.error(chalk.red.bold(" shot down ..."));
        process.exit(1);
    });

}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:52,代码来源:simple_secure_server.ts


示例5: main

async function main() {

    const server = new OPCUAServer(server_options);

    console.log(chalk.yellow("  server PID          :"), process.pid);

    server.on("post_initialize", () => {

        const addressSpace = server.engine.addressSpace!;

        // to do: expose new nodeid here
        const ns = addressSpace.getNamespaceIndex("http://yourorganisation.org/my_data_type/");
        const myStructureType = addressSpace.findVariableType("MyStructureType", ns);
        if (!myStructureType) {
           console.log(" ns = ", ns, "cannot find MyStructureDataType ");
           return;
        }

        const namespace = addressSpace.getOwnNamespace();
        const someObject =  namespace.addObject({
            browseName: "SomeObject",
            organizedBy: addressSpace.rootFolder.objects
        });

        myStructureType.instantiate({
            browseName: "MyVar",
            componentOf: someObject
        });

    });

    try {
        await server.start();
    } catch (err) {
        console.log(" Server failed to start ... exiting");
        process.exit(-3);
    }

    const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl!;

    console.log(chalk.yellow("  server on port      :"), chalk.cyan(server.endpoints[0].port.toString()));
    console.log(chalk.yellow("  endpointUrl         :"), chalk.cyan(endpointUrl));
    console.log(chalk.yellow("\n  server now waiting for connections. CTRL+C to stop"));

    process.on("SIGINT", async () => {
        // only work on linux apparently
        await server.shutdown(1000);
        console.log(chalk.red.bold(" shutting down completed "));
        process.exit(-1);
    });
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:51,代码来源:simple_server_with_custom_extension_objects.ts


示例6: main

async function main() {

    const tmpFolder = path.join(__dirname, "../certificates/myApp");

    const applicationGroup = new CertificateManager({
        location: tmpFolder
    });
    await applicationGroup.initialize();

    const server = new OPCUAServer(server_options);

    console.log(" Configuration rootdir =  ", server.serverCertificateManager.rootDir);

    console.log(chalk.yellow("  server PID          :"), process.pid);

    server.on("post_initialize", () => {

        const addressSpace = server.engine.addressSpace!;
        // to do: expose new nodeid here
        const ns = addressSpace.getNamespaceIndex("http://yourorganisation.org/my_data_type/");

        installPushCertificateManagement(addressSpace, {
            applicationGroup: server.serverCertificateManager,
            userTokenGroup: server.userCertificateManager
        });

        console.log("Certificate rejected folder ", server.serverCertificateManager.rejectedFolder);

    });

    try {
        await server.start();
    } catch (err) {
        console.log(" Server failed to start ... exiting");
        process.exit(-3);
    }

    const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl!;

    console.log(chalk.yellow("  server on port      :"), chalk.cyan(server.endpoints[0].port.toString()));
    console.log(chalk.yellow("  endpointUrl         :"), chalk.cyan(endpointUrl));
    console.log(chalk.yellow("\n  server now waiting for connections. CTRL+C to stop"));

    process.on("SIGINT", async () => {
        // only work on linux apparently
        await server.shutdown(1000);
        console.log(chalk.red.bold(" shutting down completed "));
        process.exit(-1);
    });
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:50,代码来源:server_with_push_certificate.ts


示例7: startMultiHeadServer

async function startMultiHeadServer() {

    const server_options: OPCUAServerOptions = {
        isAuditing: false,
        nodeset_filename: [
            nodesets.standard
        ],
        serverInfo: {
            applicationName: { text: "Mini NodeOPCUA Server", locale: "en" },
            applicationUri: makeApplicationUrn("%FQDN%", "MiniNodeOPCUA-Server"),
            productUri: "Mini NodeOPCUA-Server"
        },

        // default endpoint
        allowAnonymous: false,
        alternateHostname: ["MyHostname1"],
        port: port1,
        securityModes: [MessageSecurityMode.None],
        securityPolicies: [SecurityPolicy.None],

        // alternate endpoint
        alternateEndpoints: [
            {
                allowAnonymous: false,
                alternateHostname: ["1.2.3.4"],
                port: port2,
                securityModes: [MessageSecurityMode.SignAndEncrypt],
                securityPolicies: [SecurityPolicy.Basic256Sha256]
            }
        ]
    };

    server = new OPCUAServer(server_options);

    server.on("post_initialize", () => {/**/
    });

    console.log(chalk.yellow("  server PID          :"), process.pid);

    try {
        await server.start();
    } catch (err) {
        console.log(" Server failed to start ... exiting => err:", err.message);
        return;
    }

}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:47,代码来源:test_server_with_alternate_names.ts


示例8: startServer

async function startServer() {

    const server_options: OPCUAServerOptions = {

        port: port1,

        nodeset_filename: [
            nodesets.standard
        ],

        serverInfo: {
            applicationUri: makeApplicationUrn("%FQDN%", "MiniNodeOPCUA-Server"),
            productUri: "Mini NodeOPCUA-Server",

            applicationName: { text: "Mini NodeOPCUA Server", locale: "en" }

        },

        alternateHostname: ["MyHostname1", "MyHostname2"],

        isAuditing: false
    };

    server = new OPCUAServer(server_options);

    server.on("post_initialize", () => {/**/
    });

    console.log(chalk.yellow("  server PID          :"), process.pid);

    try {
        await server.start();
    } catch (err) {
        console.log(" Server failed to start ... exiting => err:", err.message);
        return;
    }

    for (const endpoint of server.endpoints) {
        const endpointUrl = endpoint.endpointDescriptions()[0].endpointUrl!;
        console.log(chalk.yellow("  server on port1      :"), endpoint.port.toString());
        console.log(chalk.yellow("  endpointUrl1         :"), chalk.cyan(endpointUrl));
    }

}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:44,代码来源:test_server_with_alternate_names.ts


示例9: main

async function main() {
    process.title = "Node OPCUA Server on port : " + server_options.port;

    const server = new OPCUAServer(server_options);


    server.on("post_initialize", () => {/**/
    });

    console.log(chalk.yellow("  server PID          :"), process.pid);

    try {
        await server.start();
    } catch (err) {
        console.log(" Server failed to start ... exiting");
        process.exit(-3);
    }

    const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl!;

    console.log(chalk.yellow("  server on port      :"), server.endpoints[0].port.toString());
    console.log(chalk.yellow("  endpointUrl         :"), chalk.cyan(endpointUrl));
    console.log(chalk.yellow("\n  server now waiting for connections. CTRL+C to stop"));

    server.on("create_session", (session: ServerSession) => {
        console.log(" SESSION CREATED");
        console.log(chalk.cyan("    client application URI: "), session.clientDescription!.applicationUri);
        console.log(chalk.cyan("        client product URI: "), session.clientDescription!.productUri);
        console.log(chalk.cyan("   client application name: "), session.clientDescription!.applicationName.toString());
        console.log(chalk.cyan("   client application type: "), session.clientDescription!.applicationType.toString());
        console.log(chalk.cyan("              session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
        console.log(chalk.cyan("           session timeout: "), session.sessionTimeout);
        console.log(chalk.cyan("                session id: "), session.nodeId);
    });

    server.on("session_closed", (session: ServerSession, reason: string) => {
        console.log(" SESSION CLOSED :", reason);
        console.log(chalk.cyan("              session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
    });
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:40,代码来源:mini_server.ts


示例10: stopServer

async function stopServer() {
    await server.shutdown();
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:3,代码来源:test_server_with_alternate_names.ts



注:本文中的node-opcua.OPCUAServer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript node-opcua-address-space.AddressSpace类代码示例发布时间:2022-05-25
下一篇:
TypeScript node-opcua.OPCUAClient类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap