예제 #1
0
  private void WriteFrameToOutputPorts(Frame aFrame) {
    // Write frame with valid data
    WriteIntegerToFilterOutputPort(TIMESTAMP_ID, FilterFramework.outPipe1);
    WriteLongToFilterOutputPort(aFrame.getTimeStamp(), FilterFramework.outPipe1);

    WriteIntegerToFilterOutputPort(VELOCITY_ID, FilterFramework.outPipe1);
    WriteLongToFilterOutputPort(aFrame.getVelocity(), FilterFramework.outPipe1);

    WriteIntegerToFilterOutputPort(ALTITUDE_MEASURE_ID, FilterFramework.outPipe1);
    WriteLongToFilterOutputPort(aFrame.getAltitudeMeasure(), FilterFramework.outPipe1);

    if (aFrame.getHasInvalidPressureMeasure() == true) {
      WriteIntegerToFilterOutputPort(PRESSURE_EXTRAPOLATED_MEASURE_ID, FilterFramework.outPipe1);
      WriteLongToFilterOutputPort(
          aFrame.getExtrapolatedPressureMeasure(), FilterFramework.outPipe1);
    } else {
      WriteIntegerToFilterOutputPort(PRESSURE_MEASURE_ID, FilterFramework.outPipe1);
      WriteLongToFilterOutputPort(aFrame.getPressureMeasure(), FilterFramework.outPipe1);
    }
    WriteIntegerToFilterOutputPort(TEMPERATURE_MEASURE_ID, FilterFramework.outPipe1);
    WriteLongToFilterOutputPort(aFrame.getTemperatureMeasure(), FilterFramework.outPipe1);

    WriteIntegerToFilterOutputPort(ATTITUDE_MEASURE_ID, FilterFramework.outPipe1);
    WriteLongToFilterOutputPort(aFrame.getAttitudeMeasure(), FilterFramework.outPipe1);

    // Write wildpoints
    if (aFrame.getHasInvalidPressureMeasure() == true) {
      WriteIntegerToFilterOutputPort(TIMESTAMP_ID, FilterFramework.outPipe2);
      WriteLongToFilterOutputPort(aFrame.getTimeStamp(), FilterFramework.outPipe2);

      WriteIntegerToFilterOutputPort(PRESSURE_MEASURE_ID, FilterFramework.outPipe2);
      WriteLongToFilterOutputPort(aFrame.getPressureMeasure(), FilterFramework.outPipe2);
    }
  }
예제 #2
0
 Frame(Frame aFrame) {
   this(
       aFrame.getTimeStamp(),
       aFrame.getVelocity(),
       aFrame.getAltitudeMeasure(),
       aFrame.getPressureMeasure(),
       aFrame.getTemperatureMeasure(),
       aFrame.getAttitudeMeasure(),
       aFrame.getExtrapolatedPressureMeasure());
 }
예제 #3
0
  // Tries to extrapolate and fill extrapolated pressure measures to
  // frames with invalid pressure
  private void ExtrapolateFramesInList(List<Frame> aFrameQueue, boolean aIsOnFlush) {
    if (aFrameQueue.isEmpty()) {
      return;
    }

    Frame firstFrame = aFrameQueue.get(0);
    if (firstFrame.getHasInvalidPressureMeasure() == true
        && firstFrame.getExtrapolatedPressureMeasure() == 0) {
      // the stream has started with invalid pressure measure.
      // Find last valid and use it to fill invalid measurements
      long validMeasure = 0;
      Frame fr = null;
      for (int i = 0; i < aFrameQueue.size(); i++) {
        fr = aFrameQueue.get(i);
        if ((fr.getHasInvalidPressureMeasure() == false)
            || (fr.getHasInvalidPressureMeasure() == true
                && fr.getExtrapolatedPressureMeasure() > 0)) {
          validMeasure = fr.getPressureMeasure();
          break;
        }
      }

      for (int i = 0; i < aFrameQueue.size(); i++) {
        fr = aFrameQueue.get(i);
        fr.setExtrapolatedPressureMeasure(validMeasure);
        aFrameQueue.set(i, fr);
        if (fr.getHasInvalidPressureMeasure() == false) {
          break;
        }
      }
    } else {
      if (aFrameQueue.size() < 3) {
        if (aIsOnFlush && aFrameQueue.size() > 1) {
          // in that case there are 2 elements.
          // First inserted is valid
          // Second is invalid
          // In that no third element is expeced. Use first one to fill the pressure of second one
          Frame fr = aFrameQueue.get(0);
          long validPressure =
              fr.getHasInvalidPressureMeasure()
                  ? fr.getExtrapolatedPressureMeasure()
                  : fr.getPressureMeasure();
          fr = aFrameQueue.get(1);
          fr.setExtrapolatedPressureMeasure(validPressure);
          aFrameQueue.set(1, fr);
        } else {
          // in that case there are 2 elements.
          // First inserted is valid
          // Second is invalid
          // In that case do nothing. Thirt element required for decition how to fix invalid
          // pressure
          return;
        }
      } else {
        // Got 3 ot more elements
        // and the first one is valid
        Frame fr = aFrameQueue.get(1);
        boolean isValidSecond =
            (fr.getHasInvalidPressureMeasure() == false
                || (fr.getHasInvalidPressureMeasure() == true
                    && fr.getExtrapolatedPressureMeasure() > 0));

        fr = aFrameQueue.get(2);
        boolean isValidThird =
            (fr.getHasInvalidPressureMeasure() == false
                || (fr.getHasInvalidPressureMeasure() == true
                    && fr.getExtrapolatedPressureMeasure() > 0));

        if (!isValidSecond && !isValidThird) {
          // Extrapolate the second with the first value
          fr = aFrameQueue.get(0);
          long validPressure =
              fr.getHasInvalidPressureMeasure()
                  ? fr.getExtrapolatedPressureMeasure()
                  : fr.getPressureMeasure();
          // fix second with right pressure
          fr = aFrameQueue.get(1);
          fr.setExtrapolatedPressureMeasure(validPressure);
          aFrameQueue.set(1, fr);
        }
        if (!isValidSecond && isValidThird) {
          // Interpolate second value
          fr = aFrameQueue.get(0);
          long firstValidPressure =
              fr.getHasInvalidPressureMeasure()
                  ? fr.getExtrapolatedPressureMeasure()
                  : fr.getPressureMeasure();
          fr = aFrameQueue.get(2);
          long secondValidPressure =
              fr.getHasInvalidPressureMeasure()
                  ? fr.getExtrapolatedPressureMeasure()
                  : fr.getPressureMeasure();
          double interpolVal = (firstValidPressure + secondValidPressure) / 2.0;
          fr = aFrameQueue.get(1);
          fr.setExtrapolatedPressureMeasure(Double.doubleToLongBits(interpolVal));
        }
      }
    }
  }