LASP 1.0
Library for Acoustic Signal Processing
Loading...
Searching...
No Matches
StreamMgr Class Reference

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
 
StreamMgroperator= (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 DaqgetDaq (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< StreamMgrgetInstance ()
 Get access to stream manager instance.
 

Friends

class InDataHandler
 
class Siggen
 

Detailed Description

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.

Member Enumeration Documentation

◆ StreamType

enum class StreamMgr::StreamType : us
strong
Enumerator
input 

Input stream.

output 

Output stream.

Definition at line 75 of file lasp_streammgr.h.

Constructor & Destructor Documentation

◆ ~StreamMgr()

StreamMgr::~StreamMgr ( )

Definition at line 245 of file lasp_streammgr.cpp.

◆ StreamMgr()

StreamMgr::StreamMgr ( const StreamMgr )
delete

Member Function Documentation

◆ getDaq()

const Daq * StreamMgr::getDaq ( StreamType  type) const

Get DAQ pointer for a given stream. Gives a nullptr if stream is not running.

Parameters
typeThe stream type to get a DAQ ptr for.
Returns
Pointer to DAQ

Definition at line 469 of file lasp_streammgr.cpp.

◆ getDeviceInfo()

DeviceInfoList StreamMgr::getDeviceInfo ( ) const
inline

Obtain a list of devices currently available. When the StreamMgr is first created, this.

Returns
A copy of the internal stored list of devices

Definition at line 102 of file lasp_streammgr.h.

◆ getInstance()

SmgrHandle StreamMgr::getInstance ( )
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.

Returns
Reference to stream manager.
Stream manager handle

Definition at line 35 of file lasp_streammgr.cpp.

◆ getStreamStatus()

Daq::StreamStatus StreamMgr::getStreamStatus ( const StreamType  type) const

Get the streamstatus object corresponding to a given stream.

Parameters
typeType of stream, input, inputType, etc.
Returns
status object.

Definition at line 455 of file lasp_streammgr.cpp.

◆ isStreamRunning()

bool StreamMgr::isStreamRunning ( const StreamType  type) const
inline

Definition at line 142 of file lasp_streammgr.h.

◆ isStreamRunningOK()

bool StreamMgr::isStreamRunningOK ( const StreamType  type) const
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.

Parameters
typeThe type of stream to check for.

Definition at line 139 of file lasp_streammgr.h.

◆ operator=()

StreamMgr & StreamMgr::operator= ( const StreamMgr )
delete

◆ rescanDAQDevices()

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.

Parameters
backgroundPerform searching for DAQ devices in the background. If set to true, the function returns immediately.
callbackFunction to call when complete.

Definition at line 80 of file lasp_streammgr.cpp.

◆ setSiggen()

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.

Parameters
sNew Siggen pointer

Definition at line 153 of file lasp_streammgr.cpp.

◆ startStream()

void StreamMgr::startStream ( const DaqConfiguration config)

Start a stream based on given configuration.

Parameters
configConfiguration 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.

◆ stopAllStreams()

void StreamMgr::stopAllStreams ( )

Stop and delete all streams. Also called on destruction of the StreamMgr.

Definition at line 263 of file lasp_streammgr.cpp.

◆ stopStream()

void StreamMgr::stopStream ( const StreamType  stype)

Stop stream of given type (input / output/ duplex);.

Parameters
stypeThe 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.

Friends And Related Symbol Documentation

◆ InDataHandler

friend class InDataHandler
friend

Definition at line 67 of file lasp_streammgr.h.

◆ Siggen

friend class Siggen
friend

Definition at line 68 of file lasp_streammgr.h.


The documentation for this class was generated from the following files: