Skip to content

Commit

Permalink
Add error message for client side sampling interval issues
Browse files Browse the repository at this point in the history
  • Loading branch information
UsualSpec committed Jul 12, 2024
1 parent dcb3b38 commit 0574729
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server/management/templates/startpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ <h2>{{ device.client_uid | e }}</h2>
data: {deviceUid:clientUid},
success: function(resp) {
if (!resp.status && resp.inMeasuringMode && !resp.ppHasExited && resp.ppHasWrittenOnce) {
if (resp.lastSampleTimestamp) {
// check if we wrote to the client side DB
var lastSampleTsWrittenOnClient = new Date(resp.lastSampleTimestamp);

var samplingInt = resp.measurementSettings.ppSamplingInterval;
var nextSamplingDeadline = new Date();
nextSamplingDeadline.setMilliseconds(nextSamplingDeadline.getMilliseconds() - 100 * samplingInt);
console.log(nextSamplingDeadline);
console.log(lastSampleTsWrittenOnClient);
if (lastSampleTsWrittenOnClient < nextSamplingDeadline) {
setAlertSeverity(statusBox,"alert-warning");
statusBox.text("Trying to measure, but last client side measurement may be outdated. Check the client for hardware and timing issues.");
return;
}
}
$.ajax({
type:"POST",
url:"{{ url_for('getLastMeasurementTimestampOfDevicePost') }}",
Expand All @@ -55,6 +70,7 @@ <h2>{{ device.client_uid | e }}</h2>
} else {
setAlertSeverity(statusBox,"alert-success");
statusBox.text("Measuring");

}
},
error: function(xhr) {
Expand Down

0 comments on commit 0574729

Please sign in to comment.