예제 #1
0
        static void ReportEntry(ActionProgramRun ap, List<HistoryEntry> hl, int pos, string prefix)
        {
            if (hl != null && pos >= 0 && pos < hl.Count)     // if within range.. (1 based)
            {
                try
                {
                    Variables values = new Variables();
                    ActionVars.HistoryEventVars(values, hl[pos], prefix);
                    ActionVars.ShipBasicInformation(values, hl[pos].ShipInformation, prefix);
                    ActionVars.SystemVars(values, hl[pos].System, prefix);
                    ap.Add(values);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("Exception reporting entry variables in event " + ex.Message);
                }

                ap[prefix + "JID"] = hl[pos].Journalid.ToStringInvariant();
                ap[prefix + "Count"] = hl.Count.ToString(System.Globalization.CultureInfo.InvariantCulture);     // give a count of matches
            }
            else
            {
                ap[prefix + "JID"] = "0";
                ap[prefix + "Count"] = "0";
            }
        }
예제 #2
0
 static void ReportHistoryEntry(ActionProgramRun ap, HistoryEntry he, string prefix)
 {
     try
     {
         ConditionVariables values = new ConditionVariables();
         ActionVars.HistoryEventVars(values, he, prefix);
         ActionVars.ShipInformation(values, he.ShipInformation, prefix, true);
         ActionVars.SystemVars(values, he.System, prefix);
         ap.Add(values);
     }
     catch { }
 }
예제 #3
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            string res;

            if (ap.functions.ExpandString(UserData, out res) != Conditions.ConditionFunctions.ExpandResult.Failed)
            {
                StringParser sp = new StringParser(res);

                string prefix  = "ST_";
                string cmdname = sp.NextQuotedWord();

                if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase))
                {
                    prefix = sp.NextWord();

                    if (prefix == null)
                    {
                        ap.ReportError("Missing name after Prefix in Star");
                        return(true);
                    }

                    cmdname = sp.NextQuotedWord();
                }

                if (cmdname != null)
                {
                    ISystem sc = SystemClassDB.GetSystem(cmdname);
                    ap[prefix + "Found"] = sc != null ? "1" : "0";

                    if (sc != null)
                    {
                        Conditions.ConditionVariables vars = new Conditions.ConditionVariables();
                        ActionVars.SystemVars(vars, sc, prefix);
                        ap.Add(vars);
                        ActionVars.SystemVarsFurtherInfo(ap, (ap.actioncontroller as ActionController).HistoryList, sc, prefix);
                    }
                }
                else
                {
                    ap.ReportError("Missing starname in Star");
                }
            }
            else
            {
                ap.ReportError(res);
            }

            return(true);
        }
예제 #4
0
        private void NewStarListComputed(ISystem sys, BaseUtils.SortedListDoubleDuplicate <ISystem> list)      // In UI thread
        {
            System.Diagnostics.Debug.Assert(System.Windows.Forms.Application.MessageLoop);
            int i = 1;

            foreach (var s in list)
            {
                string p = ret_prefix + (i++).ToStringInvariant() + "_";
                ActionVars.SystemVars(apr.variables, s.Value, p);
                ActionVars.SystemVarsFurtherInfo(apr, (apr.ActionController as ActionController).HistoryList, s.Value, p);
                apr[p + "Dist"] = Math.Sqrt(s.Key).ToStringInvariant("0.##");
            }

            apr[ret_prefix + "Count"] = list.Count.ToStringInvariant();

            apr.ResumeAfterPause();
        }
예제 #5
0
        static void ReportEntry(ActionProgramRun ap, List <HistoryEntry> hl, int pos, string prefix)
        {
            if (hl != null && pos >= 0 && pos < hl.Count)     // if within range.. (1 based)
            {
                try
                {
                    ConditionVariables values = new ConditionVariables();
                    ActionVars.HistoryEventVars(values, hl[pos], prefix);
                    ActionVars.ShipBasicInformation(values, hl[pos].ShipInformation, prefix);
                    ActionVars.SystemVars(values, hl[pos].System, prefix);
                    ap.Add(values);
                }
                catch { }

                ap[prefix + "Count"] = hl.Count.ToString(System.Globalization.CultureInfo.InvariantCulture);     // give a count of matches
            }
            else
            {
                ap[prefix + "JID"]   = "0";
                ap[prefix + "Count"] = "0";
            }
        }
예제 #6
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            string res;

            if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed)
            {
                StringParser sp = new StringParser(res);

                string prefix  = "ST_";
                string cmdname = sp.NextQuotedWord();

                if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase))
                {
                    prefix = sp.NextWord();

                    if (prefix == null)
                    {
                        ap.ReportError("Missing name after Prefix in Star");
                        return(true);
                    }

                    cmdname = sp.NextQuotedWord();
                }

                if (cmdname != null)
                {
                    ISystem sc = SystemCache.FindSystem(cmdname);
                    ap[prefix + "Found"] = sc != null ? "1" : "0";

                    if (sc != null)
                    {
                        BaseUtils.Variables vars = new BaseUtils.Variables();
                        ActionVars.SystemVars(vars, sc, prefix);
                        ap.Add(vars);
                        ActionVars.SystemVarsFurtherInfo(ap, (ap.ActionController as ActionController).HistoryList, sc, prefix);

                        string options = sp.NextWord();

                        if (options != null)
                        {
                            if (options.Equals("NEAREST", StringComparison.InvariantCultureIgnoreCase))
                            {
                                double mindist = sp.NextDouble(0.01);
                                double maxdist = sp.NextDouble(20.0);
                                int    number  = sp.NextInt(50);
                                bool   cube    = (sp.NextWord() ?? "Spherical").Equals("Cube", StringComparison.InvariantCultureIgnoreCase); // spherical default for all but cube

                                StarDistanceComputer computer = new StarDistanceComputer();

                                apr        = ap;
                                ret_prefix = prefix;

                                computer.CalculateClosestSystems(sc,
                                                                 (sys, list) => (apr.ActionController as ActionController).DiscoveryForm.BeginInvoke(new Action(() => NewStarListComputed(sys, list))),
                                                                 (mindist > 0) ? (number - 1) : number, // adds an implicit 1 on for centre star
                                                                 mindist, maxdist, !cube);

                                return(false);   // go to sleep until value computed
                            }
                        }
                    }
                }
                else
                {
                    ap.ReportError("Missing starname in Star");
                }
            }
            else
            {
                ap.ReportError(res);
            }


            return(true);
        }