Beispiel #1
0
        public void ExecuteAction(int actionId, IOWAsteroidEvent astEvent, System.Windows.Forms.IWin32Window owner, OWEventArguments eventArgs)
        {
            if (actionId == 1)
            {
                if (astEvent != null)
                {
                    IOWLocalEventData siteData     = astEvent as IOWLocalEventData;
                    IOWUserConfig     userSettings = astEvent as IOWUserConfig;
                    IOWAsteroidEvent2 evt2         = astEvent as IOWAsteroidEvent2;

                    //TODO: Use the configured format string

                    string errorInTime = string.Empty;
                    if (evt2 != null &&
                        evt2.ErrorInTime != -1)
                    {
                        if (evt2.ErrorInTime > 90)
                        {
                            double err = evt2.ErrorInTime / 60;
                            errorInTime = string.Format(" +/- {0} min", err.ToString("#0.0"));
                        }
                        else
                        {
                            errorInTime = string.Format(" +/- {0} sec", evt2.ErrorInTime.ToString("#0"));
                        }
                    }

                    //string maxDuration = string.Empty;
                    //if (astEvent.MaxDuration > 90)
                    //{
                    //    double dur = astEvent.MaxDuration / 60;
                    //    maxDuration = string.Format("{0} min", dur.ToString("#0.0"));
                    //}
                    //else
                    //    maxDuration = string.Format("{0} sec", astEvent.MaxDuration.ToString("#0"));

                    //string eventInfo =
                    //    astEvent.AsteroidName + " occults " + astEvent.StarName + "; m = " + astEvent.StarMagnitude.ToString() + "; " + ((int)Math.Round(siteData.StarAltitude)).ToString() + "° " + GetStarDirection(userSettings, siteData.StarAzimuth) + "\r\n" +
                    //    siteData.EventTime.ToString("dd MMM; HH:mm:ss UT") + errorInTime + "; dur: " + maxDuration + "; drop: " + astEvent.MagnitudeDrop.ToString("#0.0") + "m;";

                    string eventInfo =
                        "#WaitUntil 1," +
                        siteData.EventTime.AddSeconds(Convert.ToInt32(astEvent.MaxDuration / 2)).ToString("dd/MM/yyyy HH:mm:ss").Replace("-", "/") +
                        "\r\n" +
                        astEvent.AsteroidName +
                        "\t" +
                        evt2.Occelmnt.StarRAHours.ToString().Replace(",", ".") +
                        "\t" +
                        evt2.Occelmnt.StarDEDeg.ToString().Replace(",", ".") +
                        "\r\n";

                    Clipboard.SetText(eventInfo);
                    bool existed = false;
                    if (File.Exists(config.ConfigFilePath))
                    {
                        existed = true;
                    }
                    using (StreamWriter writer = new StreamWriter(config.ConfigFilePath, true))
                    {
                        if (!existed)
                        {
                            writer.Write(config.ConfigHeader);
                        }
                        writer.Write(eventInfo);
                    }

                    MessageBox.Show(
                        owner,
                        GetResourceString("OWAE.doneText", "The following info has been copied to the ACP file") +
                        "\r\n\r\n" +
                        eventInfo +
                        "\r\n" +
                        config.ConfigFilePath,
                        GetResourceString("OWAE.AddinName", "ACP Exporter"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                }
            }

            //if (actionId == 2)
            //{
            //    OWEventArguments args = eventArgs;
            //}

            if (actionId == 7)
            {
                if (astEvent != null)
                {
                    IOWLocalEventData siteData     = astEvent as IOWLocalEventData;
                    IOWUserConfig     userSettings = astEvent as IOWUserConfig;
                    IOWAsteroidEvent2 evt2         = astEvent as IOWAsteroidEvent2;
                    IOWStationInfo    stationInfo  = astEvent as IOWStationInfo;

                    //TODO: Observation Report will be prepared here
                }
            }
        }
Beispiel #2
0
        void IOWAddin.ExecuteAction(
            int actionId,
            IOWAsteroidEvent astEvent,
            IWin32Window owner,
            OWEventArguments eventArgs)
        {
            if (actionId == START_GUIDE)
            {
                if (astEvent != null)
                {
                    IOWLocalEventData siteData = astEvent as IOWLocalEventData;
                    IOWAsteroidEvent2 evt2     = astEvent as IOWAsteroidEvent2;

                    if (siteData != null && evt2 != null && File.Exists(GuideConfig.GuidePath))
                    {
                        DateTime dateAndTime = siteData.EventTime;

                        string date = dateAndTime.ToString("yyyyMMdd HH:mm:ssUT");

                        // Read coordintes
                        double coord_RA  = evt2.Occelmnt.StarRAHours;
                        double coord_DEC = evt2.Occelmnt.StarDEDeg;

                        // Convert RA-format from hh.hhhhh into hhmmss.ssss
                        if (coord_RA < 0.0)
                        {
                            coord_RA = coord_RA + 24.0;
                        }

                        // coordinate setting for Guide: hhmmss.ssss,dd.dddd
                        string coord = string.Concat(AstroConvert.ToStringValue(coord_RA, "HHMMSS.T"), ",", AstroConvert.ToStringValue(coord_DEC, "+DDMMSS"));


                        // Build Guide Options
                        // https://www.projectpluto.com/random.htm#command_line
                        // Format: -tyyyymmdd hh:mm:ss.ssss -ohhmmss.ssss,dd.ddddd
                        string guideOptions;

                        if (GuideConfig.GuideConfiguration == "")
                        {
                            guideOptions = string.Concat("-t", date, " -o", coord, " " + GuideConfig.CommandLineArguments);
                        }
                        else
                        {
                            guideOptions = string.Concat("-m", GuideConfig.GuideConfiguration, ".mar ", "-t", date, " -o", coord, " " + GuideConfig.CommandLineArguments);
                        }

                        if (!GuideConfig.AlwaysNewInstance)
                        {
                            if (m_CurrentGuideProcess != null &&
                                !m_CurrentGuideProcess.HasExited)
                            {
                                try
                                {
                                    m_CurrentGuideProcess.Kill();
                                }
                                catch (Exception ex)
                                {
                                    Trace.WriteLine(ex.ToString());
                                }
                            }
                        }

                        ProcessStartInfo startInfo = new ProcessStartInfo();
                        startInfo.UseShellExecute  = false;
                        startInfo.WorkingDirectory = Path.GetDirectoryName(GuideConfig.GuidePath);
                        startInfo.FileName         = GuideConfig.GuidePath;
                        startInfo.Verb             = "runas";
                        startInfo.Arguments        = guideOptions;
                        startInfo.ErrorDialog      = true;

                        m_CurrentGuideProcess = Process.Start(startInfo);
                    }
                }
            }
            if (actionId == CHANGE_LANGUAGE)
            {
                if (eventArgs.OWEventId == OWEventArguments.EVT_CURR_LANGUAGE_CHANGED)
                {
                    SetLanguage((int)eventArgs.Args);
                }
            }
        }