AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Public Types | Public Member Functions | List of all members
alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface Class Referenceabstract

#include <PowerResourceManagerInterface.h>

Inheritance diagram for alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface:
Inheritance graph
[legend]

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 partialState=PowerResourceTypeFlag::TYPE_ALL_FLAG)
 
virtual std::shared_ptr< PowerResourceIdcreate (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
 

Detailed Description

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.

Member Typedef Documentation

◆ PartialStateBitSet

Alias for the bitset of partial states in low power mode.

Member Enumeration Documentation

◆ PowerResourceLevel

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.

Enumerator
STANDBY_LOW 

A STANDBY level means hardware components are in standby mode, they are suitable for background activities. STANDBY_LOW usually means all the hardware components work in the lowest standby power levels

STANDBY_MED 

STANDBY_MED usually means all the hardware components work in the medium standby power levels.

STANDBY_HIGH 

STANDBY_HIGH usually means all the hardware components work in the highest standby power levels.

ACTIVE_LOW 

An ACTIVE level means hardware components are in active mode, they are suitable for foreground activities. ACTIVE_LOW usually means all the hardware components work in the lowest active power levels

ACTIVE_MED 

ACTIVE_LOW usually means all the hardware components work in the medium active power levels.

ACTIVE_HIGH 

ACTIVE_HIGH usually means all the hardware components work in the highest active power levels.

◆ PowerResourceTypeFlag

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.

Enumerator
TYPE_ALL_FLAG 

The default flag value which corresponds to all power resource types.

TYPE_CPU_FLAG 

Flag value which represents the CPU resource type.

TYPE_DDR_FLAG 

Flag value which represents the DDR resource type.

TYPE_STORAGE_FLAG 

Flag value which represents the storage resource type.

TYPE_NETWORK_FLAG 

Flag value which represents the network resource type.

TYPE_RESERVED_ONE_FLAG 

Flag value which represents the first reserved resource type.

TYPE_RESERVED_TWO_FLAG 

Flag value which represents the second reserved resource type.

◆ 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.

Enumerator
TYPE_CPU 

CPU capacity is limited or improved under the CPU resource type.

TYPE_DDR 

DDR latency/bandwidth are limited or improved under the DDR resource type.

TYPE_STORAGE 

Disk I/O performance is limited or improved under the storage resource type.

TYPE_NETWORK 

Network latency is limited or improved under the network resource type.

TYPE_RESERVED_ONE 

A reserved type that allows platforms to reserve custom PowerResourceTypeFlags.

TYPE_RESERVED_TWO 

A reserved type that allows platforms to reserve custom PowerResourceTypeFlags.

NUM_OF_TYPES 

Number of power resource types. This must always be the last enum member.

Constructor & Destructor Documentation

◆ ~PowerResourceManagerInterface()

virtual alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::~PowerResourceManagerInterface ( )
virtualdefault

Destructor

Member Function Documentation

◆ acquire()

virtual bool alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::acquire ( const std::shared_ptr< PowerResourceId > &  id,
const std::chrono::milliseconds  autoReleaseTimeout = std::chrono::milliseconds::zero() 
)
pure virtual

Acquire a power resource.

Parameters
idshared pointer of type PowerResourceId representing the resource.
autoReleaseTimeoutauto release timeout value. Zero denotes auto release disabled.
Returns
true if acquire was successful, false if it failed.

Implemented in alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.

◆ acquirePowerResource()

virtual void alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::acquirePowerResource ( const std::string &  component,
const PowerResourceLevel  level = PowerResourceLevel::STANDBY_MED 
)
pure virtual

Acquire a power resource for the component.

Parameters
componentcomponent name.
levelpower resource level.

Implemented in alexaClientSDK::avsCommon::utils::power::AggregatedPowerResourceManager, and alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.

◆ close()

virtual bool alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::close ( const std::shared_ptr< PowerResourceId > &  id)
pure virtual

Close a power resource.

Parameters
idshared pointer of type PowerResourceId representing the resource.
Returns
true if close was successful, false if it failed.

Implemented in alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.

◆ create()

virtual std::shared_ptr<PowerResourceId> alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::create ( const std::string &  resourceId,
bool  isRefCounted = true,
const PowerResourceLevel  level = PowerResourceLevel::STANDBY_MED 
)
pure virtual

Create a power resource keyed by the unique string resourceId.

Parameters
resourceIdmentions what the resource is for.
isRefCountedwhether refcounting is enabled for this resource
levelpower resource level.
Returns
shared pointer of type PowerResourceId representing the resource

Implemented in alexaClientSDK::avsCommon::utils::power::AggregatedPowerResourceManager, and alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.

◆ getTimeSinceLastPartialMS()

std::chrono::milliseconds alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::getTimeSinceLastPartialMS ( const std::string &  component,
PartialStateBitSet  partialState = PowerResourceTypeFlag::TYPE_ALL_FLAG 
)
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.

Parameters
componentcomponent name.
partialStatethe 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.
Returns
time since last partial system resume - zero indicates that either the platform doesn't support the partial state or that the device was never in partial low power mode.

Provides the default PowerResourceManagerInterface time since last partial in MS.

Parameters
componentcomponent name.
partialStatethe partial low power mode state (PowerResourceTypeFlags) to check.
Returns
Return default value of 0 milliseconds in the form of std::chrono::milliseconds.

◆ getTimeSinceLastResumeMS()

std::chrono::milliseconds alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::getTimeSinceLastResumeMS ( )
inlinevirtual

Acquires the time since latest system resume.

Returns
time since last system resume, if implemented by power manager, zero otherwise.

Provides the default PowerResourceManagerInterface time since last resume in MS.

Returns
Return default value of 0 milliseconds in the form of std::chrono::milliseconds.

◆ isPowerResourceAcquired()

virtual bool alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::isPowerResourceAcquired ( const std::string &  component)
pure virtual

Checks whether a power resource had been acquired or not.

Parameters
componentcomponent name.
Returns
true if the power resource had been acquired, otherwise return false.

Implemented in alexaClientSDK::avsCommon::utils::power::AggregatedPowerResourceManager, and alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.

◆ release()

virtual bool alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::release ( const std::shared_ptr< PowerResourceId > &  id)
pure virtual

Release a power resource.

Parameters
idshared pointer of type PowerResourceId representing the resource.
Returns
true if release was successful, false if it failed.

Implemented in alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.

◆ releasePowerResource()

virtual void alexaClientSDK::avsCommon::sdkInterfaces::PowerResourceManagerInterface::releasePowerResource ( const std::string &  component)
pure virtual

Release the acquired power resource of the specified component.

Parameters
componentcomponent name.

Implemented in alexaClientSDK::avsCommon::utils::power::AggregatedPowerResourceManager, and alexaClientSDK::avsCommon::utils::power::NoOpPowerResourceManager.


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

AlexaClientSDK 1.25.0 - Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0