Ejemplo n.º 1
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());
        }
Ejemplo n.º 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("#,###,###,###"));
        }