Skip to content

Commit

Permalink
Added maximal recording time.
Browse files Browse the repository at this point in the history
  • Loading branch information
shajen committed Nov 22, 2024
1 parent bb4e773 commit 74dcc1a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions sources/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ constexpr auto LOG_FILES_COUNT = 9; // kee
constexpr auto PERFORMANCE_LOGGER_INTERVAL = 1000; // print stats every n frames
constexpr auto RECORDER_FLUSH_INTERVAL = std::chrono::milliseconds(100); // flush recordings to mqtt every 2 * n bytes
constexpr auto RESAMPLER_THRESHOLD = 125; // max interpolation or decimation factor of RESAMPLER
constexpr auto TRANSMISSION_MAX_TIME = std::chrono::minutes(10); // break transmission if longer that

// SCANNING SETTINGS
constexpr auto NOISE_LEARNING_TIME = std::chrono::milliseconds(2000); // noise learnig time
Expand Down
2 changes: 1 addition & 1 deletion sources/radio/blocks/transmission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void Transmission::process(const float* power) {
void Transmission::clearSignals(const float* avgPower, const float* rawPower, const std::chrono::milliseconds now) {
for (auto it = m_signals.begin(); it != m_signals.cend();) {
const auto& [index, signal] = *it;
if (signal.isTimeout(now)) {
if (signal.isTimeout(now) || signal.isMaximalTime(now)) {
Logger::info(
LABEL,
"stop, frequency: {}, center frequency: {}, avg power: {}, raw power:{}",
Expand Down
2 changes: 2 additions & 0 deletions sources/radio/signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ void Signal::newData(const Index, const float avgPower, const Index rawIndex, co

bool Signal::isMinimalTime(const std::chrono::milliseconds& now) const { return m_firstDataTime + m_config.recordingMinTime() <= now; }

bool Signal::isMaximalTime(const std::chrono::milliseconds& now) const { return m_firstDataTime + TRANSMISSION_MAX_TIME <= now; }

bool Signal::isTimeout(const std::chrono::milliseconds& now) const { return m_lastDataTime + m_config.recordingTimeout() <= now; }

bool Signal::needFlush(const std::chrono::milliseconds& now) const { return m_lastDataTime == now && isMinimalTime(now); }
Expand Down
1 change: 1 addition & 0 deletions sources/radio/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Signal {
void newData(const Index avgIndex, const float avgPower, const Index rawIndex, const float rawPower, const std::chrono::milliseconds& now);

bool isMinimalTime(const std::chrono::milliseconds& now) const;
bool isMaximalTime(const std::chrono::milliseconds& now) const;
bool isTimeout(const std::chrono::milliseconds& now) const;
bool needFlush(const std::chrono::milliseconds& now) const;
float getPower() const;
Expand Down

0 comments on commit 74dcc1a

Please sign in to comment.