ESP  0.1
The Example-based Sensor Predictions (ESP) system tries to bring machine learning to the maker community.
InputStream Class Referenceabstract

Base class for input streams that provide live sensor data to the ESP system. To use an InputStream instance in your application, pass it to useInputStream() in your setup() function. More...

#include <istream.h>

Inheritance diagram for InputStream:
Stream AudioFileStream AudioStream BaseSerialInputStream FirmataStream IOStream IOStreamVector OscInputStream SerialStream TcpInputStream

Public Types

using normalizeFunc = std::function< double(double)>
 
using vectorNormalizeFunc = std::function< vector< double >(vector< double >)>
 
typedef std::function< void(GRT::MatrixDouble)> onDataReadyCallback
 

Public Member Functions

 InputStream ()
 
virtual ~InputStream ()=default
 
virtual int getNumInputDimensions ()=0
 
virtual int getNumOutputDimensions ()
 
void useNormalizer (normalizeFunc f)
 
void useNormalizer (vectorNormalizeFunc f)
 
void onDataReadyEvent (onDataReadyCallback callback)
 
template<typename T1 , typename arg , class T >
void onDataReadyEvent (T1 *owner, void(T::*listenerMethod)(arg))
 
void setLabelsForAllDimensions (const vector< string > labels)
 
void setLabelsForAllDimensions (std::initializer_list< string > list)
 
const vector< string > & getLabels () const
 
- Public Member Functions inherited from Stream
 Stream ()
 
virtual bool start ()
 
virtual void stop ()
 
void toggle ()
 
bool hasStarted ()
 

Protected Member Functions

vector< double > normalize (vector< double >)
 

Protected Attributes

vector< string > InputStream_labels_
 
onDataReadyCallback data_ready_callback_
 
normalizeFunc normalizer_
 
vectorNormalizeFunc vectorNormalizer_
 
- Protected Attributes inherited from Stream
std::atomic_bool has_started_
 

Detailed Description

Base class for input streams that provide live sensor data to the ESP system. To use an InputStream instance in your application, pass it to useInputStream() in your setup() function.

Member Typedef Documentation

using InputStream::normalizeFunc = std::function<double(double)>
typedef std::function<void(GRT::MatrixDouble)> InputStream::onDataReadyCallback
using InputStream::vectorNormalizeFunc = std::function<vector<double>(vector<double>)>

Constructor & Destructor Documentation

InputStream::InputStream ( )
virtual InputStream::~InputStream ( )
virtualdefault

Member Function Documentation

const vector< string > & InputStream::getLabels ( ) const
virtual int InputStream::getNumInputDimensions ( )
pure virtual

Get the number of dimensions of the data that's provided by the input stream (before it's run through the normalizer, if any).

Implemented in OscInputStream, TcpInputStream, FirmataStream, SerialStream, BaseSerialInputStream, AudioFileStream, and AudioStream.

virtual int InputStream::getNumOutputDimensions ( )
inlinevirtual
vector< double > InputStream::normalize ( vector< double >  input)
protected
void InputStream::onDataReadyEvent ( onDataReadyCallback  callback)
inline
template<typename T1 , typename arg , class T >
void InputStream::onDataReadyEvent ( T1 *  owner,
void(T::*)(arg)  listenerMethod 
)
inline
void InputStream::setLabelsForAllDimensions ( std::initializer_list< string >  list)
void InputStream::useNormalizer ( normalizeFunc  f)
inline
void InputStream::useNormalizer ( vectorNormalizeFunc  f)
inline

Member Data Documentation

onDataReadyCallback InputStream::data_ready_callback_
protected
vector<string> InputStream::InputStream_labels_
protected
normalizeFunc InputStream::normalizer_
protected
vectorNormalizeFunc InputStream::vectorNormalizer_
protected

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