/// <summary>
        /// Set the appropriate cradle LED based on battery charging state.
        /// </summary>
        /// <param name="chargingState"></param>
        private string SetAppropriateLEDs(ChargingService.ChargingState chargingState)
        {
            String message = string.Empty;

            // try to prevent unnecessary string allocations since this method gets called a lot.
            if (Log.Level >= LogLevel.Trace)
            {
                Log.Trace(Name + ": Updating battery charging state and LEDs.");
            }

            // try to prevent unnecessary string allocations since this method gets called a lot.
            if (Log.Level >= LogLevel.Trace)
            {
                Log.Trace(string.Format("{0}: Current battery charging state is \"{1}\"", Name, chargingState));
            }

            List <Controller.LEDState> positionsList = new List <Controller.LEDState>();

            if (chargingState == ChargingService.ChargingState.Charging)
            {
                positionsList.Add(Controller.LEDState.Green);
                positionsList.Add(Controller.LEDState.Yellow);

                message += GetBlankLines(1) + GetMessage(chargingState.ToString());
            }
            else if (chargingState == ChargingService.ChargingState.TopOff)
            {
                // If instrument is in topoff mode (trickle charge), then
                // still display "Charging" message, but don't show yellow LED.
                positionsList.Add(Controller.LEDState.Green);
                message += GetBlankLines(1) + GetMessage(ChargingService.ChargingState.Charging.ToString());
            }
            else if (chargingState == ChargingService.ChargingState.LowBattery)
            {
                positionsList.Add(Controller.LEDState.Yellow);
                message += GetBlankLines(1) + GetMessage(chargingState.ToString());
            }
            else if (chargingState == ChargingService.ChargingState.Error)
            {
                positionsList.Add(Controller.LEDState.Red);
                message += GetBlankLines(1) + GetMessage(chargingState.ToString());
            }
            else
            {
                positionsList.Add(Controller.LEDState.Green);
            }

            TurnLEDOn(positionsList);

            return(message);
        }
Пример #2
0
		/// <summary>
		/// Test battery charging.
		/// </summary>
		private void TestBatteryCharging()
		{
            if ( !Configuration.DockingStation.IsRechargeable() )
                return;

            if ( !IsInstrumentDocked() )
                return;

            if ( _dockedInstrument == null )
                _dockedInstrument = ReadDockedInstrument();

            if ( _dockedInstrument == null )
            {
                ReportDiagnostic( DiagnosticResources.BATTERY_INSTALLED, false /*battery installed == false*/, true /*failed*/ );
                return;
            }

			// Find the battery code.
			string batteryCode = string.Empty;
            foreach ( InstalledComponent installedComponent in _dockedInstrument.InstalledComponents )
			{
				if ( installedComponent.Component.Type.Code.StartsWith( "BP" ) ) 
					batteryCode = installedComponent.Component.Type.Code;
			}

			// Determine if a battery is installed
			if ( batteryCode == string.Empty )
                ReportDiagnostic( DiagnosticResources.BATTERY_INSTALLED, false /*battery installed == false*/, true /*failed*/ );

			// Check the battery type.
			string message = GetText( DiagnosticResources.INSTRUMENT_BATTERY_CODE_PROMPT, batteryCode , DiagnosticResources.PRESS_LEFT_SUCCESS_PROMPT );
			Controller.Key keyPressed = GetPassFailKey( message );
			ReportDiagnostic( DiagnosticResources.INSTRUMENT_BATTERY_CODE, keyPressed , ( keyPressed != Controller.Key.Left ) );

			// If correct battery type, test charging.
			if ( keyPressed == Controller.Key.Left )
			{
#if !MANUAL
                InstrumentChargingOperation chargingOp = new InstrumentChargingOperation();
                chargingOp.Execute();
                ChargingService.ChargingState chState = chargingOp.ChargingState;
                // Note that "NotCharging" is a passable state. The instrument will report a
                // phase of ChargeComplete if it's receiving charge current from the IDS but
                // isn't currently using it.  This will result in a NotCharging chargingstate.
                // The instrument will report a phase of ChargeOff if it's NOT receiving a
                // charge current from the IDS.  This is what we're interested in detecting 
                // and it results in a ChargingState.Error.
                bool failed = chargingOp.ChargingState == ChargingService.ChargingState.Error;
                ReportDiagnostic( DiagnosticResources.INSTRUMENT_CHARGING,  chState.ToString(), failed );
#else
                message = GetText( DiagnosticResources.INSTRUMENT_CHARGING_PROMPT" , batteryCode , DiagnosticResources.PRESS_LEFT_SUCCESS_PROMPT" );
                keyPressed = GetPassFailKey( message );
                ReportDiagnostic( DiagnosticResources.INSTRUMENT_CHARGING" , keyPressed , ( keyPressed != Controller.Keys.Left ) );
#endif
			}
		}