How to use the node-opcua-factory.getStructuredTypeSchema function in node-opcua-factory

To help you get started, we’ve selected a few node-opcua-factory 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 / nodeset_to_xml.ts View on Github external
assert(value instanceof Variant);

    const dataTypeNode = addressSpace.findNode(node.dataType);
    if (!dataTypeNode) {
        return;
    }
    const dataTypeName = dataTypeNode.browseName.toString();

    const baseDataTypeName = (DataType as any)[DataType[value.dataType]];

    // console.log("nodeset_to_xml #_dumpValue Cannot find ", dataTypeName,node.dataType.toString());
    if (!hasStructuredType(dataTypeName)) {
        return;
    } // this is not a extension object

    const schema = getStructuredTypeSchema(dataTypeName);

    function encodeXml(value1: any) {
        _dumpVariantExtensionObjectValue_Body(xw, schema, value1);
    }

    xw.startElement("Value");

    // determine if dataTypeName is a ExtensionObject
    const isExtensionObject = dataTypeName === "LocalizedText" ? false : true;

    if (isExtensionObject) {

        if (value.arrayType === VariantArrayType.Array) {
            xw.startElement("ListOf" + baseDataTypeName);
            value.value.forEach(_dumpVariantExtensionObjectValue.bind(null, xw, schema));
            xw.endElement();
github node-opcua / node-opcua / packages / node-opcua-schemas / source / tools.ts View on Github external
field.category = FieldCategory.complex;
                        field.schema = getOrCreateStructuredTypeSchema(fieldTypeName, typeDictionary);
                        if (!field.schema) {
                            // tslint:disable-next-line:no-console
                            console.log("cannot find schema for ", fieldTypeName);
                        }
                    }
                    break;
                case "ua":
                    field.fieldType = fieldTypeName;
                    if (hasBuiltInType(fieldTypeName)) {
                        field.category = FieldCategory.basic;
                        field.schema = getBuildInType(fieldTypeName);
                    } else if (hasStructuredType(fieldTypeName)) {
                        field.category = FieldCategory.complex;
                        field.schema = getStructuredTypeSchema(fieldTypeName);

                    } else {
                        field.category = FieldCategory.basic;
                        // try in this
                        field.schema = getOrCreateStructuredTypeSchema(fieldTypeName, typeDictionary);
                        if (!field.schema) {
                            // tslint:disable-next-line:no-console
                            console.log("What should I do ??", fieldTypeName, " ", hasStructuredType(fieldTypeName));
                        } else {
                            if (hasBuiltInType(fieldTypeName)) {
                                field.category = FieldCategory.basic;
                            } else {
                                field.category = FieldCategory.complex;
                            }
                        }
                    }
github node-opcua / node-opcua / packages / node-opcua-generator / source / factory_code_generator.ts View on Github external
function get_class_tscript_filename_local(schemaName: string): string {

    let schema = getStructuredTypeSchema(schemaName);
    if (!schema) {
        schema = generatedObjectSchema[schemaName];
        if (!schema) {
            throw new Error("cannot find script file for " + schemaName);
        }
        return "./_" + schemaName;
    }
    let generateTypeScriptSource = "/* fix me schema.prototype.schema.generate_ts_source*/";
    if (!generateTypeScriptSource) {
        const folder = "."; // exports.folder_for_generated_file;
        generateTypeScriptSource = path.join(folder, "_" + schemaName + ".ts");
    }
    return generateTypeScriptSource;
}