Command
Main > frePPLe Manual > Modeling > Command
All state changes in frePPLe are modeled as commands.
Commands are read from XML input, and executed at the end of parsing/processing all input.
Commands are read and executed, but are never exported or saved again.
A wide range of commands exists to control the application:
- command_python allows to execute Python code in the embedded interpreter.
- command_list groups a number of commands, which can be executed in sequence or in parallel.
- command_loadlib dynamically loads an extension module.
- command_system executes a operating system command.
- command_readxml processes a XML-file from the local file system.
- command_readxmlstring processes a XML-formatted string.
- command_setenv updates an environment variable.
- command_erase removes part of the model or plan from memory.
- command_save saves the model to an XML-formatted file.
- command_saveplan saves the most important plan information to a file.
- command_size prints information about the memory size of the model and other system parameters.
- command_solve runs a solver.
command_python
The command allows you to run Python code in the embedded interpreter. You can specify the Python code directly, or provide the name of a file containing the code.
The interpreter can execute generic scripts, and it also has access to the frePPLe objects.
The interpreter is multi-threaded. Multiple python scripts can run in parallel. However, Python internally executes only one thread at a time and the interpreter switches between the active threads.
A single, global interpreter instance is used. A global Python variable or function is thus visible across multiple invocations of the Python interpreter.
| Field | Type | Description |
| cmdline | String | Python command to be executed. |
| filename | normalizedString | Filename with Python commands to be executed. When both the CMDLINE and FILENAME fields are filled in only the CMDLINE Python code will be executed. |
| verbose | boolean | Echo information about the command execution in the log. |
Example XML structure:
<plan>
<commands>
<command xsi:type="command_python"
cmdline="print 'Hello World'" />
</commands>
</plan>
command_list
This command groups a number of commands, which can be executed in sequence or in parallel.
| Field | Type | Description |
| command | command | The sub-commands part of this list.Multiple sub-commands can be defined. |
| abortonerror | boolean | When executing commands sequentially, this field specifies the behavior in the case of an error:
The default is true. |
| maxparallel | Positive integer | Maximum number of commands to be executed in parallel. The default value is 1, ie sequential execution. |
| verbose | boolean | Echo information about the command execution in the log. This field is inherited by the sub-commands. |
Example XML structure:
<plan>
<commands>
<verbose>true</verbose>
<command xsi-type="command_list" maxparallel="100">
<command xsi:type="command_system"
cmdline="sleep 1 && echo after 1 second" />
<command xsi:type="command_system"
cmdline="sleep 2 && echo after 2 second" />
</command>
</commands>
</plan>
command_loadlib
This command dynamically loads an extension module.
| Field | Type | Description |
| filename | normalizedString | Name of the shared library file to be loaded. The operating system should allow frePPLe to locate the file. The directories listed in the following environment variable should include the module shared library.
|
| parameter | parameter | Initialization and configuration values that are passed to the module's initialization routine. A parameter consists of a PARAMETER and VALUE pair, as shown in the example below. |
| verbose | boolean | Echo information about the command execution in the log. |
Example XML structure:
<plan>
<commands>
<verbose>true</verbose>
<command xsi:type="command_loadlib" filename="mod_python.so" />
<commandxsi:type="command_loadlib" filename="your_module.so">
<parameter name="test1" value="val1"/>
<parameter>
<name>test2</name>
<value>val2</value>
</parameter>
</command>
</commands>
</plan>
command_system
Executes a operating system command in seperate process.
| Field | Type | Description |
| cmdline | string | Command line to be executed in an operating shell. |
| verbose | boolean | Echo information about the command execution in the log. |
Example XML structure:
<plan>
<commands>
<verbose>true</verbose>
<command xsi:type="command_system" cmdline="sleep 1" />
<command xsi:type="command_system" cmdline="do_something.sh" />
</commands>
</plan>
command_readxml
This command reads and processes a XML-file from the local file system.
| Field | Type | Description |
| filename | normalizedString | Name of the data file to be loaded. |
| validate | boolean | When set to true, the XML data are validated against the XML-schema. The default value is true, for security reasons. When parsing large files with a trusted structure setting this field to false will speed up the import. |
| verbose | boolean | Echo information about the command execution in the log. |
Example XML structure:
<plan>
<commands>
<command xsi:type="command_readxml" filename="input.xml" />
</commands>
</plan>
command_readxmlstring
This command processes a XML-formatted data string.
| Field | Type | Description |
| data | string | XML-formatted data to be processed. |
| validate | boolean | When set to true, the XML data are validated against the XML-schema. The default value is true, for security reasons. When processing large data strings with a trusted structure setting this field to false will speed up the execution. |
| verbose | boolean | Echo information about the command execution in the log. |
Example XML structure:
<plan>
<commands>
<commandxsi:type="command_readxmlstring">
<data>
<![CDATA[
<plan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<locations>
<location name="Location 1" action="R"/>
</locations>
</plan>
]]>
</data>
</command>
</commands>
</plan>
command_setenv
This command updates an environment variable.
| Field | Type | Description |
| variable | normalizedString | Environment variable to be updated. |
| value | string | New value of the variable. |
| verbose | boolean | Echo information about the command execution in the log. |
Example XML structure:
<plan>
<commands>
<command xsi:type="command_setenv" variable="VAR1" value="VAL1" />
<!-- Showing the variables in a shell command. -->
<command xsi:type="command_system" cmdline="echo ${VAR1}" />
</commands>
</plan>
command_erase
Use this command to erase the plan or the entire model from memory.
| Field | Type | Description |
| mode | Plan Model | When set to "model" the complete model is erased. You will again have a completely empty model. When set to "plan" only the plan information is erased, ie all operationplans with their load- and flowplans are removed (except the ones that are locked). |
| verbose | boolean | Echo information about the command execution in the log. |
Example XML structure:
<plan>
<commands>
<command xsi:type="command_erase" mode="plan" />
</commands>
</plan>
command_save
This commands saves the model into an XML-formatted file.
| Field | Type | Description |
| filename | normalizedString | Name of the output file. |
| content | STANDARD PLAN PLANDETAIL | Controls the level of detail in the output:
|
| headerstart | string | The first line of the XML output. The default value is: <?xml version="1.0" encoding="UTF-8"?> |
| headeratts | string | Predefined attributes of the XML root-element. The default value is: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| verbose | boolean | Echo information about the command execution in the log. |
Example XML structure:
<plan>
<commands>
<command xsi:type="command_save" filename="output.xml" />
</commands>
</plan>
command_saveplan
This command saves the most important plan information to a file.
It is used for the unit tests, but its' usefullness in a real-life implementation is probably limited.
| Field | Type | Description |
| filename | normalizedString | Name of the output file. |
| verbose | boolean | Echo information about the command execution in the log. |
Example XML structure:
<plan>
<commands>
<command xsi:type="command_saveplan" />
<filename>output.xml</filename>
</command>
</commands>
</plan>
command_size
This command prints information about the memory size of the model and other sytem parameters.
| Field | Type | Description |
| verbose | boolean | Echo information about the command execution in the log. |
Example XML structure:
<plan>
<commands>
<command xsi:type="command_size" />
</commands>
</plan>
command_solve
This command will execute a solver.
| Field | Type | Description |
| solver | solver | Points to the solver to execute. |
| verbose | boolean | Echo information about the command execution in the log. Note that the solver itself uses its LOGLEVEL field to control the amount of information to write about its' progress. |
Example XML structure:
<plan>
<commands>
<verbose>true</verbose>
<command xsi:type="command_solve">
<solver xsi:type="solver_mrp" name="MRP"
constraints="7" loglevel="2" />
</COMMAND>
</commands>
</plan>
