/// <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 } }
/// <summary> /// Test instrument ping. /// </summary> /// <remarks> /// Attempt to ping the instrument and read its settings. /// </remarks> private bool TestInstrumentCommunication() { if ( !IsInstrumentDocked() ) return false; _dockedInstrument = ReadDockedInstrument(); ReportDiagnostic( DiagnosticResources.INSTRUMENT_PING, _dockedInstrument != null, _dockedInstrument == null ); return _dockedInstrument != null; }
internal List <GasEndPoint> GetGasEndPoints(string eventCode, DockingStationAction dsAction, StringBuilder explanation, List <string> explanationCodes, List <string> errorCodes) { Log.Debug(string.Format("{0}.GetGasEndPoints, {1}", Name, eventCode)); //explanationCodes.Clear(); //errorCodes.Clear(); // SGF 20-Feb-2013 INS-3821 ISC.iNet.DS.DomainModel.Instrument dockedInstrument = Master.Instance.SwitchService.Instrument; DockingStation dockingStation = Configuration.DockingStation; List <GasEndPoint> gasEndPoints = new List <GasEndPoint>(); foreach (InstalledComponent installedComponent in dockedInstrument.InstalledComponents) { if (!(installedComponent.Component is Sensor)) { continue; } Sensor sensor = (Sensor)installedComponent.Component; if (!sensor.Enabled) { Log.Info(string.Format("{0}: Ignoring disabled sensor {1}", Name, sensor.Uid)); continue; } // SGF 21-May-2012 INS-3078 -- Comment out the following if statement //if (!GasOperationsSupported(sensor)) //{ // Log.Debug( string.Format( "{0}.GasOperationsSupported returned False for sensor {1}. Ignoring sensor.", Name, sensor.SerialNumber ) ); // continue; //} if (sensor.CalibrationGas.Code.Length == 0) { throw new ApplicationException("Sensor " + sensor.Uid + " has null calibration gas code."); } // SGF 03-Nov-2010 Single Sensor Cal and Bump if (dsAction is InstrumentGasAction) { InstrumentGasAction gasAction = (InstrumentGasAction)dsAction; if (gasAction.ComponentCodes.Count != 0 && !gasAction.ComponentCodes.Contains(sensor.Type.Code)) { Log.Debug(string.Format("{0}: Component type {1} is not included in the defined list of components to test. Ignoring sensor.", Name, sensor.Type.Code)); continue; } } Log.Debug(string.Format("{0}: Looking for sensor {1}'s cal gas ({2})", Name, sensor.Uid, sensor.CalibrationGas.Code)); _empty = _expired = _gasFound = _freshFound = _zeroFound = false; _gasNeeded = true; // SGF 21-May-2012 INS-3078 // INS-8630 RHP v7.5 clear the messages for every installed component to avoid confusion explanationCodes.Clear(); errorCodes.Clear(); // SGF 20-Feb-2013 INS-3821 // Loop thru the cylinders for the docking station and if the cylinder contains the gas that // the sensor needs, add that cylinder as a gas end point in the docking station action. FindInstalledCylinderGases(eventCode, gasEndPoints, dockingStation, installedComponent, explanation, explanationCodes, errorCodes); if (!_freshFound && !_zeroFound) { // Present which type of air should be, but is not, available. If the port1 restrictions // only allow for zero air, present 'ZERO AIR'; otherwise, present 'FRESH AIR'. if (Configuration.DockingStation.Port1Restrictions == PortRestrictions.ZeroAir) { explanationCodes.Add("ZEROAIR"); errorCodes.Add(string.Format("{0} ({1})", "ZEROAIR", GasCode.O2)); // SGF 20-Feb-2013 INS-3821 } else if (Configuration.DockingStation.Port1Restrictions == PortRestrictions.FreshAir) { GasType gasType = GasType.Cache[GasCode.FreshAir]; if (gasType != null) { explanationCodes.Add(gasType.Symbol); errorCodes.Add(string.Format("{0} ({1})", gasType.Symbol, gasType.Code)); // SGF 20-Feb-2013 INS-3821 } } else // SGF 19-Jan-2012 INS-1913 & INS-1914 { // either fresh air or zero air is allowed; present which type is connected, if something is connected. GasEndPoint gasEndPoint = dockingStation.GasEndPoints[0]; Cylinder cyl = gasEndPoint.Cylinder; if (cyl.IsZeroAir) { explanationCodes.Add("ZEROAIR"); errorCodes.Add(string.Format("{0} ({1})", "ZEROAIR", GasCode.O2)); // SGF 20-Feb-2013 INS-3821 } else //suresh 14-Mar-2012 INS-4427 (DEV) { // If port 1 cylinder is not Zero Air then we report that 'Fresh air' is unavailable GasType gasType = GasType.Cache[GasCode.FreshAir]; if (gasType != null) { explanationCodes.Add(gasType.Symbol); errorCodes.Add(string.Format("{0} ({1})", gasType.Symbol, gasType.Code)); // SGF 20-Feb-2013 INS-3821 } } } if (_expired) { explanationCodes.Add("Expired"); errorCodes.Add("Expired"); // INS-8630 RHP v7.5 - Notify iNet on the expired state } else if (_empty) { explanationCodes.Add(PressureLevel.Empty.ToString()); errorCodes.Add(PressureLevel.Empty.ToString()); // INS-8630 RHP v7.5 - Notify iNet on the empty state } explanation.Append("Fresh air not found for sensor " + sensor.Uid + '\n'); Log.Debug(string.Format("{0}: Returning nothing: gasFound={1}, freshFound={2}, expired={3}, empty={4}", Name, _gasFound, _freshFound, _expired, _empty)); return(new List <GasEndPoint>()); } if (_gasNeeded && !_gasFound) // SGF 21-May-2012 INS-3078 -- add the '_gasNeeded' clause to the if-condition { // If gas not found, IDS needs the symbol for that gas for display on its LCD. // Look it up in our cache. For Fresh Air, we just return the gas code; // The IDS knows to look for that as a special case. if (sensor.CalibrationGas.Code == GasCode.FreshAir) { GasType gasType = GasType.Cache[GasCode.FreshAir]; if (gasType != null) { explanationCodes.Add(gasType.Symbol); errorCodes.Add(string.Format("{0} ({1})", gasType.Symbol, gasType.Code)); // SGF 20-Feb-2013 INS-3821 } } // DSW-1758 RHP v9.6.1 - Added (! (_expired || _empty) ) since gas symbol has already been added to explanationCodes for Empty/Expired states. else if (!(_expired || _empty)) { // If we're doing a bump test, and this is a combustible sensor either in LEL or PPM mode, // and docking station has a CombustibleBumpTestGas setting, then make sure we report that the // gas type not found is the CombustibleBumpTestGas and not the sensor cal gas. string sensorGasCode = sensor.CalibrationGas.Code; if ((eventCode == EventCode.BumpTest) && (sensor.Type.Code == SensorCode.CombustibleLEL || sensor.Type.Code == SensorCode.CombustiblePPM) && (Configuration.DockingStation.CombustibleBumpTestGas.Length > 0)) { sensorGasCode = Configuration.DockingStation.CombustibleBumpTestGas; } GasType gasType = GasType.Cache[sensorGasCode]; if (gasType != null) { explanationCodes.Add(gasType.Symbol); errorCodes.Add(string.Format("{0} ({1})", gasType.Symbol, gasType.Code)); // SGF 20-Feb-2013 INS-3821 } } if (_expired) { explanationCodes.Add("Expired"); errorCodes.Add("Expired"); // INS-8630 RHP v7.5 - Notify iNet on the expired state } else if (_empty) { explanationCodes.Add(PressureLevel.Empty.ToString()); errorCodes.Add(PressureLevel.Empty.ToString()); // INS-8630 RHP v7.5 - Notify iNet on the empty state } explanation.Append("Could not find cylinder needed for sensor " + sensor.Uid + ", CalGasCode=\"" + sensor.CalibrationGas.Code + "\" ("); for (int i = 0; i < explanationCodes.Count; i++) { if (i > 0) { explanation.Append(" "); } explanation.Append(explanationCodes[i]); } explanation.Append(")\n"); Log.Debug(string.Format("{0}: Returning nothing: gasFound={1}, freshFound={2}, expired={3}, empty={4}", Name, _gasFound, _freshFound, _expired, _empty)); return(new List <GasEndPoint>()); } // Zero air is required for CO2 sensors; Only zero air is used to zero CO2, never fresh air. if ((sensor.CalibrationGas.Code == GasCode.CO2) && !_zeroFound) { GasType gasType = GasType.Cache[GasCode.O2]; if (gasType != null) { explanationCodes.Add("ZEROAIR"); // SGF 5-Feb-2013 INS-3837 errorCodes.Add(string.Format("{0} ({1})", "ZEROAIR", GasCode.O2)); // SGF 20-Feb-2013 INS-3821 } if (_expired) { explanationCodes.Add("Expired"); } else if (_empty) { explanationCodes.Add(PressureLevel.Empty.ToString()); } explanation.Append("Zero air not found for CO2 sensor " + sensor.Uid + '\n'); Log.Debug(string.Format("{0}: Returning nothing: gasFound={1}, freshFound={2}, expired={3}, empty={4}", Name, _gasFound, _freshFound, _expired, _empty)); return(new List <GasEndPoint>());; } } Log.Debug(string.Format("{0}.GetGasEndPoints returned {1} gas end points", Name, gasEndPoints.Count)); return(gasEndPoints); }