Example #1
0
        public void Run()
        {
            int num = 0;

            while (!this.stopEvent.WaitOne(num))
            {
                if (this.hHwLib == IntPtr.Zero)
                {
                    return;
                }
                WDHWLib.DRIVE_BAY_PRESENCE_DATA drive_BAY_PRESENCE_DATA = default(WDHWLib.DRIVE_BAY_PRESENCE_DATA);
                drive_BAY_PRESENCE_DATA.presenceChanged = 0u;
                WDHWLib.HWStatus hwstatus = WDHWLib.HWWaitForDriveBayChange(this.hHwLib, ref drive_BAY_PRESENCE_DATA);
                if (hwstatus != WDHWLib.HWStatus.HW_STATUS_OK)
                {
                    if (num == 0)
                    {
                        Logger.Warn("Wait for bay change failed: {0}", new object[]
                        {
                            hwstatus.ToString()
                        });
                        num = 10000;
                    }
                }
                else
                {
                    if (drive_BAY_PRESENCE_DATA.presenceChanged != 0u)
                    {
                        this.Update();
                    }
                    num = 0;
                }
            }
        }
Example #2
0
 public bool SetBayPower(DriveBay bay, bool power)
 {
     if (bay.ControlPort == -1 || bay.IsBoot)
     {
         return(false);
     }
     lock (this.hwSyncObj)
     {
         Logger.Info("Setting bay {0} power = {1}", new object[]
         {
             bay.Number,
             power
         });
         WDHWLib.HWStatus hwstatus = WDHWLib.HWSetDriveBayPower(this.hHwLib, (uint)bay.ControlPort, power);
         if (hwstatus != WDHWLib.HWStatus.HW_STATUS_OK)
         {
             Logger.Warn("Failed to set drive bay power {0}={1}: {2}", new object[]
             {
                 bay.ControlPort,
                 power,
                 hwstatus.ToString()
             });
             return(false);
         }
     }
     return(true);
 }