Skip to content

Commit

Permalink
Merge pull request #270 from anarkiwi/anno
Browse files Browse the repository at this point in the history
Remove annotation limit.
  • Loading branch information
anarkiwi authored May 9, 2024
2 parents f749590 + a9a96cc commit cc6f17e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
15 changes: 5 additions & 10 deletions lib/write_freq_samples_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,6 @@ void write_freq_samples_impl::recv_inference_(const pmt::pmt_t msg) {
if (rotate_) {
return;
}
if (!inference_q_.write_available()) {
d_logger->error("inference annotation queue full");
return;
}
const std::string msg_str = pmt_to_string(msg);
d_logger->info("inference results: {}", msg_str);
try {
Expand All @@ -279,6 +275,7 @@ void write_freq_samples_impl::recv_inference_(const pmt::pmt_t msg) {
continue;
}
for (auto &prediction : prediction_class.value()) {
boost::lock_guard<boost::mutex> guard(queue_lock_);
// TODO: add confidence and model to description.
inference_item_type inference_item;
inference_item.sample_start = sample_clock;
Expand All @@ -287,9 +284,7 @@ void write_freq_samples_impl::recv_inference_(const pmt::pmt_t msg) {
inference_item.freq_upper_edge = last_rx_freq_ + (sample_rate / 2);
inference_item.description = prediction_class.key();
inference_item.label = inference_item.description;
if (!inference_q_.push(inference_item)) {
d_logger->error("inference annotation queue full");
}
inference_q_.push(inference_item);
}
}
}
Expand Down Expand Up @@ -341,11 +336,11 @@ void write_freq_samples_impl::close_() {
sigmf_record_t record =
create_sigmf(final_samples_path, open_time_, datatype_, samp_rate_,
last_rx_freq_, gain_);
d_logger->info("writing {} annotations", inference_q_.read_available());
// TODO: handle annotations for the rotate case.
boost::lock_guard<boost::mutex> guard(queue_lock_);
while (!inference_q_.empty()) {
inference_item_type inference_item;
inference_q_.pop(inference_item);
inference_item_type inference_item = inference_q_.front();
inference_q_.pop();
auto anno = sigmf::Annotation<sigmf::core::DescrT>();
anno.access<sigmf::core::AnnotationT>().sample_start =
inference_item.sample_start;
Expand Down
9 changes: 4 additions & 5 deletions lib/write_freq_samples_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,14 @@
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/filter/zstd.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/lockfree/spsc_queue.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <gnuradio/iqtlabs/write_freq_samples.h>
#include <queue>

namespace gr {
namespace iqtlabs {

#define MAX_ANNOTATIONS 1024

typedef struct inference_item {
COUNT_T sample_count;
COUNT_T sample_start;
Expand Down Expand Up @@ -256,8 +255,8 @@ class write_freq_samples_impl : public write_freq_samples, base_impl {
COUNT_T rotate_secs_;
TIME_T open_time_;

boost::lockfree::spsc_queue<inference_item_type> inference_q_{
MAX_ANNOTATIONS};
std::queue<inference_item_type> inference_q_;
boost::mutex queue_lock_;
boost::scoped_ptr<boost::iostreams::filtering_ostream> outbuf_p;
std::string outfile_;

Expand Down

0 comments on commit cc6f17e

Please sign in to comment.