![]() |
SoDaRadio-12.2.0-cut_dependencies:6c82803
|
This is a thread that subscribes to the SoDaRadio command and IF streams. More...
#include <IFServer.hxx>
Public Member Functions | |
| IFServer (const std::string &name) | |
| create the plugin thread instance. | |
| void | subscribeToMailBox (const std::string &mbox_name, SoDa::BaseMBox *mbox_p) |
| connect to useful mailboxes. | |
| void | run () |
| This is the method that does the actual work. | |
| void | shutDown () |
| Each thread must implement this method. | |
| void | execRepCommand (SoDa::Command *cmd) |
| A thread may implement any or all of the command execution methods (execRepCommand, execSetCommand, execGetCommand). | |
| Public Member Functions inherited from SoDa::Thread | |
| void | registerThread (SoDa::ThreadPtr me) |
| virtual void | subscribeToMailBoxes (const std::vector< MailBoxBasePtr > &mailboxes)=0 |
| the creator of this thread may offer one or more mailboxes to this object. | |
| void | operator() () |
| void | start () |
| Execute the thread's run loop. | |
| void | join () |
| more properly "Wait for this thread to exit its run loop". | |
| void | execCommand (CommandPtr cmd) |
| Execute (dispatch) a message removed from the command stream to one of the basic Command handler functions. | |
| virtual void | execGetCommand (CommandPtr cmd) |
| optional method to handle "GET" commands – commands that request a response | |
| virtual void | execSetCommand (CommandPtr cmd) |
| optional method to handle "SET" commands – commands that set internal state in the object. | |
| virtual void | execRepCommand (CommandPtr cmd) |
| optional method that reports status or the result of some action. | |
| void | sleep_ms (unsigned int milliseconds) |
| void | sleep_us (unsigned int microseconds) |
| uint32_t | getID () |
| Get the process/thread ID for this thread – helps with figuring out who caused a segfault. | |
| Public Member Functions inherited from SoDa::Base | |
| Base (const std::string &oname) | |
| The constructor – pass a name for the object. | |
| void | registerSelf (BasePtr ptr) |
| std::string & | getObjName () |
| get the name of this object | |
| BasePtr | findSoDaObject (const std::string &oname) |
| find a SoDa Object by name. | |
| double | getTime () |
| Get a time stamp in nS resolution that monotonically increases and that is very inexpensive (typically < 100nS). | |
| BasePtr | getSelfPtr () |
| get a pointer to myself. | |
| Public Member Functions inherited from SoDa::Debug | |
| Debug (std::string _unit_name=std::string("UNKNOWN")) | |
| Debug (const char *_unit_name_cstr) | |
| Debug (unsigned int _debug_level, std::string _unit_name=std::string("UNKNOWN")) | |
| Debug (unsigned int _debug_level, const char *_unit_name_cstr) | |
| void | debugMsg (const std::string &msg, unsigned int threshold=1) |
| void | debugMsg (const SoDa::Format &fmt, unsigned int threshold=1) |
| void | debugMsg (const char *msg, unsigned int threshold=1) |
| void | setDebugLevel (unsigned int v) |
| unsigned int | getDebugLevel () |
Protected Member Functions | |
| bool | sendBuffer (SoDa::Buf *rxbuf) |
| send a buffer of complex samples to clients connected to the socket. | |
| Protected Member Functions inherited from SoDa::Thread | |
| Thread (const std::string &oname, const std::string &version=std::string("12.2.0")) | |
| make the thread object. | |
| Protected Member Functions inherited from SoDa::Debug | |
| std::string | curDateTime () |
Protected Attributes | |
| unsigned int | cmd_subs |
| mailbox subscription ID for command stream | |
| SoDa::CmdMBox * | cmd_stream |
| mailbox producing command stream from user | |
| unsigned int | rx_subs |
| mailbox subscription ID for command stream | |
| SoDa::DatMBox * | rx_stream |
| mailbox producing command stream from user | |
| SoDa::UD::ServerSocket * | server_socket |
| unix domain server socket object. | |
| double | current_rx_center_freq |
| Protected Attributes inherited from SoDa::Thread | |
| std::weak_ptr< Thread > | self |
| A pointer to ourself. | |
| Protected Attributes inherited from SoDa::Debug | |
| std::string | unit_name |
| the name of the unit reporting status | |
| unsigned int | debug_level |
| the debug level (threshold) for messages | |
Additional Inherited Members | |
| Static Public Member Functions inherited from SoDa::Debug | |
| static void | setDefaultLevel (unsigned int v) |
| static unsigned int | getDefaultLevel () |
| static void | setGlobalLevel (unsigned int v) |
| static unsigned int | getGlobalLevel () |
| Static Public Attributes inherited from SoDa::Debug | |
| static std::mutex | debug_msg_mutex |
| Static Protected Attributes inherited from SoDa::Debug | |
| static unsigned int | default_debug_level |
| static unsigned int | global_debug_level |
This is a thread that subscribes to the SoDaRadio command and IF streams.
It listens for new IF buffers from the RX thread, and makes them available on a unix domain socket called "IFServer" and located in the directory from which SoDaRadio was started.
Each block is of the form:
uint32 buffer_length (bytes) double center complex<float> [buffer_length]
Definition at line 81 of file IFServer.hxx.
| IFServer::IFServer | ( | const std::string & | name | ) |
create the plugin thread instance.
This will register the plugin with the thread registrar and make the server process aware of the plugin's existence.
| name | This is a convenience name used in error reports and debugging aids. It need not be unique or even meaningful. |
| void IFServer::execRepCommand | ( | SoDa::Command * | cmd | ) |
A thread may implement any or all of the command execution methods (execRepCommand, execSetCommand, execGetCommand).
execRepCommand interprets an incoming SoDa::Command where the SoDa::Command::CmdType is REP (report). Commands of this kind carry information like "this is my status" or "the current RX front end tuning frequency is X MHz."
This plugin listens on the command channel for "STOP" messages and "RX_FE_FREQ" messages. The former tells the plugin to exit the run method. The latter tells the plugin that the IF center frequency has changed to the new RX_FE_FREQ.
| cmd | a command of type SoDa::Command that includes the type of command (report, setter, getter), the parameter being referenced (RX_FE_FREQ, STOP...) and an optional data value. |
|
virtual |
This is the method that does the actual work.
It is called by the server for each thread. The thread should not return from this function until a STOP message arrives on the command stream.
Reimplemented from SoDa::Thread.
|
protected |
send a buffer of complex samples to clients connected to the socket.
The buffer is preceded by a buffer length (UI32) and the current center frequency (double). The buffer itself is a sequence of complex<float> values.
| rxbuf | a complex<float> buffer wrapped in a SoDa::Buf object. |
|
virtual |
Each thread must implement this method.
It provides for an orderly shutdown of all open connections, or other resources and processes in a thread. It is not necessarily the destructor for this thread.
Reimplemented from SoDa::Thread.
| void IFServer::subscribeToMailBox | ( | const std::string & | mbox_name, |
| SoDa::BaseMBox * | mbox_p ) |
connect to useful mailboxes.
This is a virtual method that should be implemented by any SoDa::Thread object, as it is the mechanism through which a thread may subscribe or connect to the data and command streams.
The SoDaRadio server will offer each mailbox/stream to every thread. A thread may subscribe to or ignore the stream.
| mbox_name | which mailbox are we being offered? |
| mbox_p | a pointer to the mailbox we are being offered. |
|
protected |
mailbox producing command stream from user
Definition at line 160 of file IFServer.hxx.
|
protected |
mailbox subscription ID for command stream
Definition at line 159 of file IFServer.hxx.
|
protected |
Definition at line 171 of file IFServer.hxx.
|
protected |
mailbox producing command stream from user
Definition at line 162 of file IFServer.hxx.
|
protected |
mailbox subscription ID for command stream
Definition at line 161 of file IFServer.hxx.
|
protected |
unix domain server socket object.
SoDa::UD::ServerSocket wraps the normal select/read/write/accept/connect interface in a simple socket object.
Definition at line 169 of file IFServer.hxx.