Пример #1
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")
                            : "Embedded Timestamp Not Found"));
            }

            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;
        }
Пример #2
0
        private void LoadFrame(int frameId)
        {
            Bitmap displayBitmap;

            m_CurrentPixelmap = m_AdvFile.GetFrameData(frameId, out m_CurrentImageData, out m_CurrentStatusData, out displayBitmap);

            picSmallImage.Image = displayBitmap;

            int    numSatellites    = 0;
            string gamma            = "";
            string gain             = "";
            string shutter          = "";
            string offset           = "";
            string systemTime       = string.Empty;
            string almanacOffsetStr = "";
            string almanacStatusStr = "";

            lvFrameStatusData.Items.Clear();

            foreach (AdvTagDefinition statusTag in m_CurrentStatusData.TagValues.Keys)
            {
                string tagValue = m_CurrentStatusData.TagValues[statusTag];
                if ((statusTag.Name == "SystemTime" || statusTag.Name == "NTPStartTimestamp" || statusTag.Name == "NTPEndTimestamp" || statusTag.Name == "StartTimestampSecondary" || statusTag.Name == "EndTimestampSecondary") &&
                    !string.IsNullOrEmpty(tagValue))
                {
                    systemTime = AdvFile.ADV_ZERO_DATE_REF.AddMilliseconds(long.Parse(tagValue)).ToString("dd-MMM-yyyy HH:mm:ss.fff");
                    tagValue   = systemTime;
                }
                else if (statusTag.Name == "SystemTimeFileTime" && !string.IsNullOrEmpty(tagValue))
                {
                    tagValue = new DateTime(long.Parse(tagValue)).ToString("dd-MMM-yyyy HH:mm:ss.ffffff");
                }
                else if (statusTag.Name == "OcrTime" && !string.IsNullOrEmpty(tagValue))
                {
                    tagValue = new DateTime(long.Parse(tagValue)).ToString("dd-MMM-yyyy HH:mm:ss.ffff");
                }

                if (statusTag.Name == "GPSTrackedSatellites" && !string.IsNullOrEmpty(tagValue))
                {
                    numSatellites = int.Parse(tagValue);
                }
                else if (statusTag.Name == "Gamma" && !string.IsNullOrEmpty(tagValue))
                {
                    gamma    = string.Format("{0:0.000}", float.Parse(tagValue));
                    tagValue = gamma;
                }
                else if (statusTag.Name == "Gain" && !string.IsNullOrEmpty(tagValue))
                {
                    gain     = string.Format("{0:0} dB", float.Parse(tagValue));
                    tagValue = gain;
                }
                else if (statusTag.Name == "Shutter" && !string.IsNullOrEmpty(tagValue))
                {
                    shutter  = string.Format("{0:0.000} sec", float.Parse(tagValue));
                    tagValue = shutter;
                }
                else if (statusTag.Name == "Offset" && !string.IsNullOrEmpty(tagValue))
                {
                    offset   = string.Format("{0:0.00} %", float.Parse(tagValue));
                    tagValue = offset;
                }
                else if ((statusTag.Name == "VideoCameraFrameId" || statusTag.Name == "HardwareTimerFrameId") && !string.IsNullOrEmpty(tagValue))
                {
                    tagValue = int.Parse(tagValue).ToString("#,###,###,###,###");
                }
                else if (statusTag.Name == "GPSAlmanacStatus" && !string.IsNullOrEmpty(tagValue))
                {
                    int almanacStatus = int.Parse(tagValue);
                    tagValue         = AdvStatusValuesHelper.TranslateGpsAlmanacStatus(almanacStatus);
                    almanacStatusStr = tagValue;
                }
                else if (statusTag.Name == "GPSAlmanacOffset" && !string.IsNullOrEmpty(tagValue))
                {
                    int almanacOffset = int.Parse(tagValue);
                    if ((almanacOffset & 0x80) == 0x80)
                    {
                        almanacOffset = (short)(almanacOffset + (0xFF << 8));
                    }

                    tagValue         = AdvStatusValuesHelper.TranslateGpsAlmanacOffset(1, almanacOffset, false);
                    almanacOffsetStr = tagValue;
                }
                else if (statusTag.Name == "GPSFixStatus" && !string.IsNullOrEmpty(tagValue))
                {
                    int fixStatus = int.Parse(tagValue);
                    tagValue = AdvStatusValuesHelper.TranslateGpsFixStatus(fixStatus);
                }

                if (!string.IsNullOrEmpty(tagValue) && (statusTag.Name == "UserCommand" || statusTag.Name == "SystemError" || statusTag.Name == "GPSFix"))
                {
                    string[] tokens = tagValue.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < tokens.Length; i++)
                    {
                        ListViewItem li = lvFrameStatusData.Items.Add(string.Format("{0}[{1}]", statusTag.Name, i + 1));
                        li.SubItems.Add(tokens[i]);
                        li.Tag = statusTag;
                    }
                }
                else
                {
                    ListViewItem li = lvFrameStatusData.Items.Add(statusTag.Name);
                    li.SubItems.Add(tagValue);
                    li.Tag = statusTag;
                }
            }

            lblFrameId.Text    = string.Format("Frame {0} of {1}", frameId, sbFrames.Maximum);
            lblFrameStart.Text = m_CurrentImageData.MidExposureUtc.AddMilliseconds(-0.5 * m_CurrentImageData.ExposureMilliseconds).ToString("dd MMM yyyy HH:mm:ss.fff");
            lblFrameEnd.Text   = m_CurrentImageData.MidExposureUtc.AddMilliseconds(0.5 * m_CurrentImageData.ExposureMilliseconds).ToString("dd MMM yyyy HH:mm:ss.fff");

            lblFrameNumSatellites.Text = numSatellites.ToString();
            lblFrameGain.Text          = gain;
            lblFrameGamma.Text         = gamma;
            lblFrameOffset.Text        = offset;
            lblFrameSystemTime.Text    = systemTime;
            lblFrameAlmanacOffset.Text = almanacOffsetStr;
            lblFrameAlmanacStatus.Text = almanacStatusStr;

            double fps = 1000.0 / m_CurrentImageData.ExposureMilliseconds;

            lblFrameExposure.Text = string.Format("{0:0.0} ms ({1} {2})", m_CurrentImageData.ExposureMilliseconds, fps > 0 ? Math.Round(fps) : Math.Round(1 / fps), fps > 0 ? "fps" : "spf");

            lblFrameLayout.Text   = string.Format("#{0} - {1}", m_CurrentImageData.LayoutId, m_CurrentImageData.ByteMode);
            lblDataBlockSize.Text = string.Format("{0} bytes", m_CurrentImageData.DataBlocksBytesCount.ToString("#,###,###,###"));
        }
Пример #3
0
        private string StatusDataToCsvRow(AdvImageData imageData, AdvStatusData statusData, int frameNo, out string headerRow)
        {
            var output = new StringBuilder();

            output.AppendFormat("\"{0}\"", frameNo);
            output.AppendFormat(",\"{0}\"", imageData.MidExposureUtc.AddMilliseconds(-1 * imageData.ExposureMilliseconds / 2.0).ToString("dd-MMM-yyyy HH:mm:ss.fff"));
            output.AppendFormat(",\"{0}\"", imageData.MidExposureUtc.AddMilliseconds(imageData.ExposureMilliseconds / 2.0).ToString("dd-MMM-yyyy HH:mm:ss.fff"));

            var header = new StringBuilder();

            header.Append("FrameNo,OCRStartTimestamp,OCREndTimestamp");

            foreach (AdvTagDefinition statusTag in statusData.TagValues.Keys)
            {
                string tagValue = statusData.TagValues[statusTag];
                if ((statusTag.Name == "SystemTime" || statusTag.Name == "NTPStartTimestamp" || statusTag.Name == "NTPEndTimestamp" || statusTag.Name == "StartTimestampSecondary" || statusTag.Name == "EndTimestampSecondary") &&
                    !string.IsNullOrEmpty(tagValue))
                {
                    tagValue = AdvFile.ADV_ZERO_DATE_REF.AddMilliseconds(long.Parse(tagValue)).ToString("dd-MMM-yyyy HH:mm:ss.fff");
                }
                else if (statusTag.Name == "GPSTrackedSatellites" && !string.IsNullOrEmpty(tagValue))
                {
                    tagValue = int.Parse(tagValue).ToString();
                }
                else if (statusTag.Name == "Gamma" && !string.IsNullOrEmpty(tagValue))
                {
                    tagValue = string.Format("{0:0.000}", float.Parse(tagValue));
                }
                else if (statusTag.Name == "Gain" && !string.IsNullOrEmpty(tagValue))
                {
                    tagValue = string.Format("{0:0} dB", float.Parse(tagValue));
                }
                else if (statusTag.Name == "Shutter" && !string.IsNullOrEmpty(tagValue))
                {
                    tagValue = string.Format("{0:0.000} sec", float.Parse(tagValue));
                }
                else if (statusTag.Name == "Offset" && !string.IsNullOrEmpty(tagValue))
                {
                    tagValue = string.Format("{0:0.00} %", float.Parse(tagValue));
                }
                else if ((statusTag.Name == "VideoCameraFrameId" || statusTag.Name == "HardwareTimerFrameId") &&
                         !string.IsNullOrEmpty(tagValue))
                {
                    tagValue = int.Parse(tagValue).ToString("#,###,###,###,###");
                }
                else if (statusTag.Name == "GPSAlmanacStatus" && !string.IsNullOrEmpty(tagValue))
                {
                    int almanacStatus = int.Parse(tagValue);
                    tagValue = AdvStatusValuesHelper.TranslateGpsAlmanacStatus(almanacStatus);
                }
                else if (statusTag.Name == "GPSAlmanacOffset" && !string.IsNullOrEmpty(tagValue))
                {
                    int almanacOffset = int.Parse(tagValue);
                    if ((almanacOffset & 0x80) == 0x80)
                    {
                        almanacOffset = (short)(almanacOffset + (0xFF << 8));
                    }

                    tagValue = AdvStatusValuesHelper.TranslateGpsAlmanacOffset(1, almanacOffset, false);
                }
                else if (statusTag.Name == "GPSFixStatus" && !string.IsNullOrEmpty(tagValue))
                {
                    int fixStatus = int.Parse(tagValue);
                    tagValue = AdvStatusValuesHelper.TranslateGpsFixStatus(fixStatus);
                }

                if (!string.IsNullOrEmpty(tagValue) && (statusTag.Name == "UserCommand" || statusTag.Name == "SystemError" || statusTag.Name == "GPSFix"))
                {
                    string[] tokens = tagValue.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    tagValue = string.Empty;
                    for (int i = 0; i < tokens.Length; i++)
                    {
                        tagValue += string.Format("{0}[{1}];", statusTag.Name, i + 1);
                    }
                }

                if (tagValue == null)
                {
                    tagValue = string.Empty;
                }

                output.AppendFormat(",\"{0}\"", tagValue.Replace("\"", "\"\""));
                header.AppendFormat(",{0}", statusTag.Name);
            }

            headerRow = header.ToString();
            return(output.ToString());
        }
Пример #4
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")
                            : "Embedded Timestamp Not Found"));
            }

            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;
        }