Home2L - C/C++ API v1.4-0-g38cc (2024-05-25)
Smart Tools for a Private Home
|
Defining custom drivers.
Defining an own driver can be done in two ways:
The advantage of an event-based driver is that all driver functionality can be implemented in a single thread (the driver thread), so that the necessity of synchronization inside the driver can be avoided.
Loadable drivers must always provide a driver function and are thus by default function-based drivers. See HOME2L_DRIVER on how loadable drivers can use their own CRcDriver class or CRcEventDriver .
There is a clear distinction between an initialization (or elaboration) phase and the active phase. All resources must be registered in the initialization phase (Operation rcdOpInit). rcdOpDriveValue operations can only occur in the active phase.
Classes | |
class | CRcDriver |
Driver for local resources. More... | |
class | CRcEventDriver |
Local driver using the event processor mechanism for the 'DriveValue()' functionality. More... | |
Macros | |
#define | HOME2L_DRIVER(NAME) |
Define the entry point of a binary driver. More... | |
Typedefs | |
typedef void | FRcDriverFunc(ERcDriverOperation, CRcDriver *, CResource *, CRcValueState *) |
Resources driver function. More... | |
Enumerations | |
enum | ERcDriverOperation { rcdOpInit = 0 , rcdOpStop , rcdOpDriveValue } |
Driver operations. More... | |
#define HOME2L_DRIVER | ( | NAME | ) |
Define the entry point of a binary driver.
Example 1: Function-Based Driver
Example 2: Class-Based Driver
This pattern allows loadable drives to use a different CRcDriver class than the base class, for example, CRcEventDriver or an own derived class.
Definition at line 2448 of file resources.H.
typedef void FRcDriverFunc(ERcDriverOperation, CRcDriver *, CResource *, CRcValueState *) |
enum ERcDriverOperation |
Driver operations.
Enumerator | |
---|---|
rcdOpInit | Initialize driver object(s) of a linked-in driver. Parameter: CRcDriver *drv. 'drv' is a 'CRcDriver' (base class) object pre-initialized and registered with a LID and 'FRcDriverFunc' according to the driver declaration table. For a function-based driver which implements 'rcdStop' and 'rcdOpDriveValue' accordingly, everything is fine now. If the driver wants to use its own objects with classes derived from 'CRcDriver', it must unregister 'drv' and may then create and register own driver(s). |
rcdOpStop | Stop the driver; refers to CRcDriver::Stop(). Parameter: CRcDriver *drv. |
rcdOpDriveValue | Drive a value; refers to CRcDriver::DriveValue(). Parameters: CRcDriver *driver, CResource *rc, CRcValueState *vs. |
Definition at line 2376 of file resources.H.