LASP 1.0
Library for Acoustic Signal Processing
|
Stream manager. Used to manage the input and output streams. Implemented as a singleton: only one stream manager can be in existance for a given program. The thread that instantiates a stream manager is the only thread that should interact with the stream manager. If this is not true, undefined behavior can be expected. If LASP is compiled in debug mode, this fact is asserted. More...
#include <lasp_streammgr.h>
Public Types | |
enum class | StreamType : us { input = 1 << 0 , output = 1 << 1 } |
Public Member Functions | |
~StreamMgr () | |
StreamMgr (const StreamMgr &)=delete | |
StreamMgr & | operator= (const StreamMgr &)=delete |
DeviceInfoList | getDeviceInfo () const |
Obtain a list of devices currently available. When the StreamMgr is first created, this. | |
void | rescanDAQDevices (bool background=false, std::function< void()> callback=std::function< void()>()) |
Triggers a background scan of the DAQ devices, which updates the internally stored list of devices. Throws a runtime error when a background thread is already scanning for devices, or if a stream is running. | |
void | startStream (const DaqConfiguration &config) |
Start a stream based on given configuration. | |
bool | isStreamRunningOK (const StreamType type) const |
Check if a certain stream is running. If running with no errors, it returns true. If an error occured, or the stream is not running, it gives false. | |
bool | isStreamRunning (const StreamType type) const |
Daq::StreamStatus | getStreamStatus (const StreamType type) const |
Get the streamstatus object corresponding to a given stream. | |
const Daq * | getDaq (StreamType type) const |
Get DAQ pointer for a given stream. Gives a nullptr if stream is not running. | |
void | stopStream (const StreamType stype) |
Stop stream of given type (input / output/ duplex);. | |
void | stopAllStreams () |
Stop and delete all streams. Also called on destruction of the StreamMgr. | |
void | setSiggen (std::shared_ptr< Siggen > s) |
Set active signal generator for output streams. Only one ‘Siggen’ is active at the same time. Siggen controls its own data race protection using a mutex. If no Siggen is there, and an output stream is running, it will send a default signal of 0. | |
Static Public Member Functions | |
static std::shared_ptr< StreamMgr > | getInstance () |
Get access to stream manager instance. | |
Friends | |
class | InDataHandler |
class | Siggen |
Stream manager. Used to manage the input and output streams. Implemented as a singleton: only one stream manager can be in existance for a given program. The thread that instantiates a stream manager is the only thread that should interact with the stream manager. If this is not true, undefined behavior can be expected. If LASP is compiled in debug mode, this fact is asserted.
Definition at line 27 of file lasp_streammgr.h.
|
strong |
Enumerator | |
---|---|
input | Input stream. |
output | Output stream. |
Definition at line 75 of file lasp_streammgr.h.
StreamMgr::~StreamMgr | ( | ) |
Definition at line 245 of file lasp_streammgr.cpp.
|
delete |
const Daq * StreamMgr::getDaq | ( | StreamType | type | ) | const |
Get DAQ pointer for a given stream. Gives a nullptr if stream is not running.
type | The stream type to get a DAQ ptr for. |
Definition at line 469 of file lasp_streammgr.cpp.
|
inline |
Obtain a list of devices currently available. When the StreamMgr is first created, this.
Definition at line 102 of file lasp_streammgr.h.
|
static |
Get access to stream manager instance.
The only way to obtain a stream manager, can only be called from the thread that does it the first time.
Definition at line 35 of file lasp_streammgr.cpp.
Daq::StreamStatus StreamMgr::getStreamStatus | ( | const StreamType | type | ) | const |
Get the streamstatus object corresponding to a given stream.
type | Type of stream, input, inputType, etc. |
Definition at line 455 of file lasp_streammgr.cpp.
|
inline |
Definition at line 142 of file lasp_streammgr.h.
|
inline |
Check if a certain stream is running. If running with no errors, it returns true. If an error occured, or the stream is not running, it gives false.
type | The type of stream to check for. |
Definition at line 139 of file lasp_streammgr.h.
void StreamMgr::rescanDAQDevices | ( | bool | background = false , |
std::function< void()> | callback = std::function<void()>() |
||
) |
Triggers a background scan of the DAQ devices, which updates the internally stored list of devices. Throws a runtime error when a background thread is already scanning for devices, or if a stream is running.
background | Perform searching for DAQ devices in the background. If set to true, the function returns immediately. |
callback | Function to call when complete. |
Definition at line 80 of file lasp_streammgr.cpp.
void StreamMgr::setSiggen | ( | std::shared_ptr< Siggen > | s | ) |
Set active signal generator for output streams. Only one ‘Siggen’ is active at the same time. Siggen controls its own data race protection using a mutex. If no Siggen is there, and an output stream is running, it will send a default signal of 0.
s | New Siggen pointer |
Definition at line 153 of file lasp_streammgr.cpp.
void StreamMgr::startStream | ( | const DaqConfiguration & | config | ) |
Start a stream based on given configuration.
config | Configuration of a device |
Give incallback as parameter to stream
Reset handlers in case of an input stream
Create input filters
No input filter for monitor channel, which comes as the first input channel In the list
Give outcallback as parameter to stream
Reset signal generator in case of an output stream
Start the DAQ. If it fails, everything is still nicely cleaned up and the daq unique_ptr cleans up resources nicely.
Definition at line 270 of file lasp_streammgr.cpp.
void StreamMgr::stopAllStreams | ( | ) |
Stop and delete all streams. Also called on destruction of the StreamMgr.
Definition at line 263 of file lasp_streammgr.cpp.
void StreamMgr::stopStream | ( | const StreamType | stype | ) |
Stop stream of given type (input / output/ duplex);.
stype | The stream type to stop. |
Kills input stream
Send reset to all in data handlers
t == output
Kill input stream in case that one is a duplex stream
Definition at line 400 of file lasp_streammgr.cpp.
|
friend |
Definition at line 67 of file lasp_streammgr.h.
|
friend |
Definition at line 68 of file lasp_streammgr.h.