How to use the node-opcua.DataType 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 / node-opcua-end2end-test / test_helpers / bin / simple_server_that_terminate_session_too_early.js View on Github external
// Add a mechanism to dismiss session early
    const obj = namespace.addObject({ 
        nodeId: "ns=1;s=MyObject",
        browseName: "MyObject" ,
        organizedBy: myDevices,
    });

    const simulateNetworkOutage = namespace.addMethod(obj, {
        browseName: "SimulateNetworkOutage",
        executable: true,
        inputArguments: [
            {
                name: "outageDuration",
                description: {text: "specifies the number of miliseconds the Outage should be"},
                dataType: opcua.DataType.UInt32
            }
        ],
        nodeId: "ns=1;s=SimulateNetworkOutage",
        outputArguments: [],
        userExecutable: true,
    });

    async function simulateNetworkOutageFunc(
        /*this: UAMethod,*/ inputArguments/*: Variant[]*/, context/*: SessionContext*/, callback/*: MethodFunctorCallback*/
    ){
        const outageDuration = inputArguments[0].value;
        console.log("Simulating Server Outage for ", outageDuration, "ms");
        await server.suspendEndPoints();
        setTimeout(async () => {
            await server.resumeEndPoints();
            console.log("Server Outage is now resolved ");
github node-opcua / node-opcua / documentation / server_with_method.js View on Github external
inputArguments:  [
                {
                    name:"nbBarks",
                    description: { text: "specifies the number of time I should bark" },
                    dataType: opcua.DataType.UInt32        
                },{
                    name:"volume",
                    description: { text: "specifies the sound volume [0 = quiet ,100 = loud]" },
                    dataType: opcua.DataType.UInt32
                }
             ],
        
            outputArguments: [{
                 name:"Barks",
                 description:{ text: "the generated barks" },
                 dataType: opcua.DataType.String ,
                 valueRank: 1
            }]
        });
        
        // optionally, we can adjust userAccessLevel attribute 
        method.outputArguments.userAccessLevel = opcua.makeAccessLevelFlag("CurrentRead");
        method.inputArguments.userAccessLevel = opcua.makeAccessLevelFlag("CurrentRead");
        
        
        method.bindMethod((inputArguments,context,callback) => {
        
            const nbBarks = inputArguments[0].value;
            const volume =  inputArguments[1].value;
        
            console.log("Hello World ! I will bark ",nbBarks," times");
            console.log("the requested volume is ",volume,"");
github node-opcua / node-opcua / packages / node-opcua-samples / bin / interactive_client.js View on Github external
#!/usr/bin/env node
/* eslint no-process-exit: 0 */
"use strict";
const chalk = require("chalk");
const readline = require("readline");
const treeify = require("treeify");
const sprintf = require("sprintf-js").sprintf;
const util = require("util");
const fs = require("fs");
const path = require("path");
const _ = require("underscore");

const opcua = require("node-opcua");
const UAProxyManager = opcua.UAProxyManager;
const DataType = opcua.DataType;



const utils = opcua.utils;

const assert = require("node-opcua-assert").assert;

console.log(" Version ", opcua.version);

const sessionTimeout = 2 * 60 * 1000; // 2 minutes

const client = opcua.OPCUAClient.create({
    requestedSessionTimeout: sessionTimeout,
    keepSessionAlive: true
});
github node-opcua / node-opcua / documentation / server_with_method.js View on Github external
const namespace = addressSpace.getOwnNamespace();
        
        const myDevice = namespace.addObject({
            organizedBy: addressSpace.rootFolder.objects,
            browseName: "MyDevice"
        });
        
        const method = namespace.addMethod(myDevice,{
        
            browseName: "Bark",
        
            inputArguments:  [
                {
                    name:"nbBarks",
                    description: { text: "specifies the number of time I should bark" },
                    dataType: opcua.DataType.UInt32        
                },{
                    name:"volume",
                    description: { text: "specifies the sound volume [0 = quiet ,100 = loud]" },
                    dataType: opcua.DataType.UInt32
                }
             ],
        
            outputArguments: [{
                 name:"Barks",
                 description:{ text: "the generated barks" },
                 dataType: opcua.DataType.String ,
                 valueRank: 1
            }]
        });
        
        // optionally, we can adjust userAccessLevel attribute 
github node-opcua / node-opcua / packages / node-opcua-end2end-test / test_helpers / hvac_system.js View on Github external
"use strict";

const chalk = require("chalk");
const _ = require("underscore");
const assert = require("node-opcua-assert").assert;
const opcua = require("node-opcua");
const StatusCodes = opcua.StatusCodes;
const DataType = opcua.DataType;
const standardUnits = opcua.standardUnits;

const doDebug = false;

/**
 * @method createHVACSystem
 *
 * @startuml
 *
 * class HVACModuleType {
 * }
 * HVACModuleType -up-> ObjectType
 * HVACModuleType o-down-> ExteriorTemperatureSensor     << (P,#F0F0FF)TemperatureSensorType >>
 * HVACModuleType o-down-> InteriorTemperatureSensor     << (P,#F0F0FF)TemperatureSensorType >>
 * HVACModuleType o-down-> TargetTemperature     << (P,#F0F0FF)TemperatureSensorType >>
 * HVACModuleType o-down-> HVACEnabledEventType  << (E,#00F0FF)BaseEventType >>
github node-opcua / node-opcua / packages / node-opcua-end2end-test / test_helpers / build_server_with_temperature_device.js View on Github external
"use strict";
const _ = require("underscore");
const assert = require("node-opcua-assert").assert;
require("should");

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

const OPCUAServer = opcua.OPCUAServer;
const StatusCodes = opcua.StatusCodes;
const Variant = opcua.Variant;
const DataType = opcua.DataType;
const DataValue = opcua.DataValue;
const is_valid_endpointUrl = opcua.is_valid_endpointUrl;

const debugLog = require("node-opcua-debug").make_debugLog(__filename);

const address_space_for_conformance_testing = require("node-opcua-address-space-for-conformance-testing");
const build_address_space_for_conformance_testing = address_space_for_conformance_testing.build_address_space_for_conformance_testing;




/**
 * add a fake analog data item for testing
 * @method addTestUAAnalogItem
 *
 * @param parentNode
github node-opcua / node-opcua / documentation / weather.js View on Github external
            value: {  get: function () { return extract_value(opcua.DataType.Double, city_name,"temperature"); } }
        });
github PacktPublishing / Industrial-Internet-Application-Development / Chapter03 / opcua / hub / index.js View on Github external
function (cb) {
      session.writeSingleNode("ns=1;s=Variable1", new opcua.Variant({
        dataType: opcua.DataType.Double,
        value: 100
      }), function (err) {
        cb(err);
      });
    },
github node-opcua / node-opcua / documentation / server_with_da_variables.js View on Github external
          value: { get: function(){return new opcua.Variant({dataType: opcua.DataType.Double , value: fakeValue}); } }
    });