AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <PowerResourceManagerInterface.h>
Classes | |
class | PowerResourceId |
Public Types | |
enum | PowerResourceLevel { PowerResourceLevel::STANDBY_LOW = 0, PowerResourceLevel::STANDBY_MED, PowerResourceLevel::STANDBY_HIGH, PowerResourceLevel::ACTIVE_LOW, PowerResourceLevel::ACTIVE_MED, PowerResourceLevel::ACTIVE_HIGH } |
enum | PowerResourceTypeIndex { TYPE_CPU = 0, TYPE_DDR, TYPE_STORAGE, TYPE_NETWORK, TYPE_RESERVED_ONE, TYPE_RESERVED_TWO, NUM_OF_TYPES } |
enum | PowerResourceTypeFlag { TYPE_ALL_FLAG = 0, TYPE_CPU_FLAG = 1 << PowerResourceTypeIndex::TYPE_CPU, TYPE_DDR_FLAG = 1 << PowerResourceTypeIndex::TYPE_DDR, TYPE_STORAGE_FLAG = 1 << PowerResourceTypeIndex::TYPE_STORAGE, TYPE_NETWORK_FLAG = 1 << PowerResourceTypeIndex::TYPE_NETWORK, TYPE_RESERVED_ONE_FLAG = 1 << PowerResourceTypeIndex::TYPE_RESERVED_ONE, TYPE_RESERVED_TWO_FLAG = 1 << PowerResourceTypeIndex::TYPE_RESERVED_TWO } |
using | PartialStateBitSet = std::bitset< PowerResourceTypeIndex::NUM_OF_TYPES > |
Public Member Functions | |
virtual | ~PowerResourceManagerInterface ()=default |
virtual void | acquirePowerResource (const std::string &component, const PowerResourceLevel level=PowerResourceLevel::STANDBY_MED)=0 |
virtual void | releasePowerResource (const std::string &component)=0 |
virtual bool | isPowerResourceAcquired (const std::string &component)=0 |
virtual std::chrono::milliseconds | getTimeSinceLastResumeMS () |
virtual std::chrono::milliseconds | getTimeSinceLastPartialMS (const std::string &component, PartialStateBitSet &resourceFlags, PartialStateBitSet partialState=PowerResourceTypeFlag::TYPE_ALL_FLAG) |
virtual std::shared_ptr< PowerResourceId > | create (const std::string &resourceId, bool isRefCounted=true, const PowerResourceLevel level=PowerResourceLevel::STANDBY_MED)=0 |
virtual bool | acquire (const std::shared_ptr< PowerResourceId > &id, const std::chrono::milliseconds autoReleaseTimeout=std::chrono::milliseconds::zero())=0 |
virtual bool | release (const std::shared_ptr< PowerResourceId > &id)=0 |
virtual bool | close (const std::shared_ptr< PowerResourceId > &id)=0 |
This interface provides APIs for components of AVS-SDK to manage power resources. These components, such as AudioInputProcessor and SpeechSynthesizer, can claim the level of power resource they need when active (listening or speacking) by invoking the acquirePowerResource API, such that the power management system keeps the hardware devices works in the claimed power levels. When the component is inactive, it invokes the releasePowerResource API to release the acquired power resource level. This interface defined 6 power resource levels. To implement this interface, the user need define a mapping from them to the real power resource levels of the power management system.
using alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::PartialStateBitSet = std::bitset<PowerResourceTypeIndex::NUM_OF_TYPES> |
Alias for the bitset of partial states in low power mode.
|
strong |
Power resource levels. Each hardware device may have multiple STANDBY and ACTIVE power modes. For example, CPU can work in different frequency and number of cores. It has a latency to switch from low power mode to high power mode, and the latency increases with the gaps of the power levels. Power management system defines a group of power polices; each policy specifies the power modes of hardware components. To implement this interface, the user needs to map the power polices (that allow applications to proactively claim) to the 6 power resource levels we defined in this enumaration.
Power resource type flags. Each hardware device might have multiple power resource types that they must support. This interface describes some of the commonly-used resource types that consumers of this interface may choose to implement. These resource types are presented in a bitwise format to allow combinations of resource types to be added as well. The resource types can be used to set a particular value or to perform a bitwise comparison.
enum alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::PowerResourceTypeIndex |
Power resource type index. These indices represent a bit position for each of the different power resource types that are likely to be used on a given system. These can be used in combination with std::bitset by using the [] operator.
|
virtualdefault |
Destructor
|
pure virtual |
Acquire a power resource.
id | shared pointer of type PowerResourceId representing the resource. |
autoReleaseTimeout | auto release timeout value. Zero denotes auto release disabled. |
Implemented in alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.
|
pure virtual |
Acquire a power resource for the component.
component | component name. |
level | power resource level. |
Implemented in alexaClientSDK::avsCommon::utils::power::AggregatedPowerResourceManager, and alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.
|
pure virtual |
Close a power resource.
id | shared pointer of type PowerResourceId representing the resource. |
Implemented in alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.
|
pure virtual |
Create a power resource keyed by the unique string resourceId.
resourceId | mentions what the resource is for. |
isRefCounted | whether refcounting is enabled for this resource |
level | power resource level. |
Implemented in alexaClientSDK::avsCommon::utils::power::AggregatedPowerResourceManager, and alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.
|
inlinevirtual |
Acquires the time since latest partial low power mode state change. This API should only be called after a power resource has been acquired.
component | component name. |
resourceFlags | in/out parameter to get resource flags which exit lpm state last. This parameter is passed by the caller of this API and it gets updated with the bit pattern which represents one bit position for each resource type.Ref:enum PowerResourceTypeIndex |
partialState | the partial low power mode state (PowerResourceTypeFlags) to check. The state type is determined based on the bits that are passed in. For example, if TYPE_CPU is passed in then the time since the most recent CPU low power mode state will be returned. The default behavior of this partial state, TYPE_ALL, returns the most recent low power mode state value. If more than one partial state is passed in, e.g. TYPE_CPU|TYPE_DDR, this API will return the time from the most recent change of the types given. |
Provides the default PowerResourceManagerInterface
time since last partial in MS.
component | component name. |
resourceFlags | in/out parameter to get resource flags which exit lpm state last. |
partialState | the partial low power mode state (PowerResourceTypeFlags) to check. |
|
inlinevirtual |
Acquires the time since latest system resume.
Provides the default PowerResourceManagerInterface
time since last resume in MS.
|
pure virtual |
Checks whether a power resource had been acquired or not.
component | component name. |
Implemented in alexaClientSDK::avsCommon::utils::power::AggregatedPowerResourceManager, and alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.
|
pure virtual |
Release a power resource.
id | shared pointer of type PowerResourceId representing the resource. |
Implemented in alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.
|
pure virtual |
Release the acquired power resource of the specified component.
component | component name. |
Implemented in alexaClientSDK::avsCommon::utils::power::AggregatedPowerResourceManager, and alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0