How to use the node-opcua.OPCUAServer function in node-opcua

To help you get started, we’ve selected a few node-opcua examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / playground / test_server.ts View on Github external
async function main() {
    try {

        const server = new OPCUAServer({
            registerServerMethod: RegisterServerMethod.LDS
        });

        await server.initialize();

        server.on("request", (request: Request) => {

            console.log(request.constructor.name, request.requestHeader.requestHandle);

            // you can either check the instance of the request object directl
            if (request instanceof BrowseRequest) {
                console.log("BrowseRequest.requestedMaxReferencesPerNode=", request.requestedMaxReferencesPerNode);
            } else if (request instanceof ActivateSessionRequest) {
                console.log(request.toString());
            }
github node-opcua / node-opcua / packages / playground / test_server_with_method.ts View on Github external
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();
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_server_with_custom_extension_objects.ts View on Github external
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();
github node-opcua / node-opcua / documentation / weather.js View on Github external
(async () => {

    try {
      
      const server = new opcua.OPCUAServer({
         port: 4334, // the port of the listening socket of the servery
         buildInfo: {
           productName: "WeatherStation",
           buildNumber: "7658",
           buildDate: new Date(2019,6,14),
         }
      });
      
      
      await server.initialize();
      
      construct_my_address_space(server);
      
      await server.start();
      
      console.log("Server is now listening ... ( press CTRL+C to stop)");
github node-opcua / node-opcua / documentation / sample_server.js View on Github external
/*global require,setInterval,console */
const opcua = require("node-opcua");

// Let's create an instance of OPCUAServer
const 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)
    }
});

function post_initialize() {
    console.log("initialized");
    function construct_my_address_space(server) {
    
        const addressSpace = server.engine.addressSpace;
        const namespace = addressSpace.getOwnNamespace();
github node-opcua / node-opcua / documentation / server_with_method.js View on Github external
(async () => {

    try {
        const server = new opcua.OPCUAServer({
            port: 4334 // the port of the listening socket of the server
        });
        
        
        await server.initialize();
        
        const addressSpace = server.engine.addressSpace;
        const namespace = addressSpace.getOwnNamespace();
        
        const myDevice = namespace.addObject({
            organizedBy: addressSpace.rootFolder.objects,
            browseName: "MyDevice"
        });
        
        const method = namespace.addMethod(myDevice,{
github node-opcua / node-opcua / documentation / server_with_da_variables.js View on Github external
/* global console, require */
var opcua = require("node-opcua");

const server = new opcua.OPCUAServer({
    port: 4334 // the port of the listening socket of the server
});

function post_initialize() {

    const addressSpace = server.engine.addressSpace;
    const namespace = addressSpace.getOwnNamespace();

    const myDevice = namespace.addObject({
        organizedBy: addressSpace.rootFolder.objects,
        browseName: "MyDevice"
    });
    
    
    const fakeValue = 1;
github node-opcua / node-opcua / packages / node-opcua-samples / bin / mini_server.ts View on Github external
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!;
github node-opcua / node-opcua / packages / node-opcua-aggregates / bin / sample_aggregate_server.js View on Github external
const opcua = require("node-opcua");
const path = require("path");

const server = new opcua.OPCUAServer({
    certificateFile: path.join(__dirname,"../../node-opcua-samples/certificates/server_cert_2048.pem"),
    privateKey: path.join(__dirname,"../../node-opcua-samples/certificates/server_key_2018.pem")
});

const addAggregateSupport = require("..").addAggregateSupport;

server.start(function(err){

    addAggregateSupport(server.engine.addressSpace);

    console.log("err= ",err);

});
github PacktPublishing / Industrial-Internet-Application-Development / Chapter03 / opcua / sensor / index.js View on Github external
var opcua = require("node-opcua");
var min = 1;
var max = 100;

var host = new opcua.OPCUAServer({
  buildInfo: {
    buildDate: new Date(2018, 8, 8),
    buildNumber: "1234",
    productName: "productName",
  },
  port: 4334,
  resourcePath: "UA/resourcePath",
});

host.initialize(function () {
  var space = host.engine.addressSpace;

  var componentOf = space.addObject({
    browseName: "browseName",
    organizedBy: space.rootFolder.objects,
  });