APIs

Show:

Constructor

ClientSession

(
  • conditionId
  • eventId
  • comment
  • callback
)

Parameters:

  • conditionId NodeId
  • eventId Buffer
  • comment String | LocalizedText
  • callback Function
    • err Error | Null

Item Index

Methods

Properties

Methods

browse

(
  • nodeToBrowse
  • callback
  • nodesToBrowse
  • callback
  • nodesToBrowse
  • nodeToBrowse
)
Promise async

Parameters:

  • nodeToBrowse String | BrowseDescription
  • callback Function
  • nodesToBrowse Array
  • callback Function
    • Error | Null
    • Array

      an array containing the BrowseResult of each BrowseDescription.

  • nodesToBrowse Array
  • nodeToBrowse String | BrowseDescription

Returns:

Promise:

Example:

session.browse("RootFolder",function(err,browseResult) {
                      if(err) return callback(err);
                      console.log(browseResult.toString());
                      callback();
                    } );
                    
const browseDescription = {
                       nodeId: "ObjectsFolder",
                       referenceTypeId: "Organizes",
                       browseDirection: BrowseDirection.Inverse,
                       includeSubtypes: true,
                       nodeClassMask: 0,
                       resultMask: 63
                    }
                    session.browse(browseDescription,function(err, browseResult) {
                       if(err) return callback(err);
                       console.log(browseResult.toString());
                       callback();
                    });
                    
session.browse([ "RootFolder", "ObjectsFolder"],function(err, browseResults) {
                          assert(browseResults.length === 2);
                    });
                    
 const browseDescriptions = [
                       {
                           nodeId: "ObjectsFolder",
                           referenceTypeId: "Organizes",
                           browseDirection: BrowseDirection.Inverse,
                           includeSubtypes: true,
                           nodeClassMask: 0,
                           resultMask: 63
                       },
                       // {...}
                     ]
                     session.browse(browseDescriptions,function(err, browseResults) {
                    
                     });
                    

call

(
  • methodToCall
  • callback
  • methodsToCall
  • callback
)

Parameters:

Example:

: const methodToCall = { objectId: "ns=2;i=12", methodId: "ns=2;i=13", inputArguments: [ new Variant({...}), new Variant({...}), ] } session.call(methodToCall,function(err,callResult) { if (!err) { console.log(" statusCode = ",callResult.statusCode); console.log(" inputArgumentResults[0] = ",callResult.inputArgumentResults[0].toString()); console.log(" inputArgumentResults[1] = ",callResult.inputArgumentResults[1].toString()); console.log(" outputArgument[0] = ",callResult.outputArgument[0].toString()); // array of variant } });

: const methodsToCall = [ { objectId: "ns=2;i=12", methodId: "ns=2;i=13", inputArguments: [ new Variant({...}), new Variant({...}), ] }]; session.call(methodsToCall,function(err,callResutls) { if (!err) { const callResult = callResutls[0]; console.log(" statusCode = ",rep.statusCode); console.log(" inputArgumentResults[0] = ",callResult.inputArgumentResults[0].toString()); console.log(" inputArgumentResults[1] = ",callResult.inputArgumentResults[1].toString()); console.log(" outputArgument[0] = ",callResult.outputArgument[0].toString()); // array of variant } });

close

(
  • [deleteSubscription=true]
  • callback
)
async

Parameters:

  • [deleteSubscription=true] Boolean optional
  • callback Function

confirmCondition from Spec 1.03 Part 9 : page 27 The Confirm Method is used to confirm an Event Notifications for a Condition instance state where ConfirmedState is FALSE. Normally, the NodeId of the object instance as the ObjectId is passed to the Call Service. However, some Servers do not expose Condition instances in the AddressSpace. Therefore all Servers shall also allow Clients to call the Confirm Method by specifying ConditionId as the ObjectId. The Method cannot be called with an ObjectId of the AcknowledgeableConditionType Node.

(
  • conditionId
  • eventId
  • comment
  • callback
)

Parameters:

  • conditionId Object
  • eventId Object
  • comment Object
  • callback Object

createMonitoredItems

(
  • options
  • callback
)
async

Parameters:

createSubscription

(
  • options
  • callback
)
async

Parameters:

  • options CreateSubscriptionRequest
    • requestedPublishingInterval Duration
    • requestedLifetimeCount Counter
    • requestedMaxKeepAliveCount Counter
    • maxNotificationsPerPublish Counter
    • publishingEnabled Boolean
    • priority Byte
  • callback Function

Example:

:

session.createSubscription(request,function(err,response) {} );
                    

deleteMonitoredItems

(
  • options
  • callback
)
async

Parameters:

deleteSubscriptions

(
  • options
  • callback
)
async

Parameters:

Example:

:

session.deleteSubscriptions(request,function(err,response) {} );

findMethodId

(
  • nodeId
  • methodName
  • callback
)

Parameters:

  • nodeId Object
  • methodName Object
  • callback Object

getArgumentDefinition

(
  • methodId
  • callback
  • [object}
  • methodId
)
Promise async

Parameters:

  • methodId NodeId
  • callback Function
    • err Error | Null
    • args.inputArguments Argument<>
    • args.outputArguments Argument<>
  • [object} Object

    callback.args

  • methodId NodeId

Returns:

Promise:

{inputArguments: .., outputArguments: ...}

getBuiltInDataType retrieve the built-in DataType of a Variable, from its DataType attribute useful to determine which DataType to use when constructing a Variant

(
  • nodeId
  • callback
)
async

Parameters:

  • nodeId NodeId

    the node id of the variable to query

  • callback Function

    the callback function

    • err
    • result DataType

Example:

const session = ...; // ClientSession
                    const nodeId = opcua.VariableIds.Server_ServerStatus_CurrentTime;
                    session.getBuildInDataType(nodeId,function(err,dataType) {
                       assert(dataType === opcua.DataType.DateTime);
                    });
                    // or
                    nodeId = opcua.coerceNodeId("ns=2;s=Scalar_Static_ImagePNG");
                    session.getBuildInDataType(nodeId,function(err,dataType) {
                       assert(dataType === opcua.DataType.ByteString);
                    });
                    

getMonitoredItems

(
  • subscriptionId
  • callback
)

Parameters:

  • subscriptionId UInt32

    the subscription Id to return

  • callback Function
    • err Error
    • monitoredItems

      the monitored Items

    • monitoredItems

      the monitored Items

getPublishEngine

() ClientSidePublishEngine

Returns:

ClientSidePublishEngine:

hasBeenClosed

() Boolean

Returns:

Boolean:

modifyMonitoredItems

(
  • options
  • callback
)
async

Parameters:

modifySubscription

(
  • options
  • callback
)
async

Parameters:

publish

(
  • options
  • callback
)
async

Parameters:

queryFirst

(
  • queryFirstRequest
  • callback
)

Parameters:

read_form4

(
  • nodeToRead
  • [maxAge]
  • callback
  • nodesToRead
  • [maxAge]
  • callback
  • nodeToRead
  • [maxAge]
  • nodesToRead
  • [maxAge]
)
Promise> async

Parameters:

  • nodeToRead ReadValueId
  • [maxAge] Number optional
  • callback Function
    • the callback function
    • err Error | Null
      • the error or null if the transaction was OK}
    • dataValue DataValue
  • nodesToRead Array
    • an array of nodeId to read or a ReadValueId
  • [maxAge] Number optional
  • callback Function
    • the callback function
    • Error | Null
      • the error or null if the transaction was OK}
    • Array
  • nodeToRead ReadValueId
  • [maxAge] Number optional
  • nodesToRead Array
  • [maxAge] Number optional

Returns:

Promise>:

Example:

`javascript
                    `
                    

form1: reading a single node

  const nodeToRead = {
                               nodeId:      "ns=2;s=Furnace_1.Temperature",
                               attributeId: AttributeIds.BrowseName
                      };
                    
                      session.read(nodeToRead,function(err,dataValue) {
                          if (!err) {
                             console.log(dataValue.toString());
                          }
                      });
                    
const nodesToRead = [
                         {
                              nodeId:      "ns=2;s=Furnace_1.Temperature",
                              attributeId: AttributeIds.BrowseName
                         }
                    ];
                    session.read(nodesToRead,function(err,dataValues) {
                      if (!err) {
                        dataValues.forEach(dataValue=>console.log(dataValue.toString()));
                      }
                    });
                    

readAllAttributes

(
  • nodes
  • callback
)
async

Parameters:

  • nodes NodeId | NodeId[]
    • nodeId to read or an array of nodeId to read
  • callback Function
    • the callback function
    • err Error | Null
      • the error or null if the transaction was OK
    • data

      a json object with the node attributes

      • statusCode StatusCodes
      • nodeId NodeId
      • <attribute>

Example:

session.readAllAttributes("ns=2;s=Furnace_1.Temperature",function(err,data) {
                       if(data.statusCode === StatusCode.Good) {
                          console.log(" nodeId      = ",data.nodeId.toString());
                          console.log(" browseName  = ",data.browseName.toString());
                          console.log(" description = ",data.description.toString());
                          console.log(" value       = ",data.value.toString()));
                    
                       }
                    });
                    

readHistoryValue

(
  • nodes
  • start
  • end
  • callback
)
async

Parameters:

  • nodes ReadValueId[]
    • the read value id
  • start Object
    • the starttime in UTC format
  • end Object
    • the endtime in UTC format
  • callback Function
    • the callback function
    • err Object | Null

      the error if write has failed or null if OK

    • results DataValue[]
      • an array of dataValue each read

Example:

session.readHistoryValue("ns=5;s=Simulation Examples.Functions.Sine1","2015-06-10T09:00:00.000Z","2015-06-10T09:01:00.000Z",function(err,dataValues) {} );

readVariableValue

(
  • node
  • callback
  • nodes
  • callback
  • node
  • nodes
)
Promise> async

Parameters:

  • node NodeId
    • the nodeId of the value to read
  • callback Function
    • the callback function
    • err Error | Null
      • the error if write has failed or null if OK
    • dataValue DataValue
      • the dataValue
  • nodes Array
    • an array of node to Read
  • callback Function
    • the callback function
    • Error | Null
      • the error if write has failed or null if OK
    • Array
      • an array of dataValue each read
  • node NodeId | String
    • the nodeId of the UAVariable to read
  • nodes Array
    • an array of node to Read

Returns:

Promise>:

Example:

session.readVariableValue("ns=2;s=Furnace_1.Temperature",function(err,dataValue) {
                       if(err) { return callback(err); }
                       if (dataValue.statusCode === opcua.StatusCodes.Good) {
                       }
                       console.log(dataValue.toString());
                       callback();
                    });

session.readVariableValue(["ns=0;i=2257","ns=0;i=2258"],function(err,dataValues) { if (!err) { console.log(dataValues[0].toString()); console.log(dataValues[1].toString()); } });

const dataValue = await session.readVariableValue("ns=1;s=Temperature");
const dataValues = await session.readVariableValue(["ns=1;s=Temperature","ns=1;s=Pressure"]);

republish

(
  • options
  • callback
)
async

Parameters:

setPublishingMode

(
  • publishingEnabled
  • subscriptionIds
  • callback
)
async

Parameters:

  • publishingEnabled Boolean
  • subscriptionIds Array
  • callback Function
    • err Error | Null
      • the Error if the async method has failed

transferSubscriptions

(
  • options
  • callback
)
async

Parameters:

translateBrowsePath

(
  • browsePath
  • callback
)
async

Parameters:

write

(
  • nodesToWrite
  • callback
  • nodeToWrite
  • callback
  • nodeToWrite
  • nodesToWrite
)
Promise> async

Parameters:

  • nodesToWrite WriteValue[]
    • the array of value to write. One or more elements.
  • callback Function
    • the callback function
    • err Object | Null

      the error if write has failed or null if OK

    • statusCodes StatusCode[]
      • an array of status code of each write
  • nodeToWrite WriteValue
    • the value to write
  • callback Function
    • the callback function
    • Object | Null

      the error if write has failed or null if OK

    • StatusCodes
      • the status code of the write
  • nodeToWrite WriteValue
    • the value to write
  • nodesToWrite Array
    • the value to write

Returns:

Promise>:

Example:

const nodesToWrite = [
                     {
                          nodeId: "ns=1;s=SetPoint1",
                          attributeId: opcua.AttributeIds.Value,
                          value: {
                             statusCode: Good,
                             value: {
                               dataType: opcua.DataType.Double,
                               value: 100.0
                             }
                          }
                     },
                     {
                          nodeId: "ns=1;s=SetPoint2",
                          attributeIds opcua.AttributeIds.Value,
                          value: {
                             statusCode: Good,
                             value: {
                               dataType: opcua.DataType.Double,
                               value: 45.0
                             }
                          }
                     }
                     ];
                     session.write(nodesToWrite,function (err,statusCodes) {
                       if(err) { return callback(err);}
                       //
                     });
const nodeToWrite = {
                          nodeId: "ns=1;s=SetPoint",
                          attributeId: opcua.AttributeIds.Value,
                          value: {
                             statusCode: Good,
                             value: {
                               dataType: opcua.DataType.Double,
                               value: 100.0
                             }
                          }
                     };
                     session.write(nodeToWrite,function (err,statusCode) {
                       if(err) { return callback(err);}
                       //
                     });

session.write(nodeToWrite).then(function(statusCode) { });

const statusCode = await session.write(nodeToWrite);

session.write(nodesToWrite).then(function(statusCodes) { });

const statusCodes = await session.write(nodesToWrite);

writeSingleNode

(
  • nodeId
  • value
  • callback
  • nodeId
  • value
)
Promise async

Parameters:

  • nodeId NodeId
    • the node id of the node to write
  • value Variant
    • the value to write
  • callback Function
    • err Object | Null

      the error if write has failed or null if OK

    • statusCode StatusCode
      • the status code of the write
  • nodeId NodeId
    • the node id of the node to write
  • value Variant
    • the value to write

Returns:

Promise:
  • the status code of the write

Properties

endpoint

EndpointDescription

the endpoint on which this session is operating

Events

keepalive_failure

raised when a keep-alive request has failed on the session, may be the session has timeout unexpectidaly on the server side, may be the connection is broken.

session_closed

send when the session has been closed by the server ( probably due to inactivity and timeout)