FlightGear next
|
#include <config.h>
#include <string.h>
#include <simgear/compiler.h>
#include <fstream>
#include <optional>
#include <string>
#include <vector>
#include <simgear/debug/ErrorReportingCallback.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/io/iostreams/sgstream.hxx>
#include <simgear/math/sg_random.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
#include <simgear/sg_inlines.h>
#include <simgear/structure/commands.hxx>
#include <simgear/structure/event_mgr.hxx>
#include <simgear/structure/exception.hxx>
#include <simgear/timing/sg_time.hxx>
#include <Network/RemoteXMLRequest.hxx>
#include <FDM/flight.hxx>
#include <Aircraft/replay.hxx>
#include <Scripting/NasalSys.hxx>
#include <Airports/xmlloader.hxx>
#include <Network/HTTPClient.hxx>
#include <Viewer/viewmgr.hxx>
#include <Viewer/view.hxx>
#include <Viewer/VRManager.hxx>
#include <Environment/presets.hxx>
#include <Navaids/NavDataCache.hxx>
#include <GUI/gui.h>
#include <Main/sentryIntegration.hxx>
#include "fg_init.hxx"
#include "fg_io.hxx"
#include "fg_os.hxx"
#include "fg_commands.hxx"
#include "fg_props.hxx"
#include "globals.hxx"
#include "logger.hxx"
#include "main.hxx"
#include "positioninit.hxx"
Go to the source code of this file.
Macros | |
#define | do_vr_recenter no_vr_support |
Functions | |
static SGPropertyNode * | get_prop (const SGPropertyNode *arg, SGPropertyNode *root) |
static SGPropertyNode * | get_prop2 (const SGPropertyNode *arg, SGPropertyNode *root) |
static void | split_value (double full_value, const char *mask, double *unmodifiable, double *modifiable) |
Get a double value and split it as required. | |
template<class T> | |
static std::optional< T > | getValueIndirect (const SGPropertyNode *node, const std::string &name, const std::string &indirectName={}) |
Retrive a typed value from a node, either from <foo> directly or indirectly. | |
static double | limit_value (double value, const SGPropertyNode *arg) |
Clamp or wrap a value as specified. | |
static bool | compare_values (SGPropertyNode *value1, SGPropertyNode *value2) |
static bool | do_null (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: do nothing. | |
static bool | do_nasal (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: run a Nasal script. | |
static bool | do_replay (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: replay the FDR buffer. | |
static bool | do_pause (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: pause/unpause the sim. | |
static bool | do_load (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: load flight. | |
static bool | do_save (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: save flight. | |
static bool | do_save_tape (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: save flight recorder tape. | |
static bool | do_load_tape (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: load flight recorder tape. | |
static void | do_view_next (bool do_it) |
static void | do_view_prev (bool do_it) |
static bool | do_view_cycle (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: cycle view. | |
static bool | do_view_push (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: view-push. | |
static bool | do_view_clone (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: clone view. | |
static bool | do_view_last_pair (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: view last pair. | |
static bool | do_view_last_pair_double (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: double view last pair. | |
static bool | do_view_new (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: double view last pair. | |
static bool | do_video_start (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: video-start. | |
static bool | do_video_stop (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: video-stop. | |
static bool | do_property_toggle (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: toggle a bool property value. | |
static bool | do_property_assign (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: assign a value to a property. | |
static bool | do_property_adjust (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: increment or decrement a property value. | |
static bool | do_property_multiply (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: multiply a property value. | |
static bool | do_property_swap (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: swap two property values. | |
static bool | do_property_scale (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: Set a property to an axis or other moving input. | |
static bool | do_property_cycle (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: cycle a property through a set of values. | |
static bool | do_property_randomize (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: randomize a numeric property value. | |
static bool | do_property_interpolate (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: interpolate a property value over time. | |
static bool | do_data_logging_commit (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: reinit the data logging system based on the current contents of the /logger tree. | |
static bool | do_log_level (const SGPropertyNode *arg, SGPropertyNode *root) |
Built-in command: set log level (0 ... 7) | |
static bool | do_load_xml_to_proptree (const SGPropertyNode *arg, SGPropertyNode *root) |
An fgcommand to allow loading of xml files via nasal, the xml file's structure will be made available within a property tree node defined under argument "targetnode", or in the given argument tree under "data" otherwise. | |
static bool | do_load_xml_from_url (const SGPropertyNode *arg, SGPropertyNode *root) |
static bool | do_save_xml_from_proptree (const SGPropertyNode *arg, SGPropertyNode *root) |
An fgcommand to allow saving of xml files via nasal, the file's structure will be determined based on what's encountered in the passed (source) property tree node. | |
static void | no_profiling_support () |
static bool | do_profiler_start (const SGPropertyNode *arg, SGPropertyNode *root) |
static bool | do_profiler_stop (const SGPropertyNode *arg, SGPropertyNode *root) |
static bool | do_reload_nasal_module (const SGPropertyNode *arg, SGPropertyNode *) |
static bool | no_vr_support (const SGPropertyNode *arg, SGPropertyNode *root) |
void | fgInitCommands () |
Initialize the default built-in commands. | |
Variables | ||
struct { | ||
const char * name | ||
SGCommandMgr::command_t command | ||
} | built_ins [] | |
Table of built-in commands. | ||
#define do_vr_recenter no_vr_support |
Definition at line 1111 of file fg_commands.cxx.
|
static |
Definition at line 204 of file fg_commands.cxx.
|
static |
Built-in command: reinit the data logging system based on the current contents of the /logger tree.
Definition at line 857 of file fg_commands.cxx.
|
static |
Built-in command: load flight.
file (optional): the name of the file to load (relative to current directory). Defaults to "fgfs.sav"
Definition at line 298 of file fg_commands.cxx.
|
static |
Built-in command: load flight recorder tape.
Definition at line 375 of file fg_commands.cxx.
|
static |
Definition at line 963 of file fg_commands.cxx.
|
static |
An fgcommand to allow loading of xml files via nasal, the xml file's structure will be made available within a property tree node defined under argument "targetnode", or in the given argument tree under "data" otherwise.
filename | a string to hold the complete path & filename of an XML file |
targetnode | a string pointing to a location within the property tree where to store the parsed XML file. If <targetnode> is undefined, then the file contents are stored under a node <data> in the argument tree. |
Definition at line 888 of file fg_commands.cxx.
|
static |
Built-in command: set log level (0 ... 7)
Definition at line 868 of file fg_commands.cxx.
|
static |
Built-in command: run a Nasal script.
Definition at line 242 of file fg_commands.cxx.
|
static |
Built-in command: do nothing.
Definition at line 233 of file fg_commands.cxx.
|
static |
Built-in command: pause/unpause the sim.
Definition at line 267 of file fg_commands.cxx.
|
static |
Definition at line 1064 of file fg_commands.cxx.
|
static |
Definition at line 1077 of file fg_commands.cxx.
|
static |
Built-in command: increment or decrement a property value.
If the 'step' argument is present, it will be used; otherwise, the command uses 'offset' and 'factor', usually from the mouse.
property: the name of the property to increment or decrement. step: the amount of the increment or decrement (default: 0). offset: offset from the current setting (used for the mouse; multiplied by factor) factor: scaling amount for the offset (defaults to 1). min: the minimum allowed value (default: no minimum). max: the maximum allowed value (default: no maximum). mask: 'integer' to apply only to the left of the decimal point, 'decimal' to apply only to the right of the decimal point, or 'all' to apply to the whole number (the default). wrap: true if the value should be wrapped when it passes min or max; both min and max must be present for this to work (default: false).
Definition at line 578 of file fg_commands.cxx.
|
static |
Built-in command: assign a value to a property.
property: the name of the property to assign. value: the value to assign; or property[1]: the property to copy from.
Definition at line 539 of file fg_commands.cxx.
|
static |
Built-in command: cycle a property through a set of values.
If the current value isn't in the list, the cycle will (re)start from the beginning.
property: the name of the property to cycle. value[*]: the list of values to cycle through.
Definition at line 709 of file fg_commands.cxx.
|
static |
Built-in command: interpolate a property value over time.
property: the name of the property value to interpolate. type: the interpolation type ("numeric", "color", etc.) easing: name of easing function (see http://easings.net/) value[0..n] any number of constant values to interpolate time/rate[0..n] time between each value, number of time elements must match those of value elements. Instead of time also rate can be used which automatically calculates the time to change the property value at the given speed. -or- property[1..n+1] any number of target values taken from named properties time/rate[0..n] time between each value, number of time elements must match those of value elements. Instead of time also rate can be used which automatically calculates the time to change the property value at the given speed.
Definition at line 786 of file fg_commands.cxx.
|
static |
Built-in command: multiply a property value.
property: the name of the property to multiply. factor: the amount by which to multiply. min: the minimum allowed value (default: no minimum). max: the maximum allowed value (default: no maximum). mask: 'integer' to apply only to the left of the decimal point, 'decimal' to apply only to the right of the decimal point, or 'all' to apply to the whole number (the default). wrap: true if the value should be wrapped when it passes min or max; both min and max must be present for this to work (default: false).
Definition at line 616 of file fg_commands.cxx.
|
static |
Built-in command: randomize a numeric property value.
property: the name of the property value to randomize. min: the minimum allowed value. max: the maximum allowed value.
Definition at line 758 of file fg_commands.cxx.
|
static |
Built-in command: Set a property to an axis or other moving input.
property: the name of the property to set. setting: the current input setting, usually between -1.0 and 1.0. offset: the offset to shift by, before applying the factor. factor: the factor to multiply by (use negative to reverse).
Definition at line 665 of file fg_commands.cxx.
|
static |
Built-in command: swap two property values.
property[0]: the name of the first property. property[1]: the name of the second property.
Definition at line 644 of file fg_commands.cxx.
|
static |
Built-in command: toggle a bool property value.
property: The name of the property to toggle.
Definition at line 524 of file fg_commands.cxx.
|
static |
Definition at line 1088 of file fg_commands.cxx.
|
static |
Built-in command: replay the FDR buffer.
Definition at line 257 of file fg_commands.cxx.
|
static |
Built-in command: save flight.
file (optional): the name of the file to save (relative to the current directory). Defaults to "fgfs.sav".
Definition at line 331 of file fg_commands.cxx.
|
static |
Built-in command: save flight recorder tape.
Definition at line 363 of file fg_commands.cxx.
|
static |
An fgcommand to allow saving of xml files via nasal, the file's structure will be determined based on what's encountered in the passed (source) property tree node.
filename | a string to hold the complete path & filename of the (new) XML file |
sourcenode | a string pointing to a location within the property tree where to find the nodes that should be written recursively into an XML file |
data | if no sourcenode is given, then the file contents are taken from the argument tree's "data" node. |
Definition at line 1013 of file fg_commands.cxx.
|
static |
Built-in command: video-start.
If arg->name exists, we use it as the leafname of the generated video, appending '.'+{/sim/video/container} if it doesn't contain '.' already.
Otherwise we use: fgvideo-{/sim/aircraft}-YYMMDD-HHMMSS.{/sim/video/container}
The video file is generated in directory {/sim/paths/screenshot-dir}.
We also create a convenience link in the same directory called fgvideo-{/sim/aircraft}.<suffix> (where <suffix> is the same suffix as the recording file) that points to the video file.
Definition at line 492 of file fg_commands.cxx.
|
static |
Built-in command: video-stop.
Definition at line 510 of file fg_commands.cxx.
|
static |
Built-in command: clone view.
Definition at line 433 of file fg_commands.cxx.
|
static |
Built-in command: cycle view.
Definition at line 409 of file fg_commands.cxx.
|
static |
Built-in command: view last pair.
Definition at line 445 of file fg_commands.cxx.
|
static |
Built-in command: double view last pair.
Definition at line 457 of file fg_commands.cxx.
|
static |
Built-in command: double view last pair.
Definition at line 469 of file fg_commands.cxx.
|
static |
Definition at line 384 of file fg_commands.cxx.
|
static |
Definition at line 396 of file fg_commands.cxx.
|
static |
Built-in command: view-push.
Definition at line 421 of file fg_commands.cxx.
void fgInitCommands | ( | ) |
Initialize the default built-in commands.
Initialize the built-in commands.
Other commands may be added by other parts of the application.
Definition at line 1197 of file fg_commands.cxx.
|
inlinestatic |
Definition at line 70 of file fg_commands.cxx.
|
inlinestatic |
Definition at line 87 of file fg_commands.cxx.
|
static |
Retrive a typed value from a node, either from <foo> directly or indirectly.
node | - base node from the command to look inside |
name | - direct name of the argument, eg 'min' or 'max' |
indirectName | - indirect name to use, eg, 'min-path'. If empty, the name is formed using the base name and appending '-prop', eg 'min-prop' and 'max-prop'. |
Definition at line 137 of file fg_commands.cxx.
|
static |
Clamp or wrap a value as specified.
Definition at line 165 of file fg_commands.cxx.
|
static |
Definition at line 1052 of file fg_commands.cxx.
|
static |
Definition at line 1104 of file fg_commands.cxx.
|
static |
Get a double value and split it as required.
Definition at line 108 of file fg_commands.cxx.
struct { ... } built_ins[] |
Table of built-in commands.
New commands do not have to be added here; any module in the application can add a new command using globals->get_commands()->addCommand(...).
SGCommandMgr::command_t command |
Definition at line 1137 of file fg_commands.cxx.
const char* name |
Definition at line 1136 of file fg_commands.cxx.