How to use the node-opcua-status-code.StatusCodes.Good function in node-opcua-status-code

To help you get started, we’ve selected a few node-opcua-status-code 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 / state_machine / finite_state_machine.ts View on Github external
// istanbul ignore next
            if (!state) {
                throw new Error("Cannot find state with name " + toStateNode);
            }
            assert(state.browseName.name!.toString() === toStateNode);
            toStateNode = state;
        }
        const fromStateNode = this.currentStateNode;

        toStateNode = this._coerceNode(toStateNode) as any as State;
        assert(toStateNode.nodeClass === NodeClass.Object);

        this.currentState.setValueFromSource({
            dataType: DataType.LocalizedText,
            value: coerceLocalizedText(toStateNode.browseName.toString())
        }, StatusCodes.Good);

        this.currentStateNode = toStateNode;

        const transitionNode = this.findTransitionNode(fromStateNode, toStateNode);

        if (transitionNode) {

            // xx console.log("transitionNode ",transitionNode.toString());
            // The inherited Property SourceNode shall be filled with the NodeId of the StateMachine instance where the
            // Transition occurs. If the Transition occurs in a SubStateMachine, then the NodeId of the SubStateMachine
            // has to be used. If the Transition occurs between a StateMachine and a SubStateMachine, then the NodeId of
            // the StateMachine has to be used, independent of the direction of the Transition.
            // Transition identifies the Transition that triggered the Event.
            // FromState identifies the State before the Transition.
            // ToState identifies the State after the Transition.
            this.raiseEvent("TransitionEventType", {
github node-opcua / node-opcua / packages / node-opcua-server-discovery / source / opcua_discovery_server.ts View on Github external
if (Object.keys(previousConfMap).length !== 0) {
                debugLog(" Warning some conf need to be removed !");
            }

        } else {
            // server is announced offline
            if (key in this.registeredServers) {
                const server1 = this.registeredServers[key];
                debugLog(chalk.cyan("unregistering server : "), chalk.yellow(server1.serverUri!));
                configurationResults = [];

                discoveryConfigurations = server1.discoveryConfiguration || [];

                for (const conf of discoveryConfigurations) {
                    await _stop_announcedOnMulticastSubnet(conf);
                    configurationResults.push(StatusCodes.Good);
                }
                delete this.registeredServers[key];
            }
        }

        const response = new RegisterServerXResponse({
            configurationResults
        });
        return response;
    }
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / extension_object_array_node.js View on Github external
function addElement(options, uaArrayVariableNode) {

    assert(uaArrayVariableNode," must provide an UAVariable containing the array");
    assert(uaArrayVariableNode instanceof UAVariable,"expecting a UAVariable node here");
    // verify that arr has been created correctly
    assert(!!uaArrayVariableNode.$$variableType && !!uaArrayVariableNode.$$dataType,
            "did you create the array Node with createExtObjArrayNode ?");
    assert(uaArrayVariableNode.$$dataType instanceof UADataType);
    assert(uaArrayVariableNode.$$dataType._extensionObjectConstructor instanceof Function);

    const checkValue = uaArrayVariableNode.readValue();
    assert(checkValue.statusCode === StatusCodes.Good);
    assert(checkValue.value.dataType === DataType.ExtensionObject);

    const addressSpace = uaArrayVariableNode.addressSpace;

    let extensionObject = null;
    let elVar = null;
    let browseName;

    if (options instanceof UAVariable) {
        elVar = options;
        extensionObject = elVar.$extensionObject; // get shared extension object
        assert(extensionObject instanceof uaArrayVariableNode.$$dataType._extensionObjectConstructor,
            "the provided variable must expose a Extension Object of the expected type ");
        // add a reference
        uaArrayVariableNode.addReference({referenceType: "HasComponent", isFoward: true, nodeId: elVar.nodeId});
        //xx elVar.bindExtensionObject();
github node-opcua / node-opcua / packages / node-opcua-client / source / private / client_publish_engine.ts View on Github external
session.republish(request, (err: Error | null, response?: RepublishResponse) => {
                if (!err && response!.responseHeader.serviceResult.equals(StatusCodes.Good)) {
                    // reprocess notification message  and keep going
                    subscription.onNotificationMessage(response!.notificationMessage);
                } else {
                    if (!err) {
                        err = new Error(response!.responseHeader.serviceResult.toString());
                    }
                    debugLog(" _send_republish ends with ", err.message);
                    isDone = true;
                }
                callback2(err ? err : undefined);
            });
        };
github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / server / server_secure_channel_layer.ts View on Github external
if (this.receiverCertificate) {
                // extract public key
                extractPublicKeyFromCertificate(this.receiverCertificate, (err, key) => {
                    if (!err) {
                        if (key) {
                            this.receiverPublicKey = key;
                            this.receiverPublicKeyLength = rsa_length(key);
                        }
                        callback(null, StatusCodes.Good);
                    } else {
                        callback(err);
                    }
                });
            } else {
                this.receiverPublicKey = null;
                callback(null, StatusCodes.Good);
            }
        });
    }
github node-opcua / node-opcua / packages / node-opcua-secure-channel / src / server / server_secure_channel_layer.js View on Github external
return StatusCodes.BadCertificateTimeInvalid;
    }

    // Has SoftwareCertificate has  been revoked by the issuer ?
    // TODO: check if certificate is revoked or not ...
    // StatusCodes.BadCertificateRevoked

    // is issuer Certificate  valid and has not been revoked by the CA that issued it. ?
    // TODO : check validity of issuer certificate
    // StatusCodes.BadCertificateIssuerRevoked

    //does the URI specified in the ApplicationDescription  match the URI in the Certificate ?
    // TODO : check ApplicationDescription of issuer certificate
    // return StatusCodes.BadCertificateUriInvalid

    return StatusCodes.Good;
}
github node-opcua / node-opcua / packages / node-opcua-client-proxy / src / proxy.js View on Github external
session.read(nodesToRead, 1, function (err, dataValues) {
            if (dataValues[0].statusCode === StatusCodes.Good) {
                clientObject.dataValue = dataValues[0].value;
            }
            if (dataValues[1].statusCode === StatusCodes.Good) {
                //xx console.log("AccessLevel ", results[3].value.toString())
                clientObject.userAccessLevel = coerceAccessLevelFlag(dataValues[1].value.value);
            }
            if (dataValues[2].statusCode === StatusCodes.Good) {
                clientObject.accessLevel = coerceAccessLevelFlag(dataValues[2].value.value);
            }
            callback(err);
        });
    }
github node-opcua / node-opcua / packages / node-opcua-data-model / schemas / DiagnosticInfo_schema.js View on Github external
if (diagnosticInfo.symbolicId  >=0) {
        encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.SymbolicId);
    }
    if (diagnosticInfo.namespaceUri >=0) {
        encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.NamespaceUri);
    }
    if (diagnosticInfo.localizedText >=0) {
        encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.LocalizedText);
    }
    if (diagnosticInfo.locale >= 0) {
        encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.Locale);
    }
    if (diagnosticInfo.additionalInfo) {
        encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.AdditionalInfo);
    }
    if (diagnosticInfo.innerStatusCode && diagnosticInfo.innerStatusCode !== StatusCodes.Good) {
        encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.InnerStatusCode);
    }
    if (diagnosticInfo.innerDiagnosticInfo) {
        encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.InnerDiagnosticInfo);
    }
    return encoding_mask;
}
github node-opcua / opcua-commander / lib / model / model.ts View on Github external
nodeId: node.nodeId,
            attributeId: attributeId
        }));

        try {

            const dataValues = await this.session.read(nodesToRead);

            const results: any[] = [];

            for (let i = 0; i < nodesToRead.length; i++) {

                const nodeToRead = nodesToRead[i];
                const dataValue = dataValues[i];

                if (dataValue.statusCode !== StatusCodes.Good) {
                    continue;
                }
                const s = toString1(nodeToRead.attributeId, dataValue);
                results.push({
                    attribute: attributeIdtoString[nodeToRead.attributeId],
                    text: s
                });
            }
            return results;
        } catch (err) {
            return [];
        }
    }
github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / server / server_secure_channel_layer.ts View on Github external
function isValidSecurityPolicy(securityPolicy: SecurityPolicy) {
    switch (securityPolicy) {
        case SecurityPolicy.None:
        case SecurityPolicy.Basic128Rsa15:
        case SecurityPolicy.Basic256:
        case SecurityPolicy.Basic256Sha256:
            return StatusCodes.Good;
        default:
            return StatusCodes.BadSecurityPolicyRejected;
    }
}