diff --git a/trunk-recorder/call.h b/trunk-recorder/call.h index 00c0ad74f..7fafd3231 100644 --- a/trunk-recorder/call.h +++ b/trunk-recorder/call.h @@ -74,6 +74,10 @@ class Call { virtual int get_priority() = 0; virtual bool get_mode() = 0; virtual bool get_duplex() = 0; + virtual double get_signal() = 0; + virtual double get_noise() = 0; + virtual void set_signal(double s) = 0; + virtual void set_noise(double n) = 0; virtual std::string get_talkgroup_display() = 0; virtual void set_talkgroup_tag(std::string tag) = 0; virtual void clear_transmission_list() = 0; diff --git a/trunk-recorder/call_conventional.cc b/trunk-recorder/call_conventional.cc index 0ec704523..92d3d9bea 100644 --- a/trunk-recorder/call_conventional.cc +++ b/trunk-recorder/call_conventional.cc @@ -9,6 +9,8 @@ Call_conventional::Call_conventional(long t, double f, System *s, Config c) : Ca void Call_conventional::restart_call() { idle_count = 0; + signal = 0; + noise = 0; curr_src_id = -1; start_time = time(NULL); stop_time = time(NULL); @@ -21,7 +23,6 @@ void Call_conventional::restart_call() { emergency = false; this->update_talkgroup_display(); recorder->start(this); - recorder->set_rssi(0); } time_t Call_conventional::get_start_time() { diff --git a/trunk-recorder/call_impl.cc b/trunk-recorder/call_impl.cc index 26f1a77ec..05c5113bf 100644 --- a/trunk-recorder/call_impl.cc +++ b/trunk-recorder/call_impl.cc @@ -60,6 +60,8 @@ Call_impl::Call_impl(long t, double f, System *s, Config c) { Call_impl::Call_impl(TrunkMessage message, System *s, Config c) { config = c; call_num = call_counter++; + noise = 0; + signal = 0; final_length = 0; idle_count = 0; curr_src_id = -1; @@ -127,7 +129,7 @@ void Call_impl::conclude_call() { if (this->is_conventional()) { - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mConcluding Recorded Call\u001b[0m - Last Update: " << this->since_last_update() << "s\tRecorder last write:" << recorder->since_last_write() << "\tCall Elapsed: " << this->elapsed() << "\tDetected RSSI: " << this->recorder->get_rssi(); + BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mConcluding Recorded Call\u001b[0m - Last Update: " << this->since_last_update() << "s\tRecorder last write:" << recorder->since_last_write() << "\tCall Elapsed: " << this->elapsed() << "\t Signal: " << this->get_signal() << "dBm\t Noise: " << this->get_noise() << "dBm"; } else { BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mConcluding Recorded Call\u001b[0m - Last Update: " << this->since_last_update() << "s\tRecorder last write:" << recorder->since_last_write() << "\tCall Elapsed: " << this->elapsed(); } @@ -289,6 +291,22 @@ bool Call_impl::get_duplex() { return duplex; } +double Call_impl::get_signal() { + return signal; +} + +double Call_impl::get_noise() { + return noise; +} + +void Call_impl::set_signal(double s) { + signal = s; +} + +void Call_impl::set_noise(double n) { + noise = n; +} + void Call_impl::set_tdma_slot(int m) { tdma_slot = m; if (!phase2_tdma && tdma_slot) { diff --git a/trunk-recorder/call_impl.h b/trunk-recorder/call_impl.h index 61d4c6905..7f5588e7d 100644 --- a/trunk-recorder/call_impl.h +++ b/trunk-recorder/call_impl.h @@ -76,6 +76,10 @@ class Call_impl : public Call { int get_priority(); bool get_mode(); bool get_duplex(); + double get_signal(); + double get_noise(); + void set_signal(double s); + void set_noise(double n); std::string get_talkgroup_display(); void set_talkgroup_tag(std::string tag); void clear_transmission_list(); @@ -96,6 +100,8 @@ class Call_impl : public Call { long call_num; long talkgroup; double curr_freq; + double noise; + double signal; std::vector transmission_list; System *sys; std::string short_name; diff --git a/trunk-recorder/gr_blocks/pwr_squelch_cc.h b/trunk-recorder/gr_blocks/pwr_squelch_cc.h index cb547a5ef..5130e6251 100644 --- a/trunk-recorder/gr_blocks/pwr_squelch_cc.h +++ b/trunk-recorder/gr_blocks/pwr_squelch_cc.h @@ -12,7 +12,7 @@ #define INCLUDED_ANALOG_PWR_SQUELCH_CC_H #include -#include +#include "squelch_base_cc.h" #include namespace gr { @@ -51,7 +51,7 @@ class ANALOG_API pwr_squelch_cc : public squelch_base_cc, virtual public block std::vector squelch_range() const override = 0; virtual double threshold() const = 0; - virtual double get_pwr() const = 0; + virtual double get_pwr() = 0; virtual void set_threshold(double db) = 0; virtual void set_alpha(double alpha) = 0; diff --git a/trunk-recorder/gr_blocks/pwr_squelch_cc_impl.cc b/trunk-recorder/gr_blocks/pwr_squelch_cc_impl.cc index e110a9279..7c87a4680 100644 --- a/trunk-recorder/gr_blocks/pwr_squelch_cc_impl.cc +++ b/trunk-recorder/gr_blocks/pwr_squelch_cc_impl.cc @@ -12,7 +12,7 @@ #include "config.h" #endif -#include "pwr_squelch_cc_impl.h" +#include "./pwr_squelch_cc_impl.h" namespace gr { namespace analog { diff --git a/trunk-recorder/gr_blocks/pwr_squelch_cc_impl.h b/trunk-recorder/gr_blocks/pwr_squelch_cc_impl.h index eb446daf9..96ee353a5 100644 --- a/trunk-recorder/gr_blocks/pwr_squelch_cc_impl.h +++ b/trunk-recorder/gr_blocks/pwr_squelch_cc_impl.h @@ -11,8 +11,8 @@ #ifndef INCLUDED_ANALOG_PWR_SQUELCH_CC_IMPL_H #define INCLUDED_ANALOG_PWR_SQUELCH_CC_IMPL_H -#include "squelch_base_cc_impl.h" -#include +#include "./squelch_base_cc_impl.h" +#include "./pwr_squelch_cc.h" #include #include diff --git a/trunk-recorder/gr_blocks/squelch_base_cc.h b/trunk-recorder/gr_blocks/squelch_base_cc.h new file mode 100644 index 000000000..48d76691f --- /dev/null +++ b/trunk-recorder/gr_blocks/squelch_base_cc.h @@ -0,0 +1,44 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#ifndef INCLUDED_ANALOG_SQUELCH_BASE_CC_H +#define INCLUDED_ANALOG_SQUELCH_BASE_CC_H + +#include +#include + +namespace gr { +namespace analog { + +/*! + * \brief basic squelch block; to be subclassed for other squelches. + * \ingroup level_blk + */ +class ANALOG_API squelch_base_cc : virtual public block +{ +protected: + virtual void update_state(const gr_complex& sample) = 0; + virtual bool mute() const = 0; + +public: + squelch_base_cc(){}; + virtual int ramp() const = 0; + virtual void set_ramp(int ramp) = 0; + virtual bool gate() const = 0; + virtual void set_gate(bool gate) = 0; + virtual bool unmuted() const = 0; + + virtual std::vector squelch_range() const = 0; +}; + +} /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_SQUELCH_BASE_CC_H */ \ No newline at end of file diff --git a/trunk-recorder/gr_blocks/squelch_base_cc_impl.cc b/trunk-recorder/gr_blocks/squelch_base_cc_impl.cc index 6fb87d379..d350b6389 100644 --- a/trunk-recorder/gr_blocks/squelch_base_cc_impl.cc +++ b/trunk-recorder/gr_blocks/squelch_base_cc_impl.cc @@ -12,7 +12,7 @@ #include "config.h" #endif -#include "squelch_base_cc_impl.h" +#include "./squelch_base_cc_impl.h" #include #include diff --git a/trunk-recorder/gr_blocks/squelch_base_cc_impl.h b/trunk-recorder/gr_blocks/squelch_base_cc_impl.h index b6753339e..6cf3767a6 100644 --- a/trunk-recorder/gr_blocks/squelch_base_cc_impl.h +++ b/trunk-recorder/gr_blocks/squelch_base_cc_impl.h @@ -11,7 +11,7 @@ #ifndef INCLUDED_GR_SQUELCH_BASE_CC_IMPL_H #define INCLUDED_GR_SQUELCH_BASE_CC_IMPL_H -#include +#include "./squelch_base_cc.h" namespace gr { namespace analog { diff --git a/trunk-recorder/monitor_systems.cc b/trunk-recorder/monitor_systems.cc index cb2d24313..62d63a6c5 100644 --- a/trunk-recorder/monitor_systems.cc +++ b/trunk-recorder/monitor_systems.cc @@ -160,19 +160,15 @@ void print_status(std::vector &sources, std::vector &systems if (call->get_state() == MONITORING) { BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m TG: " << call->get_talkgroup_display() << " Freq: " << format_freq(call->get_freq()) << " Elapsed: " << std::setw(4) << call->elapsed() << " State: " << format_state(call->get_state(), call->get_monitoring_state()); } else { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m TG: " << call->get_talkgroup_display() << " Freq: " << format_freq(call->get_freq()) << " Elapsed: " << std::setw(4) << call->elapsed() << " State: " << format_state(call->get_state()); + if (call->is_conventional() ) { + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m TG: " << call->get_talkgroup_display() << " Freq: " << format_freq(call->get_freq()) << " Elapsed: " << std::setw(4) << call->elapsed() << " State: " << format_state(call->get_state()) << " Signal " << call->get_signal() << "dBm Noise " << call->get_noise() << "dBm"; + } else { + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m TG: " << call->get_talkgroup_display() << " Freq: " << format_freq(call->get_freq()) << " Elapsed: " << std::setw(4) << call->elapsed() << " State: " << format_state(call->get_state()); + } } if (recorder) { - if (recorder->is_conventional()) { - if (recorder->get_rssi() < 0) { - BOOST_LOG_TRIVIAL(info) << "\t[ " << recorder->get_num() << " ] State: " << format_state(recorder->get_state()) << "\tRSSI: " << recorder->get_rssi() << " dBm"; - } else { - BOOST_LOG_TRIVIAL(info) << "\t[ " << recorder->get_num() << " ] State: " << format_state(recorder->get_state()) << "\tNot Detected"; - } - } else { BOOST_LOG_TRIVIAL(info) << "\t[ " << recorder->get_num() << " ] State: " << format_state(recorder->get_state()); - } } } @@ -211,10 +207,14 @@ void manage_conventional_call(Call *call, Config &config) { // means that the squelch is on and it has stopped recording if (call->get_recorder()->is_idle()) { // increase the number of periods it has not been recording for + call->set_noise(call->get_recorder()->get_pwr()); call->increase_idle_count(); - } else if (call->get_idle_count() > 0) { - // if it starts recording again, then reset the idle count - call->reset_idle_count(); + } else { + call->set_signal(call->get_recorder()->get_pwr()); + if (call->get_idle_count() > 0) { + // if it starts recording again, then reset the idle count + call->reset_idle_count(); + } } // if no additional recording has happened in the past X periods, stop and open new file diff --git a/trunk-recorder/recorders/recorder.h b/trunk-recorder/recorders/recorder.h index beffb8e96..172bccc5a 100644 --- a/trunk-recorder/recorders/recorder.h +++ b/trunk-recorder/recorders/recorder.h @@ -79,8 +79,7 @@ class Recorder { int get_num() { return rec_num; }; Recorder_Type get_type() { return type; }; double get_pwr() { return 0; }; - void set_rssi(int rssi) { this->rssi = rssi; }; - int get_rssi() { return rssi; }; + bool is_conventional() { return conventional; }; virtual void tune_offset(double f){}; diff --git a/trunk-recorder/source.cc b/trunk-recorder/source.cc index 4d9fe916c..ae3eec315 100644 --- a/trunk-recorder/source.cc +++ b/trunk-recorder/source.cc @@ -417,9 +417,6 @@ std::vector Source::get_detected_recorders() { std::vector recorders = find_conventional_recorders_by_freq(signal); for (std::vector::iterator it = recorders.begin(); it != recorders.end(); it++) { Recorder *recorder = *it; - if (!recorder->is_enabled()) { - recorder->set_rssi(rssi); - } detected_recorders.push_back(recorder); } }