How to use the node-opcua-factory.initialize_field_array 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-schemas / source / dynamic_extension_object.ts View on Github external
case FieldCategory.complex: {
            const constuctor = getOrCreateConstructor(field.fieldType, typeDictionary) || BaseUAObject;
            if (field.isArray) {
                (thisAny)[name] = (options[name] || []).map((x: any) =>
                    constuctor ? new constuctor(x) : null
                );
            } else {
                (thisAny)[name] = constuctor ? new constuctor(options[name]) : null;
            }
            // xx processStructuredType(fieldSchema);
            break;
        }
        case FieldCategory.enumeration:
        case FieldCategory.basic:
            if (field.isArray) {
                (thisAny)[name] = initialize_field_array(field, options[name]);
            } else {
                (thisAny)[name] = initialize_field(field, options[name]);
            }
            break;
    }

}
/**
github node-opcua / node-opcua / packages / node-opcua-variant / source / variant.ts View on Github external
*/
    this.setArrayType(initialize_field(schema.fields[1], options.arrayType));

    /**
     * @property value
     * @default  null
     */
    this.value = initialize_field(schema.fields[2], options.value);

    /**
     * the matrix dimensions
     * @property dimensions
     * @type {UInt32[]}
     * @default  null
     */
    this.dimensions = initialize_field_array(
      schema.fields[3],
      options.dimensions
    );

    if (options.dataType === DataType.ExtensionObject) {
      if (this.arrayType === VariantArrayType.Scalar) {
        /* istanbul ignore next */
        if (this.value && !(this.value instanceof ExtensionObject)) {
          throw new Error("A variant with DataType.ExtensionObject must have a ExtensionObject value");
        }
      } else {
        for (const e of this.value) {
          /* istanbul ignore next */
          if (e && !(e instanceof ExtensionObject)) {
            throw new Error("A variant with DataType.ExtensionObject must have a ExtensionObject value");
          }
github node-opcua / node-opcua / packages / node-opcua-schemas / source / dynamic_extension_object.ts View on Github external
case FieldCategory.complex: {
                    const constuctor = getOrCreateConstructor(field.fieldType, typeDictionary) || BaseUAObject;
                    if (field.isArray) {
                        (this as any)[name] = (options[name] || []).map((x: any) =>
                            constuctor ? new constuctor(x) : null
                        );
                    } else {
                        (this as any)[name] = constuctor ? new constuctor(options[name]) : null;
                    }
                    // xx processStructuredType(fieldSchema);
                    break;
                }
                case FieldCategory.enumeration:
                case FieldCategory.basic:
                    if (field.isArray) {
                        (this as any)[name] = initialize_field_array(field, options[name]);
                    } else {
                        (this as any)[name] = initialize_field(field, options[name]);
                    }
                    break;

            }
        }
        if (!uniqueFieldHasBeenFound) {
            if (Object.keys(options).length === 0) {
                (this as any)[switchFieldName] = 0xFFFFFFFF;
                return;
            }
            const r = schema.fields.filter((f) => f.switchValue !== undefined).map((f) => f.name).join(" , ");
            // it is possible also that the switchfield value do not correspond to a valid field
            const foundFieldForSwitchValue = schema.fields.findIndex((f) =>
                f.switchValue !== undefined && f.switchValue === options[switchFieldName]);