adjusted stats

This commit is contained in:
DJ2LS 2023-10-02 20:16:07 +02:00
parent 4b23e40aae
commit bc60f61eaa
3 changed files with 51 additions and 43 deletions

View file

@ -69,43 +69,6 @@ ChartJS.register(
Legend
)
// dummy data
//state.arq_speed_list = [{"snr":0.0,"bpm":104,"timestamp":1696189769},{"snr":0.0,"bpm":80,"timestamp":1696189778},{"snr":0.0,"bpm":70,"timestamp":1696189783},{"snr":0.0,"bpm":58,"timestamp":1696189792},{"snr":0.0,"bpm":52,"timestamp":1696189797},{"snr":"NaN","bpm":42,"timestamp":1696189811},{"snr":0.0,"bpm":22,"timestamp":1696189875},{"snr":0.0,"bpm":21,"timestamp":1696189881},{"snr":0.0,"bpm":17,"timestamp":1696189913},{"snr":0.0,"bpm":15,"timestamp":1696189932},{"snr":0.0,"bpm":15,"timestamp":1696189937},{"snr":0.0,"bpm":14,"timestamp":1696189946},{"snr":-6.1,"bpm":14,"timestamp":1696189954},{"snr":-6.1,"bpm":14,"timestamp":1696189955},{"snr":-5.5,"bpm":28,"timestamp":1696189963},{"snr":-5.5,"bpm":27,"timestamp":1696189963}]
if (typeof state.arq_speed_list == "undefined") {
var speed_listSize = 0;
} else {
var speed_listSize = state.arq_speed_list.length;
}
var speedDataBpm = [];
for (var i = 0; i < speed_listSize; i++) {
speedDataBpm.push(state.arq_speed_list[i].bpm);
}
var speedDataTime = [];
for (var i = 0; i < speed_listSize; i++) {
var timestamp = state.arq_speed_list[i].timestamp * 1000;
var h = new Date(timestamp).getHours();
var m = new Date(timestamp).getMinutes();
var s = new Date(timestamp).getSeconds();
var time = h + ":" + m + ":" + s;
speedDataTime.push(time);
}
var speedDataSnr = [];
for (var i = 0; i < speed_listSize; i++) {
let snr = NaN;
if (state.arq_speed_list[i].snr !== 0) {
snr = state.arq_speed_list[i].snr;
} else {
snr = NaN;
}
speedDataSnr.push(snr);
}
// https://www.chartjs.org/docs/latest/samples/line/segments.html
const skipped = (speedCtx, value) =>
@ -137,12 +100,12 @@ var speedDataBpm = [];
};
const transmissionSpeedChartData = computed(() => ({
labels: speedDataTime,
labels: state.arq_speed_list_timestamp,
datasets: [
{
type: "line",
label: "SNR[dB]",
data: speedDataSnr,
data: state.arq_speed_list_snr,
borderColor: "rgb(75, 192, 192, 1.0)",
pointRadius: 1,
segment: {
@ -159,7 +122,7 @@ const transmissionSpeedChartData = computed(() => ({
{
type: "bar",
label: "Speed[bpm]",
data: speedDataBpm,
data: state.arq_speed_list_bpm,
borderColor: "rgb(120, 100, 120, 1.0)",
backgroundColor: "rgba(120, 100, 120, 0.2)",
order: 0,

View file

@ -224,7 +224,7 @@ client.on("data", function (socketdata) {
stateStore.arq_seconds_until_timeout_percent = (stateStore.arq_seconds_until_timeout / 180) * 100
if(data["speed_list"].length > 0){
stateStore.arq_speed_list = data["speed_list"]
prepareStatsDataForStore(data["speed_list"])
}
@ -887,3 +887,43 @@ var crc32 = function (r) {
n = (n >>> 8) ^ o[255 & (n ^ r.charCodeAt(t))];
return (-1 ^ n) >>> 0;
};
// TODO: Maybe moving this to another module
function prepareStatsDataForStore(data){
// dummy data
//state.arq_speed_list = [{"snr":0.0,"bpm":104,"timestamp":1696189769},{"snr":0.0,"bpm":80,"timestamp":1696189778},{"snr":0.0,"bpm":70,"timestamp":1696189783},{"snr":0.0,"bpm":58,"timestamp":1696189792},{"snr":0.0,"bpm":52,"timestamp":1696189797},{"snr":"NaN","bpm":42,"timestamp":1696189811},{"snr":0.0,"bpm":22,"timestamp":1696189875},{"snr":0.0,"bpm":21,"timestamp":1696189881},{"snr":0.0,"bpm":17,"timestamp":1696189913},{"snr":0.0,"bpm":15,"timestamp":1696189932},{"snr":0.0,"bpm":15,"timestamp":1696189937},{"snr":0.0,"bpm":14,"timestamp":1696189946},{"snr":-6.1,"bpm":14,"timestamp":1696189954},{"snr":-6.1,"bpm":14,"timestamp":1696189955},{"snr":-5.5,"bpm":28,"timestamp":1696189963},{"snr":-5.5,"bpm":27,"timestamp":1696189963}]
if (typeof data == "undefined") {
var speed_listSize = 0;
} else {
var speed_listSize = data.length;
}
for (var i = 0; i < speed_listSize; i++) {
stateStore.arq_speed_list_bpm.push(data[i].bpm);
}
for (var i = 0; i < speed_listSize; i++) {
var timestamp = data[i].timestamp * 1000;
var h = new Date(timestamp).getHours();
var m = new Date(timestamp).getMinutes();
var s = new Date(timestamp).getSeconds();
var time = h + ":" + m + ":" + s;
stateStore.arq_speed_list_timestamp.push(time);
}
for (var i = 0; i < speed_listSize; i++) {
let snr = NaN;
if (data[i].snr !== 0) {
snr = data[i].snr;
} else {
snr = NaN;
}
stateStore.arq_speed_list_snr.push(snr);
}
}

View file

@ -45,7 +45,12 @@ export const useStateStore = defineStore('stateStore', () => {
var is_codec2_traffic = ref("")
var arq_speed_list = ref()
var arq_speed_list_timestamp = ref([])
var arq_speed_list_bpm = ref([])
var arq_speed_list_snr = ref([])
var arq_seconds_until_finish = ref()
var arq_seconds_until_timeout = ref()
var arq_seconds_until_timeout_percent = ref()
@ -117,5 +122,5 @@ export const useStateStore = defineStore('stateStore', () => {
return { dxcallsign, busy_state, arq_state, new_frequency, frequency, mode, bandwidth, dbfs_level_raw, dbfs_level_percent, speed_level, fft, channel_busy, channel_busy_slot, scatter, ptt_state, s_meter_strength_percent, s_meter_strength_raw, arq_total_bytes, audio_recording, hamlib_status, audio_level, alc, updateTncState, arq_transmission_percent, arq_speed_list, arq_seconds_until_finish, arq_seconds_until_timeout, arq_seconds_until_timeout_percent };
return { dxcallsign, busy_state, arq_state, new_frequency, frequency, mode, bandwidth, dbfs_level_raw, dbfs_level_percent, speed_level, fft, channel_busy, channel_busy_slot, scatter, ptt_state, s_meter_strength_percent, s_meter_strength_raw, arq_total_bytes, audio_recording, hamlib_status, audio_level, alc, updateTncState, arq_transmission_percent, arq_speed_list_bpm, arq_speed_list_timestamp, arq_speed_list_snr, arq_seconds_until_finish, arq_seconds_until_timeout, arq_seconds_until_timeout_percent };
});