Skip to content

Commit 07f5961

Browse files
authored
Resolved issue of log records count and actual log rate computing (#755)
* improve field statistic and log rows count calculate * SonarCloud issue improvement * code style improvement
1 parent 0e341d4 commit 07f5961

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/flightlog.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,9 +1143,7 @@ export function FlightLog(logData) {
11431143

11441144
this.getCurrentLogRowsCount = function () {
11451145
const stats = this.getStats(this.getLogIndex());
1146-
const countI = stats.frame['I'] ? stats.frame['I'].totalCount : 0;
1147-
const countP = stats.frame['P'] ? stats.frame['P'].totalCount : 0;
1148-
return countI + countP;
1146+
return stats.frame['I'].validCount + stats.frame['P'].validCount;
11491147
};
11501148
}
11511149

src/flightlog_parser.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@ export function FlightLogParser(logData) {
11101110
mainHistory[0] = mainHistoryRing[2];
11111111
else
11121112
mainHistory[0] = mainHistoryRing[0];
1113+
return mainStreamIsValid;
11131114
}
11141115

11151116
/**
@@ -1251,7 +1252,7 @@ export function FlightLogParser(logData) {
12511252
that.onFrameReady(gpsHomeIsValid, lastGPS, frameType, frameStart, frameEnd - frameStart);
12521253
}
12531254

1254-
return true;
1255+
return gpsHomeIsValid;
12551256
}
12561257

12571258
function completeSlowFrame(frameType, frameStart, frameEnd, raw) {
@@ -1260,6 +1261,7 @@ export function FlightLogParser(logData) {
12601261
if (that.onFrameReady) {
12611262
that.onFrameReady(true, lastSlow, frameType, frameStart, frameEnd - frameStart);
12621263
}
1264+
return true;
12631265
}
12641266

12651267
function completeInterframe(frameType, frameStart, frameEnd, raw) {
@@ -1300,6 +1302,7 @@ export function FlightLogParser(logData) {
13001302
else
13011303
mainHistory[0] = mainHistoryRing[0];
13021304
}
1305+
return mainStreamIsValid;
13031306
}
13041307

13051308
/**
@@ -1773,13 +1776,12 @@ export function FlightLogParser(logData) {
17731776
sizeCount: new Int32Array(256), /* int32 arrays are zero-filled, handy! */
17741777
validCount: 0,
17751778
corruptCount: 0,
1779+
desyncCount: 0,
17761780
field: [],
1777-
totalCount: 0
17781781
};
17791782
}
17801783

17811784
frameTypeStats = this.stats.frame[lastFrameType.marker];
1782-
frameTypeStats.totalCount++;
17831785
// If we see what looks like the beginning of a new frame, assume that the previous frame was valid:
17841786
if (lastFrameSize <= FLIGHT_LOG_MAX_FRAME_LENGTH && looksLikeFrameCompleted) {
17851787
var frameAccepted = true;
@@ -1793,7 +1795,7 @@ export function FlightLogParser(logData) {
17931795
frameTypeStats.sizeCount[lastFrameSize]++;
17941796
frameTypeStats.validCount++;
17951797
} else {
1796-
frameTypeStats.desyncCount = frameTypeStats.desyncCount ? ++frameTypeStats.desyncCount : 1;
1798+
frameTypeStats.desyncCount++;
17971799
}
17981800
} else {
17991801
//The previous frame was corrupt
@@ -1803,10 +1805,6 @@ export function FlightLogParser(logData) {
18031805
frameTypeStats.corruptCount++;
18041806
this.stats.totalCorruptFrames++;
18051807

1806-
//Let the caller know there was a corrupt frame (don't give them a pointer to the frame data because it is totally worthless)
1807-
if (this.onFrameReady)
1808-
this.onFrameReady(false, null, lastFrameType.marker, frameStart, lastFrameSize);
1809-
18101808
/*
18111809
* Start the search for a frame beginning after the first byte of the previous corrupt frame.
18121810
* This way we can find the start of the next frame after the corrupt frame if the corrupt frame

0 commit comments

Comments
 (0)