Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public _onInputDataValueChange(dataValue: DataValue): void {
assert(dataValue instanceof DataValue);
if (dataValue.statusCode === StatusCodes.BadWaitingForInitialData
&& dataValue.statusCode === StatusCodes.UncertainInitialValue) {
// we are not ready yet to use the input node value
return;
}
if (dataValue.statusCode !== StatusCodes.Good) {
// what shall we do ?
this._signalNewCondition(null);
return;
}
if (dataValue.value.dataType === DataType.Null) {
// what shall we do ?
this._signalNewCondition(null);
return;
}
const value = dataValue.value.value;
this._setStateBasedOnInputValue(value);
self.parentNodeId = options.parentNodeId;
/**
* The Historizing Attribute indicates whether the Server is actively collecting data for the
* history of the Variable.
* @property historizing
* @type {Boolean}
* This differs from the AccessLevel Attribute which identifies if the
* Variable has any historical data. A value of TRUE indicates that the Server is actively
* collecting data. A value of FALSE indicates the Server is not actively collecting data.
* Default value is FALSE.
*/
self.historizing = !!options.historizing; // coerced to boolean
self._dataValue = new DataValue({statusCode: StatusCodes.BadWaitingForInitialData, value: {}});
if (options.value) {
self.bindVariable(options.value);
}
if (options.permissions) {
self.setPermissions(options.permissions);
}
this.setMaxListeners(5000);
self.semantic_version = 0;
self.permission = null;
}
UALimitAlarm.prototype._onInputDataValueChange = function (dataValue) {
assert(dataValue instanceof DataValue);
const alarm = this;
if (dataValue.statusCode === StatusCodes.BadWaitingForInitialData) {
// we are not ready yet to use the input node value
return;
}
if (dataValue.statusCode !== StatusCodes.Good) {
// what shall we do ?
alarm._signalNewCondition(null);
return;
}
if (dataValue.value.dataType === DataType.Null) {
// what shall we do ?
alarm._signalNewCondition(null);
return;
}
const value = dataValue.value.value;
alarm._setStateBasedOnInputValue(value);
};
}
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.statusCode.equals(StatusCodes.UncertainInitialValue)
) {
debugLog(chalk.red(" Warning: UAVariable#readValue ")
+ chalk.cyan(this.browseName.toString()) +
" (" + chalk.yellow(this.nodeId.toString()) + ") exists but dataValue has not been defined");
}
return dataValue;
}
//
// The PercentDataGood and PercentDataBad shall follow the following relationship
// PercentDataGood ≥ (100 – PercentDataBad). If they are equal the result of the
// PercentDataGood calculation is used. If the values entered for PercentDataGood and
//
// PercentDataBad do not result in a valid calculation (e.g. Bad = 80; Good = 0) the result will
// have a StatusCode of Bad_AggregateInvalidInputs The StatusCode
//
// Bad_AggregateInvalidInputs will be returned if the value of PercentDataGood or
// PercentDataBad exceed 100.
node.$historicalDataConfiguration = historicalDataConfiguration;
const dataValue = node.readValue();
if (
dataValue.statusCode !== StatusCodes.BadWaitingForInitialData
&& dataValue.statusCode !== StatusCodes.UncertainInitialValue) {
on_value_change.call(node, dataValue);
}
node.on("value_changed", on_value_change);
// update the index of historizing nodes in the addressSpace
node.addressSpace.historizingNodes = node.addressSpace.historizingNodes || {};
node.addressSpace.historizingNodes[node.nodeId.toString()] = node;
}
}
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)) {
debugLog(" Warning: UAVariable#readValue ".red + self.browseName.toString().cyan + " (" + self.nodeId.toString().yellow + ") exists but dataValue has not been defined");
}
return dataValue;
};