Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_ExtendedSwitchBehaviour.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: Dec 20, 2019
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7
8#pragma once
9
11
21public:
22 typedef std::array<uint8_t, WireFormat::size<SwitchBehaviour>() + WireFormat::size<PresenceCondition>()>
24
25 ExtendedSwitchBehaviour(SwitchBehaviour corebehaviour, PresenceCondition extensioncondition);
26 virtual ~ExtendedSwitchBehaviour() = default;
27
29
31
32 virtual uint8_t* serialize(uint8_t* outbuff, size_t max_size) override;
33 virtual size_t serializedSize() const override;
34
35 virtual Type getType() const override { return Type::Extended; }
36
37 // requiresPresence depends on corebehaviour, extensionIsActive and extensionCondition.
38 // it assumes that extensionIsActive is up to date.
39 virtual bool requiresPresence() override;
40
41 // requiresAbsence depends on corebehaviour, extensionIsActive and extensionCondition.
42 // it assumes that extensionIsActive is up to date.
43 virtual bool requiresAbsence() override;
44
45 // currentPresenceCondition depends on corebehaviour, extensionIsActive and extensionCondition.
46 // it assumes that extensionIsActive is up to date.
48
49 // See SwitchBehaviour for more elaborate explanation why this is necessary.
51
56 virtual bool isValid(Time currenttime, PresenceStateDescription currentpresence);
57
58 virtual void print();
59
61
62private:
64
77 bool extensionIsActive = false;
78 std::optional<Time> prevExtensionIsValidTimeStamp = {};
79};
bool isValid()
Checks if the data has valid values.
Type
Definition: cs_Behaviour.h:22
A smart timer behaviour is a switch behaviour that is allowed to extend itself passed the until time ...
Definition: cs_ExtendedSwitchBehaviour.h:20
std::optional< Time > prevExtensionIsValidTimeStamp
Definition: cs_ExtendedSwitchBehaviour.h:78
ExtendedSwitchBehaviour(SerializedDataType arr)
PresenceCondition extensionCondition
Definition: cs_ExtendedSwitchBehaviour.h:63
virtual Type getType() const override
Definition: cs_ExtendedSwitchBehaviour.h:35
virtual PresencePredicate currentPresencePredicate() override
SerializedDataType serialize()
virtual size_t serializedSize() const override
virtual ~ExtendedSwitchBehaviour()=default
virtual uint8_t * serialize(uint8_t *outbuff, size_t max_size) override
virtual bool isValid(Time currenttime, PresenceStateDescription currentpresence)
Does the behaviour apply to the current situation? Depends on corebehaviour, extensionIsActive and ex...
virtual bool requiresPresence() override
virtual void print()
bool extensionIsActive
extensionIsActive will be set to true when at the end of the core behaviour valid period a call to is...
Definition: cs_ExtendedSwitchBehaviour.h:77
std::array< uint8_t, WireFormat::size< SwitchBehaviour >()+WireFormat::size< PresenceCondition >()> SerializedDataType
Definition: cs_ExtendedSwitchBehaviour.h:23
bool extensionPeriodIsActive()
Definition: cs_ExtendedSwitchBehaviour.h:60
ExtendedSwitchBehaviour(SwitchBehaviour corebehaviour, PresenceCondition extensioncondition)
virtual bool requiresAbsence() override
Definition: cs_PresenceCondition.h:14
Definition: cs_PresencePredicate.h:15
Class that holds the presence of a profile.
Definition: cs_PresenceDescription.h:23
Object that defines when a state transition should occur.
Definition: cs_SwitchBehaviour.h:26
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Sep 24,...
Definition: cs_Time.h:14