hueplusplus 1.2.0+ds-2build1
Loading...
Searching...
No Matches
hueplusplus::time::Timer Class Reference

Timer that is started and triggers after specified delay. More...

#include <hueplusplus/TimePattern.h>

Public Member Functions

 Timer (clock::duration duration, clock::duration variation=std::chrono::seconds(0))
 Create one-off timer.
 Timer (clock::duration duration, int numExecutions, clock::duration variation=std::chrono::seconds(0))
 Create a repeated timer.
bool isRecurring () const
 Returns true when the timer is executed more than once.
int getNumberOfExecutions () const
 Get number of executions.
clock::duration getExpiryTime () const
 Get expiry time.
clock::duration getRandomVariation () const
 Get random variation of expiry time.
std::string toString () const
 Get formatted string as expected by Hue API.

Static Public Attributes

static constexpr int infiniteExecutions = 0

Detailed Description

Timer that is started and triggers after specified delay.

The timer can have a random variation in the expiry time. It can be one-off, repeated a set number of times or repeated indefinitely.

Constructor & Destructor Documentation

◆ Timer() [1/2]

hueplusplus::time::Timer::Timer ( clock::duration duration,
clock::duration variation = std::chrono::seconds(0) )

Create one-off timer.

Parameters
durationExpiry time of the timer, max 24 hours.
variationRandom variation of expiry time, optional.

◆ Timer() [2/2]

hueplusplus::time::Timer::Timer ( clock::duration duration,
int numExecutions,
clock::duration variation = std::chrono::seconds(0) )

Create a repeated timer.

Parameters
durationExpiry time of the timer, max 24 hours.
numExecutionsNumber of executions, 1 or higher, or infiniteExecutions to always repeat.
variationRandom variation of expiry time, optional.

Member Function Documentation

◆ getExpiryTime()

system_clock::duration hueplusplus::time::Timer::getExpiryTime ( ) const

Get expiry time.

◆ getNumberOfExecutions()

int hueplusplus::time::Timer::getNumberOfExecutions ( ) const

Get number of executions.

Returns
Number of executions, or infiniteExecutions

◆ getRandomVariation()

system_clock::duration hueplusplus::time::Timer::getRandomVariation ( ) const

Get random variation of expiry time.

The expiry time can vary up to this value in both directions.

◆ isRecurring()

bool hueplusplus::time::Timer::isRecurring ( ) const

Returns true when the timer is executed more than once.

◆ toString()

std::string hueplusplus::time::Timer::toString ( ) const

Get formatted string as expected by Hue API.

Returns
one-off timer: PThh:mm:ss
one-off timer with variation: PThh:mm:ssAhh:mm:ss, with expiry time first and variation second.
recurring timer: R/PThh:mm:ss
recurring timer with n repetitions: Rnn/PThh:mm:ss
recurring timer with random variation: Rnn/PThh:mm:ssAhh:mm:ss
infinite recurring timer with random variation: R/PThh:mm:ssAhh:mm:ss

Member Data Documentation

◆ infiniteExecutions

int hueplusplus::time::Timer::infiniteExecutions = 0
staticconstexpr

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