Esempio n. 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(
                    this,
                    "Tangra does not perform a validation on the MPC report header. Please make sure it is correctly formatted before submitting a report. Press 'Help' for more information.",
                    "Warning",
                    MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
            {
                return;
            }

            TangraConfig.Settings.Astrometry.MPCHeader.COD  = tbxCOD.Text;
            TangraConfig.Settings.Astrometry.MPCHeader.CON  = tbxCON.Text;
            TangraConfig.Settings.Astrometry.MPCHeader.OBS  = tbxOBS.Text;
            TangraConfig.Settings.Astrometry.MPCHeader.MEA  = tbxMEA.Text;
            TangraConfig.Settings.Astrometry.MPCHeader.TEL  = tbxTEL.Text;
            TangraConfig.Settings.Astrometry.MPCHeader.CON2 = tbxCon2.Text;
            TangraConfig.Settings.Astrometry.MPCHeader.AC2  = tbxAck2.Text;

            if (m_Mode == MPCHeaderSettingsMode.NewMPCReport)
            {
                Header     = new MPCObsHeader(TangraConfig.Settings.Astrometry.MPCHeader);
                Header.ACK = tbxAck.Text;
                Header.COM = tbxCom.Text;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
Esempio n. 2
0
        public MPCReportFile(string fileName)
        {
            ReportFileName = fileName;
            string[] allLines = File.ReadAllLines(fileName);

            Header = new MPCObsHeader(allLines);
            ObsLines.Clear();

            int strippedLines = 0;

            foreach (string line in allLines)
            {
                if (line.Length > 3 && (ObsLines.Count > 0 || HEADER_TOKENS.IndexOf(line.Substring(0, 3)) == -1))
                {
                    // Parse observation line
                    MPCObsLine obsLine = MPCObsLine.Parse(line);
                    if (obsLine != null)
                    {
                        ObsLines.Add(obsLine);
                    }
                    else
                    {
                        strippedLines++;
                    }
                }
            }

            if (strippedLines > 0)
            {
                MessageBox.Show(string.Format("{0} lines could not be parsed are have been stripped from the file.", strippedLines), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
 public MPCReportFile(string fileName, MPCObsHeader header, Func <RovingObsLocation> rovingObsLocationProvider)
 {
     ReportFileName = fileName;
     Header         = header;
     if (header.COD == MPCObsLine.ROVING_OBS_CODE)
     {
         RovingObservatoryLocation = rovingObsLocationProvider();
     }
 }
Esempio n. 4
0
        private void SaveToReportFile()
        {
            if (m_CurrentReportFile == null)
            {
                // Is there a report form currently opened?
                // If no then ask the user to append to an existing report or create a new one
                frmChooseReportFile reportFileForm = new frmChooseReportFile();
                if (reportFileForm.ShowDialog(this.ParentForm) != DialogResult.OK)
                {
                    return;
                }

                if (reportFileForm.IsNewReport)
                {
                    frmMPCObserver frmObserver = new frmMPCObserver(frmMPCObserver.MPCHeaderSettingsMode.NewMPCReport);
                    if (frmObserver.ShowDialog(ParentForm) == DialogResult.Cancel)
                    {
                        return;
                    }

                    if (saveFileDialog.ShowDialog(ParentForm) != DialogResult.OK)
                    {
                        return;
                    }

                    MPCObsHeader header = frmObserver.Header;
                    header.NET = tbxNetCode.Text;

                    m_CurrentReportFile = new MPCReportFile(saveFileDialog.FileName, header, () => m_RovingObservatoryProvider.GetRovingObsLocation());

                    TangraConfig.Settings.RecentFiles.NewRecentFile(RecentFileType.MPCReport, saveFileDialog.FileName);
                    TangraConfig.Settings.Save();
                }
                else
                {
                    m_CurrentReportFile = new MPCReportFile(reportFileForm.ReportFileName, () => m_RovingObservatoryProvider.GetRovingObsLocation());

                    if (m_CurrentReportFile.Header.NET != tbxNetCode.Text)
                    {
                        MessageBox.Show(
                            string.Format("The selected observation file uses {0} rather than {1}. Pelase select a different observation file or change the used catalog.",
                                          m_CurrentReportFile.Header.NET, tbxNetCode.Text), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        m_CurrentReportFile = null;
                        return;
                    }
                }
            }

            if (m_CurrentReportFile != null)
            {
                foreach (string line in tbxMeasurements.Lines)
                {
                    string lineToAdd = line;
                    if (TangraConfig.Settings.Astrometry.ExportHigherPositionAccuracy && lineToAdd.Length > 80)
                    {
                        // Remove the extra signifficant digit from the RA/DE in high precision mode as those
                        // cannot be reported to the MPC with the current OBS format

                        //          1         2         3         4         5         6         7         8
                        //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                        //     K15FB7W  n2015 04 01.51040713 03 21.038 -41 43 17.18          13.5 R      E28 0.12 0.12
                        //        3200  n2017 12 06.78359306 15 58.559 +41 46 52.33          11.9 R      619 0.10 0.10

                        lineToAdd =
                            line.Substring(0, 38) +
                            double.Parse(line.Substring(38, 6), CultureInfo.InvariantCulture).ToString("00.00") +
                            line.Substring(44, 8) +
                            double.Parse(line.Substring(52, 5), CultureInfo.InvariantCulture).ToString("00.0") +
                            line.Substring(57);
                    }

                    m_CurrentReportFile.AddObservation(lineToAdd);
                }

                m_CurrentReportFile.Save();

                m_CurrentReportFile.Present(this);

                AstrometryContext.Current.CurrentReportFile = m_CurrentReportFile;
            }
        }
Esempio n. 5
0
 public MPCReportFile(string fileName, MPCObsHeader header)
 {
     ReportFileName = fileName;
     Header         = header;
 }
        private void SaveToReportFile()
        {
            if (m_CurrentReportFile == null)
            {
                // Is there a report form currently opened?
                // If no then ask the user to append to an existing report or create a new one
                frmChooseReportFile reportFileForm = new frmChooseReportFile();
                if (reportFileForm.ShowDialog(this.ParentForm) != DialogResult.OK)
                {
                    return;
                }

                if (reportFileForm.IsNewReport)
                {
                    frmMPCObserver frmObserver = new frmMPCObserver(frmMPCObserver.MPCHeaderSettingsMode.NewMPCReport);
                    if (frmObserver.ShowDialog(ParentForm) == DialogResult.Cancel)
                    {
                        return;
                    }

                    if (saveFileDialog.ShowDialog(ParentForm) != DialogResult.OK)
                    {
                        return;
                    }

                    MPCObsHeader header = frmObserver.Header;
                    header.NET          = tbxNetCode.Text;
                    m_CurrentReportFile = new MPCReportFile(saveFileDialog.FileName, header);

                    TangraConfig.Settings.RecentFiles.NewRecentFile(RecentFileType.MPCReport, saveFileDialog.FileName);
                    TangraConfig.Settings.Save();
                }
                else
                {
                    m_CurrentReportFile = new MPCReportFile(reportFileForm.ReportFileName);

                    if (m_CurrentReportFile.Header.NET != tbxNetCode.Text)
                    {
                        MessageBox.Show(
                            string.Format("The selected observation file uses {0} rather than {1}. Pelase select a different observation file or change the used catalog.",
                                          m_CurrentReportFile.Header.NET, tbxNetCode.Text), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        m_CurrentReportFile = null;
                        return;
                    }
                }
            }

            if (m_CurrentReportFile != null)
            {
                foreach (string line in tbxMeasurements.Lines)
                {
                    m_CurrentReportFile.AddObservation(line);
                }

                m_CurrentReportFile.Save();

                m_CurrentReportFile.Present(this);

                AstrometryContext.Current.CurrentReportFile = m_CurrentReportFile;
            }
        }