private void SaveDataToPXE()
        {
            _logger.LogInfo("Calibration saving data to pxe...");

            PxeWriteAccess pxeWriteAccess = new PxeWriteAccess();

            if (!Directory.Exists(_calibrationStorageLocation))
            {
                Directory.CreateDirectory(_calibrationStorageLocation);
            }

            //foreach (PulseWidth pulseWidth in Enum.GetValues(typeof(PulseWidth)))
            //{
                foreach (LINAC_ENERGY_TYPE_VALUE energy in Enum.GetValues(typeof(LINAC_ENERGY_TYPE_VALUE)))
                {
                    try
                    {
                        if (energy == LINAC_ENERGY_TYPE_VALUE.LowDose)
                            continue;

                        PulseWidth pulseWidth;

                        switch(energy)
                        {
                            case LINAC_ENERGY_TYPE_VALUE.Dual:
                                pulseWidth = PulseWidth.PulseWidth1;
                                break;
                            case LINAC_ENERGY_TYPE_VALUE.High:
                                pulseWidth = PulseWidth.PulseWidth2;
                                break;
                            case LINAC_ENERGY_TYPE_VALUE.Low:
                                pulseWidth = PulseWidth.PulseWidth3;
                                break;
#if LinacLowDose
                            case LINAC_ENERGY_TYPE_VALUE.LowDose:
                                pulseWidth = PulseWidth.PulseWidth3;
                                break;
#endif
                            default:
                                pulseWidth = PulseWidth.PulseWidth1;
                                break;
                        }

                        string pxeFile = Path.Combine(_calibrationStorageLocation, "Calibration_" + energy.ToString() + "_" + pulseWidth.ToString() + ".pxe");

                        if (File.Exists(pxeFile))
                        {
                            File.Delete(pxeFile);
                        }

                        pxeWriteAccess.CreatePXE(pxeFile);

                        if (energy == LINAC_ENERGY_TYPE_VALUE.Dual || energy == LINAC_ENERGY_TYPE_VALUE.High)
                        {
                            pxeWriteAccess.CreateHiPXEHeader(1, (uint)GetCalibrationCollection(energy, pulseWidth).GetScaleFactor(XRayEnergyEnum.HighEnergy).Length);
                            pxeWriteAccess.WriteHighEngDarkSample(PixelConverter.Convert(GetCalibrationCollection(energy, pulseWidth).GetDarkData(XRayEnergyEnum.HighEnergy)));
                            pxeWriteAccess.WriteHighEngAirSample(PixelConverter.Convert(GetCalibrationCollection(energy, pulseWidth).GetAirData(XRayEnergyEnum.HighEnergy)));
                        }

                        if (energy == LINAC_ENERGY_TYPE_VALUE.Dual
                                || energy == LINAC_ENERGY_TYPE_VALUE.Low
#if LinacLowDose
                                || energy == LINAC_ENERGY_TYPE_VALUE.LowDose
#endif
                            )
                        {
                            pxeWriteAccess.CreateLoPXEHeader(1, (uint)GetCalibrationCollection(energy, pulseWidth).GetScaleFactor(XRayEnergyEnum.LowEnergy).Length);
                            pxeWriteAccess.WriteLowEngDarkSample(PixelConverter.Convert(GetCalibrationCollection(energy, pulseWidth).GetDarkData(XRayEnergyEnum.LowEnergy)));
                            pxeWriteAccess.WriteLowEngAirSample(PixelConverter.Convert(GetCalibrationCollection(energy, pulseWidth).GetAirData(XRayEnergyEnum.LowEnergy)));
                        }

                        pxeWriteAccess.ClosePXEWrite();
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex);
                    }
                //}
            }

            _logger.LogInfo("Calibration saving data to pxe done.");
        }
Beispiel #2
0
        private void XRayDataStateStopBtn_Checked(object sender, RoutedEventArgs eventArguments)
        {
            try { AccessDetectorsData.Detectors.SetDataTransferMode(dataTransferMode.Stop); }
            catch (Exception ex) { AnomalyShow(ex); }

            try
            {
                PxeWriteAccess pxeAccess = new PxeWriteAccess();
                pxeAccess.CreatePXE("Test" + DateTime.Now.Ticks.ToString() + ".pxe");
                pxeAccess.CreatePXEHeader(1, (uint)AccessDetectorsData.Detectors.RawDataCollection.Count, (uint)AccessDetectorsData.Detectors.PixelsPerColumn);
                while (AccessDetectorsData.Detectors.RawDataCollection.Count > 0)
                {
                    DataInfo information = AccessDetectorsData.Detectors.RawDataCollection.Take();
                    float[] data = PixelConverter.Convert(information.LineData);
                    pxeAccess.WriteDataLines(1, data, 1);
                }
                pxeAccess.ClosePXEWrite();
            }
            catch (Exception ex) { AnomalyShow(ex); }
        }