How to use the node-opcua-variant.DataType.DateTime function in node-opcua-variant

To help you get started, we’ve selected a few node-opcua-variant 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-address-space / src / alarms_and_conditions / condition.js View on Github external
const key = normalizeName(varName);
    // istanbul ignore next
    if (!self._map.hasOwnProperty(key)) {
        if (doDebug) {
            debugLog(" cannot find node ".white.bold.bgRed + varName.cyan);
            debugLog("  map=", Object.keys(self._map).join(" "));
        }
    }
    self._map[key] = new Variant({
        dataType: dataType,
        value: value
    });

    if (self._map[key + ".sourceTimestamp"]) {
        self._map[key + ".sourceTimestamp"] = new Variant({
            dataType: DataType.DateTime,
            value: new Date()
        });
    }

    const variant = self._map[key];
    const node = self._node_index[key];
    assert(node instanceof UAVariable);
    self.emit("value_changed", node, variant);
};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / condition_snapshot.ts View on Github external
const key = normalizeName(varName);
        // istanbul ignore next
        if (!this._map.hasOwnProperty(key)) {
            if (doDebug) {
                debugLog(" cannot find node " + varName);
                debugLog("  map=", Object.keys(this._map).join(" "));
            }
        }
        this._map[key] = new Variant({
            dataType,
            value
        });

        if (this._map[key + ".sourceTimestamp"]) {
            this._map[key + ".sourceTimestamp"] = new Variant({
                dataType: DataType.DateTime,
                value: new Date()
            });
        }

        const variant = this._map[key];
        const node = this._node_index[key];
        if (!node) {
            // for instance localTime is optional
            debugLog("Cannot serVar " + varName + " dataType " + DataType[dataType]);
            return;
        }
        assert(node.nodeClass === NodeClass.Variable);
        this.emit("value_changed", node, variant);
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_condition_base.ts View on Github external
public _assert_valid() {
        assert(this.receiveTime.readValue().value.dataType === DataType.DateTime);
        assert(this.receiveTime.readValue().value.value instanceof Date);

        assert(this.message.readValue().value.dataType === DataType.LocalizedText);
        assert(this.severity.readValue().value.dataType === DataType.UInt16);

        assert(this.time.readValue().value.dataType === DataType.DateTime);
        assert(this.time.readValue().value.value instanceof Date);

        assert(this.quality.readValue().value.dataType === DataType.StatusCode);
        assert(this.enabledState.readValue().value.dataType === DataType.LocalizedText);
        assert(this.branchId.readValue().value.dataType === DataType.NodeId);

        // note localTime has been made optional in 1.04
        assert(!this.localTime || this.localTime.readValue().value.dataType === DataType.ExtensionObject);

    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space.ts View on Github external
const sourceNode = addressSpace.findNode(data.sourceNode.value)!;

        data.sourceName = data.sourceName || {
            dataType: DataType.String,
            value: sourceNode.getDisplayName("en")
        };

        const nowUTC = (new Date());

        // time (UtcTime)
        // TODO
        data.time = data.time || { dataType: DataType.DateTime, value: nowUTC };

        // receivedTime  (UtcTime)
        // TODO
        data.receiveTime = data.receiveTime || { dataType: DataType.DateTime, value: nowUTC };

        // localTime  (UtcTime)
        // TODO
        data.localTime = data.localTime || { dataType: DataType.DateTime, value: nowUTC };

        // message  (LocalizedText)
        data.message = data.message || { dataType: DataType.LocalizedText, value: { text: "" } };

        // severity  (UInt16)
        data.severity = data.severity || { dataType: DataType.UInt16, value: 0 };

        // xx // reminder : event type cannot be instantiated directly !
        // xx assert(eventTypeNode.isAbstract);

        const baseObjectType = addressSpace.findObjectType("BaseObjectType"); // i=58
        /* istanbul ignore next */
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / acknowledgeable_condition.js View on Github external
UAAcknowledgeableConditionBase.prototype._raiseAuditConditionAcknowledgeEvent = function(branch) {


    // raise the AuditConditionAcknowledgeEventType
    const eventData = {

        // EventType
        eventId:  { dataType: DataType.ByteString, value: branch.getEventId() },
        //xx branchId: branch.branchId.readValue().value,
        // AuditEventType
        actionTimeStamp: { dataType: DataType.DateTime, value : new Date() },
        status: { dataType: DataType.StatusCodes, value: StatusCodes.Good },
        serverId: {},
        clientAuditEntryId: {},
        clientUserId: {},
        methodId: {},
        inputArguments: {},
        comment:   {dataType: DataType.LocalizedText, value: branch.getComment() }
    };
    this.raiseEvent("AuditConditionAcknowledgeEventType",eventData);

};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_acknowledgeable_condition_base.ts View on Github external
public _raiseAuditConditionAcknowledgeEvent(branch: ConditionSnapshot): void {

        // raise the AuditConditionAcknowledgeEventType
        const eventData: RaiseEventData = {
            actionTimeStamp: { dataType: DataType.DateTime, value: new Date() },
            // xx branchId: branch.branchId.readValue().value,

            // AuditEventType
            clientAuditEntryId: {
                dataType: DataType.Null
            },

            clientUserId: {
                dataType: DataType.Null
            },

            comment: { dataType: DataType.LocalizedText, value: branch.getComment() },

            // EventType
            eventId: { dataType: DataType.ByteString, value: branch.getEventId() },
            inputArguments: {
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_condition_base.ts View on Github external
public _assert_valid() {
        assert(this.receiveTime.readValue().value.dataType === DataType.DateTime);
        assert(this.receiveTime.readValue().value.value instanceof Date);

        assert(this.message.readValue().value.dataType === DataType.LocalizedText);
        assert(this.severity.readValue().value.dataType === DataType.UInt16);

        assert(this.time.readValue().value.dataType === DataType.DateTime);
        assert(this.time.readValue().value.value instanceof Date);

        assert(this.quality.readValue().value.dataType === DataType.StatusCode);
        assert(this.enabledState.readValue().value.dataType === DataType.LocalizedText);
        assert(this.branchId.readValue().value.dataType === DataType.NodeId);

        // note localTime has been made optional in 1.04
        assert(!this.localTime || this.localTime.readValue().value.dataType === DataType.ExtensionObject);

    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space_add_event_type.js View on Github external
// sourceNode
        assert(data.hasOwnProperty("sourceNode"), "expecting a source node to be defined");
        data.sourceNode = new Variant(data.sourceNode);
        assert(data.sourceNode.dataType ===  DataType.NodeId);

        // sourceName
        const sourceNode = addressSpace.findNode(data.sourceNode.value);

        data.sourceName = data.sourceName || { dataType:  DataType.String, value: sourceNode.getDisplayName("en") };

        const nowUTC = (new Date());

        // time (UtcTime)
        // TODO
        data.time = data.time  ||  { dataType: DataType.DateTime, value: nowUTC};

        // receivedTime  (UtcTime)
        // TODO
        data.receiveTime = data.receiveTime  ||  { dataType: DataType.DateTime, value: nowUTC};

        // localTime  (UtcTime)
        // TODO
        data.localTime = data.localTime  ||  { dataType: DataType.DateTime, value: nowUTC};

        // message  (LocalizedText)
        data.message = data.message  ||  { dataType: DataType.LocalizedText, value: { text: "" } };

        // severity  (UInt16)
        data.severity = data.severity  ||  { dataType: DataType.UInt16, value: 0 };

        //xx // reminder : event type cannot be instantiated directly !
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_certificate_expiration_alarm.ts View on Github external
public setExpirationDate(value: Date) {
        return this.expirationDate.setValueFromSource({
            dataType: DataType.DateTime,
            value
        });
    }
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / condition_snapshot.ts View on Github external
public setReceiveTime(time: UtcTime) {
        assert(time instanceof Date);
        return this._set_var("receiveTime", DataType.DateTime, time);
    }