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

#include <istream.h>

Inheritance diagram for BaseSerialInputStream:
InputStream Stream ASCIISerialStream BinaryIntArraySerialStream

Public Member Functions

 BaseSerialInputStream (uint32_t usb_port_num, uint32_t baud, int numDimensions)
 
 BaseSerialInputStream (uint32_t baud, int numDimensions)
 
virtual bool start () final
 
virtual void stop () final
 
virtual int getNumInputDimensions () final
 
vector< string > getSerialDeviceList ()
 
bool selectSerialDevice (uint32_t port)
 
- Public Member Functions inherited from InputStream
 InputStream ()
 
virtual ~InputStream ()=default
 
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 ()
 
void toggle ()
 
bool hasStarted ()
 

Protected Member Functions

virtual void parseSerial (vector< unsigned char > &buffer)=0
 
- Protected Member Functions inherited from InputStream
vector< double > normalize (vector< double >)
 

Protected Attributes

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

Additional Inherited Members

- Public Types inherited from InputStream
using normalizeFunc = std::function< double(double)>
 
using vectorNormalizeFunc = std::function< vector< double >(vector< double >)>
 
typedef std::function< void(GRT::MatrixDouble)> onDataReadyCallback
 

Constructor & Destructor Documentation

BaseSerialInputStream::BaseSerialInputStream ( uint32_t  usb_port_num,
uint32_t  baud,
int  numDimensions 
)

Create an BaseSerialInputStream instance.

Parameters
portthe index of the (USB) serial port to use.
baudthe baud rate at which to communicate with the serial port
numDimensionsthe number of dimensions in the data that will come from the serial port (i.e. the number of numbers in each line of data).
BaseSerialInputStream::BaseSerialInputStream ( uint32_t  baud,
int  numDimensions 
)

Create an BaseSerialInputStream instance. This constructor doesn't require USB port so users will be asked to select them at runtime.

Parameters
baudthe baud rate at which to communicate with the serial port
numDimensionsthe number of dimensions in the data that will come from the serial port (i.e. the number of numbers in each line of data).

Member Function Documentation

int BaseSerialInputStream::getNumInputDimensions ( )
finalvirtual

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

Implements InputStream.

vector<string> BaseSerialInputStream::getSerialDeviceList ( )
inline
virtual void BaseSerialInputStream::parseSerial ( vector< unsigned char > &  buffer)
protectedpure virtual
bool BaseSerialInputStream::selectSerialDevice ( uint32_t  port)
inline
bool BaseSerialInputStream::start ( )
finalvirtual

Start the stream.

Reimplemented from Stream.

void BaseSerialInputStream::stop ( )
finalvirtual

Reimplemented from Stream.

Member Data Documentation

unique_ptr<ofSerial> BaseSerialInputStream::serial_
protected

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