/// <summary>
        /// Get the bump test gas end point for a sensor.
        /// </summary>
        /// <param name="sensor">The sensor to get the gas for.</param>
        /// <returns>The correct gas end point.</returns>
        /// <exception cref="CorrectBumpTestGasUnavailable">
        /// Thrown when no cylinder is provided for the sensor.
        /// </exception>
        protected GasEndPoint GetSensorGasEndPoint(Sensor sensor)
        {
            #region LogDebug
            if (sensor != null)
            {
                Log.Debug("BumpTest.GetSensorGasEndPoint");
                Log.Debug("Finding appropriate Bump gas for Sensor: " + sensor.Type
                          + ", S/N: " + sensor.Uid
                          + ", CalGas Code: " + sensor.CalibrationGas.Code
                          + ", Conc: " + sensor.CalibrationGasConcentration
                          + ", Measurement: " + ((SensorType)sensor.Type).MeasurementType);
            }
            #endregion

            GasEndPoint endPoint = null;

            Log.Debug("UseExpiredCylinders=" + Configuration.DockingStation.UseExpiredCylinders);

            // If UseExpiredCylinders is true, then we should try and use expired cylinders
            // if there are any. i.e., expired cylinders are "preferred" over non-expired cylinders.
            if (Configuration.DockingStation.UseExpiredCylinders)
            {
                // Get sub-list of available end points that are only the expired cylinders.
                DateTime           localTime    = Configuration.GetLocalTime();
                List <GasEndPoint> gasEndPoints = GasEndPoints.FindAll(gep => gep.Cylinder.ExpirationDate <= localTime);
                Log.Debug(string.Format("Looking for an expired cylinder to use ({0} expired candidates)....", gasEndPoints.Count));
                // See if we can find an appropriate gas to use that's in this expired end points list.
                endPoint = GetSensorGasEndPoint(sensor, gasEndPoints);
                // If we didn't find an expired cylinder to use, we need to see if there's an un-expired cylinder to use.
                if (endPoint == null)
                {
                    gasEndPoints = GasEndPoints.FindAll(gep => gep.Cylinder.ExpirationDate > localTime);
                    Log.Debug(string.Format("No expired cylinder found.  Looking for an unexpired cylinder ({0} unexpired candidates)....", gasEndPoints.Count));
                    endPoint = GetSensorGasEndPoint(sensor, gasEndPoints);
                }
            }
            else
            {
                endPoint = GetSensorGasEndPoint(sensor, GasEndPoints);
            }

            if (endPoint == null)
            {
                Log.Debug("NO APPROPRIATE BUMP GAS FOUND!");
            }

            return(endPoint);
        }
        private void ConstructorInit(PurgeType purgeType, InstrumentController instrumentController, List <GasEndPoint> gasEndPoints, InstrumentGasResponseEvent gasResponseEvent)
        {
            Log.Assert(instrumentController != null, "instrumentController cannot be null");

            _instrumentController = instrumentController;
            _purgeType            = purgeType;

            _returnGasResponseEvent = gasResponseEvent;

            // clone the supplied GasEndPoints
            foreach (GasEndPoint currentGasEndPoint in gasEndPoints)
            {
                GasEndPoint purgeGasEndPoint = (GasEndPoint)currentGasEndPoint.Clone();
                GasEndPoints.Add(purgeGasEndPoint);
            }
        }