dcsext.interfaces.Command
Command class to run a deferred function.
Contents
Description
Provides a basic Command class to call an arbitrary function at a later time.
Methods
command:register()
Schedule the object to be called by the DCS scheduler.
command:unregister()
Remove this Command from the DCS scheduler.
command:reschedule(time)
Reschedules this Command for a different model time.
Parameters
- time
- the model time to run the Command
command:run(time)
This method is run each time the command is called. This function may be overridden. The default implementation allows the Command class to run an arbitrary function provided at instantiation.
Parameters
- time
Metamethods
command:__init(delay, name, func, …)
Class constructor.
Parameters
- delay
- amount of delay in seconds before the command is run.
- name
- name of the Command, used in log output to differentiate.
- func
- the function to execute later. The function should return either a number representing how long the command should be requeued for before being executed again, otherwise nil to signal the command should not be requeue.
- …
- arguments to pass to the function
Fields
command.self
Execute the deferred function. The deferred function is called in a protected context where the function can take an arbitrary parameter list and returns the same number of values as if the function was called directly. If the environment variable DCSEXT_PROFILE == true a different execute function will be enabled which tracks how long the deferred function takes to execute. This could be beneficial when trying to debug stuttering.
Parameters
- self
- reference to Command object
- time
- time-step the command is executed
command.PRIORITY
General priority of the command. lower value is higher priority; total of 127 priority values