/// <summary> /// Does action-backend dependent stuff. /// </summary> /// <param name="args">Any kind of parameters for the stuff to do; first parameter has to be the command</param> public override void Custom(params object[] args) { if (args.Length == 0) { throw new ArgumentException("No command given"); } String command = (String)args[0]; switch (command) { case "gen_searchplan": { if (graph.statistics.edgeCounts == null) { throw new ArgumentException("Graph not analyzed yet!\nPlease execute 'custom graph analyze'!"); } LGSPAction[] oldActions; if (args.Length == 1) { oldActions = new LGSPAction[actions.Count]; int i = 0; foreach (LGSPAction action in actions.Values) { oldActions[i] = action; ++i; } } else { oldActions = new LGSPAction[args.Length - 1]; for (int i = 0; i < oldActions.Length; i++) { oldActions[i] = (LGSPAction)GetAction((String)args[i + 1]); if (oldActions[i] == null) { throw new ArgumentException("'" + (String)args[i + 1] + "' is not the name of an action!\n" + "Please use 'show actions' to get a list of the available names."); } } } int startticks = Environment.TickCount; matcherGenerator.LazyNegativeIndependentConditionEvaluation = LazyNIC; matcherGenerator.InlineIndependents = InlineIndependents; matcherGenerator.Profile = Profile; LGSPAction[] newActions = matcherGenerator.GenerateActions(graph, modelAssemblyName, actionsAssemblyName, oldActions); int stopticks = Environment.TickCount; Console.Write("Searchplans for actions "); for (int i = 0; i < oldActions.Length; i++) { actions[oldActions[i].Name] = newActions[i]; if (i != 0) { Console.Write(", "); } Console.Write("'" + oldActions[i].Name + "'"); } Console.WriteLine(" generated in " + (stopticks - startticks) + " ms."); return; } case "dump_sourcecode": if (args.Length != 2) { throw new ArgumentException("Usage: dump_sourcecode <bool>\n" + "If <bool> == true, C# files will be dumped for new searchplans."); } if (!bool.TryParse((String)args[1], out matcherGenerator.DumpDynSourceCode)) { throw new ArgumentException("Illegal bool value specified: \"" + (String)args[1] + "\""); } return; case "dump_searchplan": if (args.Length != 2) { throw new ArgumentException("Usage: dump_searchplan <bool>\n" + "If <bool> == true, VCG and TXT files will be dumped for new searchplans."); } if (!bool.TryParse((String)args[1], out matcherGenerator.DumpSearchPlan)) { throw new ArgumentException("Illegal bool value specified: \"" + (String)args[1] + "\""); } return; case "explain": { if (args.Length != 2) { throw new ArgumentException("Usage: explain <name>\n" + "Explains the searchplan of the given action."); } LGSPAction action = (LGSPAction)GetAction((String)args[1]); if (action == null) { throw new ArgumentException("'" + (String)args[1] + "' is not the name of an action!\n" + "Please use 'show actions' to get a list of the available names."); } if (action.patternGraph.schedules[0] == null) { LGSPGraphStatistics graphStatistics = null; if (StatisticsPath != null) { Console.WriteLine("static search plans from " + StatisticsPath); graphStatistics = new LGSPGraphStatistics(graph.Model); GraphStatisticsParserSerializer parserSerializer = new GraphStatisticsParserSerializer(graphStatistics); parserSerializer.Parse(StatisticsPath); } else { Console.WriteLine("static search plans"); } LGSPMatcherGenerator matcherGen = new LGSPMatcherGenerator(graph.Model); matcherGen.FillInStaticSearchPlans(graphStatistics, InlineIndependents, action); } SourceBuilder sb = new SourceBuilder(); foreach (KeyValuePair <LGSPMatchingPattern, LGSPMatchingPattern> usedSubpattern in action.rulePattern.patternGraph.usedSubpatterns) { usedSubpattern.Key.patternGraph.Explain(sb, graph.Model); } action.patternGraph.Explain(sb, graph.Model); Console.WriteLine(sb.ToString()); return; } default: throw new ArgumentException("Unknown command: " + command); } }
/// <summary> /// Create the statistics parser and serializer, binding it to the statistics object to fill or write out. /// </summary> public GraphStatisticsParserSerializer(LGSPGraphStatistics statistics) { this.statistics = statistics; }