supla-device
Loading...
Searching...
No Matches
hvac_weekly_schedule.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_CONTROL_HVAC_WEEKLY_SCHEDULE_H_
5#define SRC_SUPLA_CONTROL_HVAC_WEEKLY_SCHEDULE_H_
6
7#include <stdint.h>
8#include <supla-common/proto.h>
9
10#include "hvac_weekly_schedule_policy.h"
11#include "weekly_schedule_component.h"
12#include "weekly_schedule_storage.h"
13
14namespace Supla {
15
16namespace Control {
17
20 public:
21 explicit HvacWeeklySchedule(HvacBase *owner);
23
24 bool canActivate() const override;
25 bool isConfigured() const;
26 void saveWeeklySchedule(bool requestResend = false);
27
28 bool isActive() const override;
29 bool switchToWeeklySchedule() override;
30 void switchToManualMode() override;
31 void restoreWeeklyScheduleMode(bool enabled) override;
32 bool isWeeklyScheduleValid(const TChannelConfig_WeeklySchedule *newSchedule,
33 bool isAltWeeklySchedule = false) const;
34 int getWeeklyScheduleProgramId(const TChannelConfig_WeeklySchedule *schedule,
35 int index) const;
36 int calculateIndex(enum DayOfWeek dayOfWeek, int hour, int quarter) const;
37 bool isProgramValid(const TWeeklyScheduleProgram &program,
38 bool isAltWeeklySchedule) const;
39 bool setProgram(int programId,
40 unsigned char mode,
41 _supla_int16_t tHeat,
42 _supla_int16_t tCool,
43 bool isAltWeeklySchedule = false);
44 bool setWeeklySchedule(int index,
45 int programId,
46 bool isAltWeeklySchedule = false);
47 bool setWeeklySchedule(enum DayOfWeek dayOfWeek,
48 int hour,
49 int quarter,
50 int programId,
51 bool isAltWeeklySchedule = false);
52 int getCurrentQuarter() const;
53 TWeeklyScheduleProgram getCurrentProgram() const;
54 int getCurrentProgramId() const;
55 TWeeklyScheduleProgram getProgramAt(int quarterIndex) const;
56 TWeeklyScheduleProgram getProgramById(int programId,
57 bool isAltWeeklySchedule = false) const;
58 bool turnOnWeeklySchedule();
59 bool processWeeklySchedule() override;
60 void initDefaultWeeklySchedule(bool requestResend = true);
61 void processCacheRelease();
62
63 private:
64 bool shouldUseAltSchedule() const;
65 bool resolveCurrentHvacProgram(TWeeklyScheduleProgram *program,
66 int *programId) const;
67 bool resolveCurrentHvacProgram(const WeeklyScheduleTimeSnapshot &time,
69 int *programId);
70 bool shouldUseAltWeeklySchedule() const override;
71 bool applyResolvedWeeklyScheduleProgram(
72 const TWeeklyScheduleProgram &program,
73 int programId,
74 bool programChanged) override;
75 void onWeeklyScheduleClockState(WeeklyScheduleClockState state) override;
76 void initDefaultWeeklyScheduleForType(bool isAltWeeklySchedule,
77 bool requestResend);
78 void unloadSchedulesIfPossible();
79 Supla::Element *getScheduleOwner() const override;
80 const char *getDeviceLabel() const override;
81 const char *getScheduleStorageTag(bool isAltWeeklySchedule) const override;
82 bool validateSchedule(
83 const TChannelConfig_WeeklySchedule *schedule,
84 bool isAltWeeklySchedule) const override;
85 void fillDefaultSchedule(TChannelConfig_WeeklySchedule *schedule,
86 bool isAltWeeklySchedule) override;
87 bool supportsAltSchedule() const override;
88 bool hasAltScheduleStorage() const override {
89 return true;
90 }
91 bool hasPersistentDefaultSchedule(bool alt) const override;
92 void onNativeScheduleLoaded() override;
93 void onNativeScheduleSaved(bool alt, bool notify) override;
94
95 HvacBase *owner_ = nullptr;
97};
98
99} // namespace Control
100} // namespace Supla
101
102#endif // SRC_SUPLA_CONTROL_HVAC_WEEKLY_SCHEDULE_H_
Definition hvac_base.h:33
Definition hvac_weekly_schedule_policy.h:13
Definition hvac_weekly_schedule.h:19
Definition weekly_schedule_storage.h:20
Definition weekly_schedule_component.h:55
Base class for all elements of SuplaDevice.
Definition element.h:30
Definition weekly_schedule_component.h:24
Definition proto.h:3276
Definition proto.h:3253