Exemplo n.º 1
0
 /// <summary>
 /// Set the computer power state.
 /// </summary>
 /// <param name="powerState">Power state to set.</param>
 public static byte SetPowerState(byte deviceId, IpmiPowerState powerState)
 {
     if (clients.ContainsKey(deviceId))
     {
         return(clients[deviceId].SetPowerState(powerState));
     }
     else
     {
         return((byte)CompletionCode.InvalidDevice);
     }
 }
        /// <summary>
        /// Set the computer power state.
        /// </summary>
        /// <param name="powerState">Power state to set.</param>
        public virtual byte SetPowerState(IpmiPowerState powerState)
        {
            byte chassisOperation;

            switch (powerState)
            {
            case IpmiPowerState.Off:
                chassisOperation = ChassisControlRequest.OperationPowerDown;
                break;

            case IpmiPowerState.On:
                chassisOperation = ChassisControlRequest.OperationPowerUp;
                break;

            case IpmiPowerState.Cycle:
                chassisOperation = ChassisControlRequest.OperationPowerCycle;
                break;

            case IpmiPowerState.Reset:
                chassisOperation = ChassisControlRequest.OperationHardReset;
                break;

            case IpmiPowerState.SoftOff:
                chassisOperation = ChassisControlRequest.OperationSoftShutdown;
                break;

            default:
                chassisOperation = 6;
                break;
            }

            if (chassisOperation <= 5)
            {
                ChassisControlResponse response = (ChassisControlResponse)this.IpmiSendReceive(
                    new ChassisControlRequest(chassisOperation),
                    typeof(ChassisControlResponse));

                return(response.CompletionCode);
            }
            else
            {
                // Invalid data field in Request
                return(0xCC);
            }
        }
Exemplo n.º 3
0
        internal void SetParamaters(byte currentPowerState, byte lastEvent, byte miscState)
        {
            if (base.CompletionCode == 0)
            {

                #region Power State

                // [0] Power is on, 1 = On, 0 = Off
                byte state = Convert.ToByte((currentPowerState & 0x01));

                // Translate the current power state into an enumeration.
                switch (state)
                {
                    case 0x00:
                        this.powerstate = IpmiPowerState.Off;
                        break;
                    case 0x01:
                        this.powerstate = IpmiPowerState.On;
                        break;
                    default:
                        this.powerstate = IpmiPowerState.Invalid;
                        break;
                }

                #endregion

                #region Power Policy

                state = Convert.ToByte((currentPowerState & 0x60) >> 5);

                // Translate the state into Power on Policy.
                switch (state)
                {
                    case 0x00:
                        this.powerOnPolicy = PowerRestoreOption.StayOff;
                        break;
                    case 0x01:
                        this.powerOnPolicy = PowerRestoreOption.PreviousState;
                        break;
                    case 0x02:
                        this.powerOnPolicy = PowerRestoreOption.AlwaysPowerUp;
                        break;
                    default:
                        this.powerOnPolicy = PowerRestoreOption.Unknown;
                        break;
                }

                #endregion

                #region Power Fault

                // [7:5] -  reserved
                // [4]   -   1b = last ‘Power is on’ state was entered via IPMI command 
                // [3]   -   1b = last power downcaused by power fault
                // [2]   -   1b = last power down caused by a power interlockbeing activated 
                // [1]   -   1b = last power down caused by a Power overload
                // [0]   -   1b = AC failed
                state = Convert.ToByte((lastEvent & 0x1F));

                switch (state)
                {
                    case 0x00:
                        this.lastPowerEvent = PowerEvent.ACfailed;
                        break;
                    case 0x01:
                        this.lastPowerEvent = PowerEvent.PowerOverload;
                        break;
                    case 0x02:
                        this.lastPowerEvent = PowerEvent.PowerInterlockActive;
                        break;
                    case 0x03:
                        this.lastPowerEvent = PowerEvent.PowerFault;
                        break;
                    case 0x04:
                        this.lastPowerEvent = PowerEvent.IpmiSetState;
                        break;
                    default:
                        this.lastPowerEvent = PowerEvent.Unknown;
                        break;
                }

                #endregion

                #region Identity LED

                // [7:4] -  reserved
                // [6] -    1b = Chassis Identify command and state info supported (Optional)
                //          0b = Chassis Identify command support unspecified via this 
                //          command.
                byte identitySupport = Convert.ToByte((miscState & 0x40) >> 6);

                if (identitySupport == 0x01)
                    this.identitySupported = true;

                // [5:4] -  Chassis Identify State.  Mandatory when bit [6] = 1b, reserved (return 
                // as 00b) otherwise.Returns the present chassis identify state. Refer to 
                // the Chassis Identify command for more info.
                // 00b = chassis identify state = Off
                // 01b = chassis identify state = Temporary (timed) On
                // 10b = chassis identify state = Indefinite On
                // 11b = reserved

                byte Identity = Convert.ToByte((miscState & 0x30) >> 4);

                switch (Identity)
                {
                    case 0x00:
                        this.identityState = IdentityState.Off;
                        break;
                    case 0x01:
                        this.identityState = IdentityState.TemporaryOn;
                        break;
                    case 0x02:
                        this.identityState = IdentityState.On;
                        break;
                    default:
                        this.identityState = IdentityState.Unknown;
                        break;
                }

                #endregion

            }
            else
            {
                this.powerstate = IpmiPowerState.Invalid;
            }          
        }
        /// <summary>
        /// Set the computer power state.
        /// </summary>
        /// <param name="powerState">Power state to set.</param>
        public virtual byte SetPowerState(IpmiPowerState powerState)
        {
            byte chassisOperation;

            switch (powerState)
            {
                case IpmiPowerState.Off:
                    chassisOperation = ChassisControlRequest.OperationPowerDown;
                    break;

                case IpmiPowerState.On:
                    chassisOperation = ChassisControlRequest.OperationPowerUp;
                    break;

                case IpmiPowerState.Cycle:
                    chassisOperation = ChassisControlRequest.OperationPowerCycle;
                    break;

                case IpmiPowerState.Reset:
                    chassisOperation = ChassisControlRequest.OperationHardReset;
                    break;

                case IpmiPowerState.SoftOff:
                    chassisOperation = ChassisControlRequest.OperationSoftShutdown;
                    break;
                default:
                    chassisOperation = 6;
                    break;
            }

            if (chassisOperation <= 5)
            {
                ChassisControlResponse response = (ChassisControlResponse)this.IpmiSendReceive(
                   new ChassisControlRequest(chassisOperation),
                   typeof(ChassisControlResponse));

                return response.CompletionCode;
            }
            else
            {
                // Invalid data field in Request
                return 0xCC;
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Set the computer power state.
 /// </summary>
 /// <param name="powerState">Power state to set.</param>
 public static byte SetPowerState(byte deviceId, IpmiPowerState powerState)
 {
    
     if (clients.ContainsKey(deviceId))
     {
         return clients[deviceId].SetPowerState(powerState);
     }
     else
     {
         return (byte)CompletionCode.InvalidDevice;
     }
 }