Ejemplo n.º 1
0
        /// <summary>
        /// Set the Energy Storage Status.
        /// </summary>
        /// <param name="presence">energy storage presence</param>
        /// <param name="state">status of energy storage</param>
        /// <param name="scalingFactor">The scaling factor in Joules.</param>
        /// <param name="bladeEnergy">The blade energy.</param>
        /// <param name="nvdimmEnergy">The nvdimm energy.</param>
        /// <returns></returns>
        public virtual bool SetEnergyStorage(bool presence, EnergyStorageState state, byte scalingFactor, ushort bladeEnergy, byte nvdimmEnergy)
        {
            SetEnergyStorageResponse response = (SetEnergyStorageResponse)this.IpmiSendReceive(
                new SetEnergyStorageRequest(presence, state, scalingFactor, bladeEnergy, nvdimmEnergy), typeof(SetEnergyStorageResponse));

            return(response.CompletionCode == 0 ? true: false);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Set Energy Storage State
 /// </summary>
 internal ChassisEnergyStorageStatus(bool present, EnergyStorageState state, double percentCharge, double powerOut, bool faultDetected)
 {
     this.Present = present;
     this.State = state;
     this.PercentCharge = percentCharge;
     this.PowerOut = powerOut;
     this.FaultDetected = faultDetected;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Set Energy Storage State
 /// </summary>
 internal ChassisEnergyStorageStatus(bool present, EnergyStorageState state, double percentCharge, double powerOut, bool faultDetected)
 {
     this.Present       = present;
     this.State         = state;
     this.PercentCharge = percentCharge;
     this.PowerOut      = powerOut;
     this.FaultDetected = faultDetected;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Set the Energy Storage Status.
 /// </summary>
 /// <param name="deviceId">The device identifier.</param>
 /// <param name="presence">Energy storage presence</param>
 /// <param name="state">status of energy storage</param>
 /// <param name="scalingFactor">The scaling factor in Joules.</param>
 /// <param name="bladeEnergy">The blade energy.</param>
 /// <param name="nvdimmEnergy">The nvdimm energy.</param>
 /// <returns></returns>
 public static bool SetEnergyStorage(byte deviceId, bool presence, EnergyStorageState state, byte scalingFactor, ushort bladeEnergy, byte nvdimmEnergy)
 {
     if (clients.ContainsKey(deviceId))
     {
         return(clients[deviceId].SetEnergyStorage(presence, state, scalingFactor, bladeEnergy, nvdimmEnergy));
     }
     else
     {
         return(false);
     }
 }
        /// <summary>
        /// Set Energy Storage State
        /// </summary>
        internal SetEnergyStorageRequest(EnergyStorageState state, bool presence, byte charge, ushort holdTime, DateTime timestamp)
        {
            if(presence)
                this.state = 0x01;

            this.state = (byte)(this.state | ((byte)state << 2));

            this.percentCharge = charge;

            this.holdTime = holdTime;

            this.timestamp = Convert.ToUInt32(IpmiSharedFunc.SecondsFromUnixOffset(timestamp));
        }
        /// <summary>
        /// Set Energy Storage Constructor
        /// </summary>
        internal SetEnergyStorageRequest(bool batteryPresent, EnergyStorageState state, byte scalingFactor, 
            ushort bladeEnergy, byte nvdimmEnergy)
        {
            // Battery presence and state
            if (batteryPresent)
                this.state = 0x01;

            this.state = (byte)(this.state | ((byte)state << 2));

            // Energy scaling factor
            this.scalingFactor = scalingFactor;

            // Blade and NVDIMM energy
            this.bladeBackupEnergy = bladeEnergy;
            this.nvdimmBackupEnergy = nvdimmEnergy;

            // Rolling counter in seconds
            DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            double totalSeconds = DateTime.UtcNow.Subtract(epoch).TotalSeconds;
            this.rollingCounter = (ushort)totalSeconds;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Set Energy Storage Constructor
        /// </summary>
        internal SetEnergyStorageRequest(bool batteryPresent, EnergyStorageState state, byte scalingFactor,
                                         ushort bladeEnergy, byte nvdimmEnergy)
        {
            // Battery presence and state
            if (batteryPresent)
            {
                this.state = 0x01;
            }

            this.state = (byte)(this.state | ((byte)state << 2));

            // Energy scaling factor
            this.scalingFactor = scalingFactor;

            // Blade and NVDIMM energy
            this.bladeBackupEnergy  = bladeEnergy;
            this.nvdimmBackupEnergy = nvdimmEnergy;

            // Rolling counter in seconds
            DateTime epoch        = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            double   totalSeconds = DateTime.UtcNow.Subtract(epoch).TotalSeconds;

            this.rollingCounter = (ushort)totalSeconds;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Broadcast Set Energy Storage
        /// </summary>
        /// <param name="present">Energy Storage Presence</param>
        /// <param name="state">Energy Storage State</param>
        /// <param name="scalingFactor">The scaling factor in Joules.</param>
        /// <param name="bladeEnergy">The blade energy.</param>
        /// <param name="nvdimmEnergy">The nvdimm energy.</param>
        /// <returns>
        /// Collection of Completion Codes
        /// </returns>
        internal static Dictionary <byte, CompletionCode> BroadcastSetEnergyStorage(bool present, EnergyStorageState state,
                                                                                    byte scalingFactor, ushort bladeEnergy, byte nvdimmEnergy)
        {
            SetEnergyStorageRequest energyStorage = new SetEnergyStorageRequest(present, state, scalingFactor, bladeEnergy, nvdimmEnergy);

            return(BroadcastIpmiRequest <SetEnergyStorageRequest>(energyStorage));
        }
        /// <summary>
        /// Checks for faults on each PSU
        /// </summary>
        private static Dictionary <byte, PsuAlertFaultType> PsuAlertInvestigate()
        {
            Dictionary <byte, PsuAlertFaultType> failures = new Dictionary <byte, PsuAlertFaultType>();

            // Check status for all PSU
            foreach (PsuBase psu in ChassisState.Psu)
            {
                // If firmware update is in progress, skip this PSU
                if (ChassisState.PsuFwUpdateInProgress[psu.PsuId - 1])
                {
                    continue;
                }

                lock (ChassisState.psuLock[psu.PsuId - 1])
                {
                    PsuStatusPacket psuStatus = psu.GetPsuStatus();
                    if (psuStatus.CompletionCode != CompletionCode.Success)
                    {
                        Tracer.WriteError("PsuAlertInvestigate: GetPsuStatus on PSU ({0}) failed with return code {1}",
                                          psu.PsuId, psuStatus.CompletionCode);
                        failures.Add(psu.PsuId, PsuAlertFaultType.PsuFailure);
                    }
                    else
                    {
                        if (psuStatus.PsuStatus != (byte)Contracts.PowerState.ON)
                        {
                            // PSU is completely turned off
                            failures.Add(psu.PsuId, PsuAlertFaultType.PsuFailure);
                        }
                        else if ((ConfigLoaded.BatteryMonitoringEnabled) && (ChassisState.Psu[psu.PsuId - 1] is EmersonPsu))
                        {
                            // Check battery status for Emerson PSU
                            EmersonPsu emersonPsu = (EmersonPsu)psu;

                            // Get battery status and health
                            BatteryStatusPacket battStatus = emersonPsu.GetBatteryStatus();
                            EmersonPsu.BatteryHealthStatusPacket battHealth = emersonPsu.GetBatteryHealthStatus();

                            if ((battStatus.CompletionCode == CompletionCode.Success) &&
                                (battHealth.CompletionCode == CompletionCode.Success))
                            {
                                // Update chassis energy storage variables
                                bool batteryPresent          = (battStatus.Presence == 1) ? true : false;
                                bool batteryFault            = (battStatus.FaultDetected == 1) ? true : false;
                                EnergyStorageState battState = EnergyStorageState.Unknown;

                                if (batteryPresent)
                                {
                                    if (batteryFault)
                                    {
                                        // Battery Fault Detected.
                                        failures.Add(emersonPsu.PsuId, PsuAlertFaultType.BatteryFault);
                                        Tracer.WriteError("PsuAlertInvestigate Battery Fault Detected. PsuId {0}", emersonPsu.PsuId);
                                    }
                                    else // if no fault detected, check if system is on battery.
                                    {
                                        // Determine battery state
                                        if (battHealth.Discharging == 0)
                                        {
                                            battState = EnergyStorageState.Charging;

                                            // We are charging, reset the timer.
                                            if (BatteryDischargeTimer.IsRunning)
                                            {
                                                BatteryDischargeTimer.Reset();
                                            }
                                        }
                                        else
                                        {
                                            // Emerson stated that we can have discharging even when on AC since the charger will have hysteresis.
                                            // Hence we need to check Discharging and Battery Power Output to determine if we are on Battery.
                                            if (battStatus.BatteryPowerOutput != 0)
                                            {
                                                battState = EnergyStorageState.Discharging;
                                            }
                                            else
                                            {
                                                battState = EnergyStorageState.Floating;
                                            }
                                        }

                                        if (battState == EnergyStorageState.Discharging)
                                        {
                                            // Start the timer if not already running.
                                            if (!BatteryDischargeTimer.IsRunning)
                                            {
                                                BatteryDischargeTimer.Start();
                                            }

                                            // Psu Battery is Discharging. System is on battery.
                                            // Log it as a failure for processing in PsuAlertRemediate() which is called outside this method
                                            failures.Add(emersonPsu.PsuId, PsuAlertFaultType.OnBattery);
                                            Tracer.WriteInfo("PsuAlertInvestigate Psu Battery discharging.  PsuId {0}", emersonPsu.PsuId);
                                        }
                                    }
                                }
                                else
                                {
                                    Tracer.WriteInfo("PsuAlertInvestigate, no battery present for Psu: {0}", emersonPsu.PsuId);
                                }

                                // Update chassis energy storage values
                                ChassisEnergyStorageStatus chassisEnergyStatus =
                                    new ChassisEnergyStorageStatus(batteryPresent, battState,
                                                                   battStatus.BatteryChargeLevel, battStatus.BatteryPowerOutput, batteryFault);
                                if (!ChassisState.SetEnergyStorageStatus(emersonPsu.PsuId, chassisEnergyStatus))
                                {
                                    Tracer.WriteError(
                                        string.Format("PsuAlertInvestigate: SetEnergyStorageStatus failed for BatteryId {0}", emersonPsu.PsuId));
                                }
                            }
                            else
                            {
                                // Failed to get battery status or health. Log as battery fault
                                failures.Add(emersonPsu.PsuId, PsuAlertFaultType.BatteryFault);
                                Tracer.WriteError("PsuAlertInvestigate failed to get Battery Status. PsuId {0} Status Completion Code: {1}  Health Completion Code: {2}",
                                                  emersonPsu.PsuId, battStatus.CompletionCode, battHealth.CompletionCode);
                            }
                        }

                        // If PSU is on and there are no battery faults, check if other faults are present
                        // Add PSU to failure list so that we can log it in PsuAlertRemediate()
                        if ((!failures.ContainsKey(psu.PsuId)) && (psuStatus.FaultPresent))
                        {
                            failures.Add(psu.PsuId, PsuAlertFaultType.PsuFaultPresent);
                        }
                    }
                } // lock...
            }     // foreach...

            return(failures);
        }
Ejemplo n.º 10
0
 internal void SetParamaters(byte presence, byte state, byte charge, ushort holdTime, DateTime timestamp)
 {
     this.presence = presence;
     this.state = (EnergyStorageState)state;
     this.percentageCharge = charge;
     this.holdTimeInSeconds = holdTime;
     this.timestamp = timestamp;
 }
 internal void SetParamaters(byte presence, byte state, byte scalingFactor, ushort bladeBackupEnergy, byte nvdimmBackupEnergy, ushort rollingCounter)
 {
     this.presence = presence;
     this.state = (EnergyStorageState)state;
     this.scalingFactor = scalingFactor;
     this.bladeBackupEnergy = bladeBackupEnergy;
     this.nvdimmBackupEnergy = nvdimmBackupEnergy;
     this.rollingCounter = rollingCounter;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Get Energy Storage
        /// </summary>
        /// <returns>Flags indicating the boot device.</returns>
        public int VerifyEnergyStorage(EnergyStorageState state)
        {
            //Get Energy Storage
            EnergyStorage GetEnergyResponse = ipmi.GetEnergyStorage();

            try
            {

                if (GetEnergyResponse.CompletionCode == 0x00 &&
                    GetEnergyResponse.State == state)
                {
                    Console.WriteLine("Command Passed: {0} Completion Code: {1}", "Get Energy Storage", GetEnergyResponse.CompletionCode);
                    if (showDetail)
                        EnumProp.EnumerableObject(GetEnergyResponse);

                    return 1;
                }
                else
                {
                    Console.WriteLine("Command failed: {0} Completion Code: {1}", "Get Energy Storage", GetEnergyResponse.CompletionCode);
                    return 0;
                }

            }
            catch (Exception ex)
            {
                return WriteException(ex);
            }
        }