Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log records count computing is optimized #718

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions js/flightlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,13 @@ function FlightLog(logData) {
this.hasGpsData = function() {
return this.getStats()?.frame?.G ? true : false;;
};

this.getCurrentLogRowsCount = function () {
const stats = this.getStats(this.getLogIndex());
const countI = stats.frame['I'] ? stats.frame['I'].totalCount : 0;
const countP = stats.frame['P'] ? stats.frame['P'].totalCount : 0;
return countI + countP;
};
}

FlightLog.prototype.accRawToGs = function(value) {
Expand Down
18 changes: 9 additions & 9 deletions js/flightlog_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,9 @@ var FlightLogParser = function(logData) {
function translateFieldName(fieldName) {
var translation = translationValues[fieldName];
if (typeof translation !== 'undefined') {
return translation;
return translation;
} else {
return fieldName;
return fieldName;
}
}

Expand Down Expand Up @@ -602,14 +602,14 @@ var FlightLogParser = function(logData) {
case "Cleanflight":
that.sysConfig.firmwareType = FIRMWARE_TYPE_CLEANFLIGHT;
$('html').removeClass('isBaseF');
$('html').addClass('isCF');
$('html').addClass('isCF');
$('html').removeClass('isBF');
$('html').removeClass('isINAV');
break;
default:
that.sysConfig.firmwareType = FIRMWARE_TYPE_BASEFLIGHT;
$('html').addClass('isBaseF');
$('html').removeClass('isCF');
$('html').removeClass('isCF');
$('html').removeClass('isBF');
$('html').removeClass('isINAV');
}
Expand Down Expand Up @@ -946,7 +946,7 @@ var FlightLogParser = function(logData) {
$('html').addClass('isINAV');
} else {

// Cleanflight 1.x and others
// Cleanflight 1.x and others
that.sysConfig.firmwareVersion = '0.0.0';
that.sysConfig.firmware = 0.0;
that.sysConfig.firmwarePatch = 0;
Expand Down Expand Up @@ -1744,7 +1744,6 @@ var FlightLogParser = function(logData) {
stream.pos = stream.start;
stream.end = endOffset === undefined ? stream.end : endOffset;
stream.eof = false;

while (true) {
var command = stream.readChar();

Expand All @@ -1762,12 +1761,13 @@ var FlightLogParser = function(logData) {
sizeCount: new Int32Array(256), /* int32 arrays are zero-filled, handy! */
validCount: 0,
corruptCount: 0,
field: []
field: [],
totalCount: 0
};
}

frameTypeStats = this.stats.frame[lastFrameType.marker];

frameTypeStats.totalCount++;
// If we see what looks like the beginning of a new frame, assume that the previous frame was valid:
if (lastFrameSize <= FLIGHT_LOG_MAX_FRAME_LENGTH && looksLikeFrameCompleted) {
var frameAccepted = true;
Expand All @@ -1781,7 +1781,7 @@ var FlightLogParser = function(logData) {
frameTypeStats.sizeCount[lastFrameSize]++;
frameTypeStats.validCount++;
} else {
frameTypeStats.desyncCount++;
frameTypeStats.desyncCount = frameTypeStats.desyncCount ? ++frameTypeStats.desyncCount : 1;
}
} else {
//The previous frame was corrupt
Expand Down
7 changes: 3 additions & 4 deletions js/graph_spectrum_calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ GraphSpectrumCalc.initialize = function(flightLog, sysConfig) {
maxTime = minTime + MAX_ANALYSER_LENGTH;
demvlad marked this conversation as resolved.
Show resolved Hide resolved
timeRange = MAX_ANALYSER_LENGTH;
haslinghuis marked this conversation as resolved.
Show resolved Hide resolved
}
const allChunks = this._flightLog.getChunksInTimeRange(minTime, maxTime);
const length = allChunks.reduce((acc, chunk) => acc + chunk.frames.length, 0);
this._actualeRate = 1e6 * length / timeRange;

if (Math.abs(this._BetaflightRate - this._actualeRate) / this._actualeRate > WARNING_RATE_DIFFERENCE)
const length = flightLog.getCurrentLogRowsCount();
this._actualeRate = 1e6 * length / timeRange;
if (Math.abs(this._BetaflightRate - this._actualeRate) / this._actualeRate > WARNING_RATE_DIFFERENCE)
this._blackBoxRate = Math.round(this._actualeRate);

if (this._BetaflightRate !== this._blackBoxRate) {
Expand Down
Loading