aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2024-04-08 14:59:02 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2024-04-08 14:59:02 +0200
commit1c136653da2a89c69e5f64101eae92b3faaed260 (patch)
treedfe39449204621c5e9981026159c1cd15b8c7b7e /src
parent7c51df4e6f13b7c85300e2da2b9759adee671eae (diff)
downloadetisnoop-1c136653da2a89c69e5f64101eae92b3faaed260.tar.gz
etisnoop-1c136653da2a89c69e5f64101eae92b3faaed260.tar.bz2
etisnoop-1c136653da2a89c69e5f64101eae92b3faaed260.zip
Fix FIG completeness calculation, add length histogramnext
Diffstat (limited to 'src')
-rw-r--r--src/etianalyse.cpp42
-rw-r--r--src/fig0_1.cpp5
-rw-r--r--src/fig0_11.cpp5
-rw-r--r--src/fig0_13.cpp5
-rw-r--r--src/fig0_14.cpp5
-rw-r--r--src/fig0_16.cpp5
-rw-r--r--src/fig0_17.cpp5
-rw-r--r--src/fig0_18.cpp5
-rw-r--r--src/fig0_19.cpp5
-rw-r--r--src/fig0_2.cpp5
-rw-r--r--src/fig0_21.cpp5
-rw-r--r--src/fig0_22.cpp5
-rw-r--r--src/fig0_24.cpp5
-rw-r--r--src/fig0_25.cpp5
-rw-r--r--src/fig0_26.cpp5
-rw-r--r--src/fig0_27.cpp5
-rw-r--r--src/fig0_28.cpp5
-rw-r--r--src/fig0_3.cpp6
-rw-r--r--src/fig0_31.cpp6
-rw-r--r--src/fig0_5.cpp5
-rw-r--r--src/fig0_6.cpp5
-rw-r--r--src/fig0_8.cpp6
-rw-r--r--src/fig1.cpp24
-rw-r--r--src/repetitionrate.cpp128
-rw-r--r--src/repetitionrate.hpp15
-rw-r--r--src/utils.cpp18
-rw-r--r--src/utils.hpp13
27 files changed, 158 insertions, 190 deletions
diff --git a/src/etianalyse.cpp b/src/etianalyse.cpp
index dbd9adc..1104156 100644
--- a/src/etianalyse.cpp
+++ b/src/etianalyse.cpp
@@ -137,10 +137,6 @@ void ETI_Analyser::eti_analyse()
fprintf(stderr, "?\n");
}
- if (config.analyse_fig_rates) {
- rate_display_header(config.analyse_fig_rates_per_second);
- }
-
FILE *stat_fd = nullptr;
if (not config.statistics_filename.empty()) {
stat_fd = fopen(config.statistics_filename.c_str(), "w");
@@ -226,7 +222,7 @@ void ETI_Analyser::eti_analyse()
printbuf("FSYNC", 1, p + 1, 3, "", desc);
// LIDATA
- printbuf("LIDATA");
+ printbuf("LIDATA", 0);
// LIDATA - FC
printbuf("FC", 1, p+4, 4, "Frame Characterization field");
// LIDATA - FC - FCT
@@ -507,9 +503,7 @@ void ETI_Analyser::eti_analyse()
}
printvalue("Selected for decoding", 3, "", (subchid == -1 ? "false" : "true"));
- if (get_verbosity() > 1) {
- printbuf("Data", 3, streamdata, stl[i]*8);
- }
+ printbuf("Data", 3, streamdata, stl[i]*8);
if (subchid != -1) {
config.streams_to_decode.at(subchid).push(streamdata, stl[i]*8);
@@ -548,7 +542,7 @@ void ETI_Analyser::eti_analyse()
printbuf("TIST", 1, p + tist_ix, 4, "Time Stamp (ms)", sdesc);
if (config.analyse_fig_rates and (fct % 250) == 0) {
- rate_display_analysis(false, config.analyse_fig_rates_per_second);
+ rate_display_analysis(config.analyse_fig_rates_per_second);
}
num_frames++;
@@ -648,7 +642,7 @@ void ETI_Analyser::eti_analyse()
}
if (config.analyse_fig_rates) {
- rate_display_analysis(false, config.analyse_fig_rates_per_second);
+ rate_display_analysis(config.analyse_fig_rates_per_second);
}
figs_cleardb();
@@ -656,10 +650,6 @@ void ETI_Analyser::eti_analyse()
void ETI_Analyser::fic_analyse()
{
- if (config.analyse_fig_rates) {
- rate_display_header(config.analyse_fig_rates_per_second);
- }
-
FILE *stat_fd = nullptr;
if (not config.statistics_filename.empty()) {
stat_fd = fopen(config.statistics_filename.c_str(), "w");
@@ -754,9 +744,7 @@ void ETI_Analyser::decodeFIG(
const display_settings_t disp(config.is_fig_to_be_printed(figtype, fig0.ext()), indent);
printvalue("FIG", disp, "", strprintf("0/%d", fig0.ext()));
- if (get_verbosity() > 0) {
- printbuf("Data", disp, f, figlen);
- }
+ printbuf("Data", disp, f, figlen);
if (disp.print) {
printvalue("Length", disp, "", to_string(figlen));
@@ -773,7 +761,7 @@ void ETI_Analyser::decodeFIG(
printvalue("Decoding", disp);
print_fig_result(fig_result, disp+1);
- rate_announce_fig(figtype, fig0.ext(), fig_result.complete);
+ rate_announce_fig(figtype, fig0.ext(), fig_result.complete, figlen);
}
break;
@@ -785,9 +773,7 @@ void ETI_Analyser::decodeFIG(
const display_settings_t disp(config.is_fig_to_be_printed(figtype, fig1.ext()), indent);
printvalue("FIG", disp, "", strprintf("1/%d", fig1.ext()));
- if (get_verbosity() > 0) {
- printbuf("Data", disp, f, figlen);
- }
+ printbuf("Data", disp, f, figlen);
if (disp.print) {
printvalue("Length", disp, "", to_string(figlen));
@@ -801,7 +787,7 @@ void ETI_Analyser::decodeFIG(
fig_result.figext = fig1.ext();
printvalue("Decoding", disp);
print_fig_result(fig_result, disp+1);
- rate_announce_fig(figtype, fig1.ext(), fig_result.complete);
+ rate_announce_fig(figtype, fig1.ext(), fig_result.complete, figlen);
}
break;
case 2:
@@ -812,9 +798,7 @@ void ETI_Analyser::decodeFIG(
printvalue("FIG", disp, "", strprintf("2/%d", fig2.ext()));
- if (get_verbosity() > 0) {
- printbuf("Data", disp, f, figlen);
- }
+ printbuf("Data", disp, f, figlen);
if (disp.print) {
printvalue("Length", disp, "", to_string(figlen));
@@ -824,7 +808,7 @@ void ETI_Analyser::decodeFIG(
printvalue("Decoding", disp);
print_fig_result(fig_result, disp+1);
- rate_announce_fig(figtype, fig2.ext(), fig_result.complete);
+ rate_announce_fig(figtype, fig2.ext(), fig_result.complete, figlen);
}
break;
case 5:
@@ -840,9 +824,7 @@ void ETI_Analyser::decodeFIG(
printvalue("FIG", disp, "", strprintf("5/%d", ext));
- if (get_verbosity() > 0) {
- printbuf("Data", disp, f, figlen);
- }
+ printbuf("Data", disp, f, figlen);
if (disp.print) {
printvalue("Length", disp, "", to_string(figlen));
@@ -854,7 +836,7 @@ void ETI_Analyser::decodeFIG(
figs.push_back(figtype, ext, figlen);
bool complete = true; // TODO verify
- rate_announce_fig(figtype, ext, complete);
+ rate_announce_fig(figtype, ext, complete, figlen);
}
break;
case 6:
diff --git a/src/fig0_1.cpp b/src/fig0_1.cpp
index db2250c..58fd55b 100644
--- a/src/fig0_1.cpp
+++ b/src/fig0_1.cpp
@@ -39,9 +39,8 @@ bool fig0_1_is_complete(fig0_common_t& fig0, int subch_id)
fig0.wm_decoder.push_fig0_1_bit(subchannels_seen.front() < subchannels_seen.back());
subchannels_seen.clear();
}
- else {
- subchannels_seen.push_back(subch_id);
- }
+
+ subchannels_seen.push_back(subch_id);
return complete;
}
diff --git a/src/fig0_11.cpp b/src/fig0_11.cpp
index 196dd37..1c76ec8 100644
--- a/src/fig0_11.cpp
+++ b/src/fig0_11.cpp
@@ -39,9 +39,8 @@ bool fig0_11_is_complete(int region_id)
if (complete) {
region_ids_seen.clear();
}
- else {
- region_ids_seen.insert(region_id);
- }
+
+ region_ids_seen.insert(region_id);
return complete;
}
diff --git a/src/fig0_13.cpp b/src/fig0_13.cpp
index dd053b7..de1eda9 100644
--- a/src/fig0_13.cpp
+++ b/src/fig0_13.cpp
@@ -46,9 +46,8 @@ bool fig0_13_is_complete(SId_t SId, SCIdS_t SCIdS)
if (complete) {
components_ids_seen.clear();
}
- else {
- components_ids_seen.insert(key);
- }
+
+ components_ids_seen.insert(key);
return complete;
}
diff --git a/src/fig0_14.cpp b/src/fig0_14.cpp
index de32820..97ef9a9 100644
--- a/src/fig0_14.cpp
+++ b/src/fig0_14.cpp
@@ -39,9 +39,8 @@ bool fig0_14_is_complete(int subch_id)
if (complete) {
subch_ids_seen.clear();
}
- else {
- subch_ids_seen.insert(subch_id);
- }
+
+ subch_ids_seen.insert(subch_id);
return complete;
}
diff --git a/src/fig0_16.cpp b/src/fig0_16.cpp
index 0f47533..59a6cd9 100644
--- a/src/fig0_16.cpp
+++ b/src/fig0_16.cpp
@@ -44,9 +44,8 @@ bool fig0_16_is_complete(SId_t SId, PNum_t PNum)
if (complete) {
components_seen.clear();
}
- else {
- components_seen.insert(key);
- }
+
+ components_seen.insert(key);
return complete;
}
diff --git a/src/fig0_17.cpp b/src/fig0_17.cpp
index 247e79e..9cee795 100644
--- a/src/fig0_17.cpp
+++ b/src/fig0_17.cpp
@@ -39,9 +39,8 @@ bool fig0_17_is_complete(int services_id)
if (complete) {
services_ids_seen.clear();
}
- else {
- services_ids_seen.insert(services_id);
- }
+
+ services_ids_seen.insert(services_id);
return complete;
}
diff --git a/src/fig0_18.cpp b/src/fig0_18.cpp
index ecbf7ba..2927a20 100644
--- a/src/fig0_18.cpp
+++ b/src/fig0_18.cpp
@@ -39,9 +39,8 @@ bool fig0_18_is_complete(int services_id)
if (complete) {
services_seen.clear();
}
- else {
- services_seen.insert(services_id);
- }
+
+ services_seen.insert(services_id);
return complete;
}
diff --git a/src/fig0_19.cpp b/src/fig0_19.cpp
index 0e6c25e..8ce0470 100644
--- a/src/fig0_19.cpp
+++ b/src/fig0_19.cpp
@@ -39,9 +39,8 @@ bool fig0_19_is_complete(int clusters_id)
if (complete) {
clusters_seen.clear();
}
- else {
- clusters_seen.insert(clusters_id);
- }
+
+ clusters_seen.insert(clusters_id);
return complete;
}
diff --git a/src/fig0_2.cpp b/src/fig0_2.cpp
index 6d309c9..777fea2 100644
--- a/src/fig0_2.cpp
+++ b/src/fig0_2.cpp
@@ -39,9 +39,8 @@ bool fig0_2_is_complete(int services_id)
if (complete) {
services_seen.clear();
}
- else {
- services_seen.insert(services_id);
- }
+
+ services_seen.insert(services_id);
return complete;
}
diff --git a/src/fig0_21.cpp b/src/fig0_21.cpp
index fbd1b13..ef93c74 100644
--- a/src/fig0_21.cpp
+++ b/src/fig0_21.cpp
@@ -39,9 +39,8 @@ bool fig0_21_is_complete(int region_id)
if (complete) {
regions_seen.clear();
}
- else {
- regions_seen.insert(region_id);
- }
+
+ regions_seen.insert(region_id);
return complete;
}
diff --git a/src/fig0_22.cpp b/src/fig0_22.cpp
index a76de31..c893cf0 100644
--- a/src/fig0_22.cpp
+++ b/src/fig0_22.cpp
@@ -41,9 +41,8 @@ bool fig0_22_is_complete(int M_S, int MainId)
if (complete) {
identifiers_seen.clear();
}
- else {
- identifiers_seen.insert(identifier);
- }
+
+ identifiers_seen.insert(identifier);
return complete;
}
diff --git a/src/fig0_24.cpp b/src/fig0_24.cpp
index 690979d..1c697ba 100644
--- a/src/fig0_24.cpp
+++ b/src/fig0_24.cpp
@@ -39,9 +39,8 @@ bool fig0_24_is_complete(int services_id)
if (complete) {
services_seen.clear();
}
- else {
- services_seen.insert(services_id);
- }
+
+ services_seen.insert(services_id);
return complete;
}
diff --git a/src/fig0_25.cpp b/src/fig0_25.cpp
index bf02d13..bc0a87f 100644
--- a/src/fig0_25.cpp
+++ b/src/fig0_25.cpp
@@ -39,9 +39,8 @@ bool fig0_25_is_complete(int services_id)
if (complete) {
services_seen.clear();
}
- else {
- services_seen.insert(services_id);
- }
+
+ services_seen.insert(services_id);
return complete;
}
diff --git a/src/fig0_26.cpp b/src/fig0_26.cpp
index 0568b60..1508814 100644
--- a/src/fig0_26.cpp
+++ b/src/fig0_26.cpp
@@ -39,9 +39,8 @@ bool fig0_26_is_complete(int cluster_id)
if (complete) {
clusters_seen.clear();
}
- else {
- clusters_seen.insert(cluster_id);
- }
+
+ clusters_seen.insert(cluster_id);
return complete;
}
diff --git a/src/fig0_27.cpp b/src/fig0_27.cpp
index fdcb5f5..d00391f 100644
--- a/src/fig0_27.cpp
+++ b/src/fig0_27.cpp
@@ -39,9 +39,8 @@ bool fig0_27_is_complete(int services_id)
if (complete) {
services_seen.clear();
}
- else {
- services_seen.insert(services_id);
- }
+
+ services_seen.insert(services_id);
return complete;
}
diff --git a/src/fig0_28.cpp b/src/fig0_28.cpp
index 3a95c5c..e86c676 100644
--- a/src/fig0_28.cpp
+++ b/src/fig0_28.cpp
@@ -39,9 +39,8 @@ bool fig0_28_is_complete(int cluster_id)
if (complete) {
clusters_seen.clear();
}
- else {
- clusters_seen.insert(cluster_id);
- }
+
+ clusters_seen.insert(cluster_id);
return complete;
}
diff --git a/src/fig0_3.cpp b/src/fig0_3.cpp
index 6c424b8..1da959d 100644
--- a/src/fig0_3.cpp
+++ b/src/fig0_3.cpp
@@ -38,9 +38,9 @@ bool fig0_3_is_complete(int components_id)
if (complete) {
components_ids_seen.clear();
}
- else {
- components_ids_seen.insert(components_id);
- }
+
+ components_ids_seen.insert(components_id);
+
return complete;
}
diff --git a/src/fig0_31.cpp b/src/fig0_31.cpp
index c869bf4..d6ede22 100644
--- a/src/fig0_31.cpp
+++ b/src/fig0_31.cpp
@@ -39,9 +39,9 @@ bool fig0_31_is_complete(uint64_t figtype_flags)
if (complete) {
figtype_flags_seen.clear();
}
- else {
- figtype_flags_seen.insert(figtype_flags);
- }
+
+ figtype_flags_seen.insert(figtype_flags);
+
return complete;
}
diff --git a/src/fig0_5.cpp b/src/fig0_5.cpp
index 2243539..cee9e5d 100644
--- a/src/fig0_5.cpp
+++ b/src/fig0_5.cpp
@@ -39,9 +39,8 @@ bool fig0_5_is_complete(int components_id)
if (complete) {
components_seen.clear();
}
- else {
- components_seen.insert(components_id);
- }
+
+ components_seen.insert(components_id);
return complete;
}
diff --git a/src/fig0_6.cpp b/src/fig0_6.cpp
index 0ba4132..6c527ae 100644
--- a/src/fig0_6.cpp
+++ b/src/fig0_6.cpp
@@ -39,9 +39,8 @@ bool fig0_6_is_complete(int link_key)
if (complete) {
links_seen.clear();
}
- else {
- links_seen.insert(link_key);
- }
+
+ links_seen.insert(link_key);
return complete;
}
diff --git a/src/fig0_8.cpp b/src/fig0_8.cpp
index 8a651ad..3ac4636 100644
--- a/src/fig0_8.cpp
+++ b/src/fig0_8.cpp
@@ -46,9 +46,9 @@ bool fig0_8_is_complete(SId_t SId, SCIdS_t SCIdS)
if (complete) {
components_seen.clear();
}
- else {
- components_seen.insert(key);
- }
+
+ components_seen.insert(key);
+
return complete;
}
diff --git a/src/fig1.cpp b/src/fig1.cpp
index 71e4508..89a54f1 100644
--- a/src/fig1.cpp
+++ b/src/fig1.cpp
@@ -25,6 +25,7 @@
*/
#include "figs.hpp"
+#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
@@ -48,6 +49,21 @@ static ensemble_database::charset_e charset_to_charset(uint8_t charset)
}
}
+static std::vector<uint16_t> service_labels_seen;
+
+bool fig1_1_is_complete(uint16_t sid)
+{
+ bool complete = std::count(service_labels_seen.begin(), service_labels_seen.end(), sid) > 0;
+
+ if (complete) {
+ service_labels_seen.clear();
+ }
+
+ service_labels_seen.push_back(sid);
+
+ return complete;
+}
+
// SHORT LABELS
fig_result_t fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
{
@@ -78,6 +94,7 @@ fig_result_t fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
r.msgs.push_back(strprintf("Label=\"%s\"", fig1.ensemble.label.label().c_str()));
r.msgs.push_back(strprintf("Short label mask=0x%04X", flag));
r.msgs.push_back(strprintf("Short label=\"%s\"", fig1.ensemble.label.shortlabel().c_str()));
+ r.complete = true;
}
}
break;
@@ -97,6 +114,8 @@ fig_result_t fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
r.msgs.push_back(strprintf("Label=\"%s\"", service.label.label().c_str()));
r.msgs.push_back(strprintf("Short label mask=0x%04X", flag));
r.msgs.push_back(strprintf("Short label=\"%s\"", service.label.shortlabel().c_str()));
+
+ r.complete = fig1_1_is_complete(sid);
}
catch (ensemble_database::not_found &e) {
r.errors.push_back("Not yet in DB");
@@ -122,6 +141,7 @@ fig_result_t fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
// TODO put label into ensembledatabase
r.msgs.push_back(strprintf("Label bytes=\"%s\"", string(label.begin(), label.end()).c_str()));
r.msgs.push_back(strprintf("Short label mask=0x%04X", flag));
+ r.complete = true; // TODO wrong
}
break;
@@ -134,6 +154,7 @@ fig_result_t fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
// TODO put label into ensembledatabase
r.msgs.push_back(strprintf("Label bytes=\"%s\"", string(label.begin(), label.end()).c_str()));
r.msgs.push_back(strprintf("Short label mask=0x%04X", flag));
+ r.complete = true; // TODO wrong
}
break;
@@ -172,12 +193,11 @@ fig_result_t fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
// TODO put label into ensembledatabase
r.msgs.push_back(strprintf("Label bytes=\"%s\"", string(label.begin(), label.end()).c_str()));
r.msgs.push_back(strprintf("Short label mask=0x%04X", flag));
+ r.complete = true; // TODO wrong
}
break;
}
- // FIG1s always contain a complete set of information
- r.complete = true;
return r;
}
diff --git a/src/repetitionrate.cpp b/src/repetitionrate.cpp
index 970bcfc..4fd4427 100644
--- a/src/repetitionrate.cpp
+++ b/src/repetitionrate.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Matthias P. Braendli (http://www.opendigitalradio.org)
+ Copyright (C) 2024 Matthias P. Braendli (http://www.opendigitalradio.org)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,11 +20,15 @@
*/
#include "repetitionrate.hpp"
+#include <algorithm>
+#include <cmath>
+#include <cstdio>
+#include <sstream>
+#include <string>
#include <vector>
+#include <array>
#include <map>
#include <set>
-#include <cmath>
-#include <limits>
using namespace std;
@@ -53,6 +57,8 @@ struct FIGRateInfo {
// Which FIBs this FIG was seen in
set<int> in_fib;
+
+ vector<uint8_t> lengths;
};
@@ -61,7 +67,7 @@ static map<FIGTypeExt, FIGRateInfo> fig_rates;
static int current_frame_number = 0;
static int current_fib = 0;
-void rate_announce_fig(int figtype, int figextension, bool complete)
+void rate_announce_fig(int figtype, int figextension, bool complete, uint8_t figlen)
{
FIGTypeExt f = {.figtype = figtype, .figextension = figextension};
@@ -77,112 +83,112 @@ void rate_announce_fig(int figtype, int figextension, bool complete)
rate.frames_complete.push_back(current_frame_number);
}
rate.in_fib.insert(current_fib);
+ rate.lengths.push_back(figlen);
}
-// Calculate the minimal, maximum and average repetition rate (FIGs per
-// second).
-void rate_min_max_avg(
+static double rate_avg(
const std::vector<int>& fig_positions,
- double* min,
- double* max,
- double* avg,
bool per_second)
{
- double avg_interval =
+ // Average interval is 1/N \sum_{i} pos_{i+1} - pos_{i}
+ // but this sums out all the intermediate pos_{i}, leaving us
+ // with 1/N (pos_{last} - pos_{first})
+ //
+ // N = size - 1 because we sum intervals, not points in time,
+ // and there's one less interval than there are points.
+
+ double avg =
(double)(fig_positions.back() - fig_positions.front()) /
(double)(fig_positions.size() - 1);
+ if (per_second) {
+ avg = 1.0 / (avg * FRAME_DURATION);
+ }
+ return avg;
+}
- int min_delta = std::numeric_limits<int>::max();
- int max_delta = 0;
- for (size_t i = 1; i < fig_positions.size(); i++) {
- const int delta = fig_positions[i] - fig_positions[i-1];
+static double length_avg(const std::vector<uint8_t>& lengths)
+{
+ double avg = 0.0;
+ for (const uint8_t l : lengths) {
+ avg += l;
+ }
+ return avg / (double)lengths.size();
+}
- // Min
- if (min_delta > delta) {
- min_delta = delta;
- }
+static string length_histogram(const std::vector<uint8_t>& lengths)
+{
+ const array<const char*, 7> hist_chars({"▁", "▂", "▃", "▄", "▅", "▆", "▇"});
- // Max
- if (max_delta < delta) {
- max_delta = delta;
- }
+ // FIB length is 30
+ vector<size_t> histogram(30);
+ for (const uint8_t l : lengths) {
+ histogram.at(l)++;
}
- *avg = avg_interval;
- *min = min_delta;
- *max = max_delta;
+ const double max_hist = *std::max_element(histogram.cbegin(), histogram.cend());
- if (per_second) {
- *avg = 1.0 /
- (*avg * FRAME_DURATION);
- *min = 1.0 / (*min * FRAME_DURATION);
- *max = 1.0 / (*min * FRAME_DURATION);
+ stringstream ss;
+ ss << "[";
+ for (const size_t h : histogram) {
+ uint8_t char_ix = floor((double)h / (max_hist+1) * hist_chars.size());
+ ss << hist_chars.at(char_ix);
}
+ ss << "]";
+ return ss.str();
}
-void rate_display_header(bool per_second)
+
+void rate_display_analysis(bool per_second)
{
+
+#define GREPPABLE_PREFIX "CAROUSEL "
+
if (per_second) {
- printf("FIG carousel analysis. Format:\n"
- " min, average, max FIGs per second (total count) - \n"
- " min, average, max complete FIGs per second (total count)\n");
+ printf(GREPPABLE_PREFIX
+ "FIG T/EXT AVG (COUNT) - AVG (COUNT) - LEN - LENGTH HISTOGRAM IN FIB(S)\n");
}
- else {
- printf("FIG carousel analysis. Format:\n"
- " min, average, max frames per FIG (total count) - \n"
- " min, average, max frames per complete FIGs (total count)\n");
- }
-}
-void rate_display_analysis(bool clear, bool per_second)
-{
for (auto& fig_rate : fig_rates) {
auto& frames_present = fig_rate.second.frames_present;
auto& frames_complete = fig_rate.second.frames_complete;
- double min = 0.0;
- double max = 0.0;
- double avg = 0.0;
-
const size_t n_present = frames_present.size();
const size_t n_complete = frames_complete.size();
- if (n_present >= 2) {
+ printf(GREPPABLE_PREFIX);
- rate_min_max_avg(frames_present, &min, &max, &avg, per_second);
+ if (n_present >= 2) {
+ double avg = rate_avg(frames_present, per_second);
- printf("FIG%2d/%2d %4.2f %4.2f %4.2f (%5zu)",
+ printf("FIG%2d/%2d %6.2f (%5zu)",
fig_rate.first.figtype, fig_rate.first.figextension,
- min, avg, max,
+ avg,
n_present);
if (n_complete >= 2) {
- rate_min_max_avg(frames_complete, &min, &max, &avg, per_second);
+ double avg = rate_avg(frames_complete, per_second);
- printf(" - %4.2f %4.2f %4.2f (%5zu)",
- min, avg, max,
- n_present);
+ printf(" - %6.2f (%5zu)", avg, n_complete);
}
else {
printf(" - None complete");
}
}
else {
- printf("FIG%2d/%2d 0",
+ printf("FIG%2d/%2d ",
fig_rate.first.figtype, fig_rate.first.figextension);
}
- printf(" - in FIB(s):");
+ printf(" - %4.1f %s - ",
+ length_avg(fig_rate.second.lengths),
+ length_histogram(fig_rate.second.lengths).c_str());
+
for (auto& fib : fig_rate.second.in_fib) {
printf(" %d", fib);
}
printf("\n");
}
-
- if (clear) {
- fig_rates.clear();
- }
}
void rate_new_fib(int fib)
diff --git a/src/repetitionrate.hpp b/src/repetitionrate.hpp
index 41b5b40..b795351 100644
--- a/src/repetitionrate.hpp
+++ b/src/repetitionrate.hpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Matthias P. Braendli (http://www.opendigitalradio.org)
+ Copyright (C) 2024 Matthias P. Braendli (http://www.opendigitalradio.org)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,28 +20,21 @@
*/
#pragma once
-#include "utils.hpp"
+#include <cstdint>
/* Tell the repetition rate analyser that we have received a given FIG.
* The complete flag should be set to true every time a complete
* set of information for that FIG has been received
*/
-void rate_announce_fig(int figtype, int figextension, bool complete);
+void rate_announce_fig(int figtype, int figextension, bool complete, uint8_t figlen);
/* Tell the repetition rate analyser that a new FIB starts.
*/
void rate_new_fib(int fib);
-/* Print small header to explain rate display
- * per_second: if true, rates are calculated in FIGs per second.
- * If false, rate is given in frames per FIG
- */
-void rate_display_header(bool per_second);
-
/* Print analysis.
- * optionally clear all statistics
* per_second: if true, rates are calculated in FIGs per second.
* If false, rate is given in frames per FIG
*/
-void rate_display_analysis(bool clear, bool per_second);
+void rate_display_analysis(bool per_second);
diff --git a/src/utils.cpp b/src/utils.cpp
index e7420bd..6707b90 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -160,7 +160,7 @@ void printbuf(const std::string& header,
const std::string& desc,
const std::string& value)
{
- display_settings_t disp(true, indent);
+ display_settings_t disp(verbosity > 1, indent);
printyaml(header, disp, buffer, size, desc, value);
}
@@ -171,15 +171,7 @@ void printbuf(const string& header,
const std::string& desc,
const std::string& value)
{
- display_settings_t d = disp;
- d.print = (verbosity > 0);
- printyaml(header, d, buffer, size, desc, value);
-}
-
-void printbuf(const std::string& header, int indent)
-{
- display_settings_t disp(true, indent);
- return printyaml(header, disp);
+ printyaml(header, disp, buffer, size, desc, value);
}
void printfig(const string& header,
@@ -221,12 +213,6 @@ void printinfo(const string &header,
}
}
-void printinfo(const std::string &header, int min_verb)
-{
- const display_settings_t disp(true, 0);
- printinfo(header, min_verb);
-}
-
void printsequencestart(int indent)
{
for (int i = 0; i < indent; i++) {
diff --git a/src/utils.hpp b/src/utils.hpp
index ee5f7c9..23f767d 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -48,28 +48,27 @@ struct display_settings_t {
std::string strprintf(const char* fmt, ...);
-void printbuf(const std::string& header,
+void printfig(const std::string& header,
const display_settings_t &disp,
uint8_t* buffer,
size_t size,
const std::string& desc="",
const std::string& value="");
-void printfig(const std::string& header,
- const display_settings_t &disp,
- uint8_t* buffer,
- size_t size,
+void printbuf(const std::string& header,
+ int indent,
+ uint8_t* buffer=nullptr,
+ size_t size=0,
const std::string& desc="",
const std::string& value="");
void printbuf(const std::string& header,
- int indent,
+ const display_settings_t &disp,
uint8_t* buffer,
size_t size,
const std::string& desc="",
const std::string& value="");
-void printbuf(const std::string& header, int indent = 0);
void printvalue(const std::string& header,
int indent = 0,