internal override void commandImplementation() { uint sledId = 1; BladePowerLimitResponse myResponse = new BladePowerLimitResponse(); GetAllBladesPowerLimitResponse myResponses = new GetAllBladesPowerLimitResponse(); try { if (this.argVal.ContainsKey('a')) { myResponses = WcsCli2CmConnectionManager.channel.GetAllBladesPowerLimit(); } else if (this.argVal.ContainsKey('i')) { dynamic mySledId = null; this.argVal.TryGetValue('i', out mySledId); sledId = (uint)mySledId; myResponse = WcsCli2CmConnectionManager.channel.GetBladePowerLimit((int)mySledId); } } catch (Exception ex) { SharedFunc.ExceptionOutput(ex); return; } if ((this.argVal.ContainsKey('a') && myResponses == null) || myResponse == null) { Console.WriteLine(WcsCliConstants.serviceResponseEmpty); return; } if (this.argVal.ContainsKey('a')) { for (int index = 0; index < myResponses.bladePowerLimitCollection.Count(); index++) { if (ResponseValidation.ValidateBladeResponse(myResponses.bladePowerLimitCollection[index].bladeNumber, null, myResponses.bladePowerLimitCollection[index], false)) { string activeStr = (myResponses.bladePowerLimitCollection[index].isPowerLimitActive)? ", Active." : ", Not active."; Console.WriteLine(WcsCliConstants.commandSuccess + "Blade " + myResponses.bladePowerLimitCollection[index].bladeNumber + ": Power Limit: " + myResponses.bladePowerLimitCollection[index].powerLimit + " Watts" + activeStr); } } } else { if (ResponseValidation.ValidateBladeResponse(myResponse.bladeNumber, null, myResponse, false)) { string activeStr = (myResponse.isPowerLimitActive) ? ", Active." : ", Not active."; Console.WriteLine(WcsCliConstants.commandSuccess + "Blade " + myResponse.bladeNumber + ": Power Limit: " + myResponse.powerLimit + " Watts" + activeStr); } } }
/// <summary> /// Get power limit value for all blades /// </summary> /// <returns>Array of blade responses containing the blade power limit values</returns> public GetAllBladesPowerLimitResponse GetAllBladesPowerLimit() { byte MaxbladeCount = (byte)ConfigLoaded.Population; GetAllBladesPowerLimitResponse responses = new GetAllBladesPowerLimitResponse(); responses.completionCode = Contracts.CompletionCode.Unknown; responses.statusDescription = string.Empty; responses.bladePowerLimitCollection = new List<BladePowerLimitResponse>(); Contracts.CompletionCode[] bladeInternalResponseCollection = new Contracts.CompletionCode[MaxbladeCount]; responses.bladePowerLimitCollection = new List<BladePowerLimitResponse>(); Tracer.WriteUserLog("Invoked GetAllBladesPowerLimit()"); try { for (int index = 0; index < ConfigLoaded.Population; index++) { int bladeId = index + 1; responses.bladePowerLimitCollection.Add(GetBladePowerLimit(bladeId)); // Set the internal blade response to the blade completion code. bladeInternalResponseCollection[index] = responses.bladePowerLimitCollection[index].completionCode; } } catch (Exception ex) { responses.completionCode = Contracts.CompletionCode.Failure; responses.statusDescription = responses.completionCode.ToString() + ": " + ex.Message; Tracer.WriteError("GetAllBladesPowerLimit Exception"); return responses; } Contracts.ChassisResponse varResponse = new Contracts.ChassisResponse(); varResponse = ChassisManagerUtil.ValidateAllBladeResponse(bladeInternalResponseCollection); responses.completionCode = varResponse.completionCode; responses.statusDescription = varResponse.statusDescription; return responses; }
internal override void commandImplementation() { uint sledId = 1; BladePowerLimitResponse myResponse = new BladePowerLimitResponse(); GetAllBladesPowerLimitResponse myResponses = new GetAllBladesPowerLimitResponse(); try { if (this.argVal.ContainsKey('a')) { myResponses = WcsCli2CmConnectionManager.channel.GetAllBladesPowerLimit(); } else if (this.argVal.ContainsKey('i')) { dynamic mySledId = null; this.argVal.TryGetValue('i', out mySledId); sledId = (uint)mySledId; myResponse = WcsCli2CmConnectionManager.channel.GetBladePowerLimit((int)mySledId); } } catch (Exception ex) { SharedFunc.ExceptionOutput(ex); return; } if ((this.argVal.ContainsKey('a') && myResponses == null) || myResponse == null) { Console.WriteLine(WcsCliConstants.serviceResponseEmpty); return; } if (this.argVal.ContainsKey('a')) { for (int index = 0; index < myResponses.bladePowerLimitCollection.Count(); index++) { if (myResponses.bladePowerLimitCollection[index].completionCode == Contracts.CompletionCode.Success) { Console.WriteLine("Blade Power Limit" + myResponses.bladePowerLimitCollection[index].bladeNumber + ": " + myResponses.bladePowerLimitCollection[index].powerLimit + " Watts"); } else if (myResponses.bladePowerLimitCollection[index].completionCode == Contracts.CompletionCode.Unknown) { Console.WriteLine("Blade " + myResponses.bladePowerLimitCollection[index].bladeNumber + ": " + WcsCliConstants.bladeStateUnknown); } else { // Display error if other than success/unknown Console.WriteLine("Blade Power Limit for blade " + myResponses.bladePowerLimitCollection[index].bladeNumber + " failed with completion code: " + myResponses.bladePowerLimitCollection[index].completionCode.ToString()); } } } else { if (myResponse.completionCode == Contracts.CompletionCode.Success) { Console.WriteLine("Blade Power Limit" + myResponse.bladeNumber + ": " + myResponse.powerLimit + " Watts"); } else if (myResponse.completionCode == Contracts.CompletionCode.Unknown) { Console.WriteLine("Blade " + myResponse.bladeNumber + ": " + WcsCliConstants.bladeStateUnknown); } else { // Display error if other than success/unknown Console.WriteLine("Blade Power Limit " + myResponse.bladeNumber + ": " + myResponse.completionCode.ToString()); } } }