Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/flightlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
};

/**
Expand Down
15 changes: 11 additions & 4 deletions src/flightlog_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function FlightLogIndex(logData) {
hasEvent: [],
minTime: false,
maxTime: false,
unLoggedTime: 0,
},
imu = new IMU(),
gyroADC,
Expand Down Expand Up @@ -125,7 +126,8 @@ export function FlightLogIndex(logData) {
if (magADC[0] === undefined) {
magADC = false;
}


let frameTime;
parser.onFrameReady = function (
frameValid,
frame,
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 3 additions & 5 deletions src/graph_spectrum_calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down