How to use node-opcua-types - 10 common examples

To help you get started, we’ve selected a few node-opcua-types 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-server / source / server_engine.ts View on Github external
dataType: variantDataType,
              value
            });
          },
          set: null // read only
        });
      }

      bindStandardScalar(VariableIds.Server_EstimatedReturnTime,
        DataType.DateTime, () => minOPCUADate);

      // TimeZoneDataType
      const timeZoneDataType = addressSpace.findDataType(resolveNodeId(DataTypeIds.TimeZoneDataType))!;
      // xx console.log(timeZoneDataType.toString());

      const timeZone = new TimeZoneDataType({
        daylightSavingInOffset: /* boolean*/ false,
        offset: /* int16 */ 0
      });
      bindStandardScalar(VariableIds.Server_LocalTime,
        DataType.ExtensionObject, () => {
          return timeZone;
        });

      bindStandardScalar(VariableIds.Server_ServiceLevel,
        DataType.Byte, () => {
          return 255;
        });

      bindStandardScalar(VariableIds.Server_Auditing,
        DataType.Boolean, () => {
          return engine.isAuditing;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.ts View on Github external
function coerceAxisScale(value: any) {
            const ret = AxisScaleEnumeration[value];
            assert(!utils.isNullOrUndefined(ret));
            return ret;
        }

        variable.setValueFromSource(options.value as Variant, StatusCodes.Good);

        variable.euRange.setValueFromSource(new Variant({
            dataType: DataType.ExtensionObject, value: new Range(options.engineeringUnitsRange)
        }));

        if (options.hasOwnProperty("instrumentRange")) {
            variable.instrumentRange.setValueFromSource(new Variant({
                dataType: DataType.ExtensionObject, value: new Range(options.instrumentRange)
            }));
        }

        variable.title.setValueFromSource(new Variant({
            dataType: DataType.LocalizedText, value: coerceLocalizedText(options.title || "")
        }));

        // Linear/Log/Ln
        variable.axisScaleType.setValueFromSource(new Variant({
            dataType: DataType.Int32, value: coerceAxisScale(options.axisScaleType)
        }));

        variable.xAxisDefinition.setValueFromSource(new Variant({
            dataType: DataType.ExtensionObject, value: new AxisInformation(options.xAxisDefinition)
        }));
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.ts View on Github external
const handler = variable.handle_semantic_changed.bind(variable);
        euRange.on("value_changed", handler);

        if (options.hasOwnProperty("instrumentRange")) {

            const instrumentRange = namespace.addVariable({
                accessLevel: "CurrentRead | CurrentWrite",
                browseName: { name: "InstrumentRange", namespaceIndex: 0 },
                dataType: "Range",
                minimumSamplingInterval: 0,
                modellingRule: options.modellingRule ? "Mandatory" : undefined,
                propertyOf: variable,
                typeDefinition: "PropertyType",
                value: new Variant({
                    dataType: DataType.ExtensionObject, value: new Range(options.instrumentRange)
                })
            });

            instrumentRange.on("value_changed", handler);

        }

        if (options.hasOwnProperty("engineeringUnits")) {

            const engineeringUnits = new EUInformation(options.engineeringUnits);
            assert(engineeringUnits instanceof EUInformation, "expecting engineering units");

            // EngineeringUnits  specifies the units for the   DataItemβ€Ÿs value (e.g., DEGC, hertz, seconds).   The
            // EUInformation   type is specified in   5.6.3.

            const eu = namespace.addVariable({
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.ts View on Github external
// Sensor or instrument failure or deactivation can result in a return ed item value which is actually
        // outside  of  this range. Client software must be prepared to deal with this   possibility. Similarly a client
        // may attempt to write a value that is outside  of  this range back to the server. The exact behaviour
        // (accept, reject, clamp, etc.) in this case is server - dependent. However ,   in general servers  shall  be
        // prepared to handle this.
        //     Example:    EURange ::= {-200.0,1400.0}

        const euRange = namespace.addVariable({
            browseName: { name: "EURange", namespaceIndex: 0 },
            dataType: "Range",
            minimumSamplingInterval: 0,
            modellingRule: options.modellingRule,
            propertyOf: variable,
            typeDefinition: "PropertyType",
            value: new Variant({
                dataType: DataType.ExtensionObject, value: new Range(options.engineeringUnitsRange)
            })
        }) as UAVariable;

        const handler = variable.handle_semantic_changed.bind(variable);
        euRange.on("value_changed", handler);

        if (options.hasOwnProperty("instrumentRange")) {

            const instrumentRange = namespace.addVariable({
                accessLevel: "CurrentRead | CurrentWrite",
                browseName: { name: "InstrumentRange", namespaceIndex: 0 },
                dataType: "Range",
                minimumSamplingInterval: 0,
                modellingRule: options.modellingRule ? "Mandatory" : undefined,
                propertyOf: variable,
                typeDefinition: "PropertyType",
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.ts View on Github external
browseName: options.browseName,
            componentOf: options.componentOf,
            dataType,
            optionals
        }) as YArrayItemVariable;

        function coerceAxisScale(value: any) {
            const ret = AxisScaleEnumeration[value];
            assert(!utils.isNullOrUndefined(ret));
            return ret;
        }

        variable.setValueFromSource(options.value as Variant, StatusCodes.Good);

        variable.euRange.setValueFromSource(new Variant({
            dataType: DataType.ExtensionObject, value: new Range(options.engineeringUnitsRange)
        }));

        if (options.hasOwnProperty("instrumentRange")) {
            variable.instrumentRange.setValueFromSource(new Variant({
                dataType: DataType.ExtensionObject, value: new Range(options.instrumentRange)
            }));
        }

        variable.title.setValueFromSource(new Variant({
            dataType: DataType.LocalizedText, value: coerceLocalizedText(options.title || "")
        }));

        // Linear/Log/Ln
        variable.axisScaleType.setValueFromSource(new Variant({
            dataType: DataType.Int32, value: coerceAxisScale(options.axisScaleType)
        }));
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_condition_base.ts View on Github external
const sourceNodes = conditionNode.findReferencesAsObject("HasCondition", false);
    if (sourceNodes.length) {
        assert(sourceNodes.length === 1);
        conditionNode.setSourceNode(sourceNodes[0].nodeId);
        conditionNode.setSourceName(sourceNodes[0].browseName.toString());
    }

    conditionNode.post_initialize();

    const branch0 = conditionNode.currentBranch();
    branch0.setRetain(false);
    branch0.setComment("");
    branch0.setQuality(StatusCodes.Good);
    branch0.setSeverity(0);
    branch0.setLocalTime(
      new TimeZoneDataType({
          daylightSavingInOffset: false,
          offset: 0
      })
    );
    branch0.setMessage("");

    branch0.setReceiveTime(minDate);
    branch0.setTime(minDate);

    // UAConditionBase
    return conditionNode;
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_condition_base.ts View on Github external
const selfConditionType = this.typeDefinitionObj;
        const conditionType = addressSpace.findObjectType("ConditionType")!;
        assert(selfConditionType.isSupertypeOf(conditionType));

        const branch = this.currentBranch();

        const now = new Date();
        // install the eventTimestamp
        // set the received Time
        branch.setTime(now);
        branch.setReceiveTime(now);

        // note : in 1.04 LocalTime property is optional
        if (this.hasOwnProperty("localTime")) {
            branch.setLocalTime(
              new TimeZoneDataType({
                  daylightSavingInOffset: false,
                  offset: 0
              })
            );
        }

        if (conditionInfo.hasOwnProperty("message") && conditionInfo.message) {
            branch.setMessage(conditionInfo.message);
        }
        // todo receive time : when the server received the event from the underlying system.
        // self.receiveTime.setValueFromSource();

        if (conditionInfo.hasOwnProperty("severity") && conditionInfo.severity !== null) {
            assert(_.isFinite(conditionInfo.severity));
            branch.setSeverity(conditionInfo.severity!);
        }
github node-opcua / node-opcua / packages / node-opcua-server / source / server_subscription.ts View on Github external
// reincorporate monitoredItemId and itemToMonitor into the requestedParameters
    const options = requestedParameters as any as MonitoredItemOptions;

    options.monitoredItemId = monitoredItemId;
    options.itemToMonitor = itemToMonitor;

    const monitoredItem = new MonitoredItem(options);
    monitoredItem.timestampsToReturn = timestampsToReturn;
    monitoredItem.$subscription = this;

    assert(monitoredItem.monitoredItemId === monitoredItemId);
    this.monitoredItems[monitoredItemId] = monitoredItem;

    const filterResult = _process_filter(node, requestedParameters.filter);

    const monitoredItemCreateResult = new MonitoredItemCreateResult({
      filterResult,
      monitoredItemId,
      revisedQueueSize: monitoredItem.queueSize,
      revisedSamplingInterval: monitoredItem.samplingInterval,
      statusCode: StatusCodes.Good
    });
    return monitoredItemCreateResult;
  }
github node-opcua / node-opcua / packages / node-opcua-service-browse / source / index.ts View on Github external
*/
BrowseRequest.schema.fields[1].documentation = "The view to browse.";
// Indicates the maximum number of references to return for each starting Node
// specified in the request. The value 0 indicates that the Client is imposing no
// limitation (see 7.5 for Counter definition).
BrowseRequest.schema.fields[2].documentation = "The maximum number of references to return in the response.";
BrowseRequest.schema.fields[3].documentation = "The list of nodes to browse.";

BrowseResponse.schema.documentation = "Browse the references for one or more nodes from the server address space.";
BrowseResponse.schema.fields[0].documentation = "A standard header included in all responses returned by servers.";
BrowseResponse.schema.fields[1].documentation = "The results for the browse operations.";
BrowseResponse.schema.fields[2].documentation = "The diagnostics associated with the results.";

BrowseResult.schema.documentation = "The result of a browse operation.";
BrowseResult.schema.fields[0].documentation = "A code indicating any error during the operation.";
BrowseResult.schema.fields[1].documentation =
    "A value that indicates the operation is incomplete and can be continued by calling BrowseNext.";

BrowseResult.schema.fields[2].documentation = "A list of references that meet the criteria specified in the request.";

ReferenceDescription.schema.documentation = "The description of a reference.";
ReferenceDescription.schema.fields[0].documentation = "The type of references.";
ReferenceDescription.schema.fields[1].documentation = "TRUE if the reference is a forward reference.";
ReferenceDescription.schema.fields[2].documentation = "The id of the target node.";
ReferenceDescription.schema.fields[3].documentation = "The browse name of the target node.";
ReferenceDescription.schema.fields[4].documentation = "The display name of the target node.";
ReferenceDescription.schema.fields[5].documentation = "The node class of the target node.";
ReferenceDescription.schema.fields[6].documentation = "The type definition of the target node.";

ViewDescription.schema.documentation =  "the view to browse.";
// ViewDescription : NodeId of the View to Query. A null value indicates the entire AddressSpace.
ViewDescription.schema.fields[0].documentation =  "The node id of the view.";
github node-opcua / node-opcua / packages / node-opcua-service-browse / source / index.ts View on Github external
* Use of the empty ViewDescription value causes all References of the nodesToBrowse to be returned. Use of any
 * other View causes only the References of the nodesToBrowse that are defined for that View to be returned.
 */
BrowseRequest.schema.fields[1].documentation = "The view to browse.";
// Indicates the maximum number of references to return for each starting Node
// specified in the request. The value 0 indicates that the Client is imposing no
// limitation (see 7.5 for Counter definition).
BrowseRequest.schema.fields[2].documentation = "The maximum number of references to return in the response.";
BrowseRequest.schema.fields[3].documentation = "The list of nodes to browse.";

BrowseResponse.schema.documentation = "Browse the references for one or more nodes from the server address space.";
BrowseResponse.schema.fields[0].documentation = "A standard header included in all responses returned by servers.";
BrowseResponse.schema.fields[1].documentation = "The results for the browse operations.";
BrowseResponse.schema.fields[2].documentation = "The diagnostics associated with the results.";

BrowseResult.schema.documentation = "The result of a browse operation.";
BrowseResult.schema.fields[0].documentation = "A code indicating any error during the operation.";
BrowseResult.schema.fields[1].documentation =
    "A value that indicates the operation is incomplete and can be continued by calling BrowseNext.";

BrowseResult.schema.fields[2].documentation = "A list of references that meet the criteria specified in the request.";

ReferenceDescription.schema.documentation = "The description of a reference.";
ReferenceDescription.schema.fields[0].documentation = "The type of references.";
ReferenceDescription.schema.fields[1].documentation = "TRUE if the reference is a forward reference.";
ReferenceDescription.schema.fields[2].documentation = "The id of the target node.";
ReferenceDescription.schema.fields[3].documentation = "The browse name of the target node.";
ReferenceDescription.schema.fields[4].documentation = "The display name of the target node.";
ReferenceDescription.schema.fields[5].documentation = "The node class of the target node.";
ReferenceDescription.schema.fields[6].documentation = "The type definition of the target node.";

ViewDescription.schema.documentation =  "the view to browse.";