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

  duration | Expiry time of the timer, max 24 hours.
  variation | Random 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

  duration | Expiry time of the timer, max 24 hours.
  numExecutions | Number of executions, 1 or higher, or infiniteExecutions to always repeat.
  variation | Random 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: PT `hh:mm:ss`
  one-off timer with variation: PT `hh:mm:ss` A `hh:mm:ss`, with expiry time first and variation second.
  recurring timer: R/PT `hh:mm:ss`
  recurring timer with n repetitions: R `nn`/PT `hh:mm:ss`
  recurring timer with random variation: R `nn`/PT `hh:mm:ss` A `hh:mm:ss`
  infinite recurring timer with random variation: R/PT `hh:mm:ss` A `hh:mm:ss`

## Member Data Documentation

## infiniteExecutions

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

static constexpr

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

- include/hueplusplus/TimePattern.h
- src/TimePattern.cpp