/// <summary>
        /// Get power reading for all blades
        /// </summary>
        /// <returns>Array of blade responses containing the power reading</returns>
        public GetAllBladesPowerReadingResponse GetAllBladesPowerReading()
        {
            byte MaxbladeCount = (byte)ConfigLoaded.Population;
            GetAllBladesPowerReadingResponse responses = new GetAllBladesPowerReadingResponse();
            responses.completionCode = Contracts.CompletionCode.Unknown;
            responses.statusDescription = string.Empty;
            responses.bladePowerReadingCollection = new List<BladePowerReadingResponse>();
            Contracts.CompletionCode[] bladeInternalResponseCollection = new Contracts.CompletionCode[MaxbladeCount];

            Tracer.WriteUserLog("Invoked GetAllBladesPowerReading()");

            try
            {
                for (int index = 0; index < ConfigLoaded.Population; index++)
                {
                    int bladeId = index + 1;
                    responses.bladePowerReadingCollection.Add(GetBladePowerReading((int)bladeId));

                    // Set the internal blade response to the blade completion code.
                    bladeInternalResponseCollection[index] = responses.bladePowerReadingCollection[index].completionCode;
                }
            }
            catch (Exception ex)
            {
                responses.completionCode = Contracts.CompletionCode.Failure;
                responses.statusDescription = responses.completionCode.ToString() + ": " + ex.Message;
                Tracer.WriteError("GetAllBladesPowerReading Exception" + ex);
                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;
            BladePowerReadingResponse myResponse = new BladePowerReadingResponse();
            GetAllBladesPowerReadingResponse myResponses = new GetAllBladesPowerReadingResponse();
            try
            {
                if (this.argVal.ContainsKey('a'))
                {
                    myResponses = WcsCli2CmConnectionManager.channel.GetAllBladesPowerReading();
                }
                else if (this.argVal.ContainsKey('i'))
                {
                    dynamic mySledId = null;
                    this.argVal.TryGetValue('i', out mySledId);
                    sledId = (uint)mySledId;
                    myResponse = WcsCli2CmConnectionManager.channel.GetBladePowerReading((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.bladePowerReadingCollection.Count(); index++)
                {
                    if (ResponseValidation.ValidateBladeResponse(myResponses.bladePowerReadingCollection[index].bladeNumber, null, myResponses.bladePowerReadingCollection[index], false))
                    {
                        Console.WriteLine(WcsCliConstants.commandSuccess + "Blade " + myResponses.bladePowerReadingCollection[index].bladeNumber + ": Power Reading: " + myResponses.bladePowerReadingCollection[index].powerReading + " Watts");
                    }
                }
            }
            else
            {
                if (ResponseValidation.ValidateBladeResponse(myResponse.bladeNumber, null, myResponse, false))
                {
                    Console.WriteLine(WcsCliConstants.commandSuccess + "Blade " + myResponse.bladeNumber + ": Power Reading: " + myResponse.powerReading + " Watts");
                }
            }
        }
Пример #3
0
        internal override void commandImplementation()
        {
            uint sledId = 1;
            BladePowerReadingResponse myResponse = new BladePowerReadingResponse();
            GetAllBladesPowerReadingResponse myResponses = new GetAllBladesPowerReadingResponse();
            try
            {
                if (this.argVal.ContainsKey('a'))
                {
                    myResponses = WcsCli2CmConnectionManager.channel.GetAllBladesPowerReading();
                }
                else if (this.argVal.ContainsKey('i'))
                {
                    dynamic mySledId = null;
                    this.argVal.TryGetValue('i', out mySledId);
                    sledId = (uint)mySledId;
                    myResponse = WcsCli2CmConnectionManager.channel.GetBladePowerReading((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.bladePowerReadingCollection.Count(); index++)
                {
                    if (myResponses.bladePowerReadingCollection[index].completionCode == Contracts.CompletionCode.Success)
                    {
                        Console.WriteLine("Blade Power Reading" + myResponses.bladePowerReadingCollection[index].bladeNumber + ": " + myResponses.bladePowerReadingCollection[index].powerReading + " Watts");
                    }
                    else if (myResponses.bladePowerReadingCollection[index].completionCode == Contracts.CompletionCode.Unknown)
                    {
                        Console.WriteLine("Blade " + myResponses.bladePowerReadingCollection[index].bladeNumber + ": " + WcsCliConstants.bladeStateUnknown);
                    }
                    else
                    {
                        // Display error if other than success/unknown
                        Console.WriteLine("Blade Power Reading for blade " + myResponses.bladePowerReadingCollection[index].bladeNumber + " failed with completion code: " + myResponses.bladePowerReadingCollection[index].completionCode.ToString());
                    }
                }
            }
            else
            {
                if (myResponse.completionCode == Contracts.CompletionCode.Success)
                {
                    Console.WriteLine("Blade Power Reading" + myResponse.bladeNumber + ": " + myResponse.powerReading + " 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 Reading " + myResponse.bladeNumber + ": " + myResponse.completionCode.ToString());
                }
            }
        }