From 83929f1c733c1c8d178dfa3a6b600140b4e0f981 Mon Sep 17 00:00:00 2001 From: demvlad Date: Wed, 7 Aug 2024 18:23:27 +0300 Subject: [PATCH 1/6] added compute of unlogged time by handling log resumd events --- src/flightlog_index.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/flightlog_index.js b/src/flightlog_index.js index 24f5dfaf..d7941c4a 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 lastTime = undefined; parser.onFrameReady = function ( frameValid, frame, @@ -140,9 +142,9 @@ export function FlightLogIndex(logData) { switch (frameType) { case "P": case "I": - var frameTime = + let frameTime = frame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME]; - + lastTime = frameTime; if (intraIndex.minTime === false) { intraIndex.minTime = frameTime; } @@ -225,6 +227,13 @@ export function FlightLogIndex(logData) { if (frame.event == FlightLogEvent.LOG_END) { sawEndMarker = true; } + + if (frame.event == FlightLogEvent.LOGGING_RESUME) { + if (lastTime) { + intraIndex.unLoggedTime += frame.data.currentTime - lastTime; + } + } + break; case "S": lastSlow = frame.slice(0); From e8797f1475507d594eb6bb1cd0a378ec9b941c25 Mon Sep 17 00:00:00 2001 From: demvlad Date: Wed, 7 Aug 2024 18:31:51 +0300 Subject: [PATCH 2/6] added getActualLoggedTime function in FlightLog --- src/flightlog.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/flightlog.js b/src/flightlog.js index 97716a56..48ba83f3 100644 --- a/src/flightlog.js +++ b/src/flightlog.js @@ -132,6 +132,11 @@ export function FlightLog(logData) { FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME ].max; }; + + this.getActualLoggedTime = function (logIndex) + const directory = logIndexes.getIntraframeDirectory(logIndex); + return directory.maxTime - directory.minTime - directory.unLoggedTime; + } /** * Get the flight controller system information that was parsed for the current log file. From 1e3f0893ab13f22558247d30dd54e3c91143a369 Mon Sep 17 00:00:00 2001 From: demvlad Date: Wed, 7 Aug 2024 19:33:59 +0300 Subject: [PATCH 3/6] improve getMinTime, getMaxTime functions in FlightLog --- src/flightlog.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/flightlog.js b/src/flightlog.js index 48ba83f3..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,26 +117,22 @@ 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 (logIndex) + this.getActualLoggedTime = function () { const directory = logIndexes.getIntraframeDirectory(logIndex); return directory.maxTime - directory.minTime - directory.unLoggedTime; - } + }; /** * Get the flight controller system information that was parsed for the current log file. From b86396eb0a5a090595573562b08e6b98c705f738 Mon Sep 17 00:00:00 2001 From: demvlad Date: Wed, 7 Aug 2024 19:39:23 +0300 Subject: [PATCH 4/6] Improved actual log rate computing in spectrum chart --- src/graph_spectrum_calc.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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); From aa685247267e2cef4a61190e9a8f7634dd86b667 Mon Sep 17 00:00:00 2001 From: demvlad Date: Wed, 7 Aug 2024 20:11:10 +0300 Subject: [PATCH 5/6] code style improvement --- src/flightlog_index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/flightlog_index.js b/src/flightlog_index.js index d7941c4a..a25d9afb 100644 --- a/src/flightlog_index.js +++ b/src/flightlog_index.js @@ -127,7 +127,7 @@ export function FlightLogIndex(logData) { magADC = false; } - let lastTime = undefined; + let lastTime; parser.onFrameReady = function ( frameValid, frame, @@ -142,8 +142,7 @@ export function FlightLogIndex(logData) { switch (frameType) { case "P": case "I": - let frameTime = - frame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME]; + let frameTime = frame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME]; lastTime = frameTime; if (intraIndex.minTime === false) { intraIndex.minTime = frameTime; From 963221541191fc8c346101ae5ddf1975d12ab981 Mon Sep 17 00:00:00 2001 From: demvlad Date: Wed, 7 Aug 2024 20:29:03 +0300 Subject: [PATCH 6/6] code style improvement --- src/flightlog_index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/flightlog_index.js b/src/flightlog_index.js index a25d9afb..e35a3809 100644 --- a/src/flightlog_index.js +++ b/src/flightlog_index.js @@ -127,7 +127,7 @@ export function FlightLogIndex(logData) { magADC = false; } - let lastTime; + let frameTime; parser.onFrameReady = function ( frameValid, frame, @@ -142,8 +142,7 @@ export function FlightLogIndex(logData) { switch (frameType) { case "P": case "I": - let frameTime = frame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME]; - lastTime = frameTime; + frameTime = frame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME]; if (intraIndex.minTime === false) { intraIndex.minTime = frameTime; } @@ -228,8 +227,8 @@ export function FlightLogIndex(logData) { } if (frame.event == FlightLogEvent.LOGGING_RESUME) { - if (lastTime) { - intraIndex.unLoggedTime += frame.data.currentTime - lastTime; + if (frameTime) { + intraIndex.unLoggedTime += frame.data.currentTime - frameTime; } }