/// <summary> /// Get/Set Power Policy /// </summary> public static PowerRestorePolicy SetPowerRestorePolicy(byte deviceId, PowerRestoreOption policyOption) { if (clients.ContainsKey(deviceId)) { return(clients[deviceId].SetPowerRestorePolicy(policyOption)); } else { return(new PowerRestorePolicy((byte)CompletionCode.InvalidDevice)); } }
/// <summary> /// Set Chassis Power Restore Policy. /// </summary> public virtual PowerRestorePolicy SetPowerRestorePolicy(PowerRestoreOption policyOption) { // Set/Get Policy SetPowerRestoreResponse response = (SetPowerRestoreResponse)this.IpmiSendReceive(new SetPowerRestoreRequest(policyOption), typeof(SetPowerRestoreResponse)); PowerRestorePolicy responseObj = new PowerRestorePolicy(response.CompletionCode); byte[] data = new byte[1]; if (response.CompletionCode == 0) { data[0] = response.PowerRestorePolicy; } responseObj.SetParamaters(data); return(responseObj); }
/// <summary> /// Set Chassis Power Restore Policy. /// </summary> public virtual PowerRestorePolicy SetPowerRestorePolicy(PowerRestoreOption policyOption) { // Set/Get Policy SetPowerRestoreResponse response = (SetPowerRestoreResponse)this.IpmiSendReceive(new SetPowerRestoreRequest(policyOption), typeof(SetPowerRestoreResponse)); PowerRestorePolicy responseObj = new PowerRestorePolicy(response.CompletionCode); byte[] data = new byte[1]; if (response.CompletionCode == 0) { data[0] = response.PowerRestorePolicy; } responseObj.SetParamaters(data); return responseObj; }
/// <summary> /// Initializes a new instance of the Set Power Restore Policy Command class. /// </summary> /// <param name="operation">Operation to perform.</param> internal SetPowerRestoreRequest(PowerRestoreOption option) { this._policyOption = (byte)option; }
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> /// Get/Set Power Policy /// </summary> public static PowerRestorePolicy SetPowerRestorePolicy(byte deviceId, PowerRestoreOption policyOption) { if (clients.ContainsKey(deviceId)) { return clients[deviceId].SetPowerRestorePolicy(policyOption); } else { return new PowerRestorePolicy((byte)CompletionCode.InvalidDevice); } }