How to use the node-opcua-status-code.StatusCodes.BadNoData function in node-opcua-status-code

To help you get started, we’ve selected a few node-opcua-status-code examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / test / helpers / create_historizing_variables.ts View on Github external
const options = {
        percentDataBad: 100,
        percentDataGood: 100,  // Therefore if all values are Good then the
        // quality will be Good, or if all values are Bad then the quality will be Bad, but if there is
        // some Good and some Bad then the quality will be Uncertain
        stepped: false, // Therefore SlopedInterpolation is used between data points.
        treatUncertainAsBad: false, // Therefore Uncertain values are included in Aggregate calls.
        useSlopedExtrapolation: false, // Therefore SteppedExtrapolation is used at end boundary conditions.
    };

    addressSpace.installHistoricalDataNode(node, options);
    installAggregateConfigurationOptions(node, options);

    // 12:00:00 - BadNoData First archive entry, Point created
    addHistory(node, "12:00:00", null, StatusCodes.BadNoData);
    // 12:00:10 10 Raw, Good
    addHistory(node, "12:00:10", 10, StatusCodes.Good);
    // 12:00:20 20 Raw, Good
    addHistory(node, "12:00:20", 20, StatusCodes.Good);
    // 12:00:30 30 Raw, Good
    addHistory(node, "12:00:30", 30, StatusCodes.Good);
    // 12:00:40 40 Raw, Bad         ANNOTATION: Operator 1
    //                                          Jan-02-2012 8:00:00 Scan failed, Bad data entered
    //                              ANNOTATION:
    //                                          Jan-04-2012 7:10:00 Value cannot be verified
    addHistory(node, "12:00:40", 40, StatusCodes.Bad);
    // 12:00:50 50 Raw, Good        ANNOTATION: Engineer1
    //                                          Jan-04-2012 7:00:00 Scanner fixed
    addHistory(node, "12:00:50", 50, StatusCodes.Good);
    // 12:01:00 60 Raw, Good
    addHistory(node, "12:01:00", 60, StatusCodes.Good);
github node-opcua / node-opcua / packages / node-opcua-aggregates / source / minmax.ts View on Github external
//   console.log(interval.toString());

    const indexStart = interval.index;
    let selectedValue: Variant | null = null;

    let counter = 0;
    let statusCode: StatusCode;
    let isPartial = interval.isPartial;

    let isRaw = false;
    let hasBad = false;

    for (let i = indexStart; i < indexStart + interval.count; i++) {
        const dataValue = interval.dataValues[i];

        if (dataValue.statusCode === StatusCodes.BadNoData) {
            isPartial = true;
            continue;
        }

        if (!isGood(dataValue.statusCode)) {
            hasBad = true;
            continue;
        }

        if (!selectedValue) {
            selectedValue = dataValue.value;
            counter = 1;
            if (i === indexStart && dataValue.sourceTimestamp!.getTime() === interval.startTime.getTime()) {
                isRaw = true;
            }
            continue;
github node-opcua / node-opcua / packages / node-opcua-aggregates / source / interval.ts View on Github external
return {
                dataValue: dataValue1,
                index
            };
        }
        if (bTreatUncertainAsBad && isGood(dataValue1.statusCode)) {
            return {
                dataValue: dataValue1,
                index
            };
        }
        index += 1;
    }
    // not found
    return {
        dataValue: new DataValue({ statusCode: StatusCodes.BadNoData }),
        index: -1
    };
}
github node-opcua / node-opcua / packages / node-opcua-aggregates / source / interpolate.ts View on Github external
if (prev2.index + 1 < prev1.index || prev1.index < interval.dataValues.length - 1) {
            // some bad data exist in between = change status code
            const mask = 0x0000FFFFFF;
            const extraBits = interpVal.statusCode.value & mask;
            interpVal.statusCode = StatusCode.makeStatusCode(StatusCodes.UncertainDataSubNormal, extraBits);
        }

        return interpVal;

    }

    /* istanbul ignore next */
    if (interval.index < 0 && interval.count === 0) {
        return new DataValue({
            sourceTimestamp: interval.startTime,
            statusCode: StatusCodes.BadNoData
        });
    }

    const dataValue1 = interval.dataValues[interval.index];

    // if a non-Bad Raw value exists at the timestamp then it is the bounding value;
    if (!isBad(dataValue1.statusCode) && interval.hasRawDataAsStart()) {
        return dataValue1;
    }   
    // find the first non-Bad Raw value before the timestamp;

    // find previous good value
    const before = interval.beforeStartDataValue(bTreatUncertainAsBad);
    if (isBad(before.dataValue.statusCode)) {
        return new DataValue({
            sourceTimestamp: interval.startTime,
github node-opcua / node-opcua / test / test_aggregates_functions.ts View on Github external
it("should find interval below start of data", () => {
            const indexHint = 0;
            const interval = getInterval(makeDate("11:10:00"), tenSeconds, indexHint, dataValues);
            interval.getPercentBad().should.eql(100);
            interval.hasRawDataAsStart().should.eql(false);

            interval.index.should.eql(0);
            interval.startTime.should.eql(makeDate("11:10:00"));
            interpolatedValue(interval, options).statusCode.should.eql(StatusCodes.BadNoData);
        });
        it("should find interval starting at raw data", () => {
github node-opcua / node-opcua / test / test_aggregates_functions.ts View on Github external
it("should find interval below start of data", () => {
            const indexHint = 0;
            const interval = getInterval(makeDate("11:10:00"), tenSeconds, indexHint, dataValues);
            interval.getPercentBad().should.eql(100);
            interval.hasRawDataAsStart().should.eql(false);

            interval.index.should.eql(0);
            interval.startTime.should.eql(makeDate("11:10:00"));
            interpolatedValue(interval, options).statusCode.should.eql(StatusCodes.BadNoData);
        });
        it("should find interval starting at raw data", () => {
github node-opcua / node-opcua / packages / node-opcua-aggregates / source / minmax.ts View on Github external
}
        const compare = predicate(selectedValue, dataValue.value);
        if (compare === "equal")  {
            counter = 1;
            continue;
        }
        if (compare === "select") {
            selectedValue = dataValue.value;
            counter = 1;
        }
    }

    if (!selectedValue) {
        return new DataValue({
            sourceTimestamp: interval.startTime,
            statusCode: StatusCodes.BadNoData
        });
    }
    if (isRaw) {
        if (hasBad) {
            statusCode = StatusCodes.UncertainDataSubNormal;
        } else {
            statusCode = StatusCodes.Good;
        }
    } else if (hasBad) {
        statusCode = StatusCode.makeStatusCode(StatusCodes.UncertainDataSubNormal, "HistorianCalculated");
    } else {
        statusCode = StatusCode.makeStatusCode(StatusCodes.Good, "HistorianCalculated");
    }

    if (counter > 1) {
        statusCode = StatusCode.makeStatusCode(statusCode, "HistorianMultiValue");