:orphan: .. **************************************************************************** .. CUI .. .. The Advanced Framework for Simulation, Integration, and Modeling (AFSIM) .. .. The use, dissemination or disclosure of data in this file is subject to .. limitation or restriction. See accompanying README and LICENSE for details. .. **************************************************************************** .. _Common_Script_Interface: Common Script Interface ----------------------- Many WSF components use the WSF 'common script interface'. An WSF component that uses the interface will accept: * Definitions of script variables: **script_variables** ... **end_script_variables** * Definitions of scripts: **script** ... **end_script** * Scripting system control commands (e.g., :command:`_.script_commands.script_call_trace`) * `Common Scripts`_ (defined below) The WSF components that currently implement common script interface include: * The simulation. * The platform. * Some processors such as :model:`WSF_SCRIPT_PROCESSOR`, and many others. * Some other platform parts, such as sensors. Example:: processor my-script-proc WSF_SCRIPT_PROCESSOR update_interval 10 sec on_update writeln("T=", TIME_NOW, " ", PLATFORM.Name(), " is updating"); end_on_update end_processor Predefined Variables ==================== All components that use the :ref:`Common_Script_Interface` will have the following predefined variables as is appropriate for the component: double TIME_NOW The current simulation time in seconds. This is available to all scripts. :class:`WsfPlatform` PLATFORM A reference to the platform. This is valid only within the platforms, sensors, and processors that implement the common script interface .. note:: This is not available in simulation-level scripts. :class:`WsfProcessor` PROCESSOR A reference to the processor. This is valid only in processors that use the common script interface (e.g., :model:`WSF_SCRIPT_PROCESSOR`). .. note:: This variable is not available in simulation-level or platform-level scripts :class:`WsfSensor` SENSOR A reference to the :command:`sensor`. This is valid within AFSIM's predefined sensors, as well as any other sensors that use the common script interface. .. note:: This variable is not available in simulation-level or platform-level scripts :class:`WsfRandom` RANDOM A reference to the random number generator used by the simulation. .. note:: Use of this object will affect the simulation's random draws and therefore repeatability of simulation outcomes. Common Scripts ============== Every WSF component that uses the common script interface will accept the following common scripts: .. command:: execute at_time [ absolute | relative ] ...script body... end_execute execute at_interval_of ...script body... end_execute These commands allow you define a script that is to execute once at a specific time or repeatedly at a specified time interval. To execute a script at a specific time: .. parsed-literal:: execute at_time :argtype:`\ ` [ absolute | relative ] :ref:`Script Body