Esempio n. 1
0
        private static void MessageHandler(object args)
        {
            if (args is SleepEvent)
            {
                SleepChangeEventHandler h = OnSleepChange;

                if (h != null)
                {
                    h((SleepEvent)args);
                }
            }
            else if (args is PowerEvent)
            {
                PowerEvent pe = (PowerEvent)args;

                PowerLevelChangeEventHandler h = OnPowerLevelChange;

                s_CurrentPowerLevel = pe.Level;

                if (h != null)
                {
                    h(pe);
                }
            }
        }
Esempio n. 2
0
        public BaseEvent ProcessEvent(uint data1, uint data2, DateTime time)
        {
            EventCategory ec = (EventCategory)(0xFF & (data1 >> 8));
            BaseEvent     be = null;

            if (ec == EventCategory.SleepLevel)
            {
                SleepEvent ev = new SleepEvent();

                ev.EventType    = (SleepEventType)(data1 & 0xFF); // data1 encodes the type in the lower 16 bits and...
                ev.Level        = SleepLevel.Awake;
                ev.WakeUpEvents = (HardwareEvent)data2;
                ev.Time         = time;

                be = ev;
            }
            else if (ec == EventCategory.PowerLevel)
            {
                PowerEvent ev = new PowerEvent();

                ev.EventType = PowerEventType.PostNotify;
                ev.Level     = (PowerLevel)data2;
                ev.Time      = time;

                be = ev;
            }

            return(be);
        }
Esempio n. 3
0
        /// <summary>
        /// The ChangePowerLevel method enables the caller to adjust the current power level of the device.
        /// The behavior of the power levels are determined by the hardware vendor.  This method raises the
        /// OnPowerLevelChange event.
        /// </summary>
        /// <param name="level">Describes the power level for which the system should enter</param>
        public static void ChangePowerLevel(PowerLevel level)
        {
            if (s_CurrentPowerLevel == level)
            {
                return;
            }

            PowerLevelChangeEventHandler h = OnPowerLevelChange;

            if (h != null)
            {
                PowerEvent e = new PowerEvent();

                e.EventType = PowerEventType.PreNotify;
                e.Level     = level;
                e.Time      = DateTime.UtcNow;

                h(e);
            }

            InternalChangePowerLevel(level);

            s_CurrentPowerLevel = level;
        }
Esempio n. 4
0
        public BaseEvent ProcessEvent(uint data1, uint data2, DateTime time)
        {
            EventCategory ec = (EventCategory)(0xFF & (data1 >> 8));
            BaseEvent be = null;

            if (ec == EventCategory.SleepLevel)
            {
                SleepEvent ev = new SleepEvent();

                ev.EventType = (SleepEventType)(data1 & 0xFF);    // data1 encodes the type in the lower 16 bits and...
                ev.Level = SleepLevel.Awake;
                ev.WakeUpEvents = (HardwareEvent)data2;
                ev.Time = time;

                be = ev;
            }
            else if (ec == EventCategory.PowerLevel)
            {
                PowerEvent ev = new PowerEvent();

                ev.EventType = PowerEventType.PostNotify;
                ev.Level = (PowerLevel)data2;
                ev.Time = time;

                be = ev;
            }

            return be;
        }
Esempio n. 5
0
        /// <summary>
        /// The ChangePowerLevel method enables the caller to adjust the current power level of the device.
        /// The behavior of the power levels are determined by the hardware vendor.  This method raises the
        /// OnPowerLevelChange event.
        /// </summary>
        /// <param name="level">Describes the power level for which the system should enter</param>
        public static void ChangePowerLevel(PowerLevel level)
        {
            if (s_CurrentPowerLevel == level) return;

            PowerLevelChangeEventHandler h = OnPowerLevelChange;

            if (h != null)
            {
                PowerEvent e = new PowerEvent();

                e.EventType = PowerEventType.PreNotify;
                e.Level = level;
                e.Time = DateTime.UtcNow;

                h(e);
            }

            InternalChangePowerLevel(level);

            s_CurrentPowerLevel = level;
        }