How to use the node-opcua-date-time.coerceClock function in node-opcua-date-time

To help you get started, we’ve selected a few node-opcua-date-time 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 / ua_variable.js View on Github external
if (!variant.dataType) {
            throw new Error("Variant must provide a valid dataType" + variant.toString());
        }
    }

    // if (variant.hasOwnProperty("value")) {
    //     if (variant.dataType === DataType.UInt32) {
    //         if (!_.isFinite(variant.value)) {
    //             throw new Error("Expecting an number");
    //         }
    //     }
    // }

    variant = Variant.coerce(variant);

    const now = coerceClock(sourceTimestamp, 0);

    const dataValue = new DataValue({
        sourceTimestamp: now.timestamp,
        sourcePicoseconds: now.picoseconds,
        serverTimestamp: now.timestamp,
        serverPicoseconds: now.picoseconds,
        statusCode: statusCode || StatusCodes.Good
    });
    dataValue.value = variant;
    self._internal_set_dataValue(dataValue, null);
};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.ts View on Github external
if (variant.dataType === null || variant.dataType === undefined) {
                throw new Error("Variant must provide a valid dataType" + variant.toString());
            }
        }

        // if (variant.hasOwnProperty("value")) {
        //     if (variant.dataType === DataType.UInt32) {
        //         if (!_.isFinite(variant.value)) {
        //             throw new Error("Expecting an number");
        //         }
        //     }
        // }

        variant = Variant.coerce(variant);

        const now = coerceClock(sourceTimestamp, 0);

        const dataValue = new DataValue({
            serverPicoseconds: now.picoseconds,
            serverTimestamp: now.timestamp,
            sourcePicoseconds: now.picoseconds,
            sourceTimestamp: now.timestamp,
            statusCode: statusCode || StatusCodes.Good
        });
        dataValue.value = variant as Variant;
        this._internal_set_dataValue(dataValue);
    }

node-opcua-date-time

pure nodejs OPCUA SDK - module date-time

MIT
Latest version published 3 months ago

Package Health Score

86 / 100
Full package analysis