diff --git a/src/flightlog.js b/src/flightlog.js index 97716a56..21cc763b 100644 --- a/src/flightlog.js +++ b/src/flightlog.js @@ -31,7 +31,7 @@ import { export function FlightLog(logData) { let ADDITIONAL_COMPUTED_FIELD_COUNT = 15 /** attitude + PID_SUM + PID_ERROR + RCCOMMAND_SCALED **/, that = this, - logIndex = false, + logIndex = 0, logIndexes = new FlightLogIndex(logData), parser = new FlightLogParser(logData), iframeDirectory, @@ -117,20 +117,21 @@ export function FlightLog(logData) { * Get the earliest time seen in the log of the given index (in microseconds), or leave off the logIndex * argument to fetch details for the current log. */ - this.getMinTime = function (logIndex) { - return getRawStats(logIndex).frame["I"].field[ - FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME - ].min; + this.getMinTime = function () { + return logIndexes.getIntraframeDirectory(logIndex).minTime; }; /** * Get the latest time seen in the log of the given index (in microseconds), or leave off the logIndex * argument to fetch details for the current log. */ - this.getMaxTime = function (logIndex) { - return getRawStats(logIndex).frame["I"].field[ - FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME - ].max; + this.getMaxTime = function () { + return logIndexes.getIntraframeDirectory(logIndex).maxTime; + }; + + this.getActualLoggedTime = function () { + const directory = logIndexes.getIntraframeDirectory(logIndex); + return directory.maxTime - directory.minTime - directory.unLoggedTime; }; /** diff --git a/src/flightlog_index.js b/src/flightlog_index.js index 24f5dfaf..e35a3809 100644 --- a/src/flightlog_index.js +++ b/src/flightlog_index.js @@ -56,6 +56,7 @@ export function FlightLogIndex(logData) { hasEvent: [], minTime: false, maxTime: false, + unLoggedTime: 0, }, imu = new IMU(), gyroADC, @@ -125,7 +126,8 @@ export function FlightLogIndex(logData) { if (magADC[0] === undefined) { magADC = false; } - + + let frameTime; parser.onFrameReady = function ( frameValid, frame, @@ -140,9 +142,7 @@ export function FlightLogIndex(logData) { switch (frameType) { case "P": case "I": - var frameTime = - frame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME]; - + frameTime = frame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME]; if (intraIndex.minTime === false) { intraIndex.minTime = frameTime; } @@ -225,6 +225,13 @@ export function FlightLogIndex(logData) { if (frame.event == FlightLogEvent.LOG_END) { sawEndMarker = true; } + + if (frame.event == FlightLogEvent.LOGGING_RESUME) { + if (frameTime) { + intraIndex.unLoggedTime += frame.data.currentTime - frameTime; + } + } + break; case "S": lastSlow = frame.slice(0); diff --git a/src/graph_spectrum_calc.js b/src/graph_spectrum_calc.js index 4445daf0..84cd6758 100644 --- a/src/graph_spectrum_calc.js +++ b/src/graph_spectrum_calc.js @@ -50,12 +50,10 @@ GraphSpectrumCalc.initialize = function(flightLog, sysConfig) { } this._BetaflightRate = this._blackBoxRate; - const minTime = this._flightLog.getMinTime(), - maxTime = this._flightLog.getMaxTime(), - timeRange = maxTime - minTime; + const actualLoggedTime = this._flightLog.getActualLoggedTime(), + length = flightLog.getCurrentLogRowsCount(); - const length = flightLog.getCurrentLogRowsCount(); - this._actualeRate = 1e6 * length / timeRange; + this._actualeRate = 1e6 * length / actualLoggedTime; if (Math.abs(this._BetaflightRate - this._actualeRate) / this._actualeRate > WARNING_RATE_DIFFERENCE) this._blackBoxRate = Math.round(this._actualeRate);