72 lines
2.7 KiB
C#
72 lines
2.7 KiB
C#
//----------------------------------------------------------------------------
|
|
//
|
|
// Copyright (c) Intel Corporation, 2010 All Rights Reserved.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
using System;
|
|
using Intel.Manageability;
|
|
using Intel.Manageability.Exceptions;
|
|
using Intel.Manageability.PowerPackages;
|
|
|
|
namespace PowerPackagesSample
|
|
{
|
|
class PowerPackagesFunctionality
|
|
{
|
|
/// <summary>
|
|
/// Get the current PowerPackage and its defined InactivityTimeout.
|
|
/// </summary>
|
|
/// <param name="amt">The Intel AMT instance</param>
|
|
public static void GetPowerPackage(IAMTInstance amt)
|
|
{
|
|
try
|
|
{
|
|
LegacyPowerPackageDetails powerPackageDetails = amt.PowerPackages.GetPowerPackage();
|
|
Console.WriteLine("Get PowerPackage succeeded\n");
|
|
Console.WriteLine("The powerPackage is " + powerPackageDetails.PowerPackage + "\n");
|
|
Console.WriteLine("The InactivityTimeout value is " + powerPackageDetails.InactivityTimeout + "\n\n");
|
|
}
|
|
catch (PowerPackagesManageabilityException p)
|
|
{
|
|
PrintException("GetPowerPackage", p);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Change the activity PowerPackage and / or its Inactivitytimeout to another one.
|
|
/// </summary>
|
|
/// <param name="amt">The Intel AMT instance</param>
|
|
public static void SetPowerPackage(IAMTInstance amt)
|
|
{
|
|
try
|
|
{
|
|
PowerPackageDetails powerPackage = new PowerPackageDetails(65535, SupportedSetPowerPackage.MEisActiveInS0_AndCanWakeupFromS3_S4_S5);
|
|
amt.PowerPackages.SetPowerPackage(powerPackage);
|
|
Console.WriteLine("Set PowerPackage succeeded\n\n");
|
|
}
|
|
catch (PowerPackagesManageabilityException p)
|
|
{
|
|
PrintException("SetPowerPackage", p);
|
|
}
|
|
catch (ManageabilityIllegalInputException ex)
|
|
{
|
|
Console.WriteLine(ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
static void PrintException(string methodName, PowerPackagesManageabilityException p)
|
|
{
|
|
Console.WriteLine(methodName + " throw: " + p.Message);
|
|
Console.WriteLine("Details:");
|
|
Console.WriteLine("========");
|
|
Console.WriteLine("\t- Machine Origin : {0}", p.MachineOrigin);
|
|
Console.WriteLine("\t- HLAPI Source Function: {0}", p.Source);
|
|
if (p.PT_STATUS != null)
|
|
Console.WriteLine("\t- Return Value : {0}", p.PT_STATUS);
|
|
if (p.Tip != string.Empty)
|
|
Console.WriteLine("\t- Counsel : {0}", p.Tip);
|
|
}
|
|
}
|
|
}
|