Example #1
0
        public void ShowStatus(FrameStateData frameState)
        {
            m_FrameState = frameState;

            var statusText = new StringBuilder();

            statusText.AppendLine(string.Format("Time Stamp: {0}", m_FrameState.SystemTime.ToString("dd MMM yyyy HH:mm:ss.fff")));

            lblStatusCombined.Text = statusText.ToString();
        }
Example #2
0
        public void OverlayStateForFrame(Bitmap currentImage, FrameStateData state, int currentFrameNo, bool isAstroDigitalVideo, bool isAstroAnalogueVideo)
        {
            using (Graphics g = Graphics.FromImage(currentImage))
            {
                if (m_CurrentImageWidth != currentImage.Width)
                    ComputeFontSizeAndTimeStampPosition(g, currentImage.Width, currentImage.Height);

                if (isAstroDigitalVideo)
                    OverlayADVState(g, currentImage, state, currentFrameNo);
                else if (isAstroAnalogueVideo)
                    OverlayAAVState(g, currentImage, state, currentFrameNo);
            }

            m_LastFrameNo = currentFrameNo;
        }
Example #3
0
        public void ShowStatus(FrameStateData frameState)
        {
            m_FrameState = frameState;

            var statusText = new StringBuilder();

            if (m_AdvSettings.PopupSatellites)
                statusText.AppendLine(string.Format("Tracked Satellites: {0}", m_FrameState.NumberSatellites));

            if (m_AdvSettings.PopupAlmanac)
            {
                statusText.AppendLine(string.Format("Almanac Status: {0}", m_FrameState.AlmanacStatus));
                statusText.AppendLine(string.Format("Almanac Offset: {0}", m_FrameState.AlmanacOffset));
            }

            if (m_AdvSettings.PopupGPSFix)
            {
                int intStatus;
                string strStatus;
                if (int.TryParse(m_FrameState.GPSFixStatus, out intStatus))
                    strStatus = AdvStatusValuesHelper.TranslateGpsFixStatus(intStatus);
                else
                    strStatus = m_FrameState.GPSFixStatus;

                statusText.AppendLine(string.Format("GPS Fix: {0}", strStatus));
            }

            if (m_AdvSettings.PopupSatellites || m_AdvSettings.PopupAlmanac || m_AdvSettings.PopupGPSFix)
                statusText.AppendLine();

            if (m_AdvSettings.PopupVideoCameraFrameId)
                statusText.AppendLine(string.Format("Camera Frame #: {0}", m_FrameState.VideoCameraFrameId.ToString("###,###,###,##0")));
            if (m_AdvSettings.PopupTimestamp)
                statusText.AppendLine(string.Format("Central Exposure Time: {0}",
                        m_FrameState.HasValidTimeStamp
                            ? m_FrameState.CentralExposureTime.ToString("dd MMM yyyy HH:mm:ss.fff")
                            : "Timestamp Not Available"));

            if (m_AdvSettings.PopupExposure)
                 statusText.AppendLine(m_FrameState.HasValidTimeStamp
                            ? string.Format("Exposure Duration: {0} ms", m_FrameState.ExposureInMilliseconds.ToString("0"))
                            : "Exposure Duration: Unknown");

            if (m_AdvSettings.PopupTimestamp || m_AdvSettings.PopupExposure || m_AdvSettings.PopupVideoCameraFrameId)
                statusText.AppendLine();

            if (m_AdvSettings.PopupSystemTime)
                statusText.AppendLine(string.Format("PC Clock Time: {0}", m_FrameState.SystemTime.ToString("dd MMM yyyy HH:mm:ss.fff")));

            if (m_AdvSettings.PopupSystemTime)
                statusText.AppendLine();

            if (m_AdvSettings.PopupGamma)
                statusText.AppendLine(string.Format("Gamma: {0:0.000} {1}", m_FrameState.Gamma, AdvStatusValuesHelper.GetWellKnownGammaForValue(m_FrameState.Gamma)));
            if (m_AdvSettings.PopupGain)
                statusText.AppendLine(m_FrameState.IsGainKnown
                    ? string.Format("Gain: {0:0} dB", m_FrameState.Gain)
                    : "Gain: Unknown");
            if (m_AdvSettings.PopupOffset)
                statusText.AppendLine(string.Format("Offset: {0:0.00} %", m_FrameState.Offset));

            lblStatusCombined.Text = statusText.ToString();
            this.Height = 197 /* Nominal height of the form */ - 117 /* Nominal height of the label*/ + lblStatusCombined.Height;
            this.Width = 213 /* Nominal width of the form */- 181 /* Nominal width of the label*/+ lblStatusCombined.Width;
            btnCopy.Top = 141  /* Nominal top position of the button */ - 117 /* Nominal height of the label*/ + lblStatusCombined.Height;
            btnCopy.Left = (this.Width - btnCopy.Width) / 2;
        }
        private FrameStateData GetCurrentFrameState(int frameNo)
        {
            if (m_CurrentFrameInfo != null)
            {
                var rv = new FrameStateData();
                rv.VideoCameraFrameId = m_CurrentFrameInfo.VideoCameraFrameId;
                rv.CentralExposureTime = m_CurrentFrameInfo.MiddleExposureTimeStamp;
                rv.SystemTime = m_CurrentFrameInfo.SystemTime;
                rv.EndFrameNtpTime = m_CurrentFrameInfo.EndExposureNtpTimeStamp;
                rv.NtpTimeStampError = m_CurrentFrameInfo.NtpTimeStampError;
                rv.ExposureInMilliseconds = m_CurrentFrameInfo.Exposure10thMs / 10.0f;

                rv.NumberIntegratedFrames = (int)m_CurrentFrameInfo.IntegratedFrames;
                rv.NumberStackedFrames = m_StackingRate;

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

                if (!m_CurrentFrameInfo.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 = m_CurrentFrameInfo.Gain;
                rv.Gamma = m_CurrentFrameInfo.Gamma;
                rv.Temperature = m_CurrentFrameInfo.Temperature;
                rv.Offset = m_CurrentFrameInfo.Offset;

                rv.NumberSatellites = m_CurrentFrameInfo.GPSTrackedSattelites;

                rv.AlmanacStatus = AdvStatusValuesHelper.TranslateGpsAlmanacStatus(almanacStatus);

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

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

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

                if (m_UseNtpTimeAsCentralExposureTime)
                {
                    rv.CentralExposureTime = ComputeCentralExposureTimeFromNtpTime(frameNo, m_CurrentFrameInfo.EndExposureNtpTimeStamp);
                }

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

                if (m_UsesNtpTimestamps && !OcrDataAvailable && m_UseNtpTimeAsCentralExposureTime)
                    AddExtraNtpDebugTimes(ref rv, m_CurrentFrameInfo);

                return rv;
            }
            else
                return new FrameStateData();
        }
        private void AddExtraNtpDebugTimes(ref FrameStateData stateData, AdvFrameInfo frameInfo)
        {
            if (stateData.AdditionalProperties == null)
                stateData.AdditionalProperties = new SafeDictionary<string, object>();

            stateData.AdditionalProperties.Add("MidTimeNTPRaw", stateData.EndFrameNtpTime.AddMilliseconds(-0.5 * stateData.ExposureInMilliseconds));
            stateData.AdditionalProperties.Add("MidTimeNTPFitted", stateData.CentralExposureTime);
            stateData.AdditionalProperties.Add("MidTimeWindowsRaw", frameInfo.EndExposureSecondaryTimeStamp.AddMilliseconds(-0.5 * stateData.ExposureInMilliseconds));
        }
Example #6
0
        public void ShowStatus(FrameStateData frameState)
        {
            m_FrameState = frameState;

            var statusText = new StringBuilder();

            if (m_AavSettings.Popup_Satellites)
                statusText.AppendLine(string.Format("Tracked Satellites: {0}", m_FrameState.NumberSatellites));

            if (m_AavSettings.Popup_Almanac)
            {
                statusText.AppendLine(string.Format("Almanac Status: {0}", m_FrameState.AlmanacStatus));
            }

            if (m_AavSettings.Popup_GPSFix)
            {
                int intStatus;
                string strStatus;
                if (int.TryParse(m_FrameState.GPSFixStatus, out intStatus))
                    strStatus = AdvStatusValuesHelper.TranslateGpsFixStatus(intStatus);
                else
                    strStatus = m_FrameState.GPSFixStatus;

                statusText.AppendLine(string.Format("GPS Fix: {0}", strStatus));
            }

            if (m_AavSettings.Popup_Satellites || m_AavSettings.Popup_Almanac || m_AavSettings.Popup_GPSFix)
                statusText.AppendLine();

            if (m_AavSettings.Popup_Timestamp)
                statusText.AppendLine(string.Format("Central Exposure Time: {0}",
                        m_FrameState.HasValidTimeStamp
                            ? m_FrameState.CentralExposureTime.ToString("dd MMM yyyy HH:mm:ss.fff")
                            : "Timestamp Not Available"));

            if (m_AavSettings.Popup_Exposure)
            {
                if (m_FrameState.HasValidTimeStamp)
                    statusText.AppendLine(string.Format("Exposure Duration: {0} ms", m_FrameState.ExposureInMilliseconds.ToString("0")));
                else if (m_FrameState.NumberStackedFrames.HasValue && m_FrameState.NumberStackedFrames.Value > 0)
                {
                    string timestamp = string.Format("Exposure Duration: x{0} stack", m_FrameState.NumberStackedFrames.Value.ToString("0"));
                    if (m_FrameState.ExposureInMilliseconds > 0)
                        timestamp += string.Format(" ({0} ms)", m_FrameState.ExposureInMilliseconds.ToString("0"));

                    statusText.AppendLine(timestamp);
                }
                else if (m_FrameState.NumberIntegratedFrames.HasValue && m_FrameState.NumberIntegratedFrames.Value > 0)
                {
                    string timestamp = string.Format("Exposure Duration: x{0} integration", m_FrameState.NumberIntegratedFrames.Value.ToString("0"));
                    if (m_FrameState.ExposureInMilliseconds > 0)
                        timestamp += string.Format(" ({0} ms)", m_FrameState.ExposureInMilliseconds.ToString("0"));

                    statusText.AppendLine(timestamp);
                }
                else
                    statusText.AppendLine("Exposure Duration: Unknown");
            }

            if (m_AavSettings.Popup_Timestamp || m_AavSettings.Popup_Exposure)
                statusText.AppendLine();

            if (m_AavSettings.Popup_Gain)
                statusText.AppendLine(m_FrameState.Gain > 0
                            ? string.Format("Gain: {0} dB", m_FrameState.Gain.ToString("0"))
                            : "Gain: Unknown");

            if (m_AavSettings.Popup_Gamma)
                statusText.AppendLine(m_FrameState.Gamma > 0
                            ? string.Format("Gamma: {0}", m_FrameState.Gamma.ToString("0.000"))
                            : "Gamma: Unknown");

            if (m_AavSettings.Popup_Temperature)
                statusText.AppendLine(m_FrameState.Temperature > 0
                            ? string.Format("Temperature: {0}", m_FrameState.Temperature.ToString("0.0"))
                            : "Temperature: Unknown");

            if (m_AavSettings.Popup_Gain || m_AavSettings.Popup_Gamma)
                statusText.AppendLine();

            if (m_AavSettings.Popup_NtpTimestamp)
                statusText.AppendLine(string.Format("NTP Timestamp: {0}", m_FrameState.HasValidNtpTimeStamp ? m_FrameState.EndFrameNtpTime.ToString("dd MMM yyyy HH:mm:ss.fff") : ""));

            if (m_AavSettings.Popup_SystemTime)
                statusText.AppendLine(string.Format("PC Clock Time: {0}", m_FrameState.SystemTime.ToString("dd MMM yyyy HH:mm:ss.fff")));

            if (m_AavSettings.Popup_SystemTime)
                statusText.AppendLine();

            lblStatusCombined.Text = statusText.ToString();
            this.Height = 182 /* Nominal height of the form */ - 117 /* Nominal height of the label*/ + lblStatusCombined.Height;
            this.Width = 213 /* Nominal width of the form */- 181 /* Nominal width of the label*/+ lblStatusCombined.Width;
            btnCopy.Top = 126  /* Nominal top position of the button */ - 117 /* Nominal height of the label*/ + lblStatusCombined.Height;
            btnCopy.Left = (this.Width - btnCopy.Width) / 2;
        }
Example #7
0
        private void OverlayADVState(Graphics g, Bitmap currentImage, FrameStateData state, int currentFrameNo)
        {
            if (TangraConfig.Settings.ADVS.OverlayTimestamp)
            {
                string timeStampStr = state.HasValidTimeStamp
                        ? string.Format("{0}.{1}", state.CentralExposureTime.ToString("dd MMM yyyy HH:mm:ss"), state.CentralExposureTime.Millisecond.ToString().PadLeft(3, '0'))
                        : "Timestamp Not Available";
                g.DrawString(timeStampStr, s_TimeStampFont, s_TimeStampBrush, m_XPos, currentImage.Height - m_YPosUpper);
                g.Save();
            }

            int numTopLines = 0;

            if (TangraConfig.Settings.ADVS.OverlayObjectName && m_AdvFileMetadataInfo != null && !string.IsNullOrWhiteSpace(m_AdvFileMetadataInfo.ObjectName) &&
                (!m_ObjectInfoDisplayed || m_FirstFrameNo == currentFrameNo))
            {
                string objectNameStr = string.Format(" {0}", m_AdvFileMetadataInfo.ObjectName);
                g.DrawString(objectNameStr, s_PropertiesFont, s_PropertiesGreenBrush, 10, 10 + numTopLines * (s_PropertiesFont.Size + 5));
                g.Save();
                numTopLines++;
                m_ObjectInfoDisplayed = true;
            }

            if (m_LastFrameNo + 1 != currentFrameNo)
                // When frames jump we stop displaying the message
                m_FramesLeftToDiplayMessage = 0;

            if (TangraConfig.Settings.ADVS.OverlayAllMessages &&
                !string.IsNullOrEmpty(state.Messages) &&
                state.Messages.Trim().Length > 0)
            {
                m_LastMessage = state.Messages.Trim();
                m_FramesLeftToDiplayMessage = 10;
            }

            if ((TangraConfig.Settings.ADVS.OverlayAdvsInfo || TangraConfig.Settings.ADVS.OverlayCameraInfo || TangraConfig.Settings.ADVS.OverlayGeoLocation) &&
                (!m_EquipmentInfoDisplayed || m_FirstFrameNo == currentFrameNo))
            {
                int numLines = 0;
                int lineNo = 0;
                if (TangraConfig.Settings.ADVS.OverlayCameraInfo) numLines += 2;
                if (TangraConfig.Settings.ADVS.OverlayAdvsInfo) numLines += 2;
                if (TangraConfig.Settings.ADVS.OverlayGeoLocation) numLines += 1;

                float startingY = currentImage.Height - numLines * (s_PropertiesFont.Size + 5) - 10;
                if (TangraConfig.Settings.ADVS.OverlayTimestamp) startingY -= m_YPosUpper;

                if (TangraConfig.Settings.ADVS.OverlayAdvsInfo && m_AdvFileMetadataInfo != null)
                {
                    g.DrawString(m_AdvFileMetadataInfo.Recorder, s_PropertiesFont, s_PropertiesWhiteBrush, 10, startingY + lineNo * (s_PropertiesFont.Size + 5));
                    lineNo++;
                    if (!string.IsNullOrEmpty(m_AdvFileMetadataInfo.AdvrVersion))
                    {
                        g.DrawString(
                            string.Format("ADVR v{0} HTCC v{1}", m_AdvFileMetadataInfo.AdvrVersion, m_AdvFileMetadataInfo.HtccFirmareVersion),
                            s_PropertiesFont, s_PropertiesWhiteBrush, 10, startingY + lineNo * (s_PropertiesFont.Size + 5));
                    }
                    lineNo++;
                }

                if (TangraConfig.Settings.ADVS.OverlayCameraInfo && m_AdvFileMetadataInfo != null)
                {
                    if (!string.IsNullOrEmpty(m_AdvFileMetadataInfo.SensorInfo))
                        g.DrawString(m_AdvFileMetadataInfo.SensorInfo, s_PropertiesFont, s_PropertiesWhiteBrush, 10, startingY + lineNo * (s_PropertiesFont.Size + 5));
                    lineNo++;
                    if (!string.IsNullOrEmpty(m_AdvFileMetadataInfo.Camera))
                        g.DrawString(m_AdvFileMetadataInfo.Camera, s_PropertiesFont, s_PropertiesWhiteBrush, 10, startingY + lineNo * (s_PropertiesFont.Size + 5));
                    lineNo++;
                }

                if (TangraConfig.Settings.ADVS.OverlayGeoLocation && m_GeoLocation != null)
                {

                    g.DrawString(m_GeoLocation.GetFormattedGeoLocation(), s_PropertiesFont, s_PropertiesWhiteBrush, 10, startingY + lineNo * (s_PropertiesFont.Size + 5));
                    lineNo++;
                }

                g.Save();

                m_EquipmentInfoDisplayed = true;
            }

            if (m_FramesLeftToDiplayMessage > 0)
            {
                if (TangraConfig.Settings.ADVS.OverlayObjectName)
                    numTopLines++;

                g.DrawString(m_LastMessage, s_PropertiesFont, s_PropertiesYellowBrush, 10, 10 + numTopLines * (s_PropertiesFont.Size + 5));
                g.Save();
                m_FramesLeftToDiplayMessage--;
            }
        }
Example #8
0
 public void ShowStatus(FrameStateData frameState)
 {
     var dataList = frameState.AdditionalProperties != null ? frameState.AdditionalProperties.Select(kvp => new TagValuePair(kvp.Key, Convert.ToString(kvp.Value))).ToList() : null;
     dataGridView.DataSource = dataList;
 }
        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();
        }