Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// AttributeIds.Value is only valid for monitoring value of UAVariables.
return handle_error(StatusCodes.BadAttributeIdInvalid);
}
if (itemToMonitor.attributeId === AttributeIds.INVALID) {
return handle_error(StatusCodes.BadAttributeIdInvalid);
}
if (!itemToMonitor.indexRange.isValid()) {
return handle_error(StatusCodes.BadIndexRangeInvalid);
}
// check dataEncoding applies only on Values
if (itemToMonitor.dataEncoding.name && itemToMonitor.attributeId !== AttributeIds.Value) {
return handle_error(StatusCodes.BadDataEncodingInvalid);
}
// check dataEncoding
if (!isValidDataEncoding(itemToMonitor.dataEncoding)) {
return handle_error(StatusCodes.BadDataEncodingUnsupported);
}
// check that item can be read by current user session
// filter
const requestedParameters = monitoredItemCreateRequest.requestedParameters;
const filter = requestedParameters.filter;
const statusCodeFilter = validateFilter(filter, itemToMonitor, node);
if (statusCodeFilter !== StatusCodes.Good) {
return handle_error(statusCodeFilter);
}
UAVariable.prototype.readValue = function (context, indexRange, dataEncoding) {
if (!context) {
context = SessionContext.defaultContext;
}
const self = this;
if (!self.isReadable(context)) {
return new DataValue({statusCode: StatusCodes.BadNotReadable});
}
if (!self.isUserReadable(context)) {
return new DataValue({statusCode: StatusCodes.BadUserAccessDenied});
}
if (!is_valid_dataEncoding(dataEncoding)) {
return new DataValue({statusCode: StatusCodes.BadDataEncodingInvalid});
}
if (self._timestamped_get_func) {
assert(self._timestamped_get_func.length === 0);
self._dataValue = self._timestamped_get_func();
}
let dataValue = self._dataValue;
if (isGoodish(dataValue.statusCode)) {
dataValue = extractRange(dataValue, indexRange);
}
/* istanbul ignore next */
if (dataValue.statusCode.equals(StatusCodes.BadWaitingForInitialData)) {
if (itemToMonitor.attributeId === AttributeIds.Value && !(node.nodeClass === NodeClass.Variable)) {
// AttributeIds.Value is only valid for monitoring value of UAVariables.
return handle_error(StatusCodes.BadAttributeIdInvalid);
}
if (itemToMonitor.attributeId === AttributeIds.INVALID) {
return handle_error(StatusCodes.BadAttributeIdInvalid);
}
if (!itemToMonitor.indexRange.isValid()) {
return handle_error(StatusCodes.BadIndexRangeInvalid);
}
// check dataEncoding applies only on Values
if (itemToMonitor.dataEncoding.name && itemToMonitor.attributeId !== AttributeIds.Value) {
return handle_error(StatusCodes.BadDataEncodingInvalid);
}
// check dataEncoding
if (!isValidDataEncoding(itemToMonitor.dataEncoding)) {
return handle_error(StatusCodes.BadDataEncodingUnsupported);
}
// check that item can be read by current user session
// filter
const requestedParameters = monitoredItemCreateRequest.requestedParameters;
const filter = requestedParameters.filter;
const statusCodeFilter = validateFilter(filter, itemToMonitor, node);
if (statusCodeFilter !== StatusCodes.Good) {
return handle_error(statusCodeFilter);
}
public readValue(context?: SessionContext | null, indexRange?: NumericRange, dataEncoding?: string) {
if (!context) {
context = SessionContext.defaultContext;
}
if (!this.isReadable(context)) {
return new DataValue({ statusCode: StatusCodes.BadNotReadable });
}
if (!this.isUserReadable(context)) {
return new DataValue({ statusCode: StatusCodes.BadUserAccessDenied });
}
if (!isValidDataEncoding(dataEncoding)) {
return new DataValue({ statusCode: StatusCodes.BadDataEncodingInvalid });
}
if (this._timestamped_get_func) {
assert(this._timestamped_get_func.length === 0);
this._dataValue = this._timestamped_get_func();
}
let dataValue = this._dataValue;
if (isGoodish(dataValue.statusCode)) {
// note : extractRange will clone the dataValue
dataValue = extractRange(dataValue, indexRange);
}
/* istanbul ignore next */
if (dataValue.statusCode.equals(StatusCodes.BadWaitingForInitialData)
): DataValue {
if (!context) {
context = SessionContext.defaultContext;
}
assert(context instanceof SessionContext);
const options: DataValueLike = {};
if (attributeId !== AttributeIds.Value) {
if (indexRange && indexRange.isDefined()) {
options.statusCode = StatusCodes.BadIndexRangeNoData;
return new DataValue(options);
}
if (isDataEncoding(dataEncoding)) {
options.statusCode = StatusCodes.BadDataEncodingInvalid;
return new DataValue(options);
}
}
switch (attributeId) {
case AttributeIds.Value:
return this.readValue(context, indexRange, dataEncoding);
case AttributeIds.DataType:
return this._readDataType();
case AttributeIds.ValueRank:
return this._readValueRank();
case AttributeIds.ArrayDimensions:
return this._readArrayDimensions();
UAVariable.prototype.readAttribute = function (context, attributeId, indexRange, dataEncoding) {
if (!context) {
context = SessionContext.defaultContext;
}
assert(context instanceof SessionContext);
const options = {};
if (attributeId !== AttributeIds.Value) {
if (indexRange && indexRange.isDefined()) {
options.statusCode = StatusCodes.BadIndexRangeNoData;
return new DataValue(options);
}
if (is_dataEncoding(dataEncoding)) {
options.statusCode = StatusCodes.BadDataEncodingInvalid;
return new DataValue(options);
}
}
switch (attributeId) {
case AttributeIds.Value:
return this.readValue(context, indexRange, dataEncoding);
case AttributeIds.DataType:
return this._readDataType();
case AttributeIds.ValueRank:
return this._readValueRank();
case AttributeIds.ArrayDimensions:
return this._readArrayDimensions();