A Controller is responsible for serialising requests for a physical bus. More...

#include <Controller.h>

Inheritance diagram for IO::Controller:
Collaboration diagram for IO::Controller:

Public Types

using List = LinkedObjectListTemplate< Controller >
 
- Public Types inherited from LinkedObjectTemplate< Controller >
using Iterator = IteratorTemplate< Controller, Controller *, Controller & >
 
using ConstIterator = IteratorTemplate< const Controller, const Controller *, const Controller & >
 

Public Member Functions

 Controller (uint8_t instance)
 Construct a controller instance. More...
 
virtual ~Controller ()
 
uint8_t getInstance () const
 Get the controller instance number. More...
 
Device::OwnedListgetDevices ()
 Get list of devices for this controller. More...
 
void freeDevices ()
 Destroy all devices for this controller. More...
 
ErrorCode createDevice (const char *id, JsonObjectConst config, Device *&device)
 Create a new devicce. More...
 
template<class DeviceClass >
ErrorCode createDevice (const char *id, const typename DeviceClass::Config &config, DeviceClass *&device)
 Create a new device as a concrete type. More...
 
DevicefindDevice (const String &id)
 Locate a device from its identifier. More...
 
virtual const FlashStringclassname () const =0
 Get the class name for this Controller. More...
 
virtual void start ()
 Start the controller. More...
 
virtual void stop ()
 Stop all controllers. More...
 
virtual bool canStop () const
 Check if it's OK to stop this controller. More...
 
const CStringgetId () const
 Get the fully-qualified unique controller identifier. More...
 
bool operator== (const String &id) const
 
- Public Member Functions inherited from LinkedObjectTemplate< Controller >
Controller * getNext () const
 
bool insertAfter (Controller *object)
 
Iterator begin () const
 
Iterator end () const
 
Iterator cbegin () const
 
Iterator cend () const
 
- Public Member Functions inherited from LinkedObject
virtual ~LinkedObject ()
 
virtual LinkedObjectnext () const
 
bool insertAfter (LinkedObject *object)
 
bool operator== (const LinkedObject &other) const
 
bool operator!= (const LinkedObject &other) const
 

Static Public Member Functions

static void registerDeviceClass (const Device::Factory &factory)
 Register a device factory. More...
 

Protected Member Functions

virtual void handleEvent (Request *request, Event event)
 Implementations override this method to process events as they pass through the stack. More...
 
void submit (Request *request)
 Queue a request. More...
 
void checkDevices ()
 
void resetTransactionTime ()
 

Friends

class Device
 
class DeviceManager
 

Detailed Description

A Controller is responsible for serialising requests for a physical bus.

Member Typedef Documentation

◆ List

Constructor & Destructor Documentation

◆ Controller()

IO::Controller::Controller ( uint8_t  instance)
inline

Construct a controller instance.

Parameters
instanceInstance number, must be unique for each class of controller

◆ ~Controller()

virtual IO::Controller::~Controller ( )
inlinevirtual

Member Function Documentation

◆ canStop()

virtual bool IO::Controller::canStop ( ) const
inlinevirtual

Check if it's OK to stop this controller.

◆ checkDevices()

void IO::Controller::checkDevices ( )
protected

◆ classname()

virtual const FlashString& IO::Controller::classname ( ) const
pure virtual

Get the class name for this Controller.

Implemented in IO::RS485::Controller, IO::RFSwitch::Controller, and IO::Custom::Controller.

◆ createDevice() [1/2]

template<class DeviceClass >
ErrorCode IO::Controller::createDevice ( const char *  id,
const typename DeviceClass::Config &  config,
DeviceClass *&  device 
)

Create a new device as a concrete type.

Parameters
idUnique identifier for the device
configDevice configuration
device(OUT) The constructed device, owned by this controller
Return values
ErrorCodeThis method template is used to manually constructing device instances.

◆ createDevice() [2/2]

ErrorCode IO::Controller::createDevice ( const char *  id,
JsonObjectConst  config,
Device *&  device 
)

Create a new devicce.

Parameters
idUnique identifier for the device
configDevice configuration
device(OUT) The constructed device
Return values
ErrorCode
Note
Created devices are owned by this controller. DO NOT delete them manually!

◆ findDevice()

Device* IO::Controller::findDevice ( const String id)

Locate a device from its identifier.

◆ freeDevices()

void IO::Controller::freeDevices ( )

Destroy all devices for this controller.

◆ getDevices()

Device::OwnedList& IO::Controller::getDevices ( )
inline

Get list of devices for this controller.

◆ getId()

const CString& IO::Controller::getId ( ) const
inline

Get the fully-qualified unique controller identifier.

◆ getInstance()

uint8_t IO::Controller::getInstance ( ) const
inline

Get the controller instance number.

◆ handleEvent()

virtual void IO::Controller::handleEvent ( Request request,
Event  event 
)
protectedvirtual

Implementations override this method to process events as they pass through the stack.

Reimplemented in IO::RFSwitch::Controller, and IO::Custom::Controller.

◆ operator==()

bool IO::Controller::operator== ( const String id) const
inline

◆ registerDeviceClass()

static void IO::Controller::registerDeviceClass ( const Device::Factory factory)
inlinestatic

Register a device factory.

Each factory has a class name which allows the device manager to dynamically construct Device instances as directed by configuration.

◆ resetTransactionTime()

void IO::Controller::resetTransactionTime ( )
inlineprotected

◆ start()

virtual void IO::Controller::start ( )
inlinevirtual

Start the controller.

Controllers may now initiate communications with registered devices. Typically they'll query device status, etc.

Reimplemented in IO::RS485::Controller.

◆ stop()

virtual void IO::Controller::stop ( )
inlinevirtual

Stop all controllers.

This method is called by the Device Manager, applications shouldn't need it.

Note
MUST call canStop() first to ensure it's safe to stop!

Reimplemented in IO::RS485::Controller.

◆ submit()

void IO::Controller::submit ( Request request)
protected

Queue a request.

The request is started immediately if the queue is empty.

Friends And Related Function Documentation

◆ Device

friend class Device
friend

◆ DeviceManager

friend class DeviceManager
friend

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