Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 12 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -505,21 +505,28 @@ <h4>Workspace</h4>
/>
<input id="analyserZoomY" class="onlyFullScreen" type="range" name="analyserZoomY" value="100" min="10" max="1000" step="10" list="analyserZoomYTicks"
/>
<input id="analyserSegmentLengthPowerAt2" class="onlyFullScreen" type="number" name="analyserSegmentLengthPowerAt2" value="9" min="6" max="20" step="1"
/>
<label id="analyserSegmentLengthPowerAt2Label" name="analyserSegmentLengthPowerAt2Label" class="onlyFullScreen" >
Segment&nbsp;length&nbsp;<br>power&nbsp;at&nbsp;2:
</label>
<input id="analyserLowLevelPSD" class="onlyFullScreen" type="number" name="analyserLowLevelPSD" value="-40" min="-40" max="10" step="5"
/>
<label id="analyserLowLevelPSDLabel" name="analyserLowLevelPSDLabel" class="onlyFullScreen" >
Limit&nbsp;dBm
</label>
<input id="analyserMaxPSD" class="onlyFullScreen" type="number" name="analyserMaxPSD" value="10" min="-35" max="100" step="5"
/>
<input id="analyserMinPSD" class="onlyFullScreen" type="number" name="analyserMinPSD" value="-40" min="-100" max="5" step="5"
/>
<label id="analyserMaxPSDLabel" name="analyserMaxPSDLabel" class="onlyFullScreen" >
Max&nbsp;dBm
</label>
<input id="analyserMinPSD" class="onlyFullScreen" type="number" name="analyserMinPSD" value="-40" min="-100" max="5" step="5"
/>
<label id="analyserMinPSDLabel" name="analyserMinPSDLabel" class="onlyFullScreen" >
Min&nbsp;dBm
</label>
<label id="analyserLowLevelPSDLabel" name="analyserLowLevelPSDLabel" class="onlyFullScreen" >
Limit&nbsp;dBm
</label>



<datalist id="analyserZoomXTicks">
<option>100</option>
Expand Down
40 changes: 29 additions & 11 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,9 @@ html.has-analyser-fullscreen.has-analyser
.analyser input#analyserMaxPSD::-webkit-inner-spin-button,
.analyser input#analyserMaxPSD::-webkit-outer-spin-button,
.analyser input#analyserLowLevelPSD::-webkit-inner-spin-button,
.analyser input#analyserLowLevelPSD::-webkit-outer-spin-button {
.analyser input#analyserLowLevelPSD::-webkit-outer-spin-button ,
.analyser input#analyserSegmentLengthPowerAt2::-webkit-inner-spin-button,
.analyser input#analyserSegmentLengthPowerAt2::-webkit-outer-spin-button {
-webkit-appearance: auto !important;
-moz-appearance: auto !important;
appearance: auto !important;
Expand All @@ -708,42 +710,58 @@ html.has-analyser-fullscreen.has-analyser
top: 30px;
}

.analyser label#analyserMaxPSDLabel {
position:absolute;
color:gray;
left: 0px;
top: 30px;
font-size: 12px;
}

.analyser input#analyserMinPSD {
width: 50px;
height: 20px;
left: 0px;
top: 55px;
}

.analyser label#analyserMinPSDLabel {
position:absolute;
color:gray;
left: 0px;
top: 55px;
font-size: 12px;
}

.analyser input#analyserLowLevelPSD {
width: 50px;
height: 20px;
left: 0px;
top: 80px;
}

.analyser label#analyserMaxPSDLabel {
.analyser label#analyserLowLevelPSDLabel {
position:absolute;
color:gray;
left: 0px;
top: 30px;
top: 80px;
font-size: 12px;
}

.analyser label#analyserMinPSDLabel {
position:absolute;
color:gray;
.analyser input#analyserSegmentLengthPowerAt2 {
width: 42px;
height: 20px;
left: 0px;
top: 55px;
font-size: 12px;
top: 42px;
}

.analyser label#analyserLowLevelPSDLabel {
.analyser label#analyserSegmentLengthPowerAt2Label {
position:absolute;
color:gray;
width: 50px;
height: 20px;
left: 0px;
top: 80px;
font-size: 12px;
top: 20px;
}

.analyser input.onlyFullScreen {
Expand Down
55 changes: 48 additions & 7 deletions src/graph_spectrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
const that = this,
prefs = new PrefStorage(),
DEFAULT_PSD_HEATMAP_MIN = -40,
DEFAULT_PSD_HEATMAP_MAX = 10;
DEFAULT_PSD_HEATMAP_MAX = 10,
DEFAULT_PSD_SEGMENT_LENGTH_POWER = 9;
let analyserZoomX = 1.0 /* 100% */,
analyserZoomY = 1.0 /* 100% */,
dataReload = false,
Expand All @@ -36,6 +37,7 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
const analyserMinPSD = $("#analyserMinPSD");
const analyserMaxPSD = $("#analyserMaxPSD");
const analyserLowLevelPSD = $("#analyserLowLevelPSD");
const analyserSegmentLengthPowerAt2 = $("#analyserSegmentLengthPowerAt2");


const spectrumToolbarElem = $("#spectrumToolbar");
Expand Down Expand Up @@ -124,6 +126,12 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
$("#analyserLowLevelPSDLabel", parentElem).css({
left: `${newSize.width - 155}px`,
});
$("#analyserSegmentLengthPowerAt2", parentElem).css({
left: `${newSize.width - 57}px`,
});
$("#analyserSegmentLengthPowerAt2Label", parentElem).css({
left: `${newSize.width - 135}px`,
});
};

const dataLoad = function (fieldIndex, curve, fieldName) {
Expand Down Expand Up @@ -154,6 +162,7 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {

case SPECTRUM_TYPE.POWER_SPECTRAL_DENSITY:
fftData = GraphSpectrumCalc.dataLoadPSD(analyserZoomY);
analyserSegmentLengthPowerAt2.prop("max", Math.ceil(Math.log2(fftData.maximalSegmentsLength)));
break;

case SPECTRUM_TYPE.FREQUENCY:
Expand Down Expand Up @@ -241,11 +250,6 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
debounce(100, function () {
analyserZoomY = 1 / (analyserZoomYElem.val() / 100);
GraphSpectrumPlot.setZoom(analyserZoomX, analyserZoomY);
// Recalculate PSD with updated samples per segment count
if (userSettings.spectrumType == SPECTRUM_TYPE.POWER_SPECTRAL_DENSITY) {
dataLoad();
GraphSpectrumPlot.setData(fftData, userSettings.spectrumType);
}
that.refresh();
}),
)
Expand Down Expand Up @@ -325,6 +329,33 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
})
.val(analyserMinPSD.val());

let segmentLengthPower2 = DEFAULT_PSD_SEGMENT_LENGTH_POWER;
GraphSpectrumCalc.setPointsPerSegmentPSD(2 ** DEFAULT_PSD_SEGMENT_LENGTH_POWER);
analyserSegmentLengthPowerAt2
.on(
"input",
function () {
// Recalculate PSD with updated samples per segment count
GraphSpectrumCalc.setPointsPerSegmentPSD(2 ** parseInt($(this).val()));
dataLoad();
GraphSpectrumPlot.setData(fftData, userSettings.spectrumType);
that.refresh();
},
)
.dblclick(function (e) {
if (e.ctrlKey) {
$(this).val(DEFAULT_PSD_SEGMENT_LENGTH_POWER).trigger("input");
}
})
.val(DEFAULT_PSD_SEGMENT_LENGTH_POWER);

analyserSegmentLengthPowerAt2
.on(
"keydown",
function (e) {
e.preventDefault();
},
);
// Spectrum type to show
userSettings.spectrumType =
userSettings.spectrumType || SPECTRUM_TYPE.FREQUENCY;
Expand All @@ -349,10 +380,16 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
const psdHeatMapSelected =
optionSelected === SPECTRUM_TYPE.PSD_VS_THROTTLE ||
optionSelected === SPECTRUM_TYPE.PSD_VS_RPM;
const psdCurveSelected =
optionSelected === SPECTRUM_TYPE.POWER_SPECTRAL_DENSITY;
overdrawSpectrumTypeElem.toggle(!pidErrorVsSetpointSelected);
analyserZoomYElem.toggleClass(
"onlyFullScreenException",
pidErrorVsSetpointSelected || psdHeatMapSelected,
pidErrorVsSetpointSelected || psdHeatMapSelected || psdCurveSelected,
);
analyserSegmentLengthPowerAt2.toggleClass(
"onlyFullScreenException",
!psdCurveSelected,
);
analyserLowLevelPSD.toggleClass(
"onlyFullScreenException",
Expand All @@ -378,6 +415,10 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
"onlyFullScreenException",
!psdHeatMapSelected,
);
$("#analyserSegmentLengthPowerAt2Label").toggleClass(
"onlyFullScreenException",
!psdCurveSelected,
);


const showSpectrumsComparisonPanel = optionSelected === SPECTRUM_TYPE.FREQUENCY || optionSelected === SPECTRUM_TYPE.POWER_SPECTRAL_DENSITY;
Expand Down
20 changes: 12 additions & 8 deletions src/graph_spectrum_calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const GraphSpectrumCalc = {
_flightLog : null,
_sysConfig : null,
_motorPoles : null,
_pointsPerSegmentPSD : 0,
};

GraphSpectrumCalc.initialize = function(flightLog, sysConfig) {
Expand Down Expand Up @@ -112,17 +113,19 @@ GraphSpectrumCalc.dataLoadFrequency = function() {
return fftData;
};

GraphSpectrumCalc.setPointsPerSegmentPSD = function(pointsCount) {
this._pointsPerSegmentPSD = pointsCount;
};

GraphSpectrumCalc.dataLoadPSD = function(analyserZoomY) {
const flightSamples = this._getFlightSamplesFreq(false);
const multiplier = Math.floor(1 / analyserZoomY); // 0. ... 10
let pointsPerSegment = 2 ** (8 + multiplier); //256, 512, 1024 ...

let overlapCount;
if (pointsPerSegment > flightSamples.samples.length) {
pointsPerSegment = flightSamples.samples.length; // Use actual sample length. It will transform to power at 2 value inside the _psd() - fft_segmented
overlapCount = 0;
let pointsPerSegment, overlapCount;
if (this._pointsPerSegmentPSD > flightSamples.samples.length) {
pointsPerSegment = flightSamples.samples.length; // Use actual sample length. It will transform to power at 2 value inside the _psd() - fft_segmented
overlapCount = 0;
} else {
overlapCount = pointsPerSegment / 2;
pointsPerSegment = this._pointsPerSegmentPSD;
overlapCount = pointsPerSegment * 3 / 4;
}

const psd = this._psd(flightSamples.samples, pointsPerSegment, overlapCount);
Expand All @@ -136,6 +139,7 @@ GraphSpectrumCalc.dataLoadPSD = function(analyserZoomY) {
minimum: psd.min,
maximum: psd.max,
maxNoiseFrequency: psd.maxNoiseFrequency,
maximalSegmentsLength: this.getNearPower2Value(flightSamples.samples.length),
};
return psdData;
};
Expand Down