supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
clock
clock.h
1
/*
2
Copyright (C) AC SOFTWARE SP. Z O.O.
3
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
*/
16
17
#ifndef SRC_SUPLA_CLOCK_CLOCK_H_
18
#define SRC_SUPLA_CLOCK_CLOCK_H_
19
20
#include <supla-common/proto.h>
21
#include <supla/element.h>
22
#include <time.h>
23
#include <supla/control/hvac_base.h>
24
25
namespace
Supla {
26
27
const
char
AutomaticTimeSyncCfgTag[] =
"timesync_auto"
;
28
29
class
Clock :
public
Element {
30
public
:
31
static
bool
IsReady();
32
static
int
GetYear();
33
static
int
GetMonth();
34
static
int
GetDay();
35
static
int
GetDayOfWeek();
// 1 - Sunday, 2 - Monday
36
static
enum
DayOfWeek GetHvacDayOfWeek();
// 0 - Sunday, 1 - Monday as enum
37
static
int
GetHour();
38
static
int
GetQuarter();
// 0 - 0..14 min, 1 - 15..29 min, 2 - 30..44 min, 3
39
// - 45..59 min
40
static
int
GetMin();
41
static
int
GetSec();
42
static
time_t GetTimeStamp();
43
44
static
Clock* GetInstance();
45
46
Clock();
47
virtual
~Clock();
48
49
virtual
bool
isReady();
50
virtual
int
getYear();
51
virtual
int
getMonth();
52
virtual
int
getDay();
53
virtual
int
getDayOfWeek();
54
virtual
enum
DayOfWeek getHvacDayOfWeek();
55
virtual
int
getHour();
56
virtual
int
getQuarter();
57
virtual
int
getMin();
58
virtual
int
getSec();
59
virtual
time_t getTimeStamp();
60
61
void
onTimer
()
override
;
62
bool
iterateConnected
()
override
;
63
void
onLoadConfig
(
SuplaDeviceClass
*sdc)
override
;
64
void
onDeviceConfigChange
(uint64_t fieldBit)
override
;
65
66
virtual
void
parseLocaltimeFromServer(
TSDC_UserLocalTimeResult
*result);
67
68
void
setUseAutomaticTimeSyncRemoteConfig(
bool
value);
69
void
printCurrentTime(
const
char
*prefix =
nullptr
);
70
71
void
setAutomaticTimeSync(
bool
value) { automaticTimeSync = value; }
72
73
protected
:
74
void
setSystemTime(time_t newTime);
75
time_t localtime = {};
76
uint32_t lastServerUpdate = 0;
77
uint32_t lastMillis = 0;
78
bool
isClockReady =
false
;
79
bool
automaticTimeSync =
true
;
80
bool
useAutomaticTimeSyncRemoteConfig =
true
;
81
};
82
83
};
// namespace Supla
84
85
#endif
// SRC_SUPLA_CLOCK_CLOCK_H_
SuplaDeviceClass
Definition
SuplaDevice.h:163
Supla::Clock::iterateConnected
bool iterateConnected() override
Method called on each SuplaDevice iteration when device is connected and registered to Supla server o...
Definition
clock.cpp:233
Supla::Clock::onTimer
void onTimer() override
Method called on timer interupt.
Definition
clock.cpp:217
Supla::Clock::onLoadConfig
void onLoadConfig(SuplaDeviceClass *sdc) override
First method called on element in SuplaDevice.begin().
Definition
clock.cpp:250
Supla::Clock::onDeviceConfigChange
void onDeviceConfigChange(uint64_t fieldBit) override
Method called when device config is changed.
Definition
clock.cpp:270
TSDC_UserLocalTimeResult
Definition
proto.h:2636
Generated by
1.17.0