Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public _setValue(value: Int64) {
// check that value is in bound
if (!this._isValueInRange(coerceInt32(value))) {
throw new Error("UAMultiStateValueDiscrete#_setValue out of range " + value);
}
const dataType = this._getDataType();
if (dataType === DataType.Int64 || dataType === DataType.UInt64) {
this.setValueFromSource({ dataType, value });
} else {
const valueN = value[1];
this.setValueFromSource({ dataType, value: valueN });
}
}
init(this: any, name: string, attrs: XmlAttributes) {
this.obj = {};
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
this.obj.nodeClass = NodeClass.VariableType;
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
this.obj.parentNodeId = attrs.ParentNodeId || null;
this.obj.dataType = convertToNodeId(attrs.DataType) || null;
this.obj.valueRank = ec.coerceInt32(attrs.ValueRank) || -1;
this.obj.arrayDimensions = this.obj.valueRank === -1 ? null : stringToUInt32Array(attrs.ArrayDimensions);
this.obj.minimumSamplingInterval =
attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0;
this.obj.historizing = false;
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
},
finish(this: any) {
const e = enumValues.findIndex((x: EnumValueType) => coerceInt32(x.value) === value);
return !(e === -1);
init: function (name, attrs) {
this.obj = {};
this.obj.nodeClass = NodeClass.Variable;
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
this.obj.parentNodeId = convertToNodeId(attrs.ParentNodeId);
this.obj.dataType = convertToNodeId(attrs.DataType);
this.obj.valueRank = ec.coerceInt32(attrs.ValueRank) || -1;
this.obj.arrayDimensions = this.obj.valueRank === -1 ? null : stringToUInt32Array(attrs.ArrayDimensions);
this.obj.minimumSamplingInterval = attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval) : 0;
this.obj.minimumSamplingInterval = parseInt(this.obj.minimumSamplingInterval);
this.obj.historizing = false;
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
this.obj.accessLevel = convertAccessLevel(attrs.AccessLevel);
this.obj.userAccessLevel = convertAccessLevel(attrs.UserAccessLevel);
},
finish: function () {
public checkVariantCompatibility(value: Variant): StatusCode {
if (this.enumValues) {
if (!this._isValueInRange(coerceInt32(value.value))) {
return StatusCodes.BadOutOfRange;
}
}
return StatusCodes.Good;
}