[Device] Implementation of system.device module including error handling.
[platform/core/csapi/system.git] / Tizen.System / Device / Power.cs
1 using System;
2
3 namespace Tizen.System
4 {
5     /// <summary>
6     /// The Power class provides methods to control the power service.
7     /// </summary>
8     public static class Power
9     {
10         /// <summary>
11         /// Locks the CPU for a specified time.
12         /// After the given timeout (in milliseconds), unlock the given lock state automatically.
13         /// </summary>
14         /// <param name="timeout">
15         /// The positive number in milliseconds or 0 for permanent lock
16         /// So you must release the permanent lock of power state with ReleaseCpuLock() if timeout_ms is zero.
17         /// </param>
18         public static void RequestCpuLock(int timeout)
19         {
20             DeviceError res = (DeviceError) Interop.Device.DevicePowerRequestLock(0, timeout);
21             if (res != DeviceError.None)
22             {
23                 throw DeviceExceptionFactory.CreateException(res, "unable to acquire power lock.");
24             }
25         }
26
27         /// <summary>
28         /// Releases the CPU lock state.
29         /// </summary>
30         public static void ReleaseCpuLock()
31         {
32             DeviceError res = (DeviceError) Interop.Device.DevicePowerReleaseLock(0);
33             if (res != DeviceError.None)
34             {
35                 throw DeviceExceptionFactory.CreateException(res, "unable to release power lock.");
36             }
37         }
38     }
39 }