/// <summary>
        /// Attempts to retrieve the Psu Status. This method
        /// calls down to the Chassis Manager with SendReceive
        /// </summary>
        private PsuStatusPacket GetPsuStatus(byte psuId)
        {
            // Initialize return packet
            PsuStatusPacket returnPacket = new PsuStatusPacket();

            returnPacket.CompletionCode = CompletionCode.UnspecifiedError;
            returnPacket.PsuStatus      = 0;
            returnPacket.FaultPresent   = false;

            try
            {
                PsuStatusResponse myResponse = new PsuStatusResponse();
                myResponse = (PsuStatusResponse)this.SendReceive(this.PsuDeviceType, this.PsuId,
                                                                 new PsuRequest((byte)PmBusCommand.STATUS_WORD, (byte)PmBusResponseLength.STATUS_WORD), typeof(PsuStatusResponse));

                if (myResponse.CompletionCode != 0)
                {
                    returnPacket.CompletionCode = (CompletionCode)myResponse.CompletionCode;
                    Tracer.WriteWarning("GetPsuStatus Failure for PSU {0}: Completion Code: {1}", psuId, myResponse.CompletionCode);
                }
                else
                {
                    returnPacket.CompletionCode = CompletionCode.Success;
                    byte   varStatus;
                    byte[] psuStatus = myResponse.PsuStatus;

                    // If there are any other faults, indicate fault is present and log the full status word
                    if (!PmBus.ExtractPowerGoodFromPsuStatus(psuStatus, out varStatus))
                    {
                        Tracer.WriteWarning("GetPsuStatus: Psu ({0}) STATUS_WORD is non-zero: " +
                                            "(High Byte: {1} Low Byte: {2}) (See STATUS_WORD register in PmBusII Manual)",
                                            this.PsuId,
                                            System.Convert.ToString(psuStatus[1], 2).PadLeft(8, '0'),
                                            System.Convert.ToString(psuStatus[0], 2).PadLeft(8, '0'));

                        returnPacket.FaultPresent = true;
                    }

                    returnPacket.PsuStatus = varStatus;
                }
            }
            catch (System.Exception ex)
            {
                returnPacket.CompletionCode = CompletionCode.UnspecifiedError;
                returnPacket.PsuStatus      = 0;
                Tracer.WriteError("GetPsuStatus Exception: " + ex);
            }
            return(returnPacket);
        }
        /// <summary>
        /// Attempts to retrieve the Psu Model Number.  This method
        /// calls down to the Chassis Manager with SendReceive
        /// </summary>
        private PsuModelNumberPacket GetPsuModel(byte psuId)
        {
            // Initialize return packet
            PsuModelNumberPacket returnPacket = new PsuModelNumberPacket();

            returnPacket.CompletionCode = CompletionCode.UnspecifiedError;
            returnPacket.ModelNumber    = "";

            try
            {
                PsuModelResponse myResponse = new PsuModelResponse();
                myResponse = (PsuModelResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuRequest((byte)PmBusCommand.MFR_MODEL, (byte)PmBusResponseLength.MFR_MODEL), typeof(PsuModelResponse));

                // check for completion code
                if (myResponse.CompletionCode != 0)
                {
                    returnPacket.CompletionCode = (CompletionCode)myResponse.CompletionCode;
                }
                else
                {
                    returnPacket.CompletionCode = CompletionCode.Success;
                    if (myResponse.PsuModelNumber != null)
                    {
                        byte[] inModelNumber  = myResponse.PsuModelNumber;
                        byte[] outModelNumber = null;
                        PmBus.PsuModelNumberParser(ref inModelNumber, out outModelNumber);
                        returnPacket.ModelNumber = System.BitConverter.ToString(outModelNumber, 0);
                    }
                    else
                    {
                        returnPacket.ModelNumber = "";
                    }
                }
            }
            catch (System.Exception ex)
            {
                returnPacket.CompletionCode = CompletionCode.UnspecifiedError;
                returnPacket.ModelNumber    = "";
                Tracer.WriteError(this.PsuId, DeviceType.Psu, ex);
            }

            return(returnPacket);
        }
Beispiel #3
0
        /// <summary>
        /// Attempts to retrieve the Psu Status. This method
        /// calls down to the Chassis Manager with SendReceive
        /// </summary>
        private PsuStatusPacket GetPsuStatus(byte psuId)
        {
            // Initialize return packet
            PsuStatusPacket returnPacket = new PsuStatusPacket();

            returnPacket.CompletionCode = CompletionCode.UnspecifiedError;
            returnPacket.PsuStatus      = 0;

            try
            {
                PsuStatusResponse myResponse = new PsuStatusResponse();
                myResponse = (PsuStatusResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuRequest((byte)PmBusCommand.STATUS_WORD, (byte)PmBusResponseLength.STATUS_WORD), typeof(PsuStatusResponse));

                if (myResponse.CompletionCode != 0)
                {
                    returnPacket.CompletionCode = (CompletionCode)myResponse.CompletionCode;
                    Tracer.WriteWarning("GetPsuStatus Failure: status({0})", returnPacket.PsuStatus);
                }
                else
                {
                    returnPacket.CompletionCode = CompletionCode.Success;
                    byte   varStatus;
                    byte[] psuStatus = myResponse.PsuStatus;

                    // If there are any other faults, print the full status word
                    if (!PmBus.ExtractPowerGoodFromPsuStatus(psuStatus, out varStatus))
                    {
                        Tracer.WriteWarning("Psu({0}) PowerGood Negated ({1} {2}) in/out curr/volt faults (See StatusWord in PmBusII Manual)", this.PsuId, System.Convert.ToString(psuStatus[0], 2).PadLeft(8, '0'), System.Convert.ToString(psuStatus[1], 2).PadLeft(8, '0'));
                    }

                    returnPacket.PsuStatus = varStatus;
                }
            }
            catch (System.Exception ex)
            {
                returnPacket.CompletionCode = CompletionCode.UnspecifiedError;
                returnPacket.PsuStatus      = 0;
                Tracer.WriteError("GetPsuStatus Exception: " + ex);
            }
            return(returnPacket);
        }
        /// <summary>
        /// Attempts to retrieve the Psu Power. This method
        /// calls down to the Chassis Manager with SendReceive
        /// </summary>
        private PsuPowerPacket GetPsuPower(byte psuId)
        {
            // Initialize return packet
            PsuPowerPacket returnPacket = new PsuPowerPacket();

            returnPacket.CompletionCode = CompletionCode.UnspecifiedError;
            returnPacket.PsuPower       = 0;

            byte[] powerValue = new byte[2];
            try
            {
                PsuPowerResponse myResponse = new PsuPowerResponse();
                myResponse = (PsuPowerResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuRequest((byte)PmBusCommand.READ_POUT, (byte)PmBusResponseLength.READ_POUT), typeof(PsuPowerResponse));

                if (myResponse.CompletionCode != 0)
                {
                    returnPacket.CompletionCode = (CompletionCode)myResponse.CompletionCode;
                }
                else
                {
                    returnPacket.CompletionCode = CompletionCode.Success;
                    powerValue = myResponse.PsuPower;
                    byte[] convertedPowerValue = null;
                    PmBus.PmBusLinearDataFormatConverter(ref powerValue, out convertedPowerValue);
                    powerValue            = convertedPowerValue;
                    returnPacket.PsuPower = System.BitConverter.ToInt32(powerValue, 0);
                }
            }
            catch (System.Exception ex)
            {
                returnPacket.CompletionCode = CompletionCode.UnspecifiedError;
                returnPacket.PsuPower       = 0;
                Tracer.WriteError(this.PsuId, DeviceType.Psu, ex);
            }
            return(returnPacket);
        }