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 switchToWeeklySchedule() override;
29 void restoreWeeklyScheduleMode(bool enabled) override;
30 bool isWeeklyScheduleEnabled() const;
31 bool isManualActionAllowed(bool turnOn) const override;
32 void onManualAction() override;
33
34 private:
35 bool requiresReadyClock() const override { return true; }
36 void onWeeklyScheduleClockState(WeeklyScheduleClockState state) override;
37 bool applyProgramAt(const WeeklyScheduleTimeSnapshot &time,
38 const TWeeklyScheduleProgram &program,
39 int programId, bool programChanged) override;
40 void syncWeeklyScheduleMode(uint8_t programMode) override;
41 void scheduleWeeklyScheduleStateSave() override;
42 bool isWeeklyScheduleValid(
43 const TChannelConfig_WeeklySchedule *newSchedule) const;
44 bool isProgramValid(const TWeeklyScheduleProgram &program) const;
45 bool applyWeeklyScheduleMode(uint8_t mode, bool programChanged) override;
46 uint8_t getCurrentProgramMode() const;
47
48 Supla::Element *getScheduleOwner() const override;
49 const char *getDeviceLabel() const override;
50 const char *getScheduleStorageTag(bool alt) const override;
51 bool validateSchedule(const TChannelConfig_WeeklySchedule *schedule,
52 bool alt) const override;
53 void fillDefaultSchedule(TChannelConfig_WeeklySchedule *schedule,
54 bool alt) override;
55 void onNativeScheduleApplied(bool alt, bool local, bool changed) override;
56 void resetRuntimeOverride();
57 bool processProgramAt(const WeeklyScheduleTimeSnapshot &time,
58 const TWeeklyScheduleProgram &program,
59 int programId, bool programChanged, bool manualAction);
60
61 Relay *owner_ = nullptr;
62 int32_t occurrence_ = -1;
63 int32_t lastTimingQuarter_ = -1;
64 uint32_t phase_ = UINT32_MAX;
65 bool timed_ = false;
66 bool suppressed_ = false;
67 bool pendingManualAction_ = false;
68};
69
70} // namespace Control
71} // namespace Supla
72
73#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:3276
Definition proto.h:3253