Skip to content

Commit

Permalink
fix meta formatting, count annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
anarkiwi committed May 10, 2024
1 parent 3a50a3f commit 4c3f2cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/iq_inference_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ iq_inference_impl::iq_inference_impl(
power_inference_(power_inference), background_(background),
inference_count_(n_inference), running_(true), last_rx_freq_(0),
last_rx_time_(0), samples_since_tag_(0), sample_clock_(0),
last_full_time_(0) {
last_full_time_(0), predictions_(0) {
batch_ = vlen_ * n_vlen_;
samples_lookback_.reset(new gr_complex[batch_ * sample_buffer]);
unsigned int alignment = volk_get_alignment();
Expand Down Expand Up @@ -296,6 +296,7 @@ bool iq_inference_impl::stop() {
inference_thread_->join();
}
run_inference_();
d_logger->info("published {} predictions", predictions_);
return true;
}

Expand Down Expand Up @@ -378,6 +379,7 @@ void iq_inference_impl::run_inference_() {
const std::string output_json_str = output_json.dump();
json_q_.push(output_json_str + "\n\n");
message_port_pub(INFERENCE_KEY, string_to_pmt(output_json_str));
++predictions_;
}
delete_output_item_(output_item);
}
Expand Down
1 change: 1 addition & 0 deletions lib/iq_inference_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class iq_inference_impl : public iq_inference, base_impl {
std::string host_, port_;
boost::scoped_ptr<std::thread> inference_thread_;
bool background_;
COUNT_T predictions_;

void process_items_(COUNT_T power_in_count, COUNT_T &power_read,
const float *&power_in, COUNT_T &consumed);
Expand Down
5 changes: 4 additions & 1 deletion lib/write_freq_samples_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ void write_freq_samples_impl::close_() {
last_rx_freq_, gain_);
// TODO: handle annotations for the rotate case.
boost::lock_guard<boost::mutex> guard(queue_lock_);
COUNT_T annotations = 0;
while (!inference_q_.empty()) {
inference_item_type inference_item = inference_q_.front();
inference_q_.pop();
Expand All @@ -356,10 +357,12 @@ void write_freq_samples_impl::close_() {
anno.access<sigmf::core::AnnotationT>().generator = "GamutRF";
record.annotations.emplace_back(anno);
}
d_logger->info("wrote {} annotations", annotations);
std::string sigmf_filename = final_samples_path_base + ".sigmf-meta";
std::string dotfilename = get_dotfile_(sigmf_filename);
std::ofstream jsonfile(dotfilename);
jsonfile << record.to_json();
nlohmann::json meta_json(record.to_json());
jsonfile << std::setw(4) << meta_json;
jsonfile.close();
rename(dotfilename.c_str(), sigmf_filename.c_str());
}
Expand Down

0 comments on commit 4c3f2cf

Please sign in to comment.