Ejemplo n.º 1
0
void DomainPowerControl_001::throwIfDynamicCapabilitiesAreWrong(const PowerControlDynamicCapsSet& capabilities)
{
    if (capabilities.isEmpty())
    {
        throw dptf_exception("Dynamic caps set is empty.  Impossible if we support power controls.");
    }

    auto controlTypes = capabilities.getControlTypes();
    for (auto controlType = controlTypes.begin(); controlType != controlTypes.end(); controlType++)
    {
        auto capability = capabilities.getCapability(*controlType);
        std::string controlTypeString = PowerControlType::ToString(capability.getPowerControlType());
        if (capability.getMaxPowerLimit() < capability.getMinPowerLimit())
        {
            std::string errorMessage = controlTypeString + " has bad power limit capabilities: max < min.";
            throw dptf_exception(errorMessage);
        }

        if (capability.getMaxTimeWindow() < capability.getMinTimeWindow())
        {
            std::string errorMessage = controlTypeString + " has bad time window capabilities: max < min.";
            throw dptf_exception(errorMessage);
        }

        if (capability.getMaxDutyCycle() < capability.getMinDutyCycle())
        {
            std::string errorMessage = controlTypeString + " has bad duty cycle capabilities: max < min.";
            throw dptf_exception(errorMessage);
        }
    }
}
void PowerControlCapabilitiesArbitrator::updatePolicyRequest(
    const PowerControlDynamicCapsSet &capSet, UIntN policyIndex)
{
    auto controlTypes = capSet.getControlTypes();
    for (auto controlType = controlTypes.begin(); controlType != controlTypes.end(); controlType++)
    {
        auto capability = capSet.getCapability(*controlType);
        m_requestedMaxPowerLimit[policyIndex][*controlType] = capability.getMaxPowerLimit();
        m_requestedMinPowerLimit[policyIndex][*controlType] = capability.getMinPowerLimit();
        m_requestedPowerLimitStep[policyIndex][*controlType] = capability.getPowerStepSize();
        m_requestedMaxTimeWindow[policyIndex][*controlType] = capability.getMaxTimeWindow();
        m_requestedMinTimeWindow[policyIndex][*controlType] = capability.getMinTimeWindow();
    }
}