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

Object that defines when a state transition should occur. More...

#include <cs_SwitchBehaviour.h>

Inheritance diagram for SwitchBehaviour:
Collaboration diagram for SwitchBehaviour:

Public Types

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

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...
 

Protected Attributes

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()
 

Private Member Functions

bool _isValid (PresenceStateDescription currentpresence)
 

Private Attributes

std::optional< uint32_t > prevInRoomTimeStamp = {}
 

Friends

class TestAccess< SwitchBehaviour >
 

Detailed Description

Object that defines when a state transition should occur.

It abstracts predicates such as: "fade to 100% in 10 minutes, starting 30 minutes before sunrise, if anyone is in this room"

Member Typedef Documentation

◆ SerializedDataType

Constructor & Destructor Documentation

◆ ~SwitchBehaviour()

virtual SwitchBehaviour::~SwitchBehaviour ( )
virtualdefault

◆ SwitchBehaviour() [1/2]

SwitchBehaviour::SwitchBehaviour ( uint8_t  intensity,
uint8_t  profileid,
DayOfWeekBitMask  activedaysofweek,
TimeOfDay  from,
TimeOfDay  until,
PresenceCondition  presencecondition 
)

◆ SwitchBehaviour() [2/2]

Member Function Documentation

◆ _isValid()

bool SwitchBehaviour::_isValid ( PresenceStateDescription  currentpresence)
private

◆ currentPresencePredicate()

virtual PresencePredicate SwitchBehaviour::currentPresencePredicate ( )
virtual

Reimplemented in ExtendedSwitchBehaviour.

◆ getType()

virtual Type SwitchBehaviour::getType ( ) const
inlineoverridevirtual

Reimplemented from Behaviour.

Reimplemented in ExtendedSwitchBehaviour.

◆ gracePeriodForPresenceIsActive()

bool SwitchBehaviour::gracePeriodForPresenceIsActive ( )

◆ isValid() [1/3]

bool SwitchBehaviour::isValid ( PresenceStateDescription  currentpresence)

◆ isValid() [2/3]

bool Behaviour::isValid ( Time  currenttime)

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

Also checks the day of week bitmask.

◆ isValid() [3/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 in ExtendedSwitchBehaviour, and ExtendedSwitchBehaviour.

◆ print()

virtual void SwitchBehaviour::print ( )
virtual

Reimplemented from Behaviour.

Reimplemented in ExtendedSwitchBehaviour.

◆ requiresAbsence()

virtual bool SwitchBehaviour::requiresAbsence ( )
overridevirtual

Reimplemented from Behaviour.

Reimplemented in ExtendedSwitchBehaviour.

◆ requiresPresence()

virtual bool SwitchBehaviour::requiresPresence ( )
overridevirtual

Reimplemented from Behaviour.

Reimplemented in ExtendedSwitchBehaviour.

◆ serialize() [1/2]

SerializedDataType SwitchBehaviour::serialize ( )

◆ serialize() [2/2]

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

Reimplemented from Behaviour.

Reimplemented in ExtendedSwitchBehaviour.

◆ serializedSize()

virtual size_t SwitchBehaviour::serializedSize ( ) const
overridevirtual

Reimplemented from Behaviour.

Reimplemented in ExtendedSwitchBehaviour.

Friends And Related Function Documentation

◆ TestAccess< SwitchBehaviour >

friend class TestAccess< SwitchBehaviour >
friend

Member Data Documentation

◆ presenceCondition

PresenceCondition SwitchBehaviour::presenceCondition
protected

◆ prevInRoomTimeStamp

std::optional<uint32_t> SwitchBehaviour::prevInRoomTimeStamp = {}
private

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