Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing auto build Actions on GitHub #994

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
-
name: Prepare
id: prepare
Expand Down Expand Up @@ -66,14 +66,14 @@ jobs:
# https://github.com/docker/setup-qemu-action
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
-
name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache
Expand Down
6,561 changes: 3,696 additions & 2,865 deletions lib/json.hpp

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion trunk-recorder/call_concluder/call_concluder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,13 @@ Call_Data_t upload_call_worker(Call_Data_t call_info) {
} else {
talkgroup_title = (char *)std::to_string(call_info.talkgroup).c_str();
}
result = convert_media(call_info.filename, call_info.converted, std::ctime(&call_info.start_time), call_info.short_name.c_str(), talkgroup_title);
result = convert_media(
call_info.filename,
call_info.converted,
std::ctime(static_cast<const time_t*>(&call_info.start_time)),
call_info.short_name.c_str(),
talkgroup_title
);

if (result < 0) {
call_info.status = FAILED;
Expand Down
55 changes: 46 additions & 9 deletions trunk-recorder/global_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,53 @@

const int DB_UNSET = 999;


struct Transmission {
long source;
long start_time;
long stop_time;
long sample_count;
long spike_count;
long error_count;
double freq;
double length;
char filename[255];
long source;
time_t start_time;
time_t stop_time;
long sample_count;
long spike_count;
long error_count;
double freq;
double length;
char filename[255];

// Add default constructor
Transmission() : source(0), start_time(0), stop_time(0),
sample_count(0), spike_count(0), error_count(0), freq(0.0),
length(0.0) {
filename[0] = '\0';
}

// Add copy constructor
Transmission(const Transmission& other) {
source = other.source;
start_time = other.start_time;
stop_time = other.stop_time;
sample_count = other.sample_count;
spike_count = other.spike_count;
error_count = other.error_count;
freq = other.freq;
length = other.length;
std::strncpy(filename, other.filename, sizeof(filename));
}

// Add assignment operator
Transmission& operator=(const Transmission& other) {
if (this != &other) {
source = other.source;
start_time = other.start_time;
stop_time = other.stop_time;
sample_count = other.sample_count;
spike_count = other.spike_count;
error_count = other.error_count;
freq = other.freq;
length = other.length;
std::strncpy(filename, other.filename, sizeof(filename));
}
return *this;
}
};

struct Config {
Expand Down
1 change: 1 addition & 0 deletions trunk-recorder/gr_blocks/selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class BLOCKS_API selector : virtual public block {
// Otherwise samples are copied to the selected output port
virtual void set_port_enabled(unsigned int port, bool enabled) = 0;
virtual bool is_port_enabled(unsigned int port) = 0;
virtual bool is_receiving_samples() = 0;
virtual bool enabled() const = 0;
virtual void set_input_index(unsigned int input_index) = 0;
virtual int input_index() const = 0;
Expand Down
17 changes: 17 additions & 0 deletions trunk-recorder/gr_blocks/selector_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ selector_impl::selector_impl(size_t itemsize,
d_input_index(input_index),
d_output_index(output_index),
d_num_inputs(0),
current_nitems(0),
d_num_outputs(0) {

d_enabled_output_ports = std::vector<bool>(d_max_port, false);
Expand Down Expand Up @@ -125,6 +126,22 @@ bool selector_impl::is_port_enabled(unsigned int port) {
return d_enabled_output_ports[port];
}


bool selector_impl::is_receiving_samples() {
uint64_t nitems = this->nitems_read(0);

if (nitems == 0) {
return true;
}

if (nitems != current_nitems) {
current_nitems = nitems;
return true;
}
BOOST_LOG_TRIVIAL(info) << "is_receiving_samples() - nitems: " << nitems << " current_nitems: " << current_nitems;
return false;
}

int selector_impl::general_work(int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
Expand Down
3 changes: 2 additions & 1 deletion trunk-recorder/gr_blocks/selector_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class selector_impl : public selector {
unsigned int d_num_inputs, d_num_outputs; // keep track of the topology
const unsigned int d_max_port = 100;
gr::thread::mutex d_mutex;
uint64_t current_nitems;

public:
selector_impl(size_t itemsize, unsigned int input_index, unsigned int output_index);
Expand All @@ -49,7 +50,7 @@ class selector_impl : public selector {

void set_port_enabled(unsigned int port, bool enabled);
bool is_port_enabled(unsigned int port);

bool is_receiving_samples();
bool enabled() const { return d_enabled; }

void set_input_index(unsigned int input_index);
Expand Down
10 changes: 5 additions & 5 deletions trunk-recorder/gr_blocks/transmission_sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,19 +414,19 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_
return nwritten;
}

time_t transmission_sink::get_start_time() {
time_t transmission_sink::get_start_time() const {
return d_start_time;
}

time_t transmission_sink::get_stop_time() {
time_t transmission_sink::get_stop_time() const {
return d_stop_time;
}

std::chrono::time_point<std::chrono::steady_clock> transmission_sink::get_last_write_time() {
std::chrono::time_point<std::chrono::steady_clock> transmission_sink::get_last_write_time() const {
return d_last_write_time;
}

void transmission_sink::add_transmission(Transmission t) {
void transmission_sink::add_transmission(const Transmission& t) {
transmission_list.push_back(t);
}

Expand All @@ -435,7 +435,7 @@ void transmission_sink::clear_transmission_list() {
transmission_list.shrink_to_fit();
}

std::vector<Transmission> transmission_sink::get_transmission_list() {
std::vector<Transmission> transmission_sink::get_transmission_list() const {
return transmission_list;
}

Expand Down
11 changes: 6 additions & 5 deletions trunk-recorder/gr_blocks/transmission_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

class Call;
struct Transmission;

namespace gr {
namespace blocks {

Expand Down Expand Up @@ -127,8 +128,8 @@ class BLOCKS_API transmission_sink : virtual public sync_block {
void set_sample_rate(unsigned int sample_rate);
void set_bits_per_sample(int bits_per_sample);
void clear_transmission_list();
std::vector<Transmission> get_transmission_list();
void add_transmission(Transmission t);
std::vector<Transmission> get_transmission_list() const;
void add_transmission(const Transmission& t);
int bits_per_sample();
unsigned int sample_rate();
double total_length_in_seconds();
Expand All @@ -139,9 +140,9 @@ class BLOCKS_API transmission_sink : virtual public sync_block {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
State get_state();
time_t get_start_time();
time_t get_stop_time();
std::chrono::time_point<std::chrono::steady_clock> get_last_write_time();
time_t get_start_time() const;
time_t get_stop_time() const;
std::chrono::time_point<std::chrono::steady_clock> get_last_write_time() const;
};

} /* namespace blocks */
Expand Down
4 changes: 2 additions & 2 deletions trunk-recorder/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ int main(int argc, char **argv) {
// ------------------------------------------------------------------
BOOST_LOG_TRIVIAL(info) << "stopping flow graph" << std::endl;
tb->stop();
tb->wait();
//tb->wait();

BOOST_LOG_TRIVIAL(info) << "stopping plugins" << std::endl;
stop_plugins();
BOOST_LOG_TRIVIAL(info) << "plugins stopped" << std::endl;
} else {
BOOST_LOG_TRIVIAL(error) << "Unable to setup a System to record, exiting..." << std::endl;
}

return exit_code;
}
11 changes: 11 additions & 0 deletions trunk-recorder/monitor_systems.cc
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,16 @@ void process_message_queues(std::vector<System *> &systems) {
}
}

void check_sources(std::vector<Source *> &sources) {
for (vector<Source *>::iterator it = sources.begin(); it != sources.end(); it++) {
Source *source = *it;
if (!source->is_alive()) {
BOOST_LOG_TRIVIAL(error) << "Source " << source->get_num() << " is no longer active";
//exit_flag = 1;
}
}
}

int monitor_messages(Config &config, gr::top_block_sptr &tb, std::vector<Source *> &sources, std::vector<System *> &systems, std::vector<Call *> &calls) {
gr::message::sptr msg;

Expand Down Expand Up @@ -865,6 +875,7 @@ int monitor_messages(Config &config, gr::top_block_sptr &tb, std::vector<Source

if ((current_time - management_timestamp) >= 1.0) {
manage_calls(config, calls);
check_sources(sources);
Call_Concluder::manage_call_data_workers();
management_timestamp = current_time;
}
Expand Down
1 change: 1 addition & 0 deletions trunk-recorder/monitor_systems.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
#include <gnuradio/top_block.h>

int monitor_messages(Config &config, gr::top_block_sptr &tb, std::vector<Source *> &sources, std::vector<System *> &systems, std::vector<Call *> &calls);
void check_sources(std::vector<Source *> &sources);
void retune_system(System *sys, gr::top_block_sptr &tb, std::vector<Source *> &sources);
#endif
1 change: 1 addition & 0 deletions trunk-recorder/plugin_manager/plugin_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void stop_plugins() {
for (std::vector<Plugin *>::iterator it = plugins.begin(); it != plugins.end(); it++) {
Plugin *plugin = *it;
if (plugin->state == PLUGIN_RUNNING) {
BOOST_LOG_TRIVIAL(info) << " - Stopping Plugin: " << plugin->name;
int err = plugin->api->stop();
if (err != 0) {
plugin->state = PLUGIN_FAILED;
Expand Down
7 changes: 7 additions & 0 deletions trunk-recorder/source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,13 @@ void Source::enable_detected_recorders() {
}
}

bool Source::is_alive() {
if (this->attached_selector) {
return recorder_selector->is_receiving_samples();
} else
return true;
}

void Source::set_signal_detector_threshold(float threshold) {
BOOST_LOG_TRIVIAL(info) << " - Setting Signal Detector Threshold to: " << threshold;
signal_detector->set_threshold(threshold);
Expand Down
1 change: 1 addition & 0 deletions trunk-recorder/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Source {
gr::basic_block_sptr get_src_block();
void attach_detector(gr::top_block_sptr tb);
void attach_selector(gr::top_block_sptr tb);
bool is_alive();
double get_min_hz();
double get_max_hz();
void set_min_max();
Expand Down
Loading