public void AddData(XRayEnergyEnum energy, PixelDataType dataType, Pixel[] data) { if (dataType == PixelDataType.Air) { AddAirData(energy, data); } else if (dataType == PixelDataType.Dark) { AddDarkData(energy, data); } }
public bool IsComplete(XRayEnergyEnum energy, PixelDataType dataType) { bool ret = false; if (_calibrationData.ContainsKey(energy)) { if (dataType == PixelDataType.Air) { ret = _calibrationData[energy].IsAirDataComplete; } else if (dataType == PixelDataType.Dark) { ret = _calibrationData[energy].IsDarkDataComplete; } } return ret; }
private void CollectData(PixelDataType dataType) { bool once = false; List<Pixel[]> highDataList = new List<Pixel[]>(); List<Pixel[]> lowDataList = new List<Pixel[]>(); LINAC_ENERGY_TYPE_VALUE linacEnergy = _dataAccess.OpcTags.LINAC_ENERGY_TYPE_STATE.Value; _IsCollectingData = true; Timer collectionTimer = new Timer(new TimerCallback(FailedCalibration), dataType.ToString() + " Data", _dataCollectionTableTimeout, Timeout.Infinite); _logger.LogInfo("Starting data collection loop."); _logger.LogInfo("Linac energy is " + linacEnergy.ToString()); while (_IsPerformingCalibration && _IsCollectingData) { DataInfo dataInfo; //_logger.LogInfo("Try to take raw data."); if (_rawDataColl.TryTake(out dataInfo, 500)) { CalibrationDataCollection collection; XRayEnergyEnum energy = (dataInfo.XRayInfo.Energy == XRayEnergyEnum.HighEnergy) ? XRayEnergyEnum.HighEnergy : XRayEnergyEnum.LowEnergy; //_logger.LogInfo("Data line energy is " + energy.ToString() + " and Linac energy is " + linacEnergy.ToString()); switch(linacEnergy) { case LINAC_ENERGY_TYPE_VALUE.Dual: collection = _DualDataCollection[PulseWidth.PulseWidth1]; break; case LINAC_ENERGY_TYPE_VALUE.High: collection = _HighDataCollection[PulseWidth.PulseWidth2]; break; case LINAC_ENERGY_TYPE_VALUE.Low: collection = _LowDataCollection[PulseWidth.PulseWidth3]; break; #if LinacLowDose case LINAC_ENERGY_TYPE_VALUE.LowDose: collection = _LowDoseDataCollection[PulseWidth.PulseWidth3]; break; #endif default: collection = _DualDataCollection[PulseWidth.PulseWidth1]; break; } collection.AddData(energy, dataType, dataInfo.LineData); if (once == false) { _logger.LogInfo("Adding Data of " + energy.ToString() + ", " + dataType.ToString()); once = true; } _IsCollectingData = !collection.IsComplete(energy, dataType); //_logger.LogInfo("Still collecting data? " + _IsCollectingData); } } collectionTimer.Dispose(); }
public void Add(PixelDataType dataType, Pixel[] data) { if (dataType == PixelDataType.Air) { if (AppConfiguration.CalibrationDataLines == _CollectedAirData.Count) { _CollectedAirData.RemoveAt(0); } _CollectedAirData.Add(data); _IsAirProcessed = false; _IsScaleFactorProcessed = false; } else if (dataType == PixelDataType.Dark) { if (AppConfiguration.CalibrationDataLines == _CollectedDarkData.Count) { _CollectedDarkData.RemoveAt(0); } _CollectedDarkData.Add(data); _IsDarkProcessed = false; _IsScaleFactorProcessed = false; } }