public LocalClientWakeupHandler(String url, int tag)
 {
   try
   {
     _remote = (IWakeupHandler)Activator.GetObject(typeof(IWakeupHandler), url);
     this._tag = tag;
     this._url = url;
   }
   catch (Exception ex)
   {
     Log.Debug("LocalClientWakeupHandler: {0}", ex.Message);
   }
 }
 public LocalClientWakeupHandler(String url, int tag)
 {
     try
     {
         _remote   = (IWakeupHandler)Activator.GetObject(typeof(IWakeupHandler), url);
         this._tag = tag;
         this._url = url;
     }
     catch (Exception ex)
     {
         Log.Debug("LocalClientWakeupHandler: {0}", ex.Message);
     }
 }
 public DateTime GetNextWakeupTime(DateTime earliestWakeupTime)
 {
   if (remote == null) return DateTime.MaxValue;
   try
   {
     return remote.GetNextWakeupTime(earliestWakeupTime);
   }
   catch (Exception)
   {
     // broken remote handler, nullify this one (dead)
     remote = null;
     return DateTime.MaxValue;
   }
 }
 public DateTime GetNextWakeupTime(DateTime earliestWakeupTime)
 {
   try
   {
     if (_remote == null)
       return DateTime.MaxValue;
     return _remote.GetNextWakeupTime(earliestWakeupTime);
   }
   catch (Exception ex)
   {
     // broken remote handler, nullify this one (dead)
     Log.Debug("LocalClientWakeupHandler: {0}", ex.Message);
     _remote = null;
     return DateTime.MaxValue;
   }
 }
Exemplo n.º 5
0
 public DateTime GetNextWakeupTime(DateTime earliestWakeupTime)
 {
     if (remote == null)
     {
         return(DateTime.MaxValue);
     }
     try
     {
         return(remote.GetNextWakeupTime(earliestWakeupTime));
     }
     catch (Exception)
     {
         // broken remote handler, nullify this one (dead)
         remote = null;
         return(DateTime.MaxValue);
     }
 }
 public DateTime GetNextWakeupTime(DateTime earliestWakeupTime)
 {
     try
     {
         if (_remote == null)
         {
             return(DateTime.MaxValue);
         }
         return(_remote.GetNextWakeupTime(earliestWakeupTime));
     }
     catch (Exception ex)
     {
         // broken remote handler, nullify this one (dead)
         Log.Debug("LocalClientWakeupHandler: {0}", ex.Message);
         _remote = null;
         return(DateTime.MaxValue);
     }
 }
Exemplo n.º 7
0
    public void Start()
    {
      Log.Info("PS: Starting PowerScheduler client plugin...");

      try
      {
        // Register for MediaPortal actions to see if user is active
        GUIWindowManager.OnNewAction += new OnActionHandler(this.OnAction);

        // Create the timer that will wakeup the system after a specific amount of time after the
        // system has been put into standby
        _wakeupTimer = new WaitableTimer();

        // Load settings
        LoadSettings();

        // Unmute master volume
        if (_settings.GetSetting("UnmuteMasterVolume").Get<bool>())
        {
          try
          {
            using (MasterVolume _masterVolume = new MasterVolume())
            {
              if (_masterVolume.IsMuted)
              {
                Log.Debug("PS: Master volume is muted - unmute it");
                _masterVolume.IsMuted = false;
              }
            }
          }
          catch (Exception ex)
          {
            Log.Error("PS: Error in handling master volume - {0}", ex.Message);
          }
        }

        // Register as global service provider instance
        if (!GlobalServiceProvider.Instance.IsRegistered<IPowerScheduler>())
        {
          GlobalServiceProvider.Instance.Add<IPowerScheduler>(this);
        }
        Log.Debug("PS: Registered PowerScheduler as IPowerScheduler service to GlobalServiceProvider");

        // Register standby/wakeup handlers
        _wakeableStandbyHandler = new WakeableStandbyHandler();
        Register(_wakeableStandbyHandler);
        _wakeableWakeupHandler = new WakeableWakeupHandler();
        Register(_wakeableWakeupHandler);
        if (!_singleSeat)
        {
          // Register special standby/wakeup handlers (remote client only)
          _factory = new PowerSchedulerFactory();
          _factory.CreateDefaultSet();
        }
        Log.Debug("PS: Registered standby/wakeup handlers to PowerScheduler client plugin");

        // Register PSClientPlugin as standby / wakeup handler for PowerScheduler server (single-seat only)
        if (_singleSeat)
          RegisterToRemotePowerScheduler();

        // Create the EventWaitHandles for the StandbyWakeupThread and GetCurrentState
        _standbyWakeupTriggered = new EventWaitHandle(false, EventResetMode.AutoReset, "MediaPortal.PowerScheduler.StandbyWakeupTriggered");
        _standbyWakeupFinished = new AutoResetEvent(false);
        _standbyWakeupSuspend = new AutoResetEvent(false);  // initially do not take suspend branch
        _standbyWakeupResume = new ManualResetEvent(true);  // initially releases (no block)

        // Start the StandbyWakeupThread responsible for checking standby conditions and setting the wakeup timer
        _parentThread = Thread.CurrentThread;
        _standbyWakeupThread = new Thread(StandbyWakeupThread);
        _standbyWakeupThread.Name = "PS StandbyWakeup";
        _standbyWakeupThread.Start();
        Log.Debug("PS: StandbyWakeupThread started");

        SendPowerSchedulerEvent(PowerSchedulerEventType.Started);
        Log.Info("PS: PowerScheduler client plugin started");
      }
      catch (Exception ex)
      {
        Log.Error("PS: Exception in Start: {0}", ex);
        Stop();
      }
    }
Exemplo n.º 8
0
 public bool IsRegistered(IWakeupHandler handler)
 {
   return _wakeupHandlers.Contains(handler);
 }
Exemplo n.º 9
0
 public void Unregister(IWakeupHandler handler)
 {
   if (_wakeupHandlers.Contains(handler))
     _wakeupHandlers.Remove(handler);
 }
Exemplo n.º 10
0
 public void Register(IWakeupHandler handler)
 {
   if (!_wakeupHandlers.Contains(handler))
     _wakeupHandlers.Add(handler);
 }
 public void Close()
 {
   _remote = null;
 }
 public RemoteWakeupHandler(String URL, int tag)
 {
   remote = (IWakeupHandler)Activator.GetObject(typeof (IWakeupHandler), URL);
   this.tag = tag;
   this.Url = URL;
 }
Exemplo n.º 13
0
 public void Close()
 {
     remote = null;
 }
Exemplo n.º 14
0
 public RemoteWakeupHandler(String URL, int tag)
 {
     remote   = (IWakeupHandler)Activator.GetObject(typeof(IWakeupHandler), URL);
     this.tag = tag;
     this.Url = URL;
 }