Home2L - C/C++ API  v1.2-2-ga4fe (2023-04-15)
Smart Tools for a Private Home
Friends | List of all members
CRcDriver Class Reference

Description

Driver for local resources.

All 'CRcDriver' objects must be allocated dynamically and registered before the Resources library is started (see RcStart() ). On registration, the library becomes owner of the object.

Registering an object of this class without a driver function ('NULL') results in a signal driver.

Definition at line 2433 of file resources.H.

#include "resources.H"

Inheritance diagram for CRcDriver:
Inheritance graph
[legend]

Friends

class CResource
 

Life cycle ...

void Register ()
 Register and enable the driver. This must be done between the calls to RcInit() and RcStart(), i.e. the initialization phase. The class takes over the ownership of 'this', which must be a dynamically allocated object, which is deleted during RcDone().
 
void Unregister ()
 Unregister the driver. This is only allowed in the elaboration phase or on shutdown. Calling this method will delete 'this' soon, so that no further accesses are allowed after this.
 
static void RegisterAndInit (const char *_lid, FRcDriverFunc *_func)
 Create, register and initialize a function-based driver.
 

Properties ...

const char * Lid ()
 
const char * ToStr (CString *)
 

Resource management ...

CResourceRegisterResource (const char *rcLid, ERcType _type, bool _writable, void *_data=NULL)
 
CResourceRegisterResource (const char *rcLid, const char *rcTypeDef, void *_data=NULL)
 see also: CResource::Register()
 

For directory services ...

void PrintInfo (FILE *f=stdout)
 
CResourceGetResource (const char *rcLid)
 
int LockResources ()
 
CResourceGetResource (int n)
 
void UnlockResources ()
 

Interface methods ...

virtual void Stop ()
 Stop all (own) threads and close all I/Os properly; Will be called from RcDone(). Resources are still registered and will be unregistered afterwards.
 
virtual void DriveValue (CResource *rc, CRcValueState *vs)
 Callback to drive a new value, will be called from CResource::DriveValue(). More...
 

Helper methods ...

void Lock ()
 
void Unlock ()
 
void ClearResources ()
 Unregister all resources.
 

Member Function Documentation

◆ DriveValue()

virtual void CRcDriver::DriveValue ( CResource rc,
CRcValueState vs 
)
protectedvirtual

Callback to drive a new value, will be called from CResource::DriveValue().

When called, this method must propagate a new requested value to the device (e.g. to an actor). Afterwards, the new value and state pointed at by 'vs' will be reported automatically by the caller.

If there are no pending requests at all, this method is called with vs->State() == rcsUnknown. Most drivers will do nothing then (e.g. the "signal" driver does so) and keep the previous value active. Some drivers (e.g. brownies/shades) may switch off their actors now. For other drivers, please remember that unknown value/states may come in and must be ignored.

In all other cases, the state of '*vs' is preset with rcsValid.

It is legal to modify '*vs' to reflect a new state or even a value different from the driven one. The method shall change the value and eventually the state as adequate.

If the new value is not known yet, the state should be set to 'rcsBusy' by calling CRcValueState::SetToReportBusy() now on 'vs', and the new value should be reported later with a valid value and state of rcsValid by calling a 'CRcResource::Report...()' method.

To report a certain (e.g. the new) value with the rcsBusy state now, the state may be set to rcsBusy and the value be set as appropriate or left as it is, in which case the driven value is reported. Again, a valid value (state of rcsValid) should be reported later.

To report nothing at all this time, call CRcValueState::SetToReportNothing() on '*vs' or set the state to rcsUnknown.

It is not allowed to call any method of the 'rc' object (e.g. 'Report' methods) from here, since the resource may be locked.

In most cases, just writing to the device is sufficient.

Reimplemented in CRcEventDriver.


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