How to use the node-opcua-service-call.CallMethodRequest function in node-opcua-service-call

To help you get started, we’ve selected a few node-opcua-service-call 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-client-proxy / source / object_explorer.ts View on Github external
// xx console.log("xxx ",arg.toString());
            const propName = lowerFirstLetter(arg.name);

            const value = inputArgs[propName];
            if (value === undefined) {
                throw new Error("expecting input argument " + propName);
            }
            if (arrayType === VariantArrayType.Array) {
                if (!_.isArray(value)) {
                    throw new Error("expecting value to be an Array or a TypedArray");
                }
            }
            return new Variant({arrayType, dataType, value});
        });

        const methodToCall = new CallMethodRequest({
            inputArguments,
            methodId: reference.nodeId,
            objectId: obj.nodeId,
        });

        session.call(methodToCall, (err: Error | null, callResult?: CallMethodResult) => {

            // istanbul ignore next
            if (err) {
                return callback(err);
            }

            callResult = callResult!;

            if (callResult.statusCode !== StatusCodes.Good) {
                return callback(new Error("Error " + callResult.statusCode.toString()));
github node-opcua / node-opcua / packages / node-opcua-client-proxy / src / proxy.js View on Github external
const propName = lowerFirstLetter(arg.name);

                const value = inputArgs[propName];
                if (value === undefined) {
                    throw new Error("expecting input argument " + propName);
                }
                if (arrayType === VariantArrayType.Array) {
                    if (!_.isArray(value)) {
                        throw new Error("expecting value to be an Array or a TypedArray");
                    }
                }

                return new Variant({arrayType: arrayType, dataType: dataType, value: value});
            });

            const methodToCall = new call_service.CallMethodRequest({
                objectId: obj.nodeId,
                methodId: reference.nodeId,
                inputArguments: inputArguments
            });

            //xx console.log(" calling ",methodToCall.toString());

            session.call(methodToCall, function (err, callResult) {

                // istanbul ignore next
                if (err) {
                    return callback(err);
                }
                if (callResult.statusCode !== StatusCodes.Good) {
                    return callback(new Error("Error " + callResult.statusCode.toString()));
                }
github node-opcua / node-opcua / packages / node-opcua-client / source / alarms_and_conditions / client_tools.ts View on Github external
(innerCallback: ErrorCallback) => {

            const methodToCalls = [];

            methodToCalls.push(new CallMethodRequest({
                inputArguments: [
                    /* eventId */ new Variant({ dataType: "ByteString", value: eventId }),
                    /* comment */ new Variant({ dataType: "LocalizedText", value: comment })
                ],
                methodId,
                objectId: conditionId
            }));

            this.call(methodToCalls, (err: Error | null, results?: CallMethodResult[]) => {
                if (err) {
                    return innerCallback(err);
                }
                statusCode = results![0].statusCode;
                innerCallback();
            });
        }
github node-opcua / node-opcua / packages / node-opcua-client / src / client_session.js View on Github external
ClientSession.prototype.getMonitoredItems = function (subscriptionId, callback) {

    // 
    // 
    // 
    const self = this;
    const methodsToCall =
        new call_service.CallMethodRequest({
            objectId: coerceNodeId("ns=0;i=2253"),  // ObjectId.Server
            methodId: coerceNodeId("ns=0;i=11492"), // MethodIds.Server_GetMonitoredItems;
            inputArguments: [
                // BaseDataType
                {dataType: DataType.UInt32, value: subscriptionId}
            ]
        });

    self.call([methodsToCall], function (err, result) {

            /* istanbul ignore next */
            if (err) {
                return callback(err);
            }

            result = result[0];

node-opcua-service-call

pure nodejs OPCUA SDK - module service-call

MIT
Latest version published 2 months ago

Package Health Score

86 / 100
Full package analysis