/// <summary> /// Get the calibration gas concentration. /// </summary> /// <param name="sensor">The sensor to get the concentration for.</param> /// <param name="endPoint">The gas end point that contains the gas.</param> protected double GetCalibrationGasConcentration(InstalledComponent installedComponent, GasEndPoint endPoint) { const string func = "GetCalibrationGasConcentration: "; Sensor sensor = (Sensor)installedComponent.Component; double availableConcentration = DomainModelConstant.NullDouble; string gasCode = sensor.CalibrationGas.Code; double lelMultiplier = GasType.Cache[gasCode].LELMultiplier; MeasurementType sensorMeasurementType = ((SensorType)sensor.Type).MeasurementType; Cylinder cylinder = endPoint.Cylinder; // Get the cylinder. // For nitrogen cylinder's, being used for O2 bumps, we assume 0% O2. if ((gasCode == GasCode.O2) && cylinder.ContainsOnlyGas(GasCode.N2)) { availableConcentration = 0.0d; } else { // Determine the gas concentration of the gas to use. foreach (GasConcentration gasCon in cylinder.GasConcentrations) { if (gasCon.Type.Code == gasCode) { availableConcentration = gasCon.Concentration; break; } else if ((gasCode == GasCode.O2) && (gasCon.Type.Code == GasCode.FreshAir)) { availableConcentration = 209000d; break; } } } // If we didn't find anything with the gas. if (availableConcentration == DomainModelConstant.NullDouble) { throw new CorrectBumpTestGasUnavailable(gasCode); } Log.Debug("Sensor cal gas concentration: " + sensor.CalibrationGasConcentration + " res: " + sensor.Resolution); // Check the measurement type for how to multiply the concentration. if (sensorMeasurementType == MeasurementType.LEL) { availableConcentration *= lelMultiplier; availableConcentration = Master.Instance.ControllerWrapper.Round(availableConcentration, 0); } else if (sensorMeasurementType != MeasurementType.PPM) { availableConcentration /= 10000; } if (availableConcentration == sensor.CalibrationGasConcentration) { return(sensor.CalibrationGasConcentration); // Its the correct concentration. } availableConcentration = Master.Instance.ControllerWrapper.Round(availableConcentration, 2); Log.Debug("gas: " + gasCode + " new conc: " + availableConcentration); // INS- RHP v7.6 - For MX6v4.4 and above, Set the sensor's calibration gas concentration to // match the concentration of gas end point that contains the gas. //if (_returnEvent.DockedInstrument.Type == DeviceType.MX6 && new Version(_returnEvent.DockedInstrument.SoftwareVersion) >= _MX6_v44 // && availableConcentration > 0.0d && sensor.BumpCriterionType != CriterionType.PPMLimit) //{ // // If sensor is %vol, and it has a zero resolution, then we want to round the concentration // // up to the next integer value. e.g., if cylinder contains 2.1% gas, then we want to round // // it to 3. // if (sensorMeasurementType == MeasurementType.VOL && sensor.Resolution == 1.0) // { // Log.Debug(string.Format("{0}Sensor is %VOL and has resolution of zero decimals. Rounding {1} up to next integer", // func, availableConcentration)); // availableConcentration = Math.Ceiling(availableConcentration); // } // Log.Debug(string.Format("{0}SETTING SENSOR FROM CONCENTRATION {1} TO {2}, (res={3})", func, sensor.CalibrationGasConcentration, availableConcentration, sensor.Resolution)); // // Set the sensor's calibration gas concentration. // _instrumentController.SetSensorCalGasConcentration(installedComponent.Position, availableConcentration, sensor.Resolution); // Log.Debug(string.Format("{0}NEW CONCENTRATION: {1}", func, _instrumentController.GetSensorCalGasConcentration(installedComponent.Position, sensor.Resolution))); //} return(availableConcentration); }