7. Adding runtime parameters - coppolam/swarmulator GitHub Wiki
Swarmulator uses a configuration file called parameters.xml
in order to load run-time parameters. These are loaded when Swarmulator starts.
Default parameters
parameters.xml
is to be found in in the conf
folder.
Here you can edit all the run-time parameters. These are described below:
-
simulation_updatefreq
: Refresh-rate of the simulation. -
simulation_realtimefactor
: Simulation real-time factor. -
window_width
: Height of the animation window (in pixels) -
window_height
: Width of the animation window (in pixels) -
scale
: Scale of the Agents drawn -
mouse_drag_speed
: Sensitivity of the mouse during drag-and-drop actions. Use 1.0 for a 1 to 1 feel. -
mouse_zoom_speed
: Sensitivity of zoom function to motion of the scroll wheel. -
animation_updatefreq
: Frame-rate of the animation. -
logger_updatefreq
: Log-rate. If the logger thread is activated, then this will create a text log at the indicated rate (with respect to the simulation time).
Adding your own runtime parameters
It is possible to easily add your own runtime parameter to Swarmulator. This can be done into three quick steps.
- Open
conf/parameters.xsd
. Here you declare the new parameter as an additional XSD element.<xs:element name="parameter_name" type="xs:parameter_type"/>
- Open
conf/parameters.xml
. Here you define the value of the parameter to be read at runtime.<new_parameter_name>default value</new_parameter_name>
That's it! Now you use the parameter anywhere in the code by callingparam->new_parameter_name()
.