AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Public Member Functions | List of all members
alexaClientSDK::acsdkAlerts::AlertScheduler Class Reference

#include <AlertScheduler.h>

Inheritance diagram for alexaClientSDK::acsdkAlerts::AlertScheduler:
Inheritance graph
Collaboration diagram for alexaClientSDK::acsdkAlerts::AlertScheduler:
Collaboration graph


struct  AlertsContextInfo

Public Member Functions

 AlertScheduler (std::shared_ptr< storage::AlertStorageInterface > alertStorage, std::shared_ptr< renderer::RendererInterface > alertRenderer, std::chrono::seconds alertPastDueTimeLimitSeconds, std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder=nullptr)
bool initialize (const std::shared_ptr< acsdkAlertsInterfaces::AlertObserverInterface > &observer, const std::shared_ptr< settings::DeviceSettingsManager > &settingsManager, bool startAlertSchedulingOnInitialization=true)
bool scheduleAlert (std::shared_ptr< Alert > alert)
bool saveOfflineStoppedAlert (const std::string &alertToken, const std::string &scheduledTime, const std::string &eventTime)
bool getOfflineStoppedAlerts (rapidjson::Value *alertContainer, rapidjson::Document::AllocatorType &allocator)
bool reloadAlertsFromDatabase (std::shared_ptr< settings::DeviceSettingsManager > settingsManager, bool shouldScheduleAlerts)
bool snoozeAlert (const std::string &alertToken, const std::string &updatedTime_ISO_8601)
bool deleteAlert (const std::string &alertToken)
bool deleteAlerts (const std::list< std::string > &tokenList)
void deleteOfflineStoppedAlert (const std::string &token, int id)
bool isAlertActive (std::shared_ptr< Alert > alert)
std::shared_ptr< AlertgetActiveAlert ()
void updateFocus (avsCommon::avs::FocusState focusState, avsCommon::avs::MixingBehavior behavior)
avsCommon::avs::FocusState getFocusState ()
AlertScheduler::AlertsContextInfo getContextInfo ()
void onLocalStop ()
void clearData (Alert::StopReason reason=Alert::StopReason::SHUTDOWN)
void shutdown ()
std::list< std::shared_ptr< Alert > > getAllAlerts ()
AlertObserverInterface function.
void onAlertStateChange (const AlertInfo &alertInfo) override
- Public Member Functions inherited from alexaClientSDK::acsdkAlertsInterfaces::AlertObserverInterface
virtual ~AlertObserverInterface ()=default

Additional Inherited Members

- Public Types inherited from alexaClientSDK::acsdkAlertsInterfaces::AlertObserverInterface
enum  State {
  State::READY, State::STARTED, State::STOPPED, State::SNOOZED,
enum  Type { Type::ALARM, Type::TIMER, Type::REMINDER }
- Static Public Member Functions inherited from alexaClientSDK::acsdkAlertsInterfaces::AlertObserverInterface
template<class T >
static bool withinBounds (T value, T minVal, T maxVal)
static std::string stateToString (State state)
static std::string typeToString (Type type)
static std::string originalTimeToString (const OriginalTime &originalTime)
- Static Public Attributes inherited from alexaClientSDK::acsdkAlertsInterfaces::AlertObserverInterface
static const int ORIGINAL_TIME_FIELD_MIN = 0
 The minimum value for the field in OriginalTime. More...
static const int ORIGINAL_TIME_HOUR_MAX = 23
 The maximum value for the hour field in OriginalTime. More...
static const int ORIGINAL_TIME_MINUTE_MAX = 59
 The maximum value for the minute field in OriginalTime. More...
static const int ORIGINAL_TIME_SECOND_MAX = 59
 The maximum value for the second field in OriginalTime. More...
static const int ORIGINAL_TIME_MILLISECOND_MAX = 999
 The maximum value for the millisecond field in OriginalTime. More...

Detailed Description

This class handles the management of AVS alerts. This is essentially a time-ordered queue, where a timer is set for the alert which must activate soonest. As alerts are added or removed, this timer must be reset.

Constructor & Destructor Documentation

◆ AlertScheduler()

alexaClientSDK::acsdkAlerts::AlertScheduler::AlertScheduler ( std::shared_ptr< storage::AlertStorageInterface alertStorage,
std::shared_ptr< renderer::RendererInterface alertRenderer,
std::chrono::seconds  alertPastDueTimeLimitSeconds,
std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface metricRecorder = nullptr 


alertStorageThe storage object where alerts can be saved, modified and deleted.
alertRendererThe object which will handle user-perceivable effects upon alert activation.
alertPastDueTimeLimitSecondsThe threshold in seconds, beyond which alerts will be considered past-due and discarded.
metricRecorderThe metric recorder.

Member Function Documentation

◆ clearData()

void alexaClientSDK::acsdkAlerts::AlertScheduler::clearData ( Alert::StopReason  reason = Alert::StopReason::SHUTDOWN)

Clear all data being managed. This includes database storage.

reasonWhat triggered the data to be cleared.

◆ deleteAlert()

bool alexaClientSDK::acsdkAlerts::AlertScheduler::deleteAlert ( const std::string &  alertToken)

Delete an alert from the schedule.

alertTokenThe AVS token identifying the alert.
Whether we successfully deleted the alert.

◆ deleteAlerts()

bool alexaClientSDK::acsdkAlerts::AlertScheduler::deleteAlerts ( const std::list< std::string > &  tokenList)

Delete multiple alerts from the schedule by their tokens. All existing alerts are deleted with all-or-none rule. In case of failure no actual deletion is made. Missing alert is not treated as an error.

tokenListList of tokens of the alerts to be deleted
true if all alerts has been deleted, false if any of the deletion failed.

◆ deleteOfflineStoppedAlert()

void alexaClientSDK::acsdkAlerts::AlertScheduler::deleteOfflineStoppedAlert ( const std::string &  token,
int  id 

Delete an offline stopped alert from list of offline stopped alerts

tokenThe alertToken of the alert to be deleted
idThe alert Id of the alert to be deleted

◆ getActiveAlert()

std::shared_ptr<Alert> alexaClientSDK::acsdkAlerts::AlertScheduler::getActiveAlert ( )

Gets the current active alert.

the current active alert, else nullptr.

◆ getAllAlerts()

std::list<std::shared_ptr<Alert> > alexaClientSDK::acsdkAlerts::AlertScheduler::getAllAlerts ( )

Utility method to get list of all alerts being tracked by AlertScheduler

list of all alerts being tracked by AlertScheduler

◆ getContextInfo()

AlertScheduler::AlertsContextInfo alexaClientSDK::acsdkAlerts::AlertScheduler::getContextInfo ( )

Collects Context data for all alerts being managed.

An AlertsContextInfo structure, containing all data needed.

◆ getFocusState()

avsCommon::avs::FocusState alexaClientSDK::acsdkAlerts::AlertScheduler::getFocusState ( )

Provide our current channel focus state.

Our current channel focus state.

◆ getOfflineStoppedAlerts()

bool alexaClientSDK::acsdkAlerts::AlertScheduler::getOfflineStoppedAlerts ( rapidjson::Value *  alertContainer,
rapidjson::Document::AllocatorType &  allocator 

Get list of offline stopped alerts

alertContainerrapidJson array to load alerts into
allocatorThe rapidjson allocator, required for the results of this function to be mergable with other rapidjson::Value objects.

◆ initialize()

bool alexaClientSDK::acsdkAlerts::AlertScheduler::initialize ( const std::shared_ptr< acsdkAlertsInterfaces::AlertObserverInterface > &  observer,
const std::shared_ptr< settings::DeviceSettingsManager > &  settingsManager,
bool  startAlertSchedulingOnInitialization = true 


This function must be called before other use of an object this class.
observerAn observer which we will notify of all alert state changes.
m_settingsManagerA settingsManager object that manages alarm volume ramp setting.
startAlertSchedulingOnInitializationWhether to start scheduling alerts after client initialization. If this is set to false, no alert scheduling will occur until onSystemClockSynchronized is called.
Whether initialization was successful.

◆ isAlertActive()

bool alexaClientSDK::acsdkAlerts::AlertScheduler::isAlertActive ( std::shared_ptr< Alert alert)

Utility function to determine if an alert is currently active.

alertThe alert being queried.
Whether the alert is active.

◆ onAlertStateChange()

void alexaClientSDK::acsdkAlerts::AlertScheduler::onAlertStateChange ( const AlertInfo alertInfo)

A callback function to notify an object that an alert has updated its state.

alertInfoThe information of the updated alert.

Implements alexaClientSDK::acsdkAlertsInterfaces::AlertObserverInterface.

◆ onLocalStop()

void alexaClientSDK::acsdkAlerts::AlertScheduler::onLocalStop ( )

Handle a local stop.

◆ reloadAlertsFromDatabase()

bool alexaClientSDK::acsdkAlerts::AlertScheduler::reloadAlertsFromDatabase ( std::shared_ptr< settings::DeviceSettingsManager settingsManager,
bool  shouldScheduleAlerts 

Reload alerts from database, then update expired alerts and set a timer for the next alert if desired. If there is an active alert, it will not interrupted or modified in any way.

settingsManagerA settingsManager object used to load alerts.
shouldScheduleAlertsWhether to start scheduling alerts.
Whether the alerts were reloaded from database successfully.

◆ saveOfflineStoppedAlert()

bool alexaClientSDK::acsdkAlerts::AlertScheduler::saveOfflineStoppedAlert ( const std::string &  alertToken,
const std::string &  scheduledTime,
const std::string &  eventTime 

Save the currently active alert as an offline stopped alert

alertTokenthe alert token of the offline stopped alert
scheduledTimethe scheduled time of the offline stopped alert
eventTimethe time the alert stopped
Whether the offline alert was successfully saved.

◆ scheduleAlert()

bool alexaClientSDK::acsdkAlerts::AlertScheduler::scheduleAlert ( std::shared_ptr< Alert alert)

Schedule an alert for rendering.

alertThe alert to be scheduled.
Whether the alert was successfully scheduled.

◆ shutdown()

void alexaClientSDK::acsdkAlerts::AlertScheduler::shutdown ( )

Handle shutdown.

◆ snoozeAlert()

bool alexaClientSDK::acsdkAlerts::AlertScheduler::snoozeAlert ( const std::string &  alertToken,
const std::string &  updatedTime_ISO_8601 

Snooze an active alert to re-activate at a new specified time. The alert, if active, will be de-activated and re-scheduled for the new time.

alertTokenThe AVS token identifying the alert.
updatedTime_ISO_8601The new time in ISO-8601 format.
Whether we successfully snoozed the alert.

◆ updateFocus()

void alexaClientSDK::acsdkAlerts::AlertScheduler::updateFocus ( avsCommon::avs::FocusState  focusState,
avsCommon::avs::MixingBehavior  behavior 

Update our state of channel focus.

focusStateThe state we now have.
behaviorThe mixing behavior.

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

AlexaClientSDK 3.0.0 - Copyright 2016-2022, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0