SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
IFRecorder.hxx
Go to the documentation of this file.
1/*
2Copyright (c) 2018, 2025 Matthew H. Reilly (kb1vc)
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are
7met:
8
9 Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in
13 the documentation and/or other materials provided with the
14 distribution.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29#include "SoDaBase.hxx"
30#include "SoDaThread.hxx"
31#include "Params.hxx"
32#include "Command.hxx"
33
34#include <queue>
35#include <mutex>
36#include <fstream>
37#include <string>
38#include <fstream>
39
40#include <SoDa/MailBox.hxx>
41
42namespace SoDa {
68 class IFRecorder;
69 typedef std::shared_ptr<IFRecorder> IFRecorderPtr;
70
71 class IFRecorder : public SoDa::Thread {
72 protected:
79
80 public:
81 static IFRecorderPtr make(ParamsPtr params) {
82 auto ret = std::shared_ptr<IFRecorder>(new IFRecorder(params));
83 ret->registerThread(ret);
84 return ret;
85 }
86
88 void subscribeToMailBoxes(const std::vector<MailBoxBasePtr> & mailboxes);
89
93 void run();
94
95 private:
111
116 void openOutStream(char * ofile_name);
117
122
123 // parameters
124 unsigned int rf_buffer_size;
126
128
131 CDatMBox::Subscription rx_subs;
132 CmdMBox::Subscription cmd_subs;
133
134 std::ofstream ostr;
136 };
137}
The Baseclass for all SoDa objects, and useful commonly used classes.
The Baseclass for all SoDa thread objects.
void run()
the run method – does the work of the audio receiver process
bool write_stream_on
when true, write each incoming buffer to the output stream.
void openOutStream(char *ofile_name)
open an output stream to receive the RF samples
CDatMBox::Subscription rx_subs
mailbox subscription ID for rx data stream
CmdMBox::Subscription cmd_subs
mailbox subscription ID for command stream
double rf_sample_rate
sample rate of RF input from USRP – assumed 625KHz
std::ofstream ostr
raw (binary) output stream.
CmdMBoxPtr cmd_stream
mailbox producing command stream from user
void execRepCommand(CommandPtr cmd)
handle Report commands from the command channel
void closeOutStream()
close the current output stream
void execSetCommand(CommandPtr cmd)
handle SET commands from the command channel
void execGetCommand(CommandPtr cmd)
execute GET commands from the command channel
double current_rx_center_freq
CDatMBoxPtr rx_stream
mailbox producing rx sample stream from USRP
IFRecorder(ParamsPtr params)
the constructor
void subscribeToMailBoxes(const std::vector< MailBoxBasePtr > &mailboxes)
implement the subscription method
unsigned int rf_buffer_size
size of input RF buffer chunk
static IFRecorderPtr make(ParamsPtr params)
The Thread baseclass for all SoDa thread objects.
std::shared_ptr< Params > ParamsPtr
Definition Params.hxx:42
std::shared_ptr< IFRecorder > IFRecorderPtr
std::shared_ptr< Command > CommandPtr
Definition Command.hxx:41
std::shared_ptr< CmdMBox > CmdMBoxPtr
Definition SoDaBase.hxx:79
std::shared_ptr< CDatMBox > CDatMBoxPtr
Definition SoDaBase.hxx:91