Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
historyData: new HistoryData({ dataValues }),
statusCode: StatusCodes.Good
});
return callback(null, result2);
}
// todo add special treatment for when startTime > endTime
// ( in this case series must be return in reverse order )
let maxNumberToExtract = 0;
let isReversed = false;
let reverseDataValue = false;
if (isMinDate(historyReadRawModifiedDetails.endTime!)) {
// end time is not specified
maxNumberToExtract = historyReadRawModifiedDetails.numValuesPerNode;
if (isMinDate(historyReadRawModifiedDetails.startTime!)) {
// end start and start time are not specified, this is invalid
const result = new HistoryReadResult({
statusCode: StatusCodes.BadHistoryOperationUnsupported // should be an error
});
return callback(null, result);
}
} else if (isMinDate(historyReadRawModifiedDetails.startTime!)) {
// start time is not specified
// end time is specified
maxNumberToExtract = historyReadRawModifiedDetails.numValuesPerNode;
isReversed = true;
reverseDataValue = false;
if (historyReadRawModifiedDetails.numValuesPerNode === 0) {
// when start time is not specified
return callback(err);
}
// now make sure that only the requested number of value is returned
if (historyReadRawModifiedDetails.numValuesPerNode >= 1) {
if (dataValues.length === 0) {
const result1 = new HistoryReadResult({
historyData: new HistoryData({ dataValues: [] }),
statusCode: StatusCodes.GoodNoData
});
return callback(null, result1);
} else {
const remaining = dataValues;
dataValues = remaining.splice(0, historyReadRawModifiedDetails.numValuesPerNode);
if (remaining.length > 0 && !isMinDate(historyReadRawModifiedDetails.endTime)) {
continuationPoint = createContinuationPoint();
context.continuationPoints = context.continuationPoints || {};
context.continuationPoints[continuationPoint.toString("hex")] = {
dataValues: remaining
};
}
}
}
const result = new HistoryReadResult({
continuationPoint: continuationPoint || undefined,
historyData: new HistoryData({ dataValues }),
statusCode: StatusCodes.Good
});
callback(null, result);
});
function inInTimeRange2(
historyReadDetails: any,
dataValue: DataValue
): boolean {
if (historyReadDetails.endTime &&
!isMinDate(historyReadDetails.endTime) &&
dataValue.sourceTimestamp! > historyReadDetails.endTime) {
return false;
}
return !(historyReadDetails.startTime &&
!isMinDate(historyReadDetails.startTime) &&
dataValue.sourceTimestamp! < historyReadDetails.startTime);
}
function inInTimeRange2(
historyReadDetails: any,
dataValue: DataValue
): boolean {
if (historyReadDetails.endTime &&
!isMinDate(historyReadDetails.endTime) &&
dataValue.sourceTimestamp! > historyReadDetails.endTime) {
return false;
}
return !(historyReadDetails.startTime &&
!isMinDate(historyReadDetails.startTime) &&
dataValue.sourceTimestamp! < historyReadDetails.startTime);
}
function inInTimeRange(
historyReadDetails: any,
dataValue: DataValue
): boolean {
if (historyReadDetails.startTime &&
!isMinDate(historyReadDetails.startTime)
&& dataValue.sourceTimestamp! < historyReadDetails.startTime) {
return false;
}
if (historyReadDetails.endTime
&& !isMinDate(historyReadDetails.endTime)
&& dataValue.sourceTimestamp! > historyReadDetails.endTime) {
return false;
}
return true;
}
function inInTimeRange(
historyReadDetails: any,
dataValue: DataValue
): boolean {
if (historyReadDetails.startTime &&
!isMinDate(historyReadDetails.startTime)
&& dataValue.sourceTimestamp! < historyReadDetails.startTime) {
return false;
}
if (historyReadDetails.endTime
&& !isMinDate(historyReadDetails.endTime)
&& dataValue.sourceTimestamp! > historyReadDetails.endTime) {
return false;
}
return true;
}