Handles requests for a specific device; the requests are executed by the relevant controller. More...
#include <Device.h>
Classes | |
| struct | Config |
| Inherited classes expand this definition as required. More... | |
| class | Factory |
| Abstract class which allows device instances to be created. More... | |
Public Types | |
| enum class | State { stopped , starting , fault , normal } |
| using | OwnedList = OwnedLinkedObjectListTemplate< Device > |
Public Types inherited from LinkedObjectTemplate< Device > | |
| using | Iterator = IteratorTemplate< Device, Device *, Device & > |
| using | ConstIterator = IteratorTemplate< const Device, const Device *, const Device & > |
Public Member Functions | |
| Device (Controller &controller, const char *id) | |
| Device constructor. More... | |
| virtual | ~Device ()=default |
| virtual const DeviceType | type () const =0 |
| ErrorCode | init (const Config &config) |
| virtual ErrorCode | init (JsonObjectConst config)=0 |
| virtual Request * | createRequest ()=0 |
| Create a request object for this device. More... | |
| const CString & | getId () const |
| The unique device identifier. More... | |
| bool | operator== (const String &id) const |
| const CString & | getName () const |
| Optional descriptive name for the device. More... | |
| virtual uint16_t | address () const |
| Devices with a numeric address should implement this method. More... | |
| unsigned | minTransactionInterval () const |
| String | caption () const |
| Obtain a descriptive caption for this device. More... | |
| Controller & | getController () const |
| Obtain the owning controller. More... | |
| State | getState () |
| Get current device state. More... | |
| virtual DevNode::ID | nodeIdMin () const |
| Get minimum valid Node ID for this device. More... | |
| DevNode::ID | nodeIdMax () const |
| Get maximum valid Node ID for this device. More... | |
| virtual uint16_t | maxNodes () const |
| Determine maximum number of nodes supported by the device. More... | |
| virtual DevNode::States | getNodeStates (DevNode) const |
| Return the current set of states for all nodes controlled by this device. More... | |
| virtual void | handleEvent (Request *request, Event event) |
| Implementations may override this method to customise event handling. More... | |
Public Member Functions inherited from LinkedObjectTemplate< Device > | |
| Device * | getNext () const |
| bool | insertAfter (Device *object) |
| Iterator | begin () const |
| Iterator | end () const |
| Iterator | cbegin () const |
| Iterator | cend () const |
Public Member Functions inherited from LinkedObject | |
| virtual | ~LinkedObject ()=default |
| virtual LinkedObject * | next () const |
| bool | insertAfter (LinkedObject *object) |
| bool | operator== (const LinkedObject &other) const |
| bool | operator!= (const LinkedObject &other) const |
Protected Member Functions | |
| void | parseJson (JsonObjectConst json, Config &cfg) |
| virtual ErrorCode | start () |
| virtual ErrorCode | stop () |
| void | submit (Request *request) |
Protected Attributes | |
| Controller & | controller |
Detailed Description
Handles requests for a specific device; the requests are executed by the relevant controller.
Member Typedef Documentation
◆ OwnedList
Member Enumeration Documentation
◆ State
|
strong |
Constructor & Destructor Documentation
◆ Device()
|
inline |
Device constructor.
- Parameters
-
controller The owning controller id Unique device identifier
◆ ~Device()
|
virtualdefault |
Member Function Documentation
◆ address()
|
inlinevirtual |
Devices with a numeric address should implement this method.
Reimplemented in IO::RS485::Device.
◆ caption()
| String IO::Device::caption | ( | ) | const |
Obtain a descriptive caption for this device.
◆ createRequest()
|
pure virtual |
Create a request object for this device.
- Return values
-
Request* Caller must destroy or submit the request
Implemented in IO::RFSwitch::Device, IO::Modbus::STS::Fan::Device, IO::Modbus::STM8Relay::Device, IO::Modbus::RID35::Device, IO::Modbus::R421A::Device, IO::Modbus::NT18B07::Device, IO::Modbus::Device, IO::DMX512::Device, and IO::Custom::Device.
◆ getController()
|
inline |
Obtain the owning controller.
◆ getId()
|
inline |
The unique device identifier.
◆ getName()
|
inline |
Optional descriptive name for the device.
◆ getNodeStates()
|
inlinevirtual |
Return the current set of states for all nodes controlled by this device.
Used to determine if, say, all nodes are ON, OFF or a combination.
Reimplemented in IO::Modbus::STM8Relay::Device, and IO::Modbus::R421A::Device.
◆ getState()
|
inline |
Get current device state.
◆ handleEvent()
Implementations may override this method to customise event handling.
Reimplemented in IO::RS485::Device, IO::Modbus::STM8Relay::Device, IO::Modbus::R421A::Device, IO::Modbus::Device, and IO::DMX512::Device.
◆ init() [1/2]
◆ init() [2/2]
|
pure virtual |
◆ maxNodes()
|
inlinevirtual |
Determine maximum number of nodes supported by the device.
- Return values
-
uint16_t 0 if device doesn't support nodes
Reimplemented in IO::Modbus::STS::Fan::Device, IO::Modbus::STM8Relay::Device, IO::Modbus::R421A::Device, IO::Modbus::NT18B07::Device, and IO::DMX512::Device.
◆ minTransactionInterval()
|
inline |
◆ nodeIdMax()
|
inline |
Get maximum valid Node ID for this device.
◆ nodeIdMin()
|
inlinevirtual |
Get minimum valid Node ID for this device.
Typically devices have a contiguous valid range of node IDs
Reimplemented in IO::Modbus::STM8Relay::Device, and IO::Modbus::R421A::Device.
◆ operator==()
|
inline |
◆ parseJson()
|
protected |
◆ start()
|
protectedvirtual |
Reimplemented in IO::DMX512::Device.
◆ stop()
|
protectedvirtual |
◆ submit()
|
protected |
◆ type()
|
pure virtual |
Implemented in IO::RS485::Device, IO::RFSwitch::Device, IO::Modbus::Device, IO::DMX512::Device, and IO::Custom::Device.
Member Data Documentation
◆ controller
|
protected |
The documentation for this class was generated from the following file:
Public Types inherited from
1.9.1