How to use the node-opcua-variant.DataType.ByteString function in node-opcua-variant

To help you get started, we’ve selected a few node-opcua-variant 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 / alarms_and_conditions / condition_snapshot.ts View on Github external
public renewEventId() {
        const addressSpace = this.condition.addressSpace;
        // create a new event  Id for this new condition
        const eventId = addressSpace.generateEventId();
        const ret = this._set_var("eventId", DataType.ByteString, eventId.value);

        // xx var branch = self; console.log("MMMMMMMMrenewEventId branch  " +
        // branch.getBranchId().toString() + " eventId = " + branch.getEventId().toString("hex"));

        return ret;
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / condition.js View on Github external
ConditionSnapshot.prototype.renewEventId = function() {
    const self = this;
    const addressSpace = self.condition.addressSpace;
    // create a new event  Id for this new condition
    const eventId = addressSpace.generateEventId();
    const ret = self._set_var("eventId", DataType.ByteString, eventId.value);

    //xx var branch = self; console.log("MMMMMMMMrenewEventId branch  " +  branch.getBranchId().toString() + " eventId = " + branch.getEventId().toString("hex"));

    return ret;
};
github node-opcua / node-opcua / packages / node-opcua-file-transfer / source / server / file_type_helpers.ts View on Github external
const data = Buffer.alloc(length);

    let ret;
    try {
        ret = await promisify(fs.read)(_fileInfo.fd, data, 0, length, _fileInfo.position[1]);
        _fileInfo.position[1] += ret.bytesRead;
    } catch (err) {
        errorLog("Read error : ", err.message);
        return { statusCode: StatusCodes.BadUnexpectedError };
    }

    //   Data Contains the returned data of the file. If the ByteString is empty it indicates that the end
    //     of the file is reached.
    return {
        outputArguments: [
            { dataType: DataType.ByteString, value: data.slice(0, ret.bytesRead) }
        ],
        statusCode: StatusCodes.Good
    };
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.ts View on Github external
if (basicType === DataType.Byte && this.valueRank === 1) {
        if (variant.arrayType === VariantArrayType.Scalar && variant.dataType === DataType.ByteString) {

            if ((this.dataType.value === DataType.Byte) && (this.dataType.namespace === 0)) { // Byte
                variant.arrayType = VariantArrayType.Array;
                variant.dataType = DataType.Byte;
                assert(variant.dataType === DataType.Byte);
                assert(!variant.value || variant.value instanceof Buffer);
            }
        }
    }
    if (basicType === DataType.ByteString && this.valueRank === -1 /* Scalar*/) {

        if (variant.arrayType === VariantArrayType.Array && variant.dataType === DataType.Byte) {
            if ((this.dataType.value === DataType.ByteString) && (this.dataType.namespace === 0)) { // Byte
                variant.arrayType = VariantArrayType.Scalar;
                variant.dataType = DataType.ByteString;
                assert(variant.dataType === DataType.ByteString);
                assert(!variant.value || variant.value instanceof Buffer);
            }
        }
    }

    return variant;

}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / acknowledgeable_condition.js View on Github external
UAAcknowledgeableConditionBase.prototype._raiseAuditConditionAcknowledgeEvent = function(branch) {


    // raise the AuditConditionAcknowledgeEventType
    const eventData = {

        // EventType
        eventId:  { dataType: DataType.ByteString, value: branch.getEventId() },
        //xx branchId: branch.branchId.readValue().value,
        // AuditEventType
        actionTimeStamp: { dataType: DataType.DateTime, value : new Date() },
        status: { dataType: DataType.StatusCodes, value: StatusCodes.Good },
        serverId: {},
        clientAuditEntryId: {},
        clientUserId: {},
        methodId: {},
        inputArguments: {},
        comment:   {dataType: DataType.LocalizedText, value: branch.getComment() }
    };
    this.raiseEvent("AuditConditionAcknowledgeEventType",eventData);

};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / loader / load_nodeset2.js View on Github external
finish: function () {
                    const base64text = this.text;
                    const byteString = Buffer.from(base64text, "base64");
                    this.parent.parent.obj.value = {
                        dataType: DataType.ByteString,
                        arrayType: VariantArrayType.Scalar,
                        value: byteString
                    };
                }
            },
github node-opcua / node-opcua / packages / node-opcua-file-transfer / source / client / client_file.ts View on Github external
const result = await this.session.call({
            inputArguments: [
                { dataType: DataType.UInt32, value: this.fileHandle },
                {
                    arrayType: VariantArrayType.Scalar,
                    dataType: DataType.Int32,
                    value: bytesToRead
                }
            ],
            methodId: this.readNodeId,
            objectId: this.fileNodeId
        });
        if (result.statusCode !== StatusCodes.Good) {
            throw new Error("Error " + result.statusCode.toString());
        }
        if (!result.outputArguments || result.outputArguments[0].dataType !== DataType.ByteString) {
            throw new Error("Error invalid output");
        }
        return result.outputArguments![0].value as Buffer;
    }
github node-opcua / node-opcua / packages / node-opcua-server-configuration / source / push_certificate_manager_helpers.ts View on Github external
const pushCertificateManager = getPushCertificateManager(this);
    if (!pushCertificateManager) {
        return { statusCode: StatusCodes.BadNotImplemented };
    }

    const result = await pushCertificateManager.getRejectedList();

    if (result.statusCode !== StatusCodes.Good) {
        return { statusCode: result.statusCode };
    }

    return {
        outputArguments: [
            {
                arrayType: VariantArrayType.Array,
                dataType: DataType.ByteString,
                value: result.certificates
            }
        ],
        statusCode: StatusCodes.Good
    };
}
github node-opcua / node-opcua / packages / node-opcua-data-value / source / datavalue.ts View on Github external
function canRange(dataValue: DataValue): boolean {
  return dataValue.value && ((dataValue.value.arrayType !== VariantArrayType.Scalar) ||
    ((dataValue.value.arrayType === VariantArrayType.Scalar) && (dataValue.value.dataType === DataType.ByteString))
    ||
    ((dataValue.value.arrayType === VariantArrayType.Scalar) && (dataValue.value.dataType === DataType.String)));
}
github node-opcua / node-opcua / packages / node-opcua-file-transfer / source / client / client_file.ts View on Github external
public async write(data: Buffer): Promise {
        await this.ensureInitialized();
        if (!this.fileHandle) {
            throw new Error("File has node been opened yet");
        }
        const result = await this.session.call({
            inputArguments: [
                { dataType: DataType.UInt32, value: this.fileHandle },
                {
                    arrayType: VariantArrayType.Scalar,
                    dataType: DataType.ByteString,
                    value: data
                }
            ],
            methodId: this.writeNodeId,
            objectId: this.fileNodeId
        });
        if (result.statusCode !== StatusCodes.Good) {
            throw new Error("Error " + result.statusCode.toString());
        }
        return;
    }