supla-device
Loading...
Searching...
No Matches
relay_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_RELAY_WEEKLY_SCHEDULE_H_
5#define SRC_SUPLA_CONTROL_RELAY_WEEKLY_SCHEDULE_H_
6
7#include <stdint.h>
8#include <supla-common/proto.h>
9
10#include "../element_with_channel_actions.h"
11#include "weekly_schedule_component.h"
12#include "weekly_schedule_storage.h"
13
14namespace Supla {
15namespace Control {
16
17class Relay;
18
20 public:
21 explicit RelayWeeklySchedule(Relay *owner);
23
24 bool isConfigured() const;
25 bool iterateAlways();
26
27 bool canActivate() const override;
28 bool onFunctionChanged() override;
29 bool switchToWeeklySchedule() override;
30 void restoreWeeklyScheduleMode(bool enabled) override;
31 bool isWeeklyScheduleEnabled() const;
32 bool isManualActionAllowed(bool turnOn) const override;
33 void onManualAction() override;
34
35 private:
36 bool requiresReadyClock() const override { return true; }
37 void onWeeklyScheduleClockState(WeeklyScheduleClockState state) override;
38 bool applyProgramAt(const WeeklyScheduleTimeSnapshot &time,
39 const TWeeklyScheduleProgram &program,
40 int programId, bool programChanged) override;
41 void syncWeeklyScheduleMode(uint8_t programMode) override;
42 void scheduleWeeklyScheduleStateSave() override;
43 bool isWeeklyScheduleValid(
44 const TChannelConfig_WeeklySchedule *newSchedule) const;
45 bool isProgramValid(const TWeeklyScheduleProgram &program) const;
46 bool applyWeeklyScheduleMode(uint8_t mode, bool programChanged) override;
47 uint8_t getCurrentProgramMode() const;
48
49 Supla::Element *getScheduleOwner() const override;
50 const char *getDeviceLabel() const override;
51 const char *getScheduleStorageTag(bool alt) const override;
52 bool validateSchedule(const TChannelConfig_WeeklySchedule *schedule,
53 bool alt) const override;
54 void fillDefaultSchedule(TChannelConfig_WeeklySchedule *schedule,
55 bool alt) override;
56 void onNativeScheduleApplied(bool alt, bool local, bool changed) override;
57 void onNativeScheduleLoaded() override;
58 void resetRuntimeOverride();
59 bool processProgramAt(const WeeklyScheduleTimeSnapshot &time,
60 const TWeeklyScheduleProgram &program,
61 int programId, bool programChanged, bool manualAction);
62
63 Relay *owner_ = nullptr;
64 // Only the last effective definition is cached, not the schedule or its ID.
65 TWeeklyScheduleProgram currentProgram_ = {0xFF, {0}, {0}};
66 int32_t occurrence_ = -1;
67 int32_t lastTimingQuarter_ = -1;
68 uint32_t phase_ = UINT32_MAX;
69 bool timed_ = false;
70 bool suppressed_ = false;
71 bool pendingManualAction_ = false;
72};
73
74} // namespace Control
75} // namespace Supla
76
77#endif // SRC_SUPLA_CONTROL_RELAY_WEEKLY_SCHEDULE_H_
Definition weekly_schedule_storage.h:131
Definition relay_weekly_schedule.h:19
Definition relay.h:45
Base class for all elements of SuplaDevice.
Definition element.h:30
Definition weekly_schedule_component.h:24
Definition proto.h:3336
Definition proto.h:3311