JQI Arduino Libraries
Arduino for the modern scientist.
 All Classes Files Functions Variables Typedefs Macros Pages
Classes | Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
SetListDevice< Device > Class Template Reference

Template class implementation of Setlist, for device-specific behavior. More...

#include <SetListArduino.h>

Inheritance diagram for SetListDevice< Device >:
SetListBase

Classes

struct  SetListCallback
 Data struct for storing setlist lines. More...
 

Public Types

typedef void(* SpecificSetListCallback )(Device *, int *)
 Type definition for device-specific callback function. More...
 

Public Member Functions

 SetListDevice (Device &device)
 Constructor for SetListDevice. More...
 
void insertToSetList (int pos, GenericSetListCallback function, int *params)
 Inserts callback function into the _setlist of SetListDevice. More...
 
int getSetListFunc (int pos)
 Returns the pointer value for a SpecificSetListCallback. More...
 
int * getSetListParams (int pos)
 Returns a pointer to the parameters to be passed to a SetList callback. More...
 
int getSetListLength ()
 Returns the length of a SetListDevice's currently programmed setlist. More...
 
void clearSetList ()
 Clears device's SetList table. More...
 
void executeSetList (int pos)
 Executes callback function at a particular SetList line. More...
 
- Public Member Functions inherited from SetListBase
 SetListBase ()
 

Static Private Member Functions

static void _holdValue (Device *, int *params)
 Empty SpecificSetListCallback function to be executed when no state change is needed on Device. More...
 

Private Attributes

Device * _device
 Pointer to the controlled device. More...
 
SetListCallback _setlist [MAX_SETLIST_LINES]
 List of callback functions & params. More...
 
int _setlistLength
 Length of device's SetList. More...
 

Detailed Description

template<class Device>
class SetListDevice< Device >

Template class implementation of Setlist, for device-specific behavior.

SetListDevice inherits from SetListBase. Each device connected to the Arduino will have its own instance of SetListDevice, which manages a list of callback functions and arguments to execute when the Arduino receives a trigger from the computer.

Template Parameters
Device
See also
SetListBase(),

Member Typedef Documentation

template<class Device>
typedef void(* SetListDevice< Device >::SpecificSetListCallback)(Device *, int *)

Type definition for device-specific callback function.

See also
SetListArduino::registerCommand()

Constructor & Destructor Documentation

template<class Device>
SetListDevice< Device >::SetListDevice ( Device &  device)
inline

Constructor for SetListDevice.

Creates an instance of SetListDevice.

Interesting point of info: be careful about how you instantiate these objects! Calling, eg,

SetListDevice newDevice(DDS1);

is different from calling

SetListDevice newDevice = new SetListDevice(DDS1);

The first will add newDevice to the stack, while the second method adds it to the heap. For our purposes, SetListDevice() is called from SetListArduino. We want newDevice to persist after that call passes out of scope, so we should have the compiler allocate memory in the heap.

Member Function Documentation

template<class Device>
static void SetListDevice< Device >::_holdValue ( Device *  ,
int *  params 
)
inlinestaticprivate

Empty SpecificSetListCallback function to be executed when no state change is needed on Device.

template<class Device>
void SetListDevice< Device >::clearSetList ( )
inlinevirtual

Clears device's SetList table.

This function doesn't actually overwrite SetListDevice::_setlist. Rather, it resets the counter SetListDevice::_setlistLength to zero.

Reimplemented from SetListBase.

template<class Device>
void SetListDevice< Device >::executeSetList ( int  pos)
inlinevirtual

Executes callback function at a particular SetList line.

If #SETLIST_DEBUG is set, will print diagnostic information to serial terminal.

Parameters
posInteger specifying the SetList line.

Reimplemented from SetListBase.

template<class Device>
int SetListDevice< Device >::getSetListFunc ( int  pos)
inlinevirtual

Returns the pointer value for a SpecificSetListCallback.

Used for debugging information.

Parameters
posInteger index specifying the SetList line.
See also
SetListArduino::readSerial()

Reimplemented from SetListBase.

template<class Device>
int SetListDevice< Device >::getSetListLength ( )
inlinevirtual

Returns the length of a SetListDevice's currently programmed setlist.

Reimplemented from SetListBase.

template<class Device>
int* SetListDevice< Device >::getSetListParams ( int  pos)
inlinevirtual

Returns a pointer to the parameters to be passed to a SetList callback.

Used for debugging information.

Parameters
posInteger index specifying the SetList line.
See also
SetListArduino::readSerial()

Reimplemented from SetListBase.

template<class Device>
void SetListDevice< Device >::insertToSetList ( int  pos,
GenericSetListCallback  function,
int *  params 
)
inlinevirtual

Inserts callback function into the _setlist of SetListDevice.

Parameters
posInteger indexing the location to place the callback function in SetListDevice::_setlist.
functionGenericSetListCallback, which will be executed when the Arduino receives the right trigger from the computer. It is passed in as a GenericSetListCallback, but is re-cast as a SpecificSetListCallback using reinterpret_cast. It is done this way to remain agnostic about the type of SetListDevice when it is passed from SetListArduino. In your Arduino sketch, you should define this function and its behavior.
paramsArray of parameters to pass to the callback function. Note, its length is limited by MAX_PARAM_NUM
See also
SetListArduino::registerCommand

Reimplemented from SetListBase.

Member Data Documentation

template<class Device>
Device* SetListDevice< Device >::_device
private

Pointer to the controlled device.

See also
SetListArduino::registerDevice()
template<class Device>
SetListCallback SetListDevice< Device >::_setlist[MAX_SETLIST_LINES]
private

List of callback functions & params.

This member data contains the device's actual SetList. The length is limited by MAX_SETLIST_LINES.

See also
SetListCallback, SetListArduino::registerCommand
template<class Device>
int SetListDevice< Device >::_setlistLength
private

Length of device's SetList.

Counter to keep track of how many SetList lines have been programmed to SetListDevice.


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