Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
ExtendedSwitchBehaviour Class Reference

A smart timer behaviour is a switch behaviour that is allowed to extend itself passed the until time defined. More...

#include <cs_ExtendedSwitchBehaviour.h>

Inheritance diagram for ExtendedSwitchBehaviour:
Collaboration diagram for ExtendedSwitchBehaviour:

Public Types

typedef std::array< uint8_t, WireFormat::size< SwitchBehaviour >()+WireFormat::size< PresenceCondition >()> SerializedDataType
 
- Public Types inherited from SwitchBehaviour
typedef std::array< uint8_t, WireFormat::size< Behaviour >()+WireFormat::size< PresenceCondition >()> SerializedDataType
 
- Public Types inherited from Behaviour
enum class  Type : uint8_t { Switch = 0 , Twilight = 1 , Extended = 2 , Undefined = 0xff }
 
typedef std::array< uint8_t, 1+13 > SerializedDataType
 

Public Member Functions

 ExtendedSwitchBehaviour (SwitchBehaviour corebehaviour, PresenceCondition extensioncondition)
 
virtual ~ExtendedSwitchBehaviour ()=default
 
 ExtendedSwitchBehaviour (SerializedDataType arr)
 
SerializedDataType serialize ()
 
virtual uint8_t * serialize (uint8_t *outbuff, size_t max_size) override
 
virtual size_t serializedSize () const override
 
virtual Type getType () const override
 
virtual bool requiresPresence () override
 
virtual bool requiresAbsence () override
 
virtual PresencePredicate currentPresencePredicate () override
 
virtual bool isValid (Time currenttime, PresenceStateDescription currentpresence)
 Does the behaviour apply to the current situation? Depends on corebehaviour, extensionIsActive and extensionCondition. More...
 
virtual void print ()
 
bool extensionPeriodIsActive ()
 
virtual bool isValid (Time currenttime, PresenceStateDescription currentpresence)
 Does the behaviour apply to the current situation? If from() == until() the behaviour isValid all day. More...
 
bool isValid (PresenceStateDescription currentpresence)
 
- Public Member Functions inherited from SwitchBehaviour
virtual ~SwitchBehaviour ()=default
 
 SwitchBehaviour (uint8_t intensity, uint8_t profileid, DayOfWeekBitMask activedaysofweek, TimeOfDay from, TimeOfDay until, PresenceCondition presencecondition)
 
 SwitchBehaviour (SerializedDataType arr)
 
SerializedDataType serialize ()
 
virtual uint8_t * serialize (uint8_t *outbuff, size_t max_size) override
 
virtual size_t serializedSize () const override
 
virtual Type getType () const override
 
virtual void print ()
 
bool gracePeriodForPresenceIsActive ()
 
virtual bool requiresPresence () override
 
virtual bool requiresAbsence () override
 
virtual PresencePredicate currentPresencePredicate ()
 
virtual bool isValid (Time currenttime, PresenceStateDescription currentpresence)
 Does the behaviour apply to the current situation? If from() == until() the behaviour isValid all day. More...
 
bool isValid (PresenceStateDescription currentpresence)
 
bool isValid (Time currenttime)
 Does the behaviour apply to the current situation? If from() == until() the behaviour isValid all day. More...
 
- Public Member Functions inherited from Behaviour
virtual ~Behaviour ()=default
 
 Behaviour (Type typ, uint8_t intensity, uint8_t profileid, DayOfWeekBitMask activedaysofweek, TimeOfDay from, TimeOfDay until)
 
 Behaviour (SerializedDataType arr)
 
SerializedDataType serialize ()
 
virtual uint8_t * serialize (uint8_t *outbuff, size_t max_size)
 
virtual size_t serializedSize () const
 
std::vector< uint8_t > serialized ()
 
virtual void print ()
 
virtual Type getType () const
 
bool isValid (Time currenttime)
 Does the behaviour apply to the current situation? If from() == until() the behaviour isValid all day. More...
 
virtual bool requiresPresence ()
 
virtual bool requiresAbsence ()
 
uint8_t value () const
 Returns the intended state when this behaviour is valid. More...
 
TimeOfDay from () const
 Returns from (incl.) which time on this behaviour applies. More...
 
TimeOfDay until () const
 Returns until (excl.) which time on this behaviour applies. More...
 

Private Attributes

PresenceCondition extensionCondition
 
bool extensionIsActive = false
 extensionIsActive will be set to true when at the end of the core behaviour valid period a call to isValid(Time,PresenceCondition) was made that returned true. More...
 
std::optional< TimeprevExtensionIsValidTimeStamp = {}
 

Additional Inherited Members

- Protected Attributes inherited from SwitchBehaviour
PresenceCondition presenceCondition
 
- Protected Attributes inherited from Behaviour
Type typ
 
uint8_t activeIntensity = 0
 
uint8_t profileId = 0
 
DayOfWeekBitMask activeDays
 
TimeOfDay behaviourAppliesFrom = TimeOfDay::Midnight()
 
TimeOfDay behaviourAppliesUntil = TimeOfDay::Midnight()
 

Detailed Description

A smart timer behaviour is a switch behaviour that is allowed to extend itself passed the until time defined.

The extension is based on a PresenceCondition.

Envisioned use case:

  • A dumb timer is annoying because it will turn off a light when a user is in the room. It would be much nicer if it delayed this until the user left.

Member Typedef Documentation

◆ SerializedDataType

Constructor & Destructor Documentation

◆ ExtendedSwitchBehaviour() [1/2]

◆ ~ExtendedSwitchBehaviour()

virtual ExtendedSwitchBehaviour::~ExtendedSwitchBehaviour ( )
virtualdefault

◆ ExtendedSwitchBehaviour() [2/2]

Member Function Documentation

◆ currentPresencePredicate()

virtual PresencePredicate ExtendedSwitchBehaviour::currentPresencePredicate ( )
overridevirtual

Reimplemented from SwitchBehaviour.

◆ extensionPeriodIsActive()

bool ExtendedSwitchBehaviour::extensionPeriodIsActive ( )
inline

◆ getType()

virtual Type ExtendedSwitchBehaviour::getType ( ) const
inlineoverridevirtual

Reimplemented from SwitchBehaviour.

◆ isValid() [1/3]

bool SwitchBehaviour::isValid ( PresenceStateDescription  currentpresence)

◆ isValid() [2/3]

virtual bool SwitchBehaviour::isValid ( Time  currenttime,
PresenceStateDescription  currentpresence 
)
virtual

Does the behaviour apply to the current situation? If from() == until() the behaviour isValid all day.

Reimplemented from SwitchBehaviour.

◆ isValid() [3/3]

virtual bool ExtendedSwitchBehaviour::isValid ( Time  currenttime,
PresenceStateDescription  currentpresence 
)
virtual

Does the behaviour apply to the current situation? Depends on corebehaviour, extensionIsActive and extensionCondition.

Reimplemented from SwitchBehaviour.

◆ print()

virtual void ExtendedSwitchBehaviour::print ( )
virtual

Reimplemented from SwitchBehaviour.

◆ requiresAbsence()

virtual bool ExtendedSwitchBehaviour::requiresAbsence ( )
overridevirtual

Reimplemented from SwitchBehaviour.

◆ requiresPresence()

virtual bool ExtendedSwitchBehaviour::requiresPresence ( )
overridevirtual

Reimplemented from SwitchBehaviour.

◆ serialize() [1/2]

SerializedDataType ExtendedSwitchBehaviour::serialize ( )

◆ serialize() [2/2]

virtual uint8_t * ExtendedSwitchBehaviour::serialize ( uint8_t *  outbuff,
size_t  max_size 
)
overridevirtual

Reimplemented from SwitchBehaviour.

◆ serializedSize()

virtual size_t ExtendedSwitchBehaviour::serializedSize ( ) const
overridevirtual

Reimplemented from SwitchBehaviour.

Member Data Documentation

◆ extensionCondition

PresenceCondition ExtendedSwitchBehaviour::extensionCondition
private

◆ extensionIsActive

bool ExtendedSwitchBehaviour::extensionIsActive = false
private

extensionIsActive will be set to true when at the end of the core behaviour valid period a call to isValid(Time,PresenceCondition) was made that returned true.

When extensionIsActive is true, the isValid(Time,PresenceCondition) function will return true when either the core behaviour isValid is satisfied, or the extensionCondition isValid is satisfied.

extensionIsActive will be reset to false [extensionCondition.timeOut] seconds after the until() value of the core behaviour, unless this timeOut is zero: in that case it will be reset to false as soon as the PresenceCondition evaluates to false.

◆ prevExtensionIsValidTimeStamp

std::optional<Time> ExtendedSwitchBehaviour::prevExtensionIsValidTimeStamp = {}
private

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