supla-device
Loading...
Searching...
No Matches
Supla::Clock Class Reference
Inheritance diagram for Supla::Clock:
Collaboration diagram for Supla::Clock:

Public Member Functions

virtual bool isReady ()
 
virtual int getYear ()
 
virtual int getMonth ()
 
virtual int getDay ()
 
virtual int getDayOfWeek ()
 
virtual enum DayOfWeek getHvacDayOfWeek ()
 
virtual int getHour ()
 
virtual int getQuarter ()
 
virtual int getMin ()
 
virtual int getSec ()
 
virtual time_t getTimeStamp ()
 
virtual bool getLocalTime (struct tm *timeInfo)
 
void onTimer () override
 Method called on timer interupt.
 
bool iterateConnected () override
 Method called on each SuplaDevice iteration when device is connected and registered to Supla server or other protocol.
 
void onLoadConfig (SuplaDeviceClass *sdc) override
 First method called on element in SuplaDevice.begin().
 
void onDeviceConfigChange (uint64_t fieldBit) override
 Method called when device config is changed.
 
virtual void parseLocaltimeFromServer (TSDC_UserLocalTimeResult *result)
 
void setUseAutomaticTimeSyncRemoteConfig (bool value)
 
void printCurrentTime (const char *prefix=nullptr)
 
void setAutomaticTimeSync (bool value)
 
- Public Member Functions inherited from Supla::Element
 Element (ElementMode mode=ElementMode::Registered)
 
virtual Control::ActionTrigger * getActionTrigger ()
 
Element * next ()
 Returns next Element from the list.
 
virtual void purgeConfig ()
 Removes all configration data related to the element from Storage::Config.
 
virtual void onLoadState ()
 Second method called on element in SuplaDevice.begin().
 
virtual void onInit ()
 Third method called on element in SuplaDevice.begin()
 
virtual void onSaveState ()
 Method called periodically during SuplaDevice iteration.
 
virtual bool isStateStorageMigrationNeeded () const
 Method called after onInit() to check if state storage migration is needed.
 
virtual void onRegistered (Supla::Protocol::SuplaSrpc *suplaSrpc=nullptr)
 Method called each time when device successfully registers to Supla server.
 
virtual void iterateAlways ()
 Method called on each SuplaDevice iteration.
 
virtual bool iterateConnected (void *ptr)
 deprecated
 
virtual void onFastTimer ()
 Method called on fast timer interupt.
 
virtual void onSoftReset ()
 Method called when device soft restart is triggered.
 
virtual int32_t handleNewValueFromServer (TSD_SuplaChannelNewValue *newValue)
 Handles "new value" request from server.
 
virtual void fillSuplaChannelNewValue (TSD_SuplaChannelNewValue *value)
 Fills TSD_SuplaChannelNewValue based on current state.
 
virtual bool getRemainingCountdownTimerSec (uint32_t *remainingSec) const
 Returns active countdown timer remaining time in seconds.
 
virtual void handleGetChannelState (TDSC_ChannelState *channelState)
 Handles "get channel state (i)" request from server.
 
virtual int handleCalcfgFromServer (TSD_DeviceCalCfgRequest *request)
 Handles CALCFG requests from server.
 
virtual uint32_t getCalcfgPendingTimeoutMs (TSD_DeviceCalCfgRequest *request) const
 Returns timeout in milliseconds for CALCFG requests that become pending.
 
virtual uint8_t handleChannelConfig (TSD_ChannelConfig *newChannelConfig, bool local=false)
 Handles "set channel config" request from server.
 
virtual uint8_t handleWeeklySchedule (TSD_ChannelConfig *newWeeklySchedule, bool altSchedule=false, bool local=false)
 Handles "set channel config" with "weekly schedule" type request from server.
 
virtual void handleSetChannelConfigResult (TSDS_SetChannelConfigResult *result)
 Handles "set channel config" reply from server.
 
virtual void handleChannelConfigFinished ()
 Handles "channel config finished" message from server.
 
virtual void handleChannelConfigFinished (int channelNumber)
 Handles "channel config finished" for a specific channel.
 
int getChannelNumber () const
 Returns channel number.
 
int getSecondaryChannelNumber () const
 Returns secondary channel number.
 
virtual bool isOwnerOfSubDeviceId (int subDeviceId) const
 Returns true if element is owner of subDeviceId.
 
virtual const Channel * getChannel () const
 Returns pointer to main channel.
 
virtual Channel * getChannel ()
 
virtual const Channel * getSecondaryChannel () const
 Returns pointer to secondary channel.
 
virtual Channel * getSecondaryChannel ()
 
const Channel * getChannelByChannelNumber (int channelNumber) const
 Returns pointer to the channel matching channelNumber.
 
Channel * getChannelByChannelNumber (int channelNumber)
 
virtual void generateKey (char *output, const char *key) const
 Generates key used for Config.
 
Element & disableChannelState ()
 Disables channel state (i) function.
 
bool isChannelStateEnabled () const
 Returns true if channel state (i) function is enabled.
 
virtual bool isAnyUpdatePending () const
 Returns true if any update is pending.
 
void setInitialCaption (const char *caption, bool secondaryChannel=false)
 Sets initial caption.
 
bool setDefaultFunction (uint32_t defaultFunction)
 Sets default channel's function.
 
bool setFunction (uint32_t newFunction)
 Sets channel's function.
 
virtual bool setRuntimeFunction (uint32_t newFunction)
 Sets channel's function at runtime.
 
virtual void onFunctionChange (uint32_t currentFunction, uint32_t newFunction)
 Called when channel function changes.
 

Static Public Member Functions

static bool IsReady ()
 Checks if Clock is set and ready.
 
static int GetYear ()
 Returns year from Clock (if is set and ready).
 
static int GetMonth ()
 Returns month from Clock (if is set and ready).
 
static int GetDay ()
 Returns day from Clock (if is set and ready).
 
static int GetDayOfWeek ()
 Returns day of week from Clock (if is set and ready).
 
static enum DayOfWeek GetHvacDayOfWeek ()
 Returns day of week from Clock to HVAC (if is set and ready).
 
static int GetHour ()
 Returns hour from Clock (if is set and ready).
 
static int GetQuarter ()
 Returns quarter from Clock (if is set and ready).
 
static int GetMin ()
 Returns minutes from Clock (if is set and ready).
 
static int GetSec ()
 Returns seconds from Clock (if is set and ready).
 
static time_t GetTimeStamp ()
 
static bool GetLocalTime (struct tm *timeInfo)
 
static Clock * GetInstance ()
 Returns pointer of Clock.
 
- Static Public Member Functions inherited from Supla::Element
static Element * begin ()
 Returns first Element (based on creation order)
 
static Element * last ()
 Returns last Element (based on creation order)
 
static Element * getElementByChannelNumber (int channelNumber)
 Returns Element by channel number.
 
static Element * getOwnerOfSubDeviceId (int subDeviceId)
 Returns Element which owns given subDeviceId.
 
static bool IsAnyUpdatePending ()
 Checks if any element has pending update for remote server.
 
static void NotifyElementsAboutConfigChange (uint64_t fieldBit)
 Notifies all elements about device config change.
 
static bool IsInvalidPtrSet ()
 When "invalid pointer" is set, previously obtained Element pointer may be invalid.
 
static void ClearInvalidPtr ()
 Clears "invalid pointer" flag.
 

Protected Member Functions

void setSystemTime (time_t newTime)
 

Protected Attributes

time_t localtime = {}
 
uint32_t lastServerUpdate = 0
 
uint32_t lastMillis = 0
 
bool isClockReady = false
 
bool automaticTimeSync = true
 
bool useAutomaticTimeSyncRemoteConfig = true
 
- Protected Attributes inherited from Supla::Element
bool registeredElement = true
 
Element * nextPtr = nullptr
 

Additional Inherited Members

- Static Protected Attributes inherited from Supla::Element
static Element * firstPtr = nullptr
 
static bool invalidatePtr = false
 

Member Function Documentation

◆ GetDay()

int Supla::Clock::GetDay ( )
static

Returns day from Clock (if is set and ready).

Returns
the day (1..31)

◆ GetDayOfWeek()

int Supla::Clock::GetDayOfWeek ( )
static

Returns day of week from Clock (if is set and ready).

Example: 1 - Sunday, 7 - Saturday

Returns
the day of week (1..7)

◆ GetHour()

int Supla::Clock::GetHour ( )
static

Returns hour from Clock (if is set and ready).

Returns
the hour (0..23)

◆ GetHvacDayOfWeek()

enum DayOfWeek Supla::Clock::GetHvacDayOfWeek ( )
static

Returns day of week from Clock to HVAC (if is set and ready).

Example: 0 - Sunday, 6 - Saturday

Returns
the day of week as enum (0..6)

◆ GetInstance()

Clock * Supla::Clock::GetInstance ( )
static

Returns pointer of Clock.

Returns
pointer of Clock

◆ GetMin()

int Supla::Clock::GetMin ( )
static

Returns minutes from Clock (if is set and ready).

Returns
the minutes (0..59)

◆ GetMonth()

int Supla::Clock::GetMonth ( )
static

Returns month from Clock (if is set and ready).

Returns
the month (1..12)

◆ GetQuarter()

int Supla::Clock::GetQuarter ( )
static

Returns quarter from Clock (if is set and ready).

Example: 0 - (0..14 min), 1 - (15..29 min), 2 - (30..44 min), 3 - (45..59 min)

Returns
the quarter (0..3)

◆ GetSec()

int Supla::Clock::GetSec ( )
static

Returns seconds from Clock (if is set and ready).

Returns
the seconds (0..59)

◆ GetYear()

int Supla::Clock::GetYear ( )
static

Returns year from Clock (if is set and ready).

Returns
the year (1900..)

◆ IsReady()

bool Supla::Clock::IsReady ( )
static

Checks if Clock is set and ready.

Returns
true if Clock is set and ready

◆ iterateConnected()

bool Supla::Clock::iterateConnected ( )
overridevirtual

Method called on each SuplaDevice iteration when device is connected and registered to Supla server or other protocol.

Returns
true when element didn't communicate with server and next element should be iterated instead. false otherwise.

Reimplemented from Supla::Element.

◆ onDeviceConfigChange()

void Supla::Clock::onDeviceConfigChange ( uint64_t fieldBit)
overridevirtual

Method called when device config is changed.

Parameters
fieldBitbit mask of changed field

Reimplemented from Supla::Element.

◆ onLoadConfig()

void Supla::Clock::onLoadConfig ( SuplaDeviceClass * sdc)
overridevirtual

First method called on element in SuplaDevice.begin().

Called only if Config Storage class is configured. Element should read its configration in this method.

Parameters
sdc

Reimplemented from Supla::Element.

◆ onTimer()

void Supla::Clock::onTimer ( )
overridevirtual

Method called on timer interupt.

It should provide all actions that have to be executed periodically regardless of other SuplaDevice activities. It is usually called every 10 ms.

Reimplemented from Supla::Element.


The documentation for this class was generated from the following files: