diff options
author | Luke Berndt <lukekb@gmail.com> | 2023-04-06 22:03:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-06 22:03:18 -0400 |
commit | 7bb5742a88d816d4ce3f8a68053d70e2e9cffbc8 (patch) | |
tree | 6dfe26d7cae1ce86db067a2bd7e7c95c0f140aca | |
parent | 9d9def8ce7afbbd324a36ccd7cb746f7d749d73d (diff) | |
parent | 570c7612cdbbd9be3a28f574143e9fcddd70592b (diff) |
Merge pull request #794 from robotastic/freq-list
OpenMHz Uploader update
-rw-r--r-- | plugins/openmhz_uploader/openmhz_uploader.cc | 52 | ||||
-rw-r--r-- | trunk-recorder/call_concluder/call_concluder.cc | 4 | ||||
-rw-r--r-- | trunk-recorder/main.cc | 31 | ||||
-rw-r--r-- | trunk-recorder/systems/system.h | 2 | ||||
-rw-r--r-- | trunk-recorder/systems/system_impl.cc | 10 | ||||
-rw-r--r-- | trunk-recorder/systems/system_impl.h | 3 |
6 files changed, 64 insertions, 38 deletions
diff --git a/plugins/openmhz_uploader/openmhz_uploader.cc b/plugins/openmhz_uploader/openmhz_uploader.cc index f4400a8e..eb969115 100644 --- a/plugins/openmhz_uploader/openmhz_uploader.cc +++ b/plugins/openmhz_uploader/openmhz_uploader.cc @@ -52,6 +52,16 @@ public: freq << std::fixed << std::setprecision(0); freq << call_info.freq; + std::ostringstream error_count; + std::string error_count_string; + error_count << std::fixed << std::setprecision(0); + error_count << call_info.error_count; + + std::ostringstream spike_count; + std::string spike_count_string; + spike_count << std::fixed << std::setprecision(0); + spike_count << call_info.spike_count; + std::ostringstream call_length; std::string call_length_string; call_length << std::fixed << std::setprecision(0); @@ -77,28 +87,6 @@ public: source_list << "]"; } - - std::ostringstream freq_list; - std::string freq_list_string; - freq_list << std::fixed << std::setprecision(2); - freq_list << "["; - - if (call_info.transmission_error_list.size() != 0) { - for (std::size_t i = 0; i < call_info.transmission_error_list.size(); i++) { - freq_list << "{\"freq\": " << std::fixed << std::setprecision(0) << call_info.freq << ", \"time\": " << call_info.transmission_error_list[i].time << ", \"pos\": " << std::fixed << std::setprecision(2) << call_info.transmission_error_list[i].position << ", \"len\": " << call_info.transmission_error_list[i].total_len << ", \"error_count\": \"" << std::setprecision(0) <<call_info.transmission_error_list[i].error_count << "\", \"spike_count\": \"" << call_info.transmission_error_list[i].spike_count << "\"}"; - - if (i < (call_info.transmission_error_list.size() - 1)) { - freq_list << ", "; - } else { - freq_list << "]"; - } - } - }else { - freq_list << "]"; - } - - - char formattedTalkgroup[62]; snprintf(formattedTalkgroup, 61, "%c[%dm%10ld%c[0m", 0x1B, 35, call_info.talkgroup, 0x1B); std::string talkgroup_display = boost::lexical_cast<std::string>(formattedTalkgroup); @@ -108,9 +96,10 @@ public: int still_running = 0; std::string response_buffer; freq_string = freq.str(); + error_count_string = error_count.str(); + spike_count_string = spike_count.str(); source_list_string = source_list.str(); - freq_list_string = freq_list.str(); call_length_string = call_length.str(); struct curl_httppost *formpost = NULL; @@ -134,6 +123,18 @@ public: curl_formadd(&formpost, &lastptr, + CURLFORM_COPYNAME, "error_count", + CURLFORM_COPYCONTENTS, error_count_string.c_str(), + CURLFORM_END); + + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "spike_count", + CURLFORM_COPYCONTENTS, spike_count_string.c_str(), + CURLFORM_END); + + curl_formadd(&formpost, + &lastptr, CURLFORM_COPYNAME, "start_time", CURLFORM_COPYCONTENTS, boost::lexical_cast<std::string>(call_info.start_time).c_str(), CURLFORM_END); @@ -173,11 +174,6 @@ public: CURLFORM_COPYNAME, "source_list", CURLFORM_COPYCONTENTS, source_list_string.c_str(), CURLFORM_END); - curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "freq_list", - CURLFORM_COPYCONTENTS, freq_list_string.c_str(), - CURLFORM_END); curl = curl_easy_init(); multi_handle = curl_multi_init(); diff --git a/trunk-recorder/call_concluder/call_concluder.cc b/trunk-recorder/call_concluder/call_concluder.cc index aa440c64..bdba0f3e 100644 --- a/trunk-recorder/call_concluder/call_concluder.cc +++ b/trunk-recorder/call_concluder/call_concluder.cc @@ -216,6 +216,8 @@ Call_Data_t Call_Concluder::create_call_data(Call *call, System *sys, Config con call_info.status = INITIAL; call_info.process_call_time = time(0); call_info.retry_attempt = 0; + call_info.error_count = 0; + call_info.spike_count = 0; call_info.freq = call->get_freq(); call_info.encrypted = call->get_encrypted(); call_info.emergency = call->get_emergency(); @@ -291,6 +293,8 @@ Call_Data_t Call_Concluder::create_call_data(Call *call, System *sys, Config con std::string tag = sys->find_unit_tag(t.source); Call_Source call_source = {t.source, t.start_time, total_length, false, "", tag}; Call_Error call_error = {t.start_time, total_length, t.length, t.error_count, t.spike_count}; + call_info.error_count = call_info.error_count + t.error_count; + call_info.spike_count = call_info.spike_count + t.spike_count; call_info.transmission_source_list.push_back(call_source); call_info.transmission_error_list.push_back(call_error); diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 9e3447dd..7584cb81 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -36,6 +36,7 @@ #include <time.h> #include <unistd.h> #include <utility> +#include <cmath> #include "./global_structs.h" #include "recorder_globals.h" @@ -837,6 +838,15 @@ void print_status() { Source *source = *it; source->print_recorders(); } + + BOOST_LOG_TRIVIAL(info) << "Control Channel Decode Rates: "; + for (std::vector<System *>::iterator it = systems.begin(); it != systems.end(); ++it) { + System_impl *sys = (System_impl *)*it; + + if ((sys->get_system_type() != "conventional") && (sys->get_system_type() != "conventionalP25") && (sys->get_system_type() != "conventionalDMR")) { + BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "] " << sys->get_decode_rate() << " msg/sec"; + } + } } void manage_calls() { @@ -1380,7 +1390,8 @@ void check_message_count(float timeDiff) { System_impl *sys = (System_impl *)*it; if ((sys->get_system_type() != "conventional") && (sys->get_system_type() != "conventionalP25") && (sys->get_system_type() != "conventionalDMR")) { - float msgs_decoded_per_second = sys->message_count / timeDiff; + int msgs_decoded_per_second = std::floor(sys->message_count / timeDiff); + sys->set_decode_rate(msgs_decoded_per_second); if (msgs_decoded_per_second < 2) { @@ -1418,8 +1429,8 @@ void monitor_messages() { int sys_num; System *sys; - time_t lastStatusTime = time(NULL); - time_t lastMsgCountTime = time(NULL); + time_t last_status_time = time(NULL); + time_t last_decode_rate_check = time(NULL); time_t management_timestamp = time(NULL); time_t current_time = time(NULL); std::vector<TrunkMessage> trunk_messages; @@ -1491,11 +1502,11 @@ void monitor_messages() { current_time = time(NULL); - float timeDiff = current_time - lastMsgCountTime; + float decode_rate_check_time_diff = current_time - last_decode_rate_check; - if (timeDiff >= 3.0) { - check_message_count(timeDiff); - lastMsgCountTime = current_time; + if (decode_rate_check_time_diff >= 3.0) { + check_message_count(decode_rate_check_time_diff); + last_decode_rate_check = current_time; for (vector<System *>::iterator sys_it = systems.begin(); sys_it != systems.end(); sys_it++) { System *system = *sys_it; if (system->get_system_type() == "p25") { @@ -1504,10 +1515,10 @@ void monitor_messages() { } } - float statusTimeDiff = current_time - lastStatusTime; + float print_status_time_diff = current_time - last_status_time; - if (statusTimeDiff > 200) { - lastStatusTime = current_time; + if (print_status_time_diff > 200) { + last_status_time = current_time; print_status(); } } diff --git a/trunk-recorder/systems/system.h b/trunk-recorder/systems/system.h index aa2419fa..12106d57 100644 --- a/trunk-recorder/systems/system.h +++ b/trunk-recorder/systems/system.h @@ -120,6 +120,8 @@ public: virtual int channel_count() = 0; virtual int get_message_count() = 0; virtual void set_message_count(int count) = 0; + virtual void set_decode_rate(int rate) = 0; + virtual int get_decode_rate() = 0; virtual void add_channel(double channel) = 0; virtual void add_conventional_recorder(analog_recorder_sptr rec) = 0; virtual std::vector<analog_recorder_sptr> get_conventional_recorders() = 0; diff --git a/trunk-recorder/systems/system_impl.cc b/trunk-recorder/systems/system_impl.cc index ca8dad22..acff168b 100644 --- a/trunk-recorder/systems/system_impl.cc +++ b/trunk-recorder/systems/system_impl.cc @@ -98,6 +98,7 @@ System_impl::System_impl(int sys_num) { d_tps_enabled = false; retune_attempts = 0; message_count = 0; + decode_rate = 0; } void System_impl::set_xor_mask(unsigned long sys_id, unsigned long wacn, unsigned long nac) { @@ -368,6 +369,15 @@ int System_impl::get_message_count() { void System_impl::set_message_count(int count) { message_count = count; } + +void System_impl::set_decode_rate(int rate) { + decode_rate = rate; +} + +int System_impl::get_decode_rate() { + return decode_rate; +} + void System_impl::add_control_channel(double control_channel) { if (control_channels.size() == 0) { control_channels.push_back(control_channel); diff --git a/trunk-recorder/systems/system_impl.h b/trunk-recorder/systems/system_impl.h index 8f294449..61b516b4 100644 --- a/trunk-recorder/systems/system_impl.h +++ b/trunk-recorder/systems/system_impl.h @@ -62,6 +62,7 @@ public: std::string upload_script; int bcfy_system_id; int message_count; + int decode_rate; int retune_attempts; time_t last_message_time; std::string bandplan; @@ -174,6 +175,8 @@ public: int control_channel_count(); int get_message_count(); void set_message_count(int count); + int get_decode_rate(); + void set_decode_rate(int rate); void add_control_channel(double channel); double get_next_control_channel(); double get_current_control_channel(); |