MIRA
Public Member Functions | List of all members
ChannelHysteresis< T > Class Template Reference

Class that can be registered as a filter when subscribing to channels to only get a callback when the state of the hysteresis trigger changes. More...

#include <filter/ChannelHysteresis.h>

Public Member Functions

 ChannelHysteresis (const T &lower, const T &upper)
 
Channel< T > subscribe (Authority &authority, const std::string &channelID, boost::function< void(typename SchmittTriggerHysteresis< T >::State, ChannelRead< T >)> fn)
 Call this instead of Authority::subscribe() More...
 
template<typename Class >
Channel< T > subscribe (Authority &authority, const std::string &channelID, void(Class::*f)(typename SchmittTriggerHysteresis< T >::State, ChannelRead< T >), Class *obj)
 Same as above but with a function and object pointer. More...
 
void callback (ChannelRead< T > value)
 Called when channel has new data. More...
 

Detailed Description

template<typename T>
class mira::ChannelHysteresis< T >

Class that can be registered as a filter when subscribing to channels to only get a callback when the state of the hysteresis trigger changes.

The constructor takes the function pointer to the proper callback and the class' callback method is registered instead.

class MyUnit : public MicroUnit
{
MyUnit() :
myFilter(5, 10) {}
void initialize()
{
myFilter.subscribe(*this, "IntChannel", &MyUnit::onCallback, this);
}
// gets only called when a value is changing the state of the hysteresis trigger
void onCallback(SchmittTriggerHysteresis<int>::State state, ChannelRead<int> channel)
{}
ChannelHysteresis<int> myFilter;
}

Constructor & Destructor Documentation

◆ ChannelHysteresis()

ChannelHysteresis ( const T &  lower,
const T &  upper 
)
inline

Member Function Documentation

◆ subscribe() [1/2]

Channel<T> subscribe ( Authority authority,
const std::string &  channelID,
boost::function< void(typename SchmittTriggerHysteresis< T >::State, ChannelRead< T >)>  fn 
)
inline

Call this instead of Authority::subscribe()

Parameters
authorityThe authority that does the basic subscription
channelIDThe ID of the channel we are subscribing on
fnThe function that should be called when the filter matches
Returns
The channel subscribed on

◆ subscribe() [2/2]

Channel<T> subscribe ( Authority authority,
const std::string &  channelID,
void(Class::*)(typename SchmittTriggerHysteresis< T >::State, ChannelRead< T >)  f,
Class obj 
)
inline

Same as above but with a function and object pointer.

Provided for convenience.

◆ callback()

void callback ( ChannelRead< T >  value)
inline

Called when channel has new data.


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