diff --git a/code/webClient/js/habdec_commands.js b/code/webClient/js/habdec_commands.js
index 90515c0..2f02b1f 100644
--- a/code/webClient/js/habdec_commands.js
+++ b/code/webClient/js/habdec_commands.js
@@ -84,7 +84,7 @@ function ws_onOpen(evt)
console.debug("ws_onOpen: init refresh.");
RefreshPowerSpectrum();
RefreshDemod();
- // RefreshLivePrint();
+ RefreshStats();
}
@@ -271,6 +271,7 @@ function DisplayStats(i_str)
'dist_circ': 0,
'max_dist': 0,
'min_elev': 90,
+ 'age': -1
};
var stats_arr = i_str.split(",");
@@ -291,14 +292,20 @@ function DisplayStats(i_str)
stats.max_dist = parseFloat(v);
if(k == 'min_elev')
stats.min_elev = parseFloat(v);
+ if(k == 'age')
+ stats.age = parseInt(v);
}
- document.getElementById("cnt_stats").innerHTML =
- "Ok: " + stats.ok
+ var stats_string = "Ok: " + stats.ok
+ " | Dist-Line: " + (stats.dist_line / 1000).toFixed(1) + "km "
+ "(" + (stats.max_dist / 1000).toFixed(1) + "km)"
+ " | Dist-Circle: " + (stats.dist_circ / 1000).toFixed(1) + "km "
- + " | MinElev: " + (stats.min_elev).toFixed(1);
+ + " | MinElev: " + (stats.min_elev).toFixed(1)
+ + " | Age: " + stats.age;
+ if(stats.age > 30)
+ document.getElementById("cnt_stats").innerHTML = "" + stats_string + "";
+ else
+ document.getElementById("cnt_stats").innerHTML = "" + stats_string + "";
}
@@ -367,15 +374,15 @@ function RefreshDemod()
}
-/*
-function RefreshLivePrint()
+// stats are send from server on every success sentence
+// but update every 2 seconds to display sentence age
+function RefreshStats()
{
if(!G_HD_CONNECTED)
return;
- SendCommand("liveprint");
- setTimeout(function () {RefreshLivePrint();}, 1000 / 4);
+ SendCommand("stats");
+ setTimeout(function () {RefreshStats();}, 2000);
}
-*/
function SetBiasT()
diff --git a/code/websocketServer/GLOBALS.h b/code/websocketServer/GLOBALS.h
index 2b40228..bcef5ca 100644
--- a/code/websocketServer/GLOBALS.h
+++ b/code/websocketServer/GLOBALS.h
@@ -68,7 +68,8 @@ public:
unsigned int num_ok_ = 0; // num of decoded packets
habdec::GpsDistance D_;
double dist_max_ = 0;
- double elev_min_ = std::numeric_limits::max();
+ double elev_min_ = 90.0;
+ std::chrono::steady_clock::time_point last_sentence_timestamp_ = std::chrono::steady_clock::now();
};
STATS stats_;
diff --git a/code/websocketServer/habdec_ws_protocol.cpp b/code/websocketServer/habdec_ws_protocol.cpp
index 4abce72..2ace2f5 100644
--- a/code/websocketServer/habdec_ws_protocol.cpp
+++ b/code/websocketServer/habdec_ws_protocol.cpp
@@ -548,6 +548,10 @@ std::vector< std::shared_ptr > HandleRequest(std::string command
p_msg->data_stream_<<",lon:"<data_stream_<<",alt:"<(
+ std::chrono::steady_clock::now() - stats.last_sentence_timestamp_).count();
+ p_msg->data_stream_<<",age:"<