Exemplo n.º 1
0
        public void NextFrame(int frameNo, MovementType movementType, bool isLastFrame, AstroImage astroImage, int firstFrameInIntegrationPeriod, string fileName)
        {
            m_CurrentFrameNo = frameNo;

            if (m_OperationState == SpectroscopyState.RunningMeasurements)
            {
                if (m_FirstMeasuredFrame == null)
                {
                    m_FirstMeasuredFrame = m_CurrentFrameNo;
                    if (m_VideoController.HasEmbeddedTimeStamps())
                    {
                        m_FirstFrameTimeStamp = m_VideoController.GetCurrentFrameTime();
                    }
                    else if (m_VideoController.HasSystemTimeStamps())
                    {
                        m_FirstFrameTimeStamp = m_VideoController.GetCurrentFrameTime();
                    }
                    m_FrameBitmapPixels = astroImage.Pixelmap.DisplayBitmapPixels;
                }

                m_Tracker.NextFrame(frameNo, astroImage);
                if (m_Tracker.IsTrackedSuccessfully)
                {
                    TrackedObject trackedStar = m_Tracker.TrackedStar;
                    SelectedStar = trackedStar.Center;

                    m_Reader = new SpectraReader(astroImage, SelectedStarBestAngle, m_SpectroscopyController.SpectraReductionContext.PixelValueCoefficient);

                    Spectra thisFrameSpectra = m_Reader.ReadSpectra(
                        trackedStar.ThisFrameX,
                        trackedStar.ThisFrameY,
                        m_SpectroscopyController.SpectraReductionContext.MeasurementAreaWing,
                        m_SpectroscopyController.SpectraReductionContext.BackgroundAreaWing,
                        m_SpectroscopyController.SpectraReductionContext.BackgroundAreaGap,
                        m_SpectroscopyController.SpectraReductionContext.BackgroundMethod);

                    thisFrameSpectra.ZeroOrderFWHM = trackedStar.PSFFit != null ? (float)trackedStar.PSFFit.FWHM : float.NaN;

                    m_AllFramesSpectra.Add(thisFrameSpectra);
                }

                if (isLastFrame || m_CancelMeasurementsRequested || m_AllFramesSpectra.Count >= m_SpectroscopyController.SpectraReductionContext.FramesToMeasure)
                {
                    m_FramePlayer.Stop();

                    m_MasterSpectra = m_SpectroscopyController.ComputeResult(
                        m_AllFramesSpectra,
                        m_SpectroscopyController.SpectraReductionContext.FrameCombineMethod,
                        m_SpectroscopyController.SpectraReductionContext.UseFineAdjustments,
                        m_SpectroscopyController.SpectraReductionContext.AlignmentAbsorptionLinePos);

                    m_AllFramesSpectra.Clear();

                    m_MasterSpectra.MeasurementInfo = m_SpectroscopyController.GetMeasurementInfo();
                    m_MasterSpectra.MeasurementInfo.FirstMeasuredFrame  = m_FirstMeasuredFrame.Value;
                    m_MasterSpectra.MeasurementInfo.LastMeasuredFrame   = m_CurrentFrameNo;
                    m_MasterSpectra.MeasurementInfo.FirstFrameTimeStamp = m_FirstFrameTimeStamp;
                    if (m_VideoController.HasEmbeddedTimeStamps())
                    {
                        m_MasterSpectra.MeasurementInfo.LastFrameTimeStamp = m_VideoController.GetCurrentFrameTime();
                    }
                    else if (m_VideoController.HasSystemTimeStamps())
                    {
                        m_MasterSpectra.MeasurementInfo.LastFrameTimeStamp = m_VideoController.GetCurrentFrameTime();
                    }

                    FrameStateData frameStatus = m_VideoController.GetCurrentFrameState();
                    m_MasterSpectra.MeasurementInfo.Gain            = frameStatus.Gain;
                    m_MasterSpectra.MeasurementInfo.ExposureSeconds = m_SpectroscopyController.SpectraReductionContext.ExposureSeconds;

                    m_MasterSpectra.MeasurementInfo.FrameBitmapPixels = m_FrameBitmapPixels;

                    m_SpectroscopyController.PopulateMasterSpectraObservationDetails(m_MasterSpectra);

                    m_OperationState = SpectroscopyState.DisplayingMeasurements;
                    m_ControlPanel.MeasurementsFinished();
                    DisplaySpectra();
                }

                Application.DoEvents();
            }
        }