Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
statusCode: StatusCodes.BadConditionAlreadyShelved
});
}
// checking duration ...
const alarmNode = shelvingState.parent;
// istanbul ignore next
if (!(alarmNode instanceof UAAlarmConditionBase)) {
return callback(null, {
statusCode: StatusCodes.BadNodeIdInvalid
});
}
const maxTimeShelved = alarmNode.getMaxTimeShelved();
assert(_.isFinite(maxTimeShelved));
assert(inputArguments[0].dataType === DataType.Double); // Duration
assert(inputArguments[0] instanceof Variant);
// xx console.log("inputArguments",inputArguments[0].toString());
const proposedDuration = inputArguments[0].value; // as double (milliseconds)
if (proposedDuration > maxTimeShelved) {
return callback(null, {
statusCode: StatusCodes.BadShelvingTimeOutOfRange
});
}
if (proposedDuration < 0) {
return callback(null, {
statusCode: StatusCodes.BadShelvingTimeOutOfRange
});
}
statusCode: StatusCodes.BadConditionAlreadyShelved
});
}
// checking duration ...
const alarmNode = context.object.parent;
// istanbul ignore next
if (!(alarmNode instanceof UAAlarmConditionBase)) {
return callback(null, {
statusCode: StatusCodes.BadNodeIdInvalid
});
}
const maxTimeShelved = alarmNode.getMaxTimeShelved();
assert(_.isFinite(maxTimeShelved));
assert(inputArguments[0].dataType === DataType.Double); // Duration
assert(inputArguments[0] instanceof Variant);
//xx console.log("inputArguments",inputArguments[0].toString());
const proposedDuration = inputArguments[0].value; // as double (milliseconds)
if (proposedDuration > maxTimeShelved) {
return callback(null, {
statusCode: StatusCodes.BadShelvingTimeOutOfRange
});
}
if (proposedDuration < 0) {
return callback(null, {
statusCode: StatusCodes.BadShelvingTimeOutOfRange
});
}
return new Variant({
dataType: DataType.StatusCode,
value: StatusCodes.BadConditionNotShelved
});
}
if (!shelvingState._sheveldTime) {
return new Variant({
dataType: DataType.StatusCode,
value: StatusCodes.BadConditionNotShelved
});
}
if (shelvingState.getCurrentState() === "OneShotShelved" &&
shelvingState._duration === UAAlarmConditionBase.MaxDuration) {
return new Variant({
dataType: DataType.Double,
value: UAAlarmConditionBase.MaxDuration
});
}
const now = new Date();
let timeToAutomaticUnshelvedState =
shelvingState._duration - (now.getTime() - shelvingState._sheveldTime.getTime());
// timeToAutomaticUnshelvedState should always be greater than (or equal) zero
timeToAutomaticUnshelvedState = Math.max(timeToAutomaticUnshelvedState, 0);
return new Variant({
dataType: DataType.Double, // duration
value: timeToAutomaticUnshelvedState
});
}
UAVariable.prototype._readMinimumSamplingInterval = function () {
// expect a Duration => Double
const options = {};
if (this.minimumSamplingInterval === undefined) {
options.statusCode = StatusCodes.BadAttributeIdInvalid;
} else {
options.value = {dataType: DataType.Double, value: this.minimumSamplingInterval};
options.statusCode = StatusCodes.Good;
}
return new DataValue(options);
};
});
}
if (options.hasOwnProperty("valuePrecision")) {
assert(_.isNumber(options.valuePrecision));
namespace.addVariable({
browseName: { name: "ValuePrecision", namespaceIndex: 0 },
dataType: "Double",
description: valuePrecision_Description,
minimumSamplingInterval: 0,
modellingRule: options.modellingRule ? "Mandatory" : undefined,
propertyOf: variable,
typeDefinition: "PropertyType",
value: new Variant({ dataType: DataType.Double, value: options.valuePrecision })
});
}
}
export class UADataItem extends UAVariable implements UADataItemPublic {
function check_valid_array(dataType: DataType, array: any): boolean {
if (_.isArray(array)) {
return true;
}
switch (dataType) {
case DataType.Double:
return array instanceof Float64Array;
case DataType.Float:
return array instanceof Float32Array;
case DataType.Int32:
return array instanceof Int32Array;
case DataType.Int16:
return array instanceof Int16Array;
case DataType.SByte:
return array instanceof Int8Array;
case DataType.UInt32:
return array instanceof Uint32Array;
case DataType.UInt16:
return array instanceof Uint16Array;
case DataType.Byte:
return array instanceof Uint8Array || array instanceof Buffer;
}
function bindServerCapabilities() {
bindStandardArray(VariableIds.Server_ServerCapabilities_ServerProfileArray,
DataType.String, "String", function () {
return engine.serverCapabilities.serverProfileArray;
});
bindStandardArray(VariableIds.Server_ServerCapabilities_LocaleIdArray,
DataType.String, "LocaleId", function () {
return engine.serverCapabilities.localeIdArray;
});
bindStandardScalar(VariableIds.Server_ServerCapabilities_MinSupportedSampleRate,
DataType.Double, function () {
return engine.serverCapabilities.minSupportedSampleRate;
});
bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxBrowseContinuationPoints,
DataType.UInt16, function () {
return engine.serverCapabilities.maxBrowseContinuationPoints;
});
bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxQueryContinuationPoints,
DataType.UInt16, function () {
return engine.serverCapabilities.maxQueryContinuationPoints;
});
bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxHistoryContinuationPoints,
DataType.UInt16, function () {
return engine.serverCapabilities.maxHistoryContinuationPoints;
get() {
const percent_used = Math.round((os.totalmem() - os.freemem()) / os.totalmem() * 100);
return new Variant({dataType: DataType.Double, value: percent_used});
}
}
finish(this: any) {
this.parent.parent.obj.value = {
dataType: DataType.Double,
value: parseFloat(this.text)
};
}
},