Skip to content

Commit

Permalink
Almost there...
Browse files Browse the repository at this point in the history
  • Loading branch information
robotastic committed Feb 20, 2024
1 parent 62f6322 commit 1d8cc56
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 26 deletions.
4 changes: 4 additions & 0 deletions trunk-recorder/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion trunk-recorder/call_conventional.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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() {
Expand Down
20 changes: 19 additions & 1 deletion trunk-recorder/call_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions trunk-recorder/call_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -96,6 +100,8 @@ class Call_impl : public Call {
long call_num;
long talkgroup;
double curr_freq;
double noise;
double signal;
std::vector<Transmission> transmission_list;
System *sys;
std::string short_name;
Expand Down
4 changes: 2 additions & 2 deletions trunk-recorder/gr_blocks/pwr_squelch_cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#define INCLUDED_ANALOG_PWR_SQUELCH_CC_H

#include <gnuradio/analog/api.h>
#include <gnuradio/analog/squelch_base_cc.h>
#include "squelch_base_cc.h"
#include <cmath>

namespace gr {
Expand Down Expand Up @@ -51,7 +51,7 @@ class ANALOG_API pwr_squelch_cc : public squelch_base_cc, virtual public block
std::vector<float> 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;

Expand Down
2 changes: 1 addition & 1 deletion trunk-recorder/gr_blocks/pwr_squelch_cc_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "config.h"
#endif

#include "pwr_squelch_cc_impl.h"
#include "./pwr_squelch_cc_impl.h"

namespace gr {
namespace analog {
Expand Down
4 changes: 2 additions & 2 deletions trunk-recorder/gr_blocks/pwr_squelch_cc_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <gnuradio/analog/pwr_squelch_cc.h>
#include "./squelch_base_cc_impl.h"
#include "./pwr_squelch_cc.h"
#include <gnuradio/filter/single_pole_iir.h>
#include <cmath>

Expand Down
44 changes: 44 additions & 0 deletions trunk-recorder/gr_blocks/squelch_base_cc.h
Original file line number Diff line number Diff line change
@@ -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 <gnuradio/analog/api.h>
#include <gnuradio/block.h>

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<float> squelch_range() const = 0;
};

} /* namespace analog */
} /* namespace gr */

#endif /* INCLUDED_ANALOG_SQUELCH_BASE_CC_H */
2 changes: 1 addition & 1 deletion trunk-recorder/gr_blocks/squelch_base_cc_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "config.h"
#endif

#include "squelch_base_cc_impl.h"
#include "./squelch_base_cc_impl.h"
#include <gnuradio/io_signature.h>
#include <gnuradio/math.h>

Expand Down
2 changes: 1 addition & 1 deletion trunk-recorder/gr_blocks/squelch_base_cc_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef INCLUDED_GR_SQUELCH_BASE_CC_IMPL_H
#define INCLUDED_GR_SQUELCH_BASE_CC_IMPL_H

#include <gnuradio/analog/squelch_base_cc.h>
#include "./squelch_base_cc.h"

namespace gr {
namespace analog {
Expand Down
24 changes: 12 additions & 12 deletions trunk-recorder/monitor_systems.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,15 @@ void print_status(std::vector<Source *> &sources, std::vector<System *> &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());
}
}
}

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions trunk-recorder/recorders/recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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){};
Expand Down
3 changes: 0 additions & 3 deletions trunk-recorder/source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,6 @@ std::vector<Recorder *> Source::get_detected_recorders() {
std::vector<Recorder *> recorders = find_conventional_recorders_by_freq(signal);
for (std::vector<Recorder *>::iterator it = recorders.begin(); it != recorders.end(); it++) {
Recorder *recorder = *it;
if (!recorder->is_enabled()) {
recorder->set_rssi(rssi);
}
detected_recorders.push_back(recorder);
}
}
Expand Down

0 comments on commit 1d8cc56

Please sign in to comment.