private FrameStateData GetCurrentFrameState(Adv.AdvFrameInfo frameInfo)
        {
            if (frameInfo != null)
            {
                var rv = new FrameStateData();
                rv.VideoCameraFrameId  = (long)frameInfo.VideoCameraFrameId;
                rv.CentralExposureTime = frameInfo.UtcMidExposureTime;
                rv.SystemTime          = frameInfo.SystemTimestamp;

                rv.ExposureInMilliseconds = frameInfo.Exposure / 10.0f;

                rv.NumberIntegratedFrames = 0;
                rv.NumberStackedFrames    = 0;

                int almanacStatus = frameInfo.GPSAlmanacStatus;
                int almanacOffset = frameInfo.GPSAlmanacOffset;

                //if (!frameInfo.AlmanacStatusIsGood && m_AlamanacOffsetLastFrameIsGood)
                //{
                //    // When the current almanac is not good, but last frame is, then apply the known almanac offset automatically
                //    almanacOffset = m_AlmanacOffsetLastFrame;
                //    rv.CentralExposureTime = rv.CentralExposureTime.AddSeconds(m_AlmanacOffsetLastFrame);
                //    almanacStatus = 2; // Certain
                //}

                rv.Gain  = frameInfo.Gain;
                rv.Gamma = frameInfo.Gamma;
                //rv.Temperature = frameInfo.Temperature;
                rv.Offset = frameInfo.Offset;

                rv.NumberSatellites = frameInfo.GPSTrackedSattelites;

                rv.AlmanacStatus = AdvStatusValuesHelper.TranslateGpsAlmanacStatus(almanacStatus);

                rv.AlmanacOffset = AdvStatusValuesHelper.TranslateGpsAlmanacOffset(almanacStatus, almanacOffset, almanacStatus > 0);

                rv.GPSFixStatus = frameInfo.GPSFixStatus.ToString("#");

                rv.Messages = string.Empty;

                if (frameInfo.HasErrorMessage)
                {
                    rv.Messages = Convert.ToString(frameInfo.Status["Error"]);
                }

                rv.IsVtiOsdCalibrationFrame = frameInfo.Status.ContainsKey("FRAME-TYPE") && Convert.ToString(frameInfo.Status["FRAME-TYPE"]) == "VTI-OSD-CALIBRATION";

                return(rv);
            }
            else
            {
                return(new FrameStateData());
            }
        }
Ejemplo n.º 2
0
        private FrameStateData AdvFrameInfoToFrameStateData(AdvFrameInfo frameInfo, int frameIndex)
        {
            if (frameInfo != null)
            {
                var rv = new FrameStateData();
                rv.VideoCameraFrameId     = frameInfo.VideoCameraFrameId;
                rv.CentralExposureTime    = frameInfo.MiddleExposureTimeStamp;
                rv.SystemTime             = frameInfo.SystemTime;
                rv.EndFrameNtpTime        = frameInfo.EndExposureNtpTimeStamp;
                rv.NtpTimeStampError      = frameInfo.NtpTimeStampError;
                rv.ExposureInMilliseconds = frameInfo.Exposure10thMs / 10.0f;

                rv.NumberIntegratedFrames = (int)frameInfo.IntegratedFrames;

                int almanacStatus = frameInfo.GPSAlmanacStatus;
                int almanacOffset = frameInfo.GetSignedAlamancOffset();

                if (!frameInfo.AlmanacStatusIsGood && frameInfo.AlmanacStatusIsGood)
                {
                    // When the current almanac is not good, but last frame is, then apply the known almanac offset automatically
                    almanacOffset          = frameInfo.GPSAlmanacOffset;
                    rv.CentralExposureTime = rv.CentralExposureTime.AddSeconds(frameInfo.GPSAlmanacOffset);
                    almanacStatus          = 2;            // Certain
                }


                rv.Gain        = frameInfo.Gain;
                rv.Gamma       = frameInfo.Gamma;
                rv.Temperature = frameInfo.Temperature;
                rv.Offset      = frameInfo.Offset;

                rv.NumberSatellites = frameInfo.GPSTrackedSattelites;

                rv.AlmanacStatus = AdvStatusValuesHelper.TranslateGpsAlmanacStatus(almanacStatus);

                rv.AlmanacOffset = AdvStatusValuesHelper.TranslateGpsAlmanacOffset(almanacStatus, almanacOffset, almanacStatus > 0);

                rv.GPSFixStatus = frameInfo.GPSFixStatus.ToString("#");

                rv.Messages = string.Empty;
                if (frameInfo.SystemErrorString != null)
                {
                    rv.Messages = string.Concat(rv.Messages, frameInfo.SystemErrorString, "\r\n");
                }
                if (frameInfo.UserCommandString != null)
                {
                    rv.Messages = string.Concat(rv.Messages, frameInfo.UserCommandString, "\r\n");
                }
                if (frameInfo.GPSFixString != null)
                {
                    rv.Messages = string.Concat(rv.Messages, frameInfo.GPSFixString, "\r\n");
                }

                if (m_UseNtpTimeAsCentralExposureTime)
                {
                    rv.CentralExposureTime = ComputeCentralExposureTimeFromNtpTime(frameIndex, frameInfo.EndExposureNtpTimeStamp);
                }

                if (m_FrameRate > 0)
                {
                    rv.ExposureInMilliseconds = (float)(1000 / m_FrameRate);
                }

                if (m_UsesNtpTimestamps && !OcrDataAvailable && m_UseNtpTimeAsCentralExposureTime)
                {
                    AddExtraNtpDebugTimes(ref rv, frameInfo);
                }

                return(rv);
            }
            else
            {
                return(new FrameStateData());
            }
        }