EmlaLockSafe
LockState Class Reference

Singleton class managing the current lock state. The class also automatically saves the lock state to flash so we know what's going on after a reboot even if there is no wifi. More...

#include <LockState.h>

Public Types

enum class  Mode : enumBaseType { emlalock = 0 , manual = 1 }
 Current mode of the safe. More...
 
enum class  DisplayTimePassed : enumBaseType { no = 0 , yes = 1 }
 States for the selection how the passed time should be displayed. More...
 
enum class  DisplayTimeLeft : enumBaseType {
  no = 0 , yes = 1 , temperature = 2 , timeWithPenalty = 3 ,
  timeWithRandomPenalty = 4
}
 States for the selection how the time left should be displayed. More...
 
using enumBaseType = uint8_t
 Enum basetype used for saving to the flash. More...
 

Static Public Member Functions

static const ModegetMode ()
 Get the mode. More...
 
static void setMode (const Mode &mode)
 Set the mode. More...
 
static const DisplayTimePassedgetDisplayTimePassed ()
 Get how the time passed should be displayed. More...
 
static void setDisplayTimePassed (const DisplayTimePassed &displayTimePassed)
 Set how the time passed should be displayed. More...
 
static const DisplayTimeLeftgetDisplayTimeLeft ()
 Get how the time left should be displayed. More...
 
static void setDisplayTimeLeft (const DisplayTimeLeft &displayTimeLeft)
 Set how the time left should be displayed. More...
 
static const time_t & getStartDate ()
 Get the Start Date. More...
 
static void setStartDate (const time_t &startDate)
 Set the Start Date. More...
 
static const time_t & getEndDate ()
 Get the End Date. More...
 
static void setEndDate (const time_t &endDate)
 Set the End Date. More...
 
static const uint32_t & getNumberOfFailedSessions ()
 Get the number of failed sessions. More...
 
static void setNumberOfFailedSessions (const uint32_t &numberOfFailedSessions)
 Set the number of failed sessions. More...
 
static const String & getTemperatureString ()
 Get the temperature string. More...
 
static void setTemperatureString (const String &temperatureString)
 Set the temperature string. More...
 
static const time_t & getCachedEndDate ()
 Get the Cached End Date. More...
 
static void setCachedEndDate (const time_t &cachedEndDate)
 Set the Cached End Date. More...
 
static const time_t & getCleaningEndDate ()
 Get the End Date of the current cleaning opening (or 0) More...
 
static void setCleaningEndDate (const time_t &cleaningEndDate)
 Set the End Date of the current cleaning opening. More...
 
static const time_t & getLastUpdateTime ()
 Get the time of the last update over the emlalock api. More...
 
static void setLastUpdateTime (const time_t &lastUpdateTime)
 Set the time of the last update over the emlalock api. More...
 

Protected Member Functions

 LockState ()
 Constructs the lock state by trying to reading the state from flash. More...
 
void loadData ()
 Loads the current state of the object to the flash. More...
 
void saveData ()
 Saves the current state of the object to the flash. More...
 

Static Protected Member Functions

static LockStategetSingleton ()
 Get the singleton instance. More...
 

Protected Attributes

std::mutex mtx
 mutex used to synchronize the data access More...
 
Mode mode
 The mode. More...
 
DisplayTimePassed displayTimePassed
 how the passed time should be displayed More...
 
DisplayTimeLeft displayTimeLeft
 how the passed time should be displayed More...
 
time_t startDate
 start date of the current session More...
 
time_t endDate
 end date of the current session More...
 
String temperatureString
 temperature string More...
 
uint32_t numberOfFailedSessions
 The number of failed session. More...
 
time_t cachedEndDate
 chache for the end date of the session which is currently configured. This value won't be saved to the flash! More...
 
time_t cleaningEndDate
 end date of the current cleaning opening or 0 if not opened for cleaning. This value won't be saved to the flash! More...
 
time_t lastUpdateTime
 time of the last update More...
 

Detailed Description

Singleton class managing the current lock state. The class also automatically saves the lock state to flash so we know what's going on after a reboot even if there is no wifi.

Author
Hugo3132

For more details see secLockstate

Access to this class is thread-safe

Member Typedef Documentation

◆ enumBaseType

using LockState::enumBaseType = uint8_t

Enum basetype used for saving to the flash.

Member Enumeration Documentation

◆ DisplayTimeLeft

States for the selection how the time left should be displayed.

Enumerator
no 
yes 
temperature 
timeWithPenalty 
timeWithRandomPenalty 

◆ DisplayTimePassed

States for the selection how the passed time should be displayed.

Enumerator
no 
yes 

◆ Mode

enum class LockState::Mode : enumBaseType
strong

Current mode of the safe.

Enumerator
emlalock 
manual 

Constructor & Destructor Documentation

◆ LockState()

LockState::LockState ( )
inlineprotected

Constructs the lock state by trying to reading the state from flash.

Member Function Documentation

◆ getCachedEndDate()

static const time_t & LockState::getCachedEndDate ( )
inlinestatic

Get the Cached End Date.

◆ getCleaningEndDate()

static const time_t & LockState::getCleaningEndDate ( )
inlinestatic

Get the End Date of the current cleaning opening (or 0)

◆ getDisplayTimeLeft()

static const DisplayTimeLeft & LockState::getDisplayTimeLeft ( )
inlinestatic

Get how the time left should be displayed.

◆ getDisplayTimePassed()

static const DisplayTimePassed & LockState::getDisplayTimePassed ( )
inlinestatic

Get how the time passed should be displayed.

◆ getEndDate()

static const time_t & LockState::getEndDate ( )
inlinestatic

Get the End Date.

◆ getLastUpdateTime()

static const time_t & LockState::getLastUpdateTime ( )
inlinestatic

Get the time of the last update over the emlalock api.

◆ getMode()

static const Mode & LockState::getMode ( )
inlinestatic

Get the mode.

◆ getNumberOfFailedSessions()

static const uint32_t & LockState::getNumberOfFailedSessions ( )
inlinestatic

Get the number of failed sessions.

◆ getSingleton()

static LockState & LockState::getSingleton ( )
inlinestaticprotected

Get the singleton instance.

◆ getStartDate()

static const time_t & LockState::getStartDate ( )
inlinestatic

Get the Start Date.

◆ getTemperatureString()

static const String & LockState::getTemperatureString ( )
inlinestatic

Get the temperature string.

◆ loadData()

void LockState::loadData ( )
inlineprotected

Loads the current state of the object to the flash.

◆ saveData()

void LockState::saveData ( )
inlineprotected

Saves the current state of the object to the flash.

◆ setCachedEndDate()

static void LockState::setCachedEndDate ( const time_t &  cachedEndDate)
inlinestatic

Set the Cached End Date.

◆ setCleaningEndDate()

static void LockState::setCleaningEndDate ( const time_t &  cleaningEndDate)
inlinestatic

Set the End Date of the current cleaning opening.

◆ setDisplayTimeLeft()

static void LockState::setDisplayTimeLeft ( const DisplayTimeLeft displayTimeLeft)
inlinestatic

Set how the time left should be displayed.

◆ setDisplayTimePassed()

static void LockState::setDisplayTimePassed ( const DisplayTimePassed displayTimePassed)
inlinestatic

Set how the time passed should be displayed.

◆ setEndDate()

static void LockState::setEndDate ( const time_t &  endDate)
inlinestatic

Set the End Date.

◆ setLastUpdateTime()

static void LockState::setLastUpdateTime ( const time_t &  lastUpdateTime)
inlinestatic

Set the time of the last update over the emlalock api.

◆ setMode()

static void LockState::setMode ( const Mode mode)
inlinestatic

Set the mode.

◆ setNumberOfFailedSessions()

static void LockState::setNumberOfFailedSessions ( const uint32_t &  numberOfFailedSessions)
inlinestatic

Set the number of failed sessions.

◆ setStartDate()

static void LockState::setStartDate ( const time_t &  startDate)
inlinestatic

Set the Start Date.

◆ setTemperatureString()

static void LockState::setTemperatureString ( const String &  temperatureString)
inlinestatic

Set the temperature string.

Member Data Documentation

◆ cachedEndDate

time_t LockState::cachedEndDate
protected

chache for the end date of the session which is currently configured. This value won't be saved to the flash!

◆ cleaningEndDate

time_t LockState::cleaningEndDate
protected

end date of the current cleaning opening or 0 if not opened for cleaning. This value won't be saved to the flash!

◆ displayTimeLeft

DisplayTimeLeft LockState::displayTimeLeft
protected

how the passed time should be displayed

◆ displayTimePassed

DisplayTimePassed LockState::displayTimePassed
protected

how the passed time should be displayed

◆ endDate

time_t LockState::endDate
protected

end date of the current session

◆ lastUpdateTime

time_t LockState::lastUpdateTime
protected

time of the last update

◆ mode

Mode LockState::mode
protected

The mode.

◆ mtx

std::mutex LockState::mtx
protected

mutex used to synchronize the data access

◆ numberOfFailedSessions

uint32_t LockState::numberOfFailedSessions
protected

The number of failed session.

◆ startDate

time_t LockState::startDate
protected

start date of the current session

◆ temperatureString

String LockState::temperatureString
protected

temperature string


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