/// <summary> /// Set PSU On/OFF /// </summary> /// <param name="psuId">Psu Id</param> /// <param name="cmd">command ON or OFF</param> /// <returns>Completion code success/failure</returns> private CompletionCode SetPsuOnOff(PmBusCommandPayload payload) { CompletionCode returnPacket = new CompletionCode(); returnPacket = CompletionCode.UnspecifiedError; try { PsuOnOffResponse response = new PsuOnOffResponse(); response = (PsuOnOffResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuPayloadRequest((byte)PmBusCommand.SET_POWER, (byte)payload, (byte)PmBusResponseLength.SET_POWER), typeof(PsuOnOffResponse)); // check for completion code if (response.CompletionCode != 0) { returnPacket = (CompletionCode)response.CompletionCode; } else { returnPacket = CompletionCode.Success; } } catch (System.Exception ex) { Tracer.WriteError("SetPsuOnOff failed with the exception: " + ex); } return(returnPacket); }
/// <summary> /// Send I2C/Smbus Payloads to BMC via MasterWriteRead for setting Pass-Through Mode /// </summary> /// <param name="bladeId"></param> /// <param name="passThroughMode"></param> /// <param name="apiName"></param> /// <returns>CompletionCode</returns> internal static CompletionCode SetMezzPassThroughMode(int bladeId, bool passThroughMode, string apiName) { // Initialize return fields CompletionCode setMezzPassThroughCompletionCode = CompletionCode.UnknownState; // Initialize I2C/Smbus payloads byte count = 0x01; // bytes to read (0x00 means write) byte[] writeData = { 0x02 }; // { starting address } try { // Send I2C/Smbus Payload to BMC for reading pass-through byte before re-writing Ipmi.SmbusWriteRead sendSmbusPayloadResponse = SendSmbusPayload((byte)bladeId, channel, slaveId, count, writeData, apiName); if (sendSmbusPayloadResponse.CompletionCode == (byte)CompletionCode.Success && sendSmbusPayloadResponse.RawData.Length == (int)count) { // Configure writeData based on passThroughMode if (passThroughMode) { // Configure writeData to activate Pass-Through Mode (smbusPayloadByte bit 0 = 1) writeData = new byte[2] { writeData[0], (byte)(sendSmbusPayloadResponse.RawData[0] | 0x01) }; // { starting address, write byte } } else { // Configure writeData to turn off Pass-Through Mode (smbusPayloadByte bit 0 = 0) writeData = new byte[2] { writeData[0], (byte)(sendSmbusPayloadResponse.RawData[0] & 0xFE) }; // { starting address, write byte } } // Send I2C/Smbus Payload to BMC for setting pass-through mode on FPGA Mezz sendSmbusPayloadResponse = SendSmbusPayload((byte)bladeId, channel, slaveId, 0x00, writeData, apiName); if (sendSmbusPayloadResponse.CompletionCode != (byte)CompletionCode.Success) { setMezzPassThroughCompletionCode = CompletionCode.I2cErrors; } else { setMezzPassThroughCompletionCode = CompletionCode.Success; } } else { Tracer.WriteError(string.Format( "{0}(): MasterWriteRead returned unexpected payload data or did not return Success Completion Code for bladeId {1} (Data: {2})", apiName, bladeId, sendSmbusPayloadResponse.MessageData)); setMezzPassThroughCompletionCode = CompletionCode.I2cErrors; } } catch (Exception ex) { Tracer.WriteError(string.Format("Exception occured in {0}() for blade {1}: {2}", apiName, bladeId, ex)); setMezzPassThroughCompletionCode = CompletionCode.UnspecifiedError; } return(setMezzPassThroughCompletionCode); }
/// <summary> /// Attempts to clear the Psu error status. This method /// calls down to the Chassis Manager with SendReceive /// </summary> private CompletionCode SetPsuClearFaults(byte psuId) { CompletionCode returnPacket = new CompletionCode(); returnPacket = CompletionCode.UnspecifiedError; try { PsuChassisResponse myResponse = new PsuChassisResponse(); myResponse = (PsuChassisResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuRequest((byte)PmBusCommand.CLEAR_FAULTS, (byte)PmBusResponseLength.CLEAR_FAULTS), typeof(PsuChassisResponse)); // check for completion code if (myResponse.CompletionCode != 0) { returnPacket = (CompletionCode)myResponse.CompletionCode; } else { returnPacket = CompletionCode.Success; } } catch (System.Exception ex) { returnPacket = CompletionCode.UnspecifiedError; Tracer.WriteError(this.PsuId, DeviceType.Psu, ex); } return(returnPacket); }
/// <summary> /// This method should be called prior to using this class /// </summary> static internal CompletionCode Init() { CompletionCode completionCode = CompletionCode.CommDevFailedToInit; // Clear this flag in case that CM retries to initialize isTerminating = false; // Safe mode is disabled by default when initialized isSafeModeEnabled = false; // Enforce that the update to the flag variable is visible to other threads orderly Thread.MemoryBarrier(); portManagers = new PortManager[numPorts]; for (int i = 0; i < numPorts; i++) { portManagers[i] = new SerialPortManager(i, numPriorityLevels); completionCode = portManagers[i].Init(); if (CompletionCodeChecker.Failed(completionCode) == true) { Tracer.WriteError("Failed to initialize portManager: {0} Logical Id: {1}", i, PortManager.GetPhysicalPortNameFromLogicalId(i)); Release(); return(completionCode); } } return(completionCode); }
/// <summary> /// This method should be called prior to using this class /// </summary> static internal CompletionCode Init() { CompletionCode completionCode = CompletionCode.CommDevFailedToInit; // populdate Blade_En State Cache. foreach (byte Id in physicalServerIdTable) { CachedBladePowerStatus.Add(Id, new BladeEnState()); } // Clear this flag in case that CM retries to initialize isTerminating = false; // Enforce that the update to the flag variable is visible to other threads orderly Thread.MemoryBarrier(); portManagers = new PortManager[numPorts]; for (int i = 0; i < numPorts; i++) { portManagers[i] = new SerialPortManager(i, numPriorityLevels); completionCode = portManagers[i].Init(); if (CompletionCodeChecker.Failed(completionCode) == true) { Tracer.WriteError("Failed to initialize portManager: {0} Logical Id: {1}", i, PortManager.GetPhysicalPortNameFromLogicalId(i)); Release(); return(completionCode); } } return(completionCode); }
public ProcessorInfo(CompletionCode completionCode, byte procId, string type, string state, ushort frequency) : this(completionCode) { this.procId = procId; this.procType = type; this.state = state; this.frequency = frequency; }
/// <summary> /// Activates a functional agent. The caller should to an 'await' /// on this to wait for it to complete. This is because some /// functional agents return data and the caller has to wait /// for the functional agent to exit so it can get the data. Eg /// FileBrowser agent that returns a filename /// </summary> /// <param name="caller">The calling agent (can be null)</param> /// <param name="agent">Functional agent to activate</param> /// <returns>the task to wait on</returns> public async Task ActivateAgent(IApplicationAgent caller, IFunctionalAgent agent) { lock (_syncActivateAgent) { if (_currentAgent != null && _currentAgent != agent) { if (caller == null && !_currentAgent.QueryAgentSwitch(agent)) { return; } _currentAgent.OnFocusLost(); } if (caller != null) { agent.Parent = caller; caller.OnPause(); } _textControlAgent = agent.TextControlAgent; setAgent(agent); } Log.Debug("Calling activateAgent: " + agent.Name); await activateAgent(agent); CompletionCode exitCode = agent.ExitCode; Log.Debug("Returned from activateAgent: " + agent.Name); setAgent(null); if (agent.ExitCommand != null) { if (agent.ExitCommand.ContextSwitch) { Context.AppPanelManager.CloseCurrentPanel(); } RunCommandDispatcher.Dispatch(agent.ExitCommand.Command); } else if (exitCode == CompletionCode.ContextSwitch) { Context.AppPanelManager.CloseCurrentPanel(); EnumWindows.RestoreFocusToTopWindow(); WindowActivityMonitor.GetActiveWindow(); } else { PausePanelChangeRequests(); EnumWindows.RestoreFocusToTopWindow(); ResumePanelChangeRequests(false); } }
internal static void GenerateResponsePacket(CompletionCode completionCode, ref byte[] payload, out byte[] responsePacket) { if (payload == null) { GenerateResponsePacket(completionCode, out responsePacket); } else { GenerateResponsePacket(completionCode, payload.Length, ref payload, out responsePacket); } }
public PCIeInfo(CompletionCode completionCode, byte number, string state, ushort vendorId, ushort deviceId, ushort systemId, ushort subSystemId) : this(completionCode) { this.status = state; this.pcieNumber = number; this.vendorId = vendorId; this.deviceId = deviceId; this.systemId = systemId; this.subSystemId = subSystemId; }
internal static void GenerateResponsePacket(CompletionCode completionCode, ref byte[] payload, out byte[] responsePacket) { if (payload == null) { GenerateResponsePacket(completionCode, out responsePacket); } else { GenerateResponsePacket(completionCode, payload.Length, ref payload, out responsePacket); } }
public SensorInfo(CompletionCode completionCode, byte sensor, string type, string reading, string status, string description) : this(completionCode) { this.sensorNumber = sensor; this.reading = reading == null ? string.Empty : reading; this.entity = entity == null ? string.Empty : entity; this.sensorType = type == null ? string.Empty : type; this.entityInstance = entityInstance == null ? string.Empty : entityInstance; this.status = status == null ? string.Empty : status; this.description = description == null ? string.Empty : description; }
/// <summary> /// Gets the PSU status for all PSUs /// </summary> private void GetAllPsuStatus() { int countStatus = 0; for (int numPsus = 0; numPsus < MaxPsuCount; numPsus++) { try { PsuStatusPacket psuStatusPacket = new PsuStatusPacket(); psuStatusPacket = ChassisState.Psu[numPsus].GetPsuStatus(); if (psuStatusPacket.CompletionCode != CompletionCode.Success) { Tracer.WriteWarning("PSU ({0}) get status request failed with return code {1}", numPsus + 1, psuStatusPacket.CompletionCode); } else { if (psuStatusPacket.PsuStatus == (byte)Contracts.PowerState.ON) { countStatus++; } else { Tracer.WriteWarning("PSU ({0}) PowerGood signal is negated - check trace log for fault information", numPsus + 1); CompletionCode clearFaultCompletionCode = ChassisState.Psu[numPsus].SetPsuClearFaults(); if (clearFaultCompletionCode != CompletionCode.Success) { Tracer.WriteError("PsuStatus clear fault (invoked upon negated power good signal) command failed. Completion code({0})", clearFaultCompletionCode); } else { Tracer.WriteWarning("PsuStatus clear fault (invoked upon negated power good signal) command succeeded."); } } } } catch (Exception e) { Tracer.WriteError("PSU {0} status check failed with Exception: {1}", numPsus + 1, e); } } // Identify whether there is a PSU failure or not if (countStatus != MaxPsuCount) { ChassisState.PsuFailure = true; } else { ChassisState.PsuFailure = false; } }
/// <summary> /// Clears Psu Fault condition /// </summary> private static CompletionCode ClearPsuFault(byte psuId) { CompletionCode clearFaultCompletionCode = ChassisState.Psu[psuId - 1].SetPsuClearFaults(); if (clearFaultCompletionCode != CompletionCode.Success) { Tracer.WriteError("ClearPsuFault for PSU {0} failed. Completion code({1})", psuId, clearFaultCompletionCode); } else { Tracer.WriteInfo("ClearPsuFault for PSU {0} succeeded.", psuId); } return(clearFaultCompletionCode); }
static byte slaveId = 0xEE; // slave address of Pikes Peak I2C Controller /// <summary> /// Send I2C/Smbus Payloads to BMC via MasterWriteRead for reading Pass-Through Mode /// </summary> /// <param name="bladeId"></param> /// <param name="passThroughMode"></param> /// <param name="apiName"></param> /// <returns>CompletionCode</returns> internal static CompletionCode GetMezzPassThroughMode(int bladeId, out bool passThroughMode, string apiName) { // initialize return fields CompletionCode getMezzPassThroughCompletionCode = CompletionCode.UnknownState; passThroughMode = false; // Initialize I2C/Smbus payloads byte count = 0x01; // bytes to read byte[] writeData = { 0x02 }; // { starting address } try { // Send I2C/Smbus Payload to BMC for reading pass-through byte Ipmi.SmbusWriteRead sendSmbusPayloadResponse = SendSmbusPayload((byte)bladeId, channel, slaveId, count, writeData, apiName); if (sendSmbusPayloadResponse.CompletionCode == (byte)CompletionCode.Success && sendSmbusPayloadResponse.RawData.Length == (int)count) { // Get Pass-Through Mode from response byte (bit 1 of response byte) if ((sendSmbusPayloadResponse.RawData[0] & 0x02) == 0x02) { passThroughMode = false; } else { passThroughMode = true; } // Set Completion Code Success since no errors found getMezzPassThroughCompletionCode = CompletionCode.Success; } else { Tracer.WriteError(string.Format( "{0}(): MasterWriteRead returned unexpected payload data or did not return Success Completion Code for bladeId {1} (Data: {2})", apiName, bladeId, sendSmbusPayloadResponse.MessageData)); getMezzPassThroughCompletionCode = CompletionCode.I2cErrors; } } catch (Exception ex) { Tracer.WriteError(string.Format("Exception occured in {0}() for blade {1}: {2}", apiName, bladeId, ex)); getMezzPassThroughCompletionCode = CompletionCode.UnspecifiedError; } return(getMezzPassThroughCompletionCode); }
// This function should be called before executing any service APIs // TODO: Add other checks that needs to be done before executing APIs - like check for chassis terminating etc internal static CompletionCode ApiGreenSignalling() { CompletionCode response = new CompletionCode(); response = CompletionCode.UnspecifiedError; int currBladeId = bladeId; // Return Success if there is no active serial console session in progress if (!BladeSerialSessionMetadata.IsSerialConsoleSessionActive()) { response = CompletionCode.Success; return(response); } // If App.config parameter, KillSerialConsoleSession, is enabled, // terminate existing serial console session and proceed executing incoming commmands. if (ConfigLoaded.KillSerialConsoleSession) { response = CompletionCode.UnspecifiedError; Tracer.WriteInfo("Kill serial console session is enabled to allow incoming commands to succeed."); Contracts.ChassisResponse sessionResponse = new Contracts.ChassisResponse(); sessionResponse = StopBladeSerialSession(ConfigLoaded.InactiveBladePortId, ConfigLoaded.InactiveBladeSerialSessionToken, true); if (sessionResponse.completionCode != Contracts.CompletionCode.Success) { Tracer.WriteError("BladeSerialSessionMetadata.ApiGreenSignalling:Error stopserialsession failed"); return(response); } response = CompletionCode.Success; return(response); } // If App.config parameter, KillSerialConsoleSession, is not enabled, maintain existing serial console session, // and ignore incoming commands, with explicit failure message output as warning in trace, since it will not // affect service correctness. else { response = CompletionCode.SerialPortOtherErrors; Tracer.WriteWarning("Serial console session in progress. Ignore incoming command with message:{0}", response); // We are returning non-Success completion code (represented as SerialPortOtherErrors) // to indicate/trigger the failure of this incoming command. return(response); } }
// This function should be called before executing any service APIs // TODO: Add other checks that needs to be done before executing APIs - like check for chassis terminating etc internal static CompletionCode ApiGreenSignalling() { CompletionCode response = new CompletionCode(); response = CompletionCode.UnspecifiedError; // Return Success if there is no active serial console session in progress - by checking the safe mode if (!IsSerialConsoleSessionActive()) { response = CompletionCode.Success; return response; } // If App.config parameter, KillSerialConsoleSession, is enabled, // terminate existing serial console session and proceed executing incoming commmands. if (ConfigLoaded.KillSerialConsoleSession) { response = CompletionCode.UnspecifiedError; Tracer.WriteInfo("Kill serial console session is enabled to allow incoming commands to succeed."); Contracts.ChassisResponse sessionResponse = new Contracts.ChassisResponse(); sessionResponse = StopBladeSerialSession(BladeId, ConfigLoaded.InactiveBladeSerialSessionToken, true); if (sessionResponse.completionCode != Contracts.CompletionCode.Success) { Tracer.WriteError("BladeSerialSessionMetadata.ApiGreenSignalling:Error stopserialsession failed BladeId: {0}", BladeId); if (sessionResponse.completionCode != Contracts.CompletionCode.NoActiveSerialSession) return response; } response = CompletionCode.Success; return response; } // If App.config parameter, KillSerialConsoleSession, is not enabled, maintain existing serial console session, // and ignore incoming commands, with explicit failure message output as warning in trace, since it will not // affect service correctness. else { response = CompletionCode.SerialPortOtherErrors; Tracer.WriteWarning("Serial console session in progress. Ignore incoming command with message:{0}", response); // We are returning non-Success completion code (represented as SerialPortOtherErrors) // to indicate/trigger the failure of this incoming command. return response; } }
public MemoryInfo(CompletionCode completionCode, byte dimm, string type, ushort speed, ushort capacity, string memVoltage, string status) : this(completionCode) { this.dimm = dimm; this.dimmType = type; // Memory Speed this.speed = speed; // Dimm Size this.size = capacity; this.memVoltage = memVoltage; this.status = status; }
/// <summary> /// Generate a response packet with a non-empty payload /// </summary> /// <param name="completionCode"></param> /// <param name="payLoadLengthInByte"></param> /// <param name="payload"></param> /// <param name="responsePacket"></param> internal static void GenerateResponsePacket(CompletionCode completionCode, int payLoadLengthInByte, ref byte[] payload, out byte[] responsePacket) { const int byteCountSegmentLengthInByte = 2; if (payLoadLengthInByte == 0) { responsePacket = new byte[3]; responsePacket[0] = (byte)completionCode; responsePacket[1] = 0; responsePacket[2] = 0; } else { byte[] byteCountSegment = BitConverter.GetBytes((short)payLoadLengthInByte); responsePacket = new byte[payLoadLengthInByte + 3]; responsePacket[0] = (byte)completionCode; Buffer.BlockCopy(byteCountSegment, 0, responsePacket, 1, byteCountSegmentLengthInByte); Buffer.BlockCopy(payload, 0, responsePacket, 3, payLoadLengthInByte); } }
/// <summary> /// Generate a response packet with a non-empty payload /// </summary> /// <param name="completionCode"></param> /// <param name="payLoadLengthInByte"></param> /// <param name="payload"></param> /// <param name="responsePacket"></param> internal static void GenerateResponsePacket(CompletionCode completionCode, int payLoadLengthInByte, ref byte[] payload, out byte[] responsePacket) { const int byteCountSegmentLengthInByte = 2; if (payLoadLengthInByte == 0) { responsePacket = new byte[3]; responsePacket[0] = (byte)completionCode; responsePacket[1] = 0; responsePacket[2] = 0; } else { byte[] byteCountSegment = BitConverter.GetBytes((short)payLoadLengthInByte); responsePacket = new byte[payLoadLengthInByte + 3]; responsePacket[0] = (byte)completionCode; Buffer.BlockCopy(byteCountSegment, 0, responsePacket, 1, byteCountSegmentLengthInByte); Buffer.BlockCopy(payload, 0, responsePacket, 3, payLoadLengthInByte); } }
/// <summary> /// Initialize Communication Device /// </summary> /// <returns>status byte which indicates whether initialization was successful or not</returns> private static byte CommunicationDeviceInitialize() { byte status = (byte)CompletionCode.UnspecifiedError; Tracer.WriteInfo("Initializing Communication Device"); CompletionCode completionCode = CommunicationDevice.Init(); #region Comm. Device Initialization Retry if (CompletionCodeChecker.Failed(completionCode)) { Tracer.WriteWarning("Initialization failed: {0}", completionCode); int loop = 0; // Retry 3 times before failing completely for (loop = 0; loop < ConfigLoaded.MaxRetries; loop++) { Tracer.WriteInfo("Initialization Retry: {0}", loop); completionCode = CommunicationDevice.Init(); if (CompletionCodeChecker.Succeeded(completionCode)) { break; } } if (loop == ConfigLoaded.MaxRetries) { Tracer.WriteError("Re-attempt at Communication Device Initialization failed with code: {0}", completionCode); return(status); } } #endregion if (CompletionCodeChecker.Succeeded(completionCode)) { Tracer.WriteInfo("Communication Device Initialization successful.."); } return((byte)CompletionCode.Success); }
/// <summary> /// Internal method to Power off blade /// </summary> /// <param name="bladeId">Blade ID(1-48)</param> /// <returns>true/false if operation was success/failure</returns> internal static bool PowerOff(int bladeId) { Tracer.WriteInfo("Received poweroff({0})", bladeId); bool powerOffStatus = false; BladePowerStatePacket bladePowerSwitchStatePacket = new BladePowerStatePacket(); // Serialize power off and power on, on the same lock variable per blade, so we prevent inconsistent power state behavior lock (ChassisState.locker[bladeId - 1]) { bladePowerSwitchStatePacket = ChassisState.BladePower[bladeId - 1].SetBladePowerState((byte)PowerState.OFF); CompletionCode status = bladePowerSwitchStatePacket.CompletionCode; // Sleep for specified amount of time after blade hard power off to prevent hardware inconsistent state // - hot-swap controller not completely draining its capacitance leading to inconsistent power state issues Thread.Sleep(ConfigLoaded.WaitTimeAfterBladeHardPowerOffInMsecs); Tracer.WriteInfo("PowerOff: Return: {0}", status); if (status != CompletionCode.Success) { Tracer.WriteError("PowerOff: Blade Hard Power Off Failed with Completion code {0:X}", status); powerOffStatus = false; } else { powerOffStatus = true; // set state to Hard Power Off Tracer.WriteInfo("PowerOff: State Transition for blade {0}: {1} -> HardPowerOff", bladeId, ChassisState.GetStateName((byte)bladeId)); ChassisState.SetBladeState((byte)bladeId, (byte)BladeState.HardPowerOff); ChassisState.PowerFailCount[bladeId - 1] = 0; // Clear blade type and cache ChassisState.BladeTypeCache[bladeId - 1] = (byte)BladeType.Unknown; WcsBladeFacade.ClearBladeClassification((byte)bladeId); } } return(powerOffStatus); }
public static bool Failed(CompletionCode completionCode) { return(completionCode != CompletionCode.Success); }
/// <summary> /// Generate a response packet with an empty payload /// </summary> /// <param name="completionCode"></param> /// <param name="responsePacket"></param> internal static void GenerateResponsePacket(CompletionCode completionCode, out byte[] responsePacket) { byte[] payload = null; GenerateResponsePacket(completionCode, 0, ref payload, out responsePacket); }
/// <summary> /// Properties in the Get Disk information command response /// </summary> public JbodInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
public JbodDiskStatus(CompletionCode completionCode) { this.completionCode = completionCode; }
public MemoryInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
/// <summary> /// Properties in the Get Disk information command response /// </summary> public JbodInfo(CompletionCode completionCode, string unit, string reading) : this(completionCode) { this.unit = unit; this.reading = reading; }
public PCIeInfo(CompletionCode completionCode, byte number, string state, string vendorId, string deviceId, string subSystemId) : this(completionCode) { this.status = state; this.pcieNumber = number; this.vendorId = vendorId; this.deviceId = deviceId; this.subSystemId = subSystemId; }
public DiskInfo(CompletionCode completionCode, byte disk, string status) : this(completionCode) { this.diskId = disk; this.diskStatus = status; }
/// <summary> /// Send Model_ID to PSU for verification /// </summary> /// <param name="modelId">The 8-byte PSU model Id extracted from the FW image file. /// This ensures target HEX file matches the PSU primary/secondary controller. /// </param> /// <returns>Completion Code.</returns> private CompletionCode SendModelId(byte[] modelId) { CompletionCode returnPacket = new CompletionCode(); returnPacket = CompletionCode.UnspecifiedError; try { Tracer.WriteInfo("SendModelId(): Sending command to PSU."); PsuChassisResponse myResponse = new PsuChassisResponse(); myResponse = (PsuChassisResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuSendModelIdRequest(this.PsuId, modelId), typeof(PsuChassisResponse)); if (myResponse.CompletionCode != 0) { returnPacket = (CompletionCode)myResponse.CompletionCode; Tracer.WriteWarning("SendModelId Failure: Completion Code: {0}", returnPacket); } else { returnPacket = CompletionCode.Success; } } catch (System.Exception ex) { returnPacket = CompletionCode.UnspecifiedError; Tracer.WriteError("SendModelId Exception: " + ex); } return returnPacket; }
/// <summary> /// Attempts to clear the Psu error status. This method /// calls down to the Chassis Manager with SendReceive /// </summary> private CompletionCode SetPsuClearFaults(byte psuId) { CompletionCode returnPacket = new CompletionCode(); returnPacket = CompletionCode.UnspecifiedError; try { PsuChassisResponse myResponse = new PsuChassisResponse(); myResponse = (PsuChassisResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuRequest((byte)PmBusCommand.CLEAR_FAULTS, (byte)PmBusResponseLength.CLEAR_FAULTS), typeof(PsuChassisResponse)); // check for completion code if (myResponse.CompletionCode != 0) { returnPacket = (CompletionCode)myResponse.CompletionCode; } else { returnPacket = CompletionCode.Success; } } catch (System.Exception ex) { returnPacket = CompletionCode.UnspecifiedError; Tracer.WriteError(this.PsuId, DeviceType.Psu, ex); } return returnPacket; }
public ProcessorInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
public ProcessorInfo(CompletionCode completionCode, byte procId, string type, string state, ushort frequency) : this(completionCode) { this.procId = procId; this.procType = type; this.state = state; this.frequency = frequency; }
public SensorInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
/// <summary> /// Set the Battery Extended Operation Mode. /// </summary> private CompletionCode SetBatteryExtendedOperationMode(byte psuId, bool toEnable) { CompletionCode returnPacket = new CompletionCode(); returnPacket = CompletionCode.UnspecifiedError; // Command payload to set battery extended operation mode byte cmdPayload = ((toEnable) ? enableBatteryExtendedOperation: disableBatteryExtendedOperation); try { PsuChassisResponse myResponse = new PsuChassisResponse(); myResponse = (PsuChassisResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuBytePayloadRequest((byte)PmBusCommand.EXTENDED_BATTERY, (byte)cmdPayload, (byte)0), typeof(PsuChassisResponse)); if (myResponse.CompletionCode != 0) { returnPacket = (CompletionCode)myResponse.CompletionCode; Tracer.WriteWarning("SetBatteryExtendedOperationMode({0}) failed with CompletionCode ({1})", this.PsuId, returnPacket); } else { returnPacket = CompletionCode.Success; } } catch (System.Exception ex) { returnPacket = CompletionCode.UnspecifiedError; Tracer.WriteError("SetBatteryExtendedOperationMode Exception: " + ex); } return returnPacket; }
public static bool Failed(CompletionCode completionCode) { return (completionCode != CompletionCode.Success); }
public SensorInfo(CompletionCode completionCode, byte sensor, string type, string reading, string status, string description) : this(completionCode) { this.sensorNumber = sensor; this.reading = reading == null ? string.Empty : reading; this.entityId = entityId == null ? string.Empty : entityId; this.sensorType = type == null ? string.Empty : type; this.entityInstance = entityInstance == null ? string.Empty : entityInstance; this.status = status == null ? string.Empty : status; this.description = description == null ? string.Empty : description; }
public PCIeInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
public ProcessorInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
/// <summary> /// Enter Bootloader mode for in-system firmware upgrade. This method /// calls down to the Chassis Manager with SendReceive /// </summary> /// <param name="primaryImage"> /// True: Firmware image is for primary controller. /// False: Firmware image is for secondary controller. /// </param> /// <returns>Completion Code.</returns> private CompletionCode EnterFirmwareUpgradeMode(bool primaryImage) { CompletionCode returnPacket = new CompletionCode(); returnPacket = CompletionCode.UnspecifiedError; // Determine password for entering programming mode byte[] cmdPayload = primaryImage ? priFwUpgradeModePassword : secFwUpgradeModePassword; try { Tracer.WriteInfo("EnterFirmwareUpgradeMode(): Sending command to PSU."); PsuChassisResponse myResponse = new PsuChassisResponse(); myResponse = (PsuChassisResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new EnterFirmwareUpgradeModeRequest(this.PsuId, cmdPayload, primaryImage), typeof(PsuChassisResponse)); if (myResponse.CompletionCode != 0) { returnPacket = (CompletionCode)myResponse.CompletionCode; Tracer.WriteWarning("EnterFirmwareUpgradeMode Failure: Completion Code: {0}", returnPacket); } else { returnPacket = CompletionCode.Success; } } catch (System.Exception ex) { returnPacket = CompletionCode.UnspecifiedError; Tracer.WriteError("EnterFirmwareUpgradeMode Exception: " + ex); } return returnPacket; }
public MemoryInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
/// <summary> /// Exit Bootloader mode and restart firmware. This method /// calls down to the Chassis Manager with SendReceive /// </summary> /// <returns>Completion Code.</returns> private CompletionCode ExitFirmwareUpgradeMode() { CompletionCode returnPacket = new CompletionCode(); returnPacket = CompletionCode.UnspecifiedError; // Password for exiting programming mode (same for primary and secondary controllers) byte[] cmdPayload = secFwUpgradeModePassword; try { Tracer.WriteInfo("ExitFirmwareUpgradeMode(): Sending command to PSU."); PsuChassisResponse myResponse = new PsuChassisResponse(); myResponse = (PsuChassisResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new ExitFirmwareUpgradeModeRequest(this.PsuId, cmdPayload), typeof(PsuChassisResponse)); if (myResponse.CompletionCode != 0) { returnPacket = (CompletionCode)myResponse.CompletionCode; Tracer.WriteWarning("ExitFirmwareUpgradeMode Failure: Completion Code: {0}", returnPacket); } else { returnPacket = CompletionCode.Success; } } catch (System.Exception ex) { returnPacket = CompletionCode.UnspecifiedError; Tracer.WriteError("ExitFirmwareUpgradeMode Exception: " + ex); } return returnPacket; }
public PCIeInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
/// <summary> /// Properties in the Get Disk information command response /// </summary> public JbodInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
public JbodDiskStatus(CompletionCode completionCode, byte channel, byte diskCount) : this(completionCode) { this.channel = channel; this.diskCount = diskCount; }
/// <summary> /// Properties in the Get Disk information command response /// </summary> public JbodInfo(CompletionCode completionCode, string unit, string reading) : this(completionCode) { this.unit = unit; this.reading = reading; }
public DiskInfo(CompletionCode completionCode, byte disk, string status) : this(completionCode) { this.diskId = disk; this.diskStatus = status; }
public SensorInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
public static bool Succeeded(CompletionCode completionCode) { return(completionCode == CompletionCode.Success); }
public MemoryInfo(CompletionCode completionCode, byte dimm, string type, ushort speed, ushort capacity, string memVoltage, string status) : this(completionCode) { this.dimm = dimm; this.dimmType = type; // Memory Speed this.speed = speed; // Dimm Size this.size = capacity; this.memVoltage = memVoltage; this.status = status; }
public DiskInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
public DiskInfo(CompletionCode completionCode) { this.completionCode = completionCode; }
/// <summary> /// Update ROM Page Address for reading program memory. This method /// calls down to the Chassis Manager with SendReceive /// </summary> /// <param name="romPage">The ROM page.</param> /// <returns>Completion Code.</returns> private CompletionCode SendRomPage(byte romPage) { CompletionCode returnPacket = new CompletionCode(); returnPacket = CompletionCode.UnspecifiedError; try { PsuChassisResponse myResponse = new PsuChassisResponse(); myResponse = (PsuChassisResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuSendRomPageRequest(this.PsuId, romPage), typeof(PsuChassisResponse)); if (myResponse.CompletionCode != 0) { returnPacket = (CompletionCode)myResponse.CompletionCode; Tracer.WriteWarning("SendRomPage Failure: Completion Code: {0}", returnPacket); } else { returnPacket = CompletionCode.Success; } } catch (System.Exception ex) { returnPacket = CompletionCode.UnspecifiedError; Tracer.WriteError("SendRomPage Exception: " + ex); } return returnPacket; }
/// <summary> /// Generate a response packet with an empty payload /// </summary> /// <param name="completionCode"></param> /// <param name="responsePacket"></param> internal static void GenerateResponsePacket(CompletionCode completionCode, out byte[] responsePacket) { byte[] payload = null; GenerateResponsePacket(completionCode, 0, ref payload, out responsePacket); }
/// <summary> /// Set Battery Extended Operation Mode /// </summary> /// <param name="psuId"></param> /// <param name="toEnable"></param> /// <returns></returns> internal virtual CompletionCode SetBatteryExtendedOperationMode(bool toEnable) { CompletionCode completionCode = CompletionCode.UnspecifiedError; return(completionCode); }
/// <summary> /// Write data to program memory. This method /// calls down to the Chassis Manager with SendReceive /// </summary> /// <param name="data">The data. /// For firmware image data (isDataRomPage == false), the payload format is as follows (offset, length): /// - Address offset: (0, 2) - offset to write the data /// - Data: (2, 8) /// /// For ROM page data (isDataRomPage == true), the payload format is as follows (offset, length): /// - Address bytes: (0, 2) /// - Page bytes: (2, 2) /// /// </param> /// <param name="isDataRomPage"> /// True: data[] contains the ROM page data /// False: data[] contains FW image data /// </param> /// <returns>Completion Code.</returns> private CompletionCode WriteProgramMemory(byte[] data, bool isDataRomPage) { CompletionCode returnPacket = new CompletionCode(); returnPacket = CompletionCode.UnspecifiedError; try { PsuChassisResponse myResponse = new PsuChassisResponse(); if (isDataRomPage) { // Write ROM Page myResponse = (PsuChassisResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuWriteProgramMemoryRomPageRequest(this.PsuId, data), typeof(PsuChassisResponse)); } else { // Write FW image data myResponse = (PsuChassisResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuWriteProgramMemoryFwRequest(this.PsuId, data), typeof(PsuChassisResponse)); } if (myResponse.CompletionCode != 0) { returnPacket = (CompletionCode)myResponse.CompletionCode; Tracer.WriteWarning("WriteProgramMemory Failure: Completion Code: {0}", returnPacket); } else { returnPacket = CompletionCode.Success; } } catch (System.Exception ex) { returnPacket = CompletionCode.UnspecifiedError; Tracer.WriteError("WriteProgramMemory Exception: " + ex); } return returnPacket; }
/// <summary> /// Set PSU On/OFF /// </summary> /// <param name="psuId">Psu Id</param> /// <param name="cmd">command ON or OFF</param> /// <returns>Completion code success/failure</returns> private CompletionCode SetPsuOnOff(PmBusCommandPayload payload) { CompletionCode returnPacket = new CompletionCode(); returnPacket = CompletionCode.UnspecifiedError; try { PsuOnOffResponse response = new PsuOnOffResponse(); response = (PsuOnOffResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuBytePayloadRequest((byte)PmBusCommand.SET_POWER, (byte)payload, (byte)PmBusResponseLength.SET_POWER), typeof(PsuOnOffResponse)); // check for completion code if (response.CompletionCode != 0) { returnPacket = (CompletionCode)response.CompletionCode; } else { returnPacket = CompletionCode.Success; } } catch (System.Exception ex) { Tracer.WriteError("SetPsuOnOff failed with the exception: " + ex); } return returnPacket; }
/// <summary> /// Gets the battery status /// </summary> /// <returns></returns> internal override BatteryStatusPacket GetBatteryStatus() { BatteryStatusPacket infoPacket = new BatteryStatusPacket(); infoPacket.CompletionCode = CompletionCode.Success; // Indicate that battery is present infoPacket.Presence = 1; // Get battery power output BatteryPowerPacket batteryPowerPacket = GetBatteryPowerOut(); if (batteryPowerPacket.CompletionCode != CompletionCode.Success) { Tracer.WriteWarning("GetBatteryPowerOut failed for battery: " + this.PsuId); } else { infoPacket.BatteryPowerOutput = batteryPowerPacket.BatteryPower; } // Get battery charge level BatteryChargeLevelPacket batteryChargeLevelPacket = GetBatteryChargeLevel(); if (batteryChargeLevelPacket.CompletionCode != CompletionCode.Success) { Tracer.WriteWarning("GetBatteryChargeLevel failed for battery: " + this.PsuId); } else { infoPacket.BatteryChargeLevel = batteryChargeLevelPacket.BatteryChargeLevel; } // Get battery fault indicator BatteryFaultIndicatorPacket batteryFaultIndicatorPacket = GetBatteryFaultIndicator(); if (batteryFaultIndicatorPacket.CompletionCode != CompletionCode.Success) { Tracer.WriteWarning("GetBatteryFaultIndicator failed for battery: " + this.PsuId); } else { infoPacket.FaultDetected = batteryFaultIndicatorPacket.BatteryFault; } // Clear fault indicator after reading it. If the fault is still present, the fault bit will still be asserted in the PSU. CompletionCode returnPacket = new CompletionCode(); returnPacket = ClearBatteryFaultIndicator(); if (returnPacket != CompletionCode.Success) { Tracer.WriteWarning("ClearBatteryFaultIndicator failed for battery: " + this.PsuId); } return infoPacket; }
public static bool Succeeded(CompletionCode completionCode) { return (completionCode == CompletionCode.Success); }
/// <summary> /// Attempts to clear the Battery Fault Indicator. This method /// calls down to the Chassis Manager with SendReceive /// </summary> private CompletionCode ClearBatteryFaultIndicator(byte psuId) { CompletionCode returnPacket = new CompletionCode(); returnPacket = CompletionCode.UnspecifiedError; // Command payload to clear fault indicators byte[] cmdPayload = clearBatteryFaultPayload; try { BatteryFaultIndicatorResponse myResponse = new BatteryFaultIndicatorResponse(); myResponse = (BatteryFaultIndicatorResponse)this.SendReceive(this.PsuDeviceType, this.PsuId, new PsuWordPayloadRequest((byte)PmBusCommand.FAULT_INDICATOR, cmdPayload, (byte)0), typeof(BatteryFaultIndicatorResponse)); if (myResponse.CompletionCode != 0) { returnPacket = (CompletionCode)myResponse.CompletionCode; Tracer.WriteWarning("ClearBatteryFaultIndicator Failure: Completion Code: {0}", returnPacket); } else { returnPacket = CompletionCode.Success; } } catch (System.Exception ex) { returnPacket = CompletionCode.UnspecifiedError; Tracer.WriteError("ClearBatteryFaultIndicator Exception: " + ex); } return returnPacket; }