WSF_SCRIPT_PROCESSOR¶
Script Class: WsfProcessor
- processor WSF_SCRIPT_PROCESSOR¶
processor <name> WSF_SCRIPT_PROCESSOR ... processor Commands ... ... Platform Part Commands ... ... External Link Commands ... behavior_tree ... ... Finite State Machine Commands ... update_interval <time-value> on_initialize ...script definition... end_on_initialize on_initialize2 ...script definition... end_on_initialize2 on_update ...script definition... end_on_update on_message ...script definition... end_on_message script void on_message_create(WsfMessage aMessage) ...script definition... end_script end_processor
Overview¶
WSF_SCRIPT_PROCESSOR is a processor that allows the user to provide scripts that can be executed whenever the processor receives a message or is called for a periodic update. In addition, it allows the definition of external links to route messages to other platforms. Besides the regular “on_update” script block on the processor, users can use behavior_tree and Finite State Machine Commands on the script processor to help them organize their script. The order of operation of a script processor each update is:
on_update script block
behavior_tree on the processor.
finite state machine evaluates the current state.
Commands¶
- on_initialize¶
on_initialize ...script definition... end_on_initialize
This block defines a script that is executed during ‘phase 1’ initialization of the processor. During phase 1 initialization the processor may not assume anything about state of platform or any of its constituent parts.
The following script variables are predefined:
double TIME_NOW; // The current simulation time WsfMessage MESSAGE; // The received message WsfPlatform PLATFORM; // The platform containing this processor WsfProcessor PROCESSOR; // This processor (the use of "this" has been deprecated)
- on_initialize2¶
on_initialize2 ...script definition... end_on_initialize2
This block defines a script that is executed during ‘phase 2’ initialization of the processor. During phase 2 initialization the processor may assume the platform and its constituent parts have completed phase 1 initialization.
The following script variables are predefined:
double TIME_NOW; // The current simulation time WsfMessage MESSAGE; // The received message WsfPlatform PLATFORM; // The platform containing this processor WsfProcessor PROCESSOR; // This processor (the use of "this" has been deprecated)
- update_interval <time-value>¶
Specify the interval at which the on_update script should be executed. If this value is not specified then the on_update script will not be executed (even if it is defined).
Default: 0.0 secs
- on_update¶
on_update ...script definition... end_on_update
This block defines a script that is executed in response to the processors periodic update (as defined by the update_interval). If update_interval is not defined or is zero then this block will not be executed.
The following script variables are predefined:
double TIME_NOW; // The current simulation time WsfPlatform PLATFORM; // The platform containing this processor WsfProcessor PROCESSOR; // This processor (the use of "this" has been deprecated)
- on_message¶
on_message [type <message-type> [subtype <message-subtype>] ] [default] script ...script definition... end_script ... end_on_message
This command block defines a script that is executed whenever the processor receives a message. If the script block is preceded by a type / subtype commands, the script will process any messages matching the type/subtype. If the script block is preceded by default, it will process the any message type not yet processed in this block.
type can be any of the following:
Type StringScript ClassWSF_ASSOCIATION_MESSAGEWSF_CONTROL_MESSAGEWSF_IMAGE_MESSAGEWSF_STATUS_MESSAGEWSF_TASK_ASSIGN_MESSAGEWSF_TASK_CANCEL_MESSAGEWSF_TASK_CONTROL_MESSAGEWSF_TASK_STATUS_MESSAGEWSF_DROP_TRACK_MESSAGEWSF_TRACK_DROP_MESSAGE(See note below)WSF_TRACK_MESSAGEWSF_TRACK_NOTIFY_MESSAGEWSF_VIDEO_MESSAGENote
on_message and WSF_MESSAGE_PROCESSOR will accept either WSF_DROP_TRACK_MESSAGE or WSF_TRACK_DROP_MESSAGE as a valid handler for WsfTrackDropMessage. When WSF was created the string type associated with WsfTrackDropMessage was confusingly called WSF_DROP_TRACK_MESSAGE instead of WSF_TRACK_DROP_MESSAGE. At some point the string type will be changed to be consistent, but in the mean time either form will be accepted in the indicated context.
The following script variables are predefined:
double TIME_NOW; // The current simulation time WsfMessage MESSAGE; // The received message WsfPlatform PLATFORM; // The platform containing this processor WsfProcessor PROCESSOR; // This processor (the use of "this" has been deprecated)
Example
on_message type WSF_TRACK_MESSAGE script WsfTrackMessage trackMsg = (WsfTrackMessage)MESSAGE; writeln("T=", TIME_NOW, " Received track: ", trackMsg.Track().TrackId().ToString()); end_script default script writeln("T=", TIME_NOW, " Received other message"); end_script end_on_message
Note
WSF_SCRIPT_PROCESSOR will forward the message to any links after on_message executes. Use WsfProcessor.SuppressMessage() to prevents this behavior.
Finite State Machine Commands¶
- show_state_evaluations¶
Indicates that information about state evaluations should be written to standard output. This essentially shows the true or false status of the evaluation of each next_state block.
- show_state_transitions¶
Indicates that information about state transitions should be written to standard output.
- state <state-name>¶
Defines a state in a state machine with the name <state-name>. Each state can use a different behavior_tree. Each state can have child states defined inside of it.
state <state-name> on_entry ... <script-commands> ... end_on_entry on_exit ... <script-commands> ... end_on_exit next_state <next-state-name-1> ... <script-commands> ... end_next_state next_state <next-state-name-n> ... <script-commands> ... end_next_state behavior_tree ... behavior_tree Commands ... end_behavior_tree state <child-state-name-1> ... end_state state <child-state-name-N> ... end_state end_state
Script Interface¶
All of the methods defined in WsfProcessor (and by derivation those in WsfPlatformPart and WsfObject) are available to any of the scripts defined within this processor.
- on_message_create¶
script void on_message_create(WsfMessage aMessage) ... end_script
This is an optional script that can be defined, which allows one to modify a message internally created by a processor prior to it being sent. This is typically used to override the default priority of a message using WsfMessage.SetPriority
Note
This script is currently invoked ONLY by WSF_TRACK_PROCESSOR prior to sending a WsfTrackMessage or a WsfTrackDropMessage to external recipients. Other processors will be modified in the future to invoke this script if it is defined.