113 lines
3.7 KiB
C#
113 lines
3.7 KiB
C#
//----------------------------------------------------------------------------
|
|
//
|
|
// Copyright (c) Intel Corporation, 2009-2014 All Rights Reserved.
|
|
//
|
|
// File: TimeSynchronizationFunctionality.cs
|
|
//
|
|
// Contents: Demonstrate the IBootControl interface.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
using System;
|
|
using Intel.Manageability;
|
|
using Intel.Manageability.TimeSynchronization;
|
|
|
|
namespace TimeSynchronizationSample
|
|
{
|
|
class TimeSynchronizationFunctionality
|
|
{
|
|
/// <summary>
|
|
/// Set the Intel AMT network time using the Time Synchronization service, to Coordinated Universal Time (UTC).
|
|
/// </summary>
|
|
/// <param name="amt">The Intel AMT instance</param>
|
|
public static void SetNetworkTime(IAMTInstance amt)
|
|
{
|
|
try
|
|
{
|
|
amt.TimeSynchronization.SetUtcNetworkTime();
|
|
Console.WriteLine("Set the Utc Intel AMT network time succeed.");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
|
|
Console.WriteLine("Set the Intel AMT time failed");
|
|
Console.WriteLine("\n" + e.Message);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Get the Intel AMT network time.
|
|
/// </summary>
|
|
/// <param name="amt">The Intel AMT instance</param>
|
|
public static void GetNetworkTime(IAMTInstance amt)
|
|
{
|
|
try
|
|
{
|
|
DateTime dateTimeOfAmt = amt.TimeSynchronization.GetNetworkTime();
|
|
Console.WriteLine("The current Intel AMT network time is {0}", dateTimeOfAmt.ToString());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
|
|
Console.WriteLine("Get the Intel AMT network time failed");
|
|
Console.WriteLine("\n" + e.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the enabled state of the time sync.
|
|
/// </summary>
|
|
/// <param name="amt">The Intel AMT instance</param>
|
|
public static void GetSyncTimeEnabledState(IAMTInstance amt)
|
|
{
|
|
try
|
|
{
|
|
SyncTimeEnabledState syncTimeEnabledState = amt.TimeSynchronization.GetSyncTimeEnabledState();
|
|
Console.WriteLine("The enabled state of the time sync is {0}", syncTimeEnabledState.ToString());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine("Get Sync Time Enabled State failed");
|
|
Console.WriteLine("\n" + e.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enable/Disable the time sync.
|
|
/// </summary>
|
|
/// <param name="amt">The Intel AMT instance</param>
|
|
public static void SetSyncTimeState(IAMTInstance amt)
|
|
{
|
|
try
|
|
{
|
|
amt.TimeSynchronization.SetSyncTimeState(true);
|
|
Console.WriteLine("Set the Sync Time state of Intel AMT network time succeed.");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine("Set the Intel AMT sync time state failed");
|
|
Console.WriteLine("\n" + e.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the setter of the network time.
|
|
/// </summary>
|
|
/// <param name="amt">The Intel AMT instance</param>
|
|
public static void GetTimeSetter(IAMTInstance amt)
|
|
{
|
|
try
|
|
{
|
|
TimeSetter timeSetter = amt.TimeSynchronization.GetTimeSetter();
|
|
Console.WriteLine("The Intel AMT time setter is {0}", timeSetter);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine("Get time setter of Intel AMT failed");
|
|
Console.WriteLine("\n" + e.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|