diff --git a/doc/dev_infrastructure/ttool_development_infrastructure.tex b/doc/dev_infrastructure/ttool_development_infrastructure.tex index d2b5148551d8d4169259a1d9f57000a1fe5a54d7..d720df526048be1d14a7e65ebb2ae98a5d575fed 100644 --- a/doc/dev_infrastructure/ttool_development_infrastructure.tex +++ b/doc/dev_infrastructure/ttool_development_infrastructure.tex @@ -1650,7 +1650,7 @@ public static void setDefaultWidthS(String defaultWith) { \end{verbatim} -The "exec" sub command of the "plugin" command can be used to execute custom functions. "exec" takes the following arguments: +The \textbf{exec} sub command of the "plugin" command can be used to execute custom functions. "exec" takes the following arguments: \begin{itemize} \item plugin name \item method name @@ -1672,5 +1672,9 @@ The following example shows how to provide an argument to a custom command. 1> plugin exec CustomizerGraphicalComponent.jar setDefaultWidth 200 \end{verbatim} - +The \textbf{exec-raw} command works similarly apart from the fact that all arguments are given as input to the plugin as one string. For instance, a commane line like: +\begin{verbatim} +1> plugin exec CustomizerGraphicalComponent.jar setDefaultWidthS 100 200 300 +\end{verbatim} +Will result in calling setDefaultWidthS with the String "100 200 300" and not with 3 String arguments ("100", "200", "300") just like for the \textbf{exec} command. \end{document} diff --git a/plugins/testPluginGraphicalComponent/CustomizerGraphicalComponent.java b/plugins/testPluginGraphicalComponent/CustomizerGraphicalComponent.java index e25772c712f4df94f1f3f774e9c7645265d3d26a..2b710003a5d0a65738fdf22e2664831fb7b664de 100644 --- a/plugins/testPluginGraphicalComponent/CustomizerGraphicalComponent.java +++ b/plugins/testPluginGraphicalComponent/CustomizerGraphicalComponent.java @@ -156,6 +156,7 @@ public class CustomizerGraphicalComponent { } public static void setDefaultWidthS(String defaultWith) { + System.out.println("default width=" + defaultWidth); try { DEFAULT_WIDTH = Integer.decode(defaultWith);; } catch (Exception e) { diff --git a/src/main/java/cli/Action.java b/src/main/java/cli/Action.java index 86a89775f68a7f2584156cb2cba6b3a35f938092..89115352a4f595fd6af35f31479703f94859ca04 100644 --- a/src/main/java/cli/Action.java +++ b/src/main/java/cli/Action.java @@ -91,6 +91,7 @@ public class Action extends Command { private final static String DIPLO_FORMAL_VERIFICATION = "diplodocus-formal-verification"; private final static String DIPLO_ONETRACE_SIMULATION = "diplodocus-onetrace-simulation"; private final static String DIPLO_GENERATE_TML = "diplodocus-generate-tml"; + private final static String DIPLO_GENERATE_XML = "diplodocus-generate-xml"; private final static String DIPLO_UPPAAL = "diplodocus-uppaal"; private final static String DIPLO_REMOVE_NOC = "diplodocus-remove-noc"; @@ -605,7 +606,7 @@ public class Action extends Command { if (map == null) { tmlm = interpreter.mgui.gtm.getTMLModeling(); if (tmlm == null) { - return "No model for simulation"; + return "No model for generation"; } } @@ -622,6 +623,53 @@ public class Action extends Command { } }; + // Diplodocus generate XML + Command diplodocusGenerateXML = new Command() { + public String getCommand() { + return DIPLO_GENERATE_XML; + } + + public String getShortCommand() { + return "dgxml"; + } + + public String getDescription() { + return "Generate the XML of a diplodocus model.\n<variable name>: variable in which the " + + "XML specification is saved"; + } + + public String executeCommand(String command, Interpreter interpreter) { + if (!interpreter.isTToolStarted()) { + return Interpreter.TTOOL_NOT_STARTED; + } + + String[] commands = command.split(" "); + if (commands.length < 1) { + return Interpreter.BAD; + } + + String varName = commands[0]; + + TMLMapping map = interpreter.mgui.gtm.getTMLMapping(); + + if (map == null) { + return "No model for generation"; + } + + String tmp = map.toXML(); + if (tmp == null) { + return "XML generation failed"; + } else { + interpreter.addVariable(varName, tmp); + return null; + } + + //} + + //return null; + } + }; + // Diplodocus uppaal Command diplodocusUPPAAL = new Command() { public String getCommand() { @@ -666,7 +714,7 @@ public class Action extends Command { } }; - // Diplodocus generate TML + // Diplodocus remove NoC Command diplodocusRemoveNoC = new Command() { public String getCommand() { return DIPLO_REMOVE_NOC; @@ -1125,6 +1173,7 @@ public class Action extends Command { addAndSortSubcommand(diplodocusFormalVerification); addAndSortSubcommand(diplodocusOneTraceSimulation); addAndSortSubcommand(diplodocusGenerateTML); + addAndSortSubcommand(diplodocusGenerateXML); addAndSortSubcommand(diplodocusUPPAAL); addAndSortSubcommand(diplodocusRemoveNoC); addAndSortSubcommand(movePanelToTheLeftPanel); diff --git a/src/main/java/cli/PluginAction.java b/src/main/java/cli/PluginAction.java index 9cb204f3d073f72cda7789746abf8a5dadaa68cf..01d50dc6d1df3d4401ef1c42af9bc8d703044a77 100644 --- a/src/main/java/cli/PluginAction.java +++ b/src/main/java/cli/PluginAction.java @@ -303,7 +303,7 @@ public class PluginAction extends Command { // execute raw command Command executeRawCommand = new Command() { public String getCommand() { - return EXECUTE_COMMAND_IN_PLUGIN; + return EXECUTE_RAW_COMMAND_IN_PLUGIN; } public String getShortCommand() { @@ -311,8 +311,10 @@ public class PluginAction extends Command { } public String getDescription() { - return "Execute a command. execraw <pluginname> <command> [-ret variable for return value (if applicable)] [arguments in one " + - "string] "; + return "Execute a command. execraw <pluginname> <command> [-ret variable for return value (if applicable)]\n\t <all arguments in " + + "one" + + " " + + "string> "; }