Nasal $FGROOT Library
FlightGear version: 2024.1.1 .
This file was generated automatically by nasal-api-docs at 04-16-2026 12-34-38AM .
nasal-api-docs v1.0.0 | Parser v1.0.0 | Python v3.13.9 .

    Theme:  
 

📄 addons
📄 aircraft
📄 annunciators
📄 aurora
📁 Autopush
📄 autopush
📄 driver
📄 dynarr
📄 route
📄 bits
📁 canvas
📁 api
📄 canvas
📄 colors
📄 element
📄 group
📄 helpers
📄 image
📄 map
📄 path
📄 svgcanvas
📄 text
📄 transform
📄 api
📁 draw
📄 compass
📄 draw
📄 scales
📄 transform
📄 draw
📄 ErrorNotification
📁 gui
📄 Config
📁 dialogs
📄 AircraftCenter
📄 InputDialog
📄 MessageBox
📄 PropertyTreeBrowser
📄 WidgetsFactoryDialog
📄 Menu
📄 MenuBar
📄 Overlay
📄 Popup
📄 Style
📁 styles
📄 DefaultStyle
📄 Widget
📁 widgets
📄 Button
📄 CdlgWidgets
📄 CheckBox
📄 ComboBox
📄 Dial
📄 Frame
📄 Label
📄 LineEdit
📄 List
📄 MenuBar
📄 PropertyTree
📄 PropertyWidgets
📄 RadioButton
📄 Rule
📄 ScrollArea
📄 Slider
📄 Switch
📄 TabWidget
📄 gui
📄 ImageTest
📄 KeyBinding
📁 map
📁 Airbus
📁 Images
📁 Images
📄 map
📄 MapDrivers
📄 MapStructure
📄 MFD_Generic
📁 PFD
📄 DataEntryElement
📄 DefaultStyle
📄 GroupElement
📄 HighlightElement
📄 HighlightTimer
📄 PointerElement
📄 RotatingElement
📄 ScrollElement
📄 TextElement
📄 UIElement
📄 PropertyElement
📄 svg
📄 tooltip
📄 checklist
📁 console
📄 repl
📄 contrail
📄 controls
📁 debug
📄 emesary.deb
📄 debug
📄 dynamic_view
📄 earthview
📄 emesary
📄 emesary_mp_bridge
📄 emexec
📄 environment
📄 events
📁 FailureMgr
📄 private
📄 public
📄 frame_utils
📄 fuel
📄 geo
📄 glide_slope_tunnel
📄 globals
📁 gui
📄 MenuBar
📄 XMLDialog
📄 gui
📁 input_helpers
📄 config_manager
📄 goflight
📄 honeycomb
📄 io
📁 jetways
📄 jetways
📁 jetways_edit
📄 jetways_edit
📄 joystick
📄 lag_adjust
📁 local_weather
📄 cloud_definitions
📄 cloud_placement_lowlevel
📄 compat_layer
📄 local_weather
📄 sea_colors
📄 weather_dynamics
📄 weather_tile_management
📄 weather_tiles
📄 local_weather_auto_init
📄 markerpins
📄 material
📄 math
📁 modules
📁 canvas_efis
📄 display-unit
📄 efis-canvas
📄 efis-framework
📄 efis
📄 eicas-message-sys
📄 main
📄 dummy
📄 repair_config
📄 modules
📄 mp_broadcast
📄 multikey
📄 multiplayer
📄 notifications
📄 orbital_target
📁 performance_monitor
📄 monitor
📄 prop_key_handler
📄 props
📄 redout
📄 route_manager
📄 scenery
📄 screen
📄 screenshot
📄 seaport
📁 std
📄 algorithm
📄 hash
📄 string
📄 Vector
📄 std
📄 string
📄 tanker
📁 towing
📄 hitch
📄 track_target
📁 tutorial
📄 tutorial
📄 video
📄 view
📄 volcano
📄 weather_scenario
📄 windsock

📄 addons     Nasal/addons.nas

addons._modules

Initialize addons configured with --addon=foobar command line switch:

- get the list of registered add-ons

- load the addon-main.nas file of each add-on into namespace

__addon[ADDON_ID]__

- call function main() from every such addon-main.nas with the add-on ghost

as argument (an addons.Addon instance).

Example:

fgfs --addon=/foo/bar/baz

- AddonManager.cxx parses /foo/bar/baz/addon-metadata.xml

- AddonManager.cxx creates prop nodes under /addons containing add-on metadata

- AddonManager.cxx loads /foo/bar/baz/addon-config.xml into the Property Tree

- AddonManager.cxx adds /foo/bar/baz to the list of aircraft paths (to get

permissions to read files from there)

- this script loads /foo/bar/baz/addon-main.nas into namespace

__addon[ADDON_ID]__

- this script calls main(addonGhost) from /foo/bar/baz/addon-main.nas.

- the add-on ghost can be used to retrieve most of the add-on metadata, for

instance:

addonGhost.id the add-on identifier

addonGhost.name the add-on name

addonGhost.version.str() the add-on version as a string

addonGhost.basePath the add-on base path (realpath() of

"/foo/bar/baz" here)

etc.

For more details, see $FG_ROOT/Docs/README.add-ons.

hashes to store listeners and timers per addon ID

addons.getNamespaceName ( a )

addons.load ( a )

addons.remove ( a )

addons._reloadFlags

addons.reload ( a )

addons.commandAddonReload ( node )

addons.init ( )

📄 aircraft     Nasal/aircraft.nas

aircraft.makeNode ( n )

This module provide basic functions and classes for use in aircraft specific

Nasal context.

helper functions

==============================================================================

creates (if necessary) and returns a property node from arg[0],

which can be a property node already, or a property path

aircraft.optarg ( args, index, default )

returns args[index] if available and non-nil, or default otherwise

aircraft.door

door

==============================================================================

class for objects moving at constant speed, with the ability to

reverse moving direction at any point. Appropriate for doors, canopies, etc.

SYNOPSIS:

door.new(<property>, <swingtime> [, <startpos>]);

property ... door node: property path or node

swingtime ... time in seconds for full movement (0 -> 1)

startpos ... initial position (default: 0)

PROPERTIES:

./position-norm (double) (default: <startpos>)

./enabled (bool) (default: 1)

EXAMPLE:

var canopy = aircraft.door.new("sim/model/foo/canopy", 5);

canopy.open();

aircraft.door.new ( node, swingtime, pos = 0 )

aircraft.door.enable ( v )

door.enable(bool) -> set ./enabled

aircraft.door.setpos ( pos )

door.setpos(double) -> set ./position-norm without movement

aircraft.door.getpos ( )

double door.getpos() -> return current position as double

aircraft.door.close ( )

door.close() -> move to closed state

aircraft.door.open ( )

door.open() -> move to open state

aircraft.door.toggle ( )

door.toggle() -> move to opposite end position

aircraft.door.stop ( )

door.stop() -> stop movement

aircraft.door.move ( target )

door.move(double) -> move to arbitrary position

aircraft.light

light

==============================================================================

class for generation of pulsing values. Appropriate for controlling

beacons, strobes, etc.

SYNOPSIS:

light.new(<property>, <pattern> [, <switch>]);

light.new(<property>, <stretch>, <pattern> [, <switch>]);

property ... light node: property path or node

stretch ... multiplicator for all pattern values

pattern ... array of on/off time intervals (in seconds)

switch ... property path or node to use as switch (default: ./enabled)

instead of ./enabled

PROPERTIES:

./state (bool) (default: 0)

./enabled (bool) (default: 0) except if <switch> given)

EXAMPLES:

aircraft.light.new("sim/model/foo/beacon", [0.4, 0.4]); # anonymous light

-------

var strobe = aircraft.light.new("sim/model/foo/strobe", [0.05, 0.05, 0.05, 1],

"controls/lighting/strobe");

strobe.switch(1);

-------

var switch = props.globals.getNode("controls/lighting/strobe", 1);

var pattern = [0.02, 0.03, 0.02, 1];

aircraft.light.new("sim/model/foo/strobe-top", 1.001, pattern, switch);

aircraft.light.new("sim/model/foo/strobe-bot", 1.005, pattern, switch);

aircraft.light.new ( )

aircraft.light.del ( )

class destructor

aircraft.light.switch ( v )

light.switch(bool) -> set light switch (also affects other lights

that use the same switch)

aircraft.light.toggle ( )

light.toggle() -> toggle light switch

aircraft.light.cont ( )

light.cont() -> continuous light

aircraft.light.blink ( count = -1, endstate = 0 )

light.blink() -> blinking light (default)

light.blink(3) -> when switched on, only run three blink sequences;

second optional arg defines state after the sequences

aircraft.light._switch_ ( )

aircraft.light._loop_ ( id )

aircraft.lowpass

lowpass

==============================================================================

class that implements a variable-interval EWMA (Exponentially Weighted

Moving Average) lowpass filter with characteristics independent of the

frame rate.

SYNOPSIS:

lowpass.new(<coefficient>);

EXAMPLE:

var lp = aircraft.lowpass.new(1.5);

print(lp.filter(10)); # prints 10

print(lp.filter(0));

aircraft.lowpass.new ( coeff )

aircraft.lowpass.filter ( v )

filter(raw_value) -> push new value, returns filtered value

aircraft.lowpass.get ( )

get() -> returns filtered value

aircraft.lowpass.set ( v )

set() -> sets new average and returns it

aircraft.lowpass._filter_ ( v )

aircraft.angular_lowpass

angular lowpass

==============================================================================

same as above, but for angles. Filters sin/cos separately and calculates the

angle again from them. This avoids unexpected jumps from 179.99 to -180 degree.

aircraft.angular_lowpass.new ( coeff )

aircraft.angular_lowpass.filter ( v )

aircraft.angular_lowpass.set ( v )

aircraft.angular_lowpass.get ( )

aircraft.data

data

==============================================================================

class that loads and saves properties to aircraft-specific data files in

~/.fgfs/aircraft-data/ (Unix) or %APPDATA%\flightgear.org\aircraft-data\.

There's no public constructor, as the only needed instance gets created

by the system.

SYNOPSIS:

data.add(<properties>);

data.save([<interval>])

properties ... about any combination of property nodes (props.Node)

or path name strings, or lists or hashes of them,

lists of lists of them, etc.

interval ... save in <interval> minutes intervals, or only once

if 'nil' or empty (and again at reinit/exit)

SIGNALS:

/sim/signals/save ... set to 'true' right before saving. Can be used

to update values that are to be saved

EXAMPLE:

var p = props.globals.getNode("/sim/model", 1);

var vec = [p, p];

var hash = {"foo": p, "bar": p};

# add properties

aircraft.data.add("/sim/fg-root", p, "/sim/fg-home");

aircraft.data.add(p, vec, hash, "/sim/fg-root");

# now save only once (and at exit/reinit, which is automatically done)

aircraft.data.save();

# or save now and every 30 sec (and at exit/reinit)

aircraft.data.save(0.5);

aircraft.data.init ( )

aircraft.data.load ( )

aircraft.data.save ( v = nil )

aircraft.data._save_ ( )

aircraft.data.add ( p... )

aircraft.data.remove ( p... )

aircraft.timer

timer

==============================================================================

class that implements timer that can be started, stopped, reset, and can

have its value saved to the aircraft specific data file. Saving the value

is done automatically by the aircraft.Data class.

SYNOPSIS:

timer.new(<property> [, <resolution:double> [, <save:bool>]])

<property> ... property path or props.Node hash that holds the timer value

<resolution> ... timer update resolution -- interval in seconds in which the

timer property is updated while running (default: 1 s)

<save> ... bool that defines whether the timer value should be saved

and restored next time, as needed for Hobbs meters

(default: 1)

EXAMPLES:

var hobbs_turbine = aircraft.timer.new("/sim/time/hobbs/turbine[0]", 60);

hobbs_turbine.start();

aircraft.timer.new("/sim/time/hobbs/battery", 60).start(); # anonymous timer

aircraft.timer.new ( prop, res = 1, save = 1 )

aircraft.timer.del ( )

aircraft.timer.start ( )

aircraft.timer.stop ( )

aircraft.timer.reset ( )

aircraft.timer._apply_ ( )

aircraft.timer._save_ ( )

aircraft.timer._loop_ ( id )

aircraft.livery

livery

=============================================================================

Class that maintains livery XML files (see English Electric Lightning for an

example). The last used livery is saved on exit and restored next time. Livery

files are regular PropertyList XML files whose properties are copied to the

main tree.

SYNOPSIS:

livery.init(<livery-dir> [, <name-path> [, <sort-path>]]);

<livery-dir> ... directory with livery XML files, relative to $FG_ROOT

<name-path> ... property path to the livery name in the livery files

and the property tree (default: sim/model/livery/name)

<sort-path> ... property path to the sort criterion (default: same as

<name-path> -- that is: alphabetic sorting)

EXAMPLE:

aircraft.livery.init("Aircraft/Lightning/Models/Liveries",

"sim/model/livery/variant",

"sim/model/livery/index"); # optional

aircraft.livery.dialog.toggle();

aircraft.livery.select("OEBH");

aircraft.livery.next();

aircraft.livery.init ( dir, nameprop = )

aircraft.livery_update

livery_update

=============================================================================

Class for maintaining liveries in MP aircraft. It is used in Nasal code that's

embedded in aircraft animation XML files, and checks in intervals whether the

parent aircraft has changed livery, in which case it changes the livery

in the remote aircraft accordingly. This class is a wrapper for overlay_update.

SYNOPSIS:

livery_update.new(<livery-dir> [, <interval:10> [, <func>]]);

<livery-dir> ... directory with livery files, relative to $FG_ROOT

<interval> ... checking interval in seconds (default: 10)

<func> ... callback function that's called with the ./sim/model/livery/file

contents as argument whenever the livery has changed. This can

be used for post-processing.

EXAMPLE:

<nasal>

<load>

var livery_update = aircraft.livery_update.new(

"Aircraft/R22/Models/Liveries", 30,

func print("R22 livery update"));

</load>

<unload>

livery_update.stop();

</unload>

</nasal>

aircraft.livery_update.new ( liveriesdir, interval = 10.01, callback = nil )

aircraft.livery_update.stop ( )

aircraft.overlay_update

overlay_update

=============================================================================

Class for maintaining overlays in MP aircraft. It is used in Nasal code that's

embedded in aircraft animation XML files, and checks in intervals whether the

parent aircraft has changed an overlay, in which case it copies the respective

overlay to the aircraft's root directory.

SYNOPSIS:

livery_update.new();

livery_update.add(<overlay-dir>, <property> [, <callback>]);

<overlay-dir> ... directory with overlay files, relative to $FG_ROOT

<property> ... MP property where the overlay file name can be found

(usually one of the sim/multiplay/generic/string properties)

<callback> ... callback function that's called with two arguments:

the file name (without extension) and the overlay directory

EXAMPLE:

<nasal>

<load>

var update = aircraft.overlay_update.new();

update.add("Aircraft/F4U/Models/Logos", "sim/multiplay/generic/string");

</load>

<unload>

update.stop();

</unload>

</nasal>

aircraft.overlay_update.new ( )

aircraft.overlay_update.add ( path, prop, callback = nil )

aircraft.overlay_update.stop ( )

aircraft.overlay_update._loop_ ( )

aircraft.steering

steering

=============================================================================

Class that implements differential braking depending on rudder position.

Note that this overrides the controls.applyBrakes() wrapper. If you need

your own version, then override it again after the steering.init() call.

SYNOPSIS:

steering.init([<property> [, <threshold>]]);

<property> ... property path or props.Node hash that enables/disables

brake steering (usually bound to the js trigger button)

<threshold> ... defines range (+- threshold) around neutral rudder

position in which both brakes are applied

EXAMPLES:

aircraft.steering.init("/controls/gear/steering", 0.2);

aircraft.steering.init();

aircraft.steering.init ( switch = )

aircraft.steering._loop_ ( id )

aircraft.steering.setbrakes ( left, right )

aircraft.autotrim

autotrim

=============================================================================

Singleton class that supports quick trimming and compensates for the lack

of resistance/force feedback in most joysticks. Normally the pilot trims such

that no real or artificially generated (by means of servo motors and spring

preloading) forces act on the stick/yoke and it is in a comfortable position.

This doesn't work well on computer joysticks.

SYNOPSIS:

autotrim.start(); # on key/button press

autotrim.stop(); # on key/button release (mod-up)

USAGE:

(1) move the stick such that the aircraft is in an orientation that

you want to trim for (forward flight, hover, ...)

(2) press autotrim button and keep it pressed

(3) move stick/yoke to neutral position (center)

(4) release autotrim button

aircraft.autotrim.init ( )

aircraft.autotrim.start ( )

aircraft.autotrim.stop ( )

aircraft.autotrim._loop_ ( id )

aircraft.autotrim.update ( )

aircraft.autotrim.new ( name )

aircraft.autotrim.start ( )

aircraft.autotrim.update ( )

aircraft.tyresmoke

tyresmoke

=============================================================================

Provides a property which can be used to contol particles used to simulate tyre

smoke on landing. Weight on wheels, vertical speed, ground speed, ground friction

factor are taken into account. Tyre slip is simulated by low pass filters.

Modifications to the model file are required.

Generic XML particle files are available, but are not mandatory

(see Hawker Seahawk for an example).

SYNOPSIS:

aircraft.tyresmoke.new(gear index [, auto = 0])

gear index - the index of the gear to which the tyre smoke is attached

auto - enable automatic update (recommended). defaults to 0 for backward compatibility.

aircraft.tyresmoke.del()

destructor.

aircraft.tyresmoke.update()

Runs the update. Not required if automatic updates are enabled.

EXAMPLE:

var tyresmoke_0 = aircraft.tyresmoke.new(0);

tyresmoke_0.update();

PARAMETERS:

number: index of gear to be animated, i.e. "2" for /gear/gear[2]/...

auto: 1 when tyresmoke should start on update loop. 0 when you're going

to call the update method from one of your own loops.

diff_norm: value adjusting the necessary percental change of roll-speed

to trigger tyre smoke. Default value is 0.05. More realistic results can

be achieved with significantly higher values (i.e. use 0.8).

check_vspeed: 1 when tyre smoke should only be triggered when vspeed is negative

(usually doesn't work for all gear, since vspeed=0.0 after the first gear touches

ground). Use 0 to make tyre smoke independent of vspeed.

Note: in reality, tyre smoke doesn't depend on vspeed, but only on acceleration

and friction.

rain_norm_trigger: threshold for deciding that there is enough standing water to

calculate spray. This is compared against rain-norm.

aircraft.tyresmoke.new ( number, auto = 0, diff_norm = 0.05, check_vspeed=1, rain_norm_trigger=0.2 )

aircraft.tyresmoke.del ( )

aircraft.tyresmoke.calc_spray_factor ( groundspeed_kts )

aircraft.tyresmoke.update ( )

aircraft.tyresmoke._wowchanged_ ( )

aircraft.tyresmoke_system

tyresmoke_system

=============================================================================

Helper class to contain the tyresmoke objects for all the gears.

Will update automatically, nothing else needs to be done by the caller.

SYNOPSIS:

aircraft.tyresmoke_system.new(<gear index 1>, <gear index 2>, ...)

<gear index> - the index of the gear to which the tyre smoke is attached

aircraft.tyresmoke_system.del()

destructor

EXAMPLE:

var tyresmoke_system = aircraft.tyresmoke_system.new(0, 1, 2, 3, 4);

aircraft.tyresmoke_system.new ( )

aircraft.tyresmoke_system.del ( )

aircraft.rain

rain

=============================================================================

Provides a property which can be used to control rain. Can be used to turn

off rain in internal views, and or used with a texture on canopies etc.

The output is co-ordinated with system precipitation:

/sim/model/rain/raining-norm rain intensity

/sim/model/rain/flow-mps drop flow speed [m/s]

See Hawker Seahawk for an example.

SYNOPSIS:

aircraft.rain.init();

aircraft.rain.update();

aircraft.rain.init ( )

aircraft.rain.update ( )

aircraft.teleport ( airport = speed = 0, distance = 0, azimuth = 0, glideslope = 0, heading = 9999 )

teleport

=============================================================================

Usage: aircraft.teleport(lat:48.3, lon:32.4, alt:5000);

aircraft.wind_speed_from ( azimuth )

returns wind speed [kt] from given direction [deg]; useful for head-wind

aircraft.kias_to_ktas ( kias, altitude )

returns true airspeed for given indicated airspeed [kt] and altitude [m]

aircraft.HUD

HUD control class to handle both HUD implementations

==============================================================================

aircraft.HUD.init ( )

aircraft.HUD.cycle_color ( )

aircraft.HUD.cycle_brightness ( )

aircraft.HUD.normal_type ( )

aircraft.HUD.cycle_type ( )

aircraft.HUD.is_active ( )

aircraft.crossfeed_valve

crossfeed_valve

=============================================================================

class that creates a fuel tank cross-feed valve. Designed for YASim aircraft;

JSBSim aircraft can simply use systems code within the FDM (see 747-400 for

an example).

WARNING: this class requires the tank properties to be ready, so call new()

after the FDM is initialized.

SYNOPSIS:

crossfeed_valve.new(<max_flow_rate>, <property>, <tank>, <tank>, ... );

crossfeed_valve.open(<update>);

crossfeed_valve.close(<update>);

<max_flow_rate> ... maximum transfer rate between the tanks in lbs/sec

<property> ... property path to use as switch - pass nil to use no such switch

<tank> ... number of a tank to connect - can have unlimited number of tanks connected

<update> ... update switch property when opening/closing valve via Nasal - 0 or 1; by default, 1

EXAMPLES:

aircraft.crossfeed_valve.new(0.5, "/controls/fuel/x-feed", 0, 1, 2);

-------

var xfeed = aircraft.crossfeed_valve.new(1, nil, 0, 1);

xfeed.open();

aircraft.crossfeed_valve.new ( flow_rate, path )

aircraft.crossfeed_valve.open ( update_prop = 1 )

aircraft.crossfeed_valve.close ( update_prop = 1 )

aircraft.crossfeed_valve._loop_ ( id )

📄 annunciators     Nasal/annunciators.nas

📄 aurora     Nasal/aurora.nas

aurora.aurora_manager

Aurora Borealis manager

this runs once at startup to randomize Aurora appearance

a little and otherwise simulates detailed Aurora evolution

only when requested by the user

aurora.aurora_manager.init ( )

aurora.aurora_manager.state ( )

aurora.aurora_manager.start ( )

aurora.aurora_manager.stop ( )

aurora.aurora_manager.update ( )

aurora.aurora_manager.evolve ( )

📁 Autopush     Nasal/Autopush/

📄 autopush     Nasal/Autopush/autopush.nas

autopush._loop ( )

autopush._start ( )

autopush._stop ( )

📄 driver     Nasal/Autopush/driver.nas

driver._advance_wp ( flip_sign = 0 )

driver._loop ( )

driver._done ( )

driver.start ( )

driver.pause ( )

driver.stop ( )

📄 dynarr     Nasal/Autopush/dynarr.nas

📄 route     Nasal/Autopush/route.nas

route._add ( pos )

route.delete_last ( )

route._stop ( fail = 0 )

route._place_user_point_models ( )

route._clear_user_point_models ( )

route._place_waypoint_models ( )

route._clear_waypoint_models ( )

route.top_view ( )

route._finalize_top_view ( )

route._calculate_route ( )

route._calculate_bezier ( user_points )

route._calculate_hdg ( )

route._check_turn_radius ( )

Checks each waypoint's turn radius and marks the route invalid if

it is smaller than the aircraft's turn radius.

route.enter ( )

route._set_userpoint_mode ( id, mode )

route.toggle_sharp ( )

route.done ( )

route.clear ( )

route.route ( )

route.route_reverse ( )

📄 bits     Nasal/bits.nas

bits.test ( n, b )

checks whether bit <b> is set in number <n>

bits.set ( n, b )

returns number <n> with bit <b> set

bits.clear ( n, b )

returns number <n> with bit <b> cleared

bits.toggle ( n, b )

returns number <n> with bit <b> toggled

bits.switch ( n, b, v )

returns number <n> with bit <b> set to value <v>

bits.string ( n, len = 1 )

returns number <n> as bit string, zero-padded to <len> digits:

bits.string(6) -> "110"

bits.string(6, 8) -> "00000110"

bits.value ( s )

returns bit string <s> as number: bits.value("110") -> 6

📁 canvas     Nasal/canvas/

📁 api     Nasal/canvas/api/

📄 canvas     Nasal/canvas/api/canvas.nas

canvas.Canvas

-------------------------------------------------------------------------------

Canvas

-------------------------------------------------------------------------------

Class for a canvas

not to be confused with the namespace canvas (case sensitive!)

canvas.Canvas._new ( canvas_ghost )

private helper for wrapCanvas;

canvas.Canvas.addPlacement ( vals )

Place this canvas somewhere onto the object. Pass criterions for placement

as a hash, eg:

my_canvas.addPlacement({

"texture": "EICAS.png",

"node": "PFD-Screen",

"parent": "Some parent name"

});

Note that we can choose whichever of the three filter criterions we use for

matching the target object for our placement. If none of the three fields is

given every texture of the model will be replaced.

canvas.Canvas.createGroup ( id = nil )

Create a new group with the given name

@param id Optional id/name for the group

canvas.Canvas.getGroup ( id )

Get the group with the given name

canvas.Canvas.setColorBackground ( )

Set the background color

@param color Vector of 3 or 4 values in [0, 1]

canvas.Canvas.getColorBackground ( )

canvas.Canvas.getPath ( )

Get path of canvas to be used eg. in Image::setFile

canvas.Canvas.del ( )

Destructor

releases associated canvas and makes this object unusable

📄 colors     Nasal/canvas/api/colors.nas

📄 element     Nasal/canvas/api/element.nas

element.Element

-------------------------------------------------------------------------------

canvas.Element

-------------------------------------------------------------------------------

Baseclass for all elements on a canvas

element.Element.new ( ghost )

Constructor

@param ghost Element ghost as retrieved from core methods

element.Element.getType ( )

element.Element.getParent ( )

Get parent group/element

element.Element.getCanvas ( )

Get the canvas this element is placed on

element.Element.equals ( el )

Check if elements represent same instance

@param el Other Element or element ghost

element.Element.setVisible ( visible = 1 )

Hide/Show element

@param visible Whether the element should be visible

element.Element.getVisible ( )

element.Element.hide ( )

Hide element (Shortcut for setVisible(0))

element.Element.show ( )

Show element (Shortcut for setVisible(1))

element.Element.toggleVisibility ( )

Toggle element visibility

element.Element.setGeoPosition ( lat, lon )

element.Element.createTransform ( vals = nil )

Create a new transformation matrix

@param vals Default values (Vector of 6 elements)

element.Element.setTranslation ( )

Shortcut for setting translation

element.Element.getTranslation ( )

Get translation set with #setTranslation

element.Element.setRotation ( rot )

Set rotation around transformation center (see #setCenter).

@note This replaces the the existing transformation. For additional scale

or translation use additional transforms (see #createTransform).

element.Element.setScale ( )

Shortcut for setting scale

element.Element.getScale ( )

Shortcut for getting scale

element.Element.setColorFill ( )

Set the fill/background/boundingbox color

@param color Vector of 3 or 4 values in [0, 1]

element.Element.getColorFill ( )

element.Element.getTransformedBounds ( )

element.Element.updateCenter ( )

Calculate the transformation center based on bounding box and center-offset

element.Element.setCenter ( )

Set transformation center (currently only used for rotation)

element.Element.getCenter ( )

Get transformation center

element.Element.setSize ( )

Set size in pixels

Use either with x, y size:

e.setSize(<x>, <y>)

or with a vector containing x, y:

e.setSize([<x>, <y>])

element.Element.getSize ( )

return vector [sx, sy] with dimensions of bounding box

element.Element.boundingbox2clip ( bb )

convert bounding box vector into clip string (yes, different order)

element.Element.setClipByBoundingBox ( bounding_box, clip_frame = nil )

set clip by bounding box

bounding_box: [xmin, ymin, xmax, ymax]

element.Element.setClipByElement ( clip_elem )

set clipping by bounding box of another element

element.Element._getTf ( )

Internal Transform for convenience transform functions

element.Element._setupCenterNodes ( cx = nil, cy = nil )

📄 group     Nasal/canvas/api/group.nas

group.Group

-------------------------------------------------------------------------------

canvas.Group

-------------------------------------------------------------------------------

Class for a group element on a canvas

group.Group.new ( ghost )

group.Group.createChild ( type, id = nil )

Create a child of given type with specified id.

type can be group, text

group.Group.createChildren ( type, count )

Create multiple children of given type

group.Group.rect ( x, y, w, h, cfg = nil )

Create a path child drawing a (rounded) rectangle

@param x Position of left border

@param y Position of top border

@param w Width

@param h Height

@param cfg Optional settings (eg. {"border-top-radius": 5})

group.Group.getChildren ( )

Get a vector of all child elements

group.Group.getChildrenOfType ( type, array = nil )

Recursively get all children of class specified by first param

group.Group.setColor ( )

Set color to children of type Path and Text. It is possible to optionally

specify which types of children should be affected by passing a vector as

the last agrument, ie. my_group.setColor(1,1,1,[Path]);

group.Group.getWidth ( )

group.Group.getHeight ( )

group.Group.getElementById ( id )

Get first child with given id (breadth-first search)

@note Use with care as it can take several miliseconds (for me eg. ~2ms).

TODO check with new C++ implementation

group.Group.removeAllChildren ( )

Remove all children

group.Group._isElementNode ( el )

private:

element nodes have type NONE and valid element names (those in the factory

list)

group.Group._wrapElement ( node )

Create element from existing node

group.Group._getFactory ( type )

📄 helpers     Nasal/canvas/api/helpers.nas

helpers._getColor ( color )

-------------------------------------------------------------------------------

canvas API helper functions

-------------------------------------------------------------------------------

helpers._arg2valarray ( )

📄 image     Nasal/canvas/api/image.nas

image.Image

-------------------------------------------------------------------------------

canvas.Image

-------------------------------------------------------------------------------

Class for an image element on a canvas

image.Image.new ( ghost )

image.Image.setFile ( file )

Set image file to be used

@param file Path to file or canvas (Use canvas://... for canvas, eg.

canvas://by-index/texture[0])

image.Image.setSourceRect ( )

Set rectangular region of source image to be used

@param left Rectangle minimum x coordinate

@param top Rectangle minimum y coordinate

@param right Rectangle maximum x coordinate

@param bottom Rectangle maximum y coordinate

@param normalized Whether to use normalized ([0,1]) or image

([0, image_width]/[0, image_height]) coordinates

image.Image.setSize ( )

Set size of image element

@param width

@param height

- or -

@param size ([width, height])

📄 map     Nasal/canvas/api/map.nas

map.Map

-------------------------------------------------------------------------------

canvas.Map

-------------------------------------------------------------------------------

Class for a group element on a canvas with possibly geographic positions

which automatically get projected according to the specified projection.

Each map consists of an arbitrary number of layers (canvas groups)

map.Map.new ( ghost )

map.Map.del ( )

map.Map.setController ( controller=nil, arg... )

map.Map.getController ( )

map.Map.addLayer ( factory, type_arg=nil, priority=nil, style=nil, opts=nil, visible=1 )

map.Map.getLayer ( type_arg )

map.Map.setRange ( range )

map.Map.setScreenRange ( range )

map.Map.setPos ( lat, lon, hdg=nil, range=nil, alt=nil )

map.Map.getPos ( )

map.Map.getLat ( me.get )

map.Map.getLon ( me.get )

map.Map.getHdg ( me.get )

map.Map.getAlt ( me.get )

map.Map.getRange ( me.get )

map.Map.getScreenRange ( me.get )

map.Map.getLatLon ( )

map.Map.getPosCoord ( )

N.B.: This always returns the same geo.Coord object,

so its values can and will change at any time (call

update() on the coord to ensure it is up-to-date,

which basically calls this method again).

map.Map.update ( predicate=nil )

Update each layer on this Map. Called by

me.controller.

📄 path     Nasal/canvas/api/path.nas

path.Path

-------------------------------------------------------------------------------

canvas.Path

-------------------------------------------------------------------------------

Class for an (OpenVG) path element on a canvas

path.Path.new ( ghost )

path.Path.reset ( )

Remove all existing path data

path.Path.setData ( cmds, coords )

Set the path data (commands and coordinates)

path.Path.setDataGeo ( cmds, coords )

path.Path.addSegment ( cmd, coords... )

Add a path segment

path.Path.addSegmentGeo ( cmd, coords... )

path.Path.pop_front ( )

Remove first segment

path.Path.pop_back ( )

Remove last segment

path.Path.getNumSegments ( )

Get the number of segments

path.Path.getNumCoords ( )

Get the number of coordinates (each command has 0..n coords)

path.Path.moveTo ( me.addSegment )

Move path cursor

path.Path.move ( me.addSegment )

path.Path.lineTo ( me.addSegment )

Add a line

path.Path.line ( me.addSegment )

path.Path.horizTo ( me.addSegment )

Add a horizontal line

path.Path.horiz ( me.addSegment )

path.Path.vertTo ( me.addSegment )

Add a vertical line

path.Path.vert ( me.addSegment )

path.Path.quadTo ( me.addSegment )

Add a quadratic Bézier curve

path.Path.quad ( me.addSegment )

path.Path.cubicTo ( me.addSegment )

Add a cubic Bézier curve

path.Path.cubic ( me.addSegment )

path.Path.squadTo ( me.addSegment )

Add a smooth quadratic Bézier curve

path.Path.squad ( me.addSegment )

path.Path.scubicTo ( me.addSegment )

Add a smooth cubic Bézier curve

path.Path.scubic ( me.addSegment )

path.Path.arcSmallCCWTo ( me.addSegment )

Draw an elliptical arc (shorter counter-clockwise arc)

path.Path.arcSmallCCW ( me.addSegment )

path.Path.arcSmallCWTo ( me.addSegment )

Draw an elliptical arc (shorter clockwise arc)

path.Path.arcSmallCW ( me.addSegment )

path.Path.arcLargeCCWTo ( me.addSegment )

Draw an elliptical arc (longer counter-clockwise arc)

path.Path.arcLargeCCW ( me.addSegment )

path.Path.arcLargeCWTo ( me.addSegment )

Draw an elliptical arc (shorter clockwise arc)

path.Path.arcLargeCW ( me.addSegment )

path.Path.close ( me.addSegment )

Close the path (implicit lineTo to first point of path)

path.Path.rect ( x, y, w, h, cfg = nil )

Add a (rounded) rectangle to the path

@param x Position of left border

@param y Position of top border

@param w Width

@param h Height

@param cfg Optional settings (eg. {"border-top-radius": 5})

path.Path.square ( x, y, l, cfg = nil )

Add a (rounded) square to the path

@param x Position of left border

@param y Position of top border

@param l length

@param cfg Optional settings (eg. {"border-top-radius": 5})

path.Path.ellipse ( rx, ry, cx = nil, cy = nil )

Add an ellipse to the path

@param rx radius x

@param ry radius y

@param cx (optional) center x coordinate or vector [cx, cy]

@param cy (optional) center y coordinate

path.Path.circle ( r, cx = nil, cy = nil )

Add a circle to the path

@param r radius

@param cx (optional) center x coordinate or vector [cx, cy]

@param cy (optional) center y coordinate

path.Path.setColor ( )

path.Path.getColor ( )

path.Path.setColorFill ( )

path.Path.getColorFill ( )

path.Path.setFill ( fill )

path.Path.setStroke ( stroke )

path.Path.getStroke ( )

path.Path.setStrokeLineWidth ( width )

path.Path.setStrokeLineCap ( linecap )

Set stroke linecap

@param linecap String, "butt", "round" or "square"

See http://www.w3.org/TR/SVG/painting.html#StrokeLinecapProperty for details

path.Path.setStrokeLineJoin ( linejoin )

Set stroke linejoin

@param linejoin String, "miter", "round" or "bevel"

See http://www.w3.org/TR/SVG/painting.html#StrokeLinejoinProperty for details

path.Path.setStrokeDashArray ( pattern )

Set stroke dasharray

@param pattern Vector, Vector of alternating dash and gap lengths

[on1, off1, on2, ...]

path.Path._removeSegment ( front )

private:

📄 svgcanvas     Nasal/canvas/api/svgcanvas.nas

svgcanvas.SVGCanvas

SPDX-License-Identifier: GPL-2.0-or-later

NOTE! This copyright does *not* cover user models that use these Nasal

services by normal function calls - this is merely considered normal use

of the code, and does *not* fall under the heading of "derived work."

-------------------------------------------------------------------------------

svgcanvas.nas - base class to populate canvas from SVG and animate elements

author: jsb

created: 06/2020

-------------------------------------------------------------------------------

Examples:

var myCanvas = SVGCanvas.new("mySVG");

myCanvas.loadsvg("myfile.svg", ["foo", "bar"]);

to hide/show a SVG element based on a property you can use:

var L = setlistener("/controls/foo", myCanvas._makeListener_showHide("foo"));

to animate a SVG element you can use:

myCanvas["bar"].setTranslation(10,20);

-------------------------------------------------------------------------------

svgcanvas.SVGCanvas.new ( name, settings=nil )

constructor

name: name of canvas

settings: hash with canvas settings

svgcanvas.SVGCanvas.del ( )

svgcanvas.SVGCanvas.loadSVG ( file, svg_keys, options=nil )

loadSVG - loads SVG file and create canvas.element objects for given IDs

file: filename to load

svg_keys: vector of id strings

options: options to canvas.parsesvg

svgcanvas.SVGCanvas.asWindow ( window_size )

openInWindow - opens the canvas in a window

window_size: vector [size_x, size_y] passed to canvas.Window.new

returns canvas.window object

svgcanvas.SVGCanvas.getPath ( )

svgcanvas.SVGCanvas.getCanvas ( )

svgcanvas.SVGCanvas.getRoot ( )

svgcanvas.SVGCanvas.updateTextElement ( svgkey, text, color = nil )

svgkey: id of text element to updateTextElement

text: new text

svgcanvas.SVGCanvas._updateClip ( key )

--------------------------------------------------------------

private methods, to be used in this and derived classes only

--------------------------------------------------------------

svgcanvas.SVGCanvas._makeListener_showHide ( svgkeys, value=nil )

returns generic listener to show/hide element(s)

svgkeys: can be a string referring to a single element

or vector of strings referring to SVG elements

(hint: if possible, group elements in SVG and animate group)

value: optional value to trigger show(); otherwise node.value will be implicitly treated as bool

svgcanvas.SVGCanvas._makeListener_rotate ( svgkeys, factors=nil )

returns listener to set rotation of element(s)

svgkeys: can be a string referring to a single element

or vector of strings referring to SVG elements

factors: optional, number (if svgkeys is a single key) or hash of numbers

{"svgkey" : factor}, missing keys will be treated as 1

svgcanvas.SVGCanvas._makeListener_translate ( svgkeys, fx, fy )

returns listener to set translation of element(s)

svgkeys: can be a string referring to a single element

or vector of strings referring to SVG elements

factors: number (if svgkeys is a single key) or hash of numbers

{"svgkey" : factor}, missing keys will be treated as 0 (=no op)

svgcanvas.SVGCanvas._makeListener_setColor ( svgkeys, color_true, color_false )

returns generic listener to change element color

svgkeys: can be a string referring to a single element

or vector of strings referring to SVG elements

(hint: putting elements in a SVG group (if possible) might be easier)

colors can be either a vector e.g. [r,g,b] or "name" from me.colors

svgcanvas.SVGCanvas._makeListener_updateText ( svgkeys, format= )

📄 text     Nasal/canvas/api/text.nas

text.font_mapper ( family = nil, weight = nil, style = nil, options = nil )

-------------------------------------------------------------------------------

canvas.Text

-------------------------------------------------------------------------------

Class for a text element on a canvas

text.Text

text.Text.new ( ghost )

text.Text.setText ( text )

Set the text

text.Text.getText ( )

text.Text.enableUpdate ( )

enable reduced property I/O update function

text.Text.updateText ( text )

reduced property I/O text update template

text.Text.enableFast ( )

enable fast setprop-based text writing

text.Text.setTextFast ( text )

fast, setprop-based text writing template

text.Text.appendText ( text )

append text to an existing string

text.Text.setAlignment ( align )

Set alignment

@param align String, one of:

left-top

left-center

left-bottom

center-top

center-center

center-bottom

right-top

right-center

right-bottom

left-baseline

center-baseline

right-baseline

left-bottom-baseline

center-bottom-baseline

right-bottom-baseline

text.Text.setFontSize ( size, aspect = 1 )

Set the font size

text.Text.setFont ( name )

Set font (by name of font file)

text.Text.setDrawMode ( mode )

Set draw mode. Binary combination of the values above. Since I have not

found a bitwise "or" we have to use a "+" instead.

e.g. my_text.setDrawMode(Text.TEXT + Text.BOUNDINGBOX);

text.Text.setPadding ( pad )

Set bounding box padding

text.Text.setMaxWidth ( w )

text.Text.setColor ( )

text.Text.getColor ( )

text.Text.setColorFill ( )

text.Text.getColorFill ( )

📄 transform     Nasal/canvas/api/transform.nas

transform.Transform

-------------------------------------------------------------------------------

Transform

-------------------------------------------------------------------------------

A transformation matrix which is used to transform an #Element on the canvas.

The dimensions of the matrix are 3x3 where the last row is always 0 0 1:

a c e

b d f

0 0 1

See http://www.w3.org/TR/SVG/coords.html#TransformMatrixDefined for details.

https://www.w3.org/TR/css-transforms-1/#mathematical-description

transform.Transform.new ( node, vals = nil )

transform.Transform.setTranslation ( )

transform.Transform.getTranslation ( )

transform.Transform.setRotation ( angle )

Set rotation (Optionally around a specified point instead of (0,0))

setRotation(rot)

setRotation(rot, cx, cy)

@note If using with rotation center different to (0,0) do not use

#setTranslation as it would interfere with the rotation.

transform.Transform.setScale ( )

Set scale (either as parameters or array)

If only one parameter is given its value is used for both x and y

setScale(x, y)

setScale([x, y])

transform.Transform.getScale ( )

transform.Transform.setGeoPosition ( lat, lon )

this function is called very often, if a canvas map is active and

the aircraft symbol is shown.

📄 api     Nasal/canvas/api.nas

api.wrapCanvas ( g )

@param g Canvas ghost

api.new ( vals )

Create a new canvas. Pass parameters as hash, eg:

var my_canvas = canvas.new({

"name": "PFD-Test",

"size": [512, 512],

"view": [768, 1024],

"mipmapping": 1

});

api.get ( arg )

Get the first existing canvas with the given name

@param name Name of the canvas

@return #Canvas, if canvas with #name exists

nil, otherwise

api.Desktop

subclass of Group representing the desktop

api.Desktop.new ( ghost )

api.Desktop.addResizedCallback ( cb )

api.Desktop.removeResizedCallback ( cb )

api.Desktop._callSizeChangedCallbacks ( )

@private

@description Helper function that calls all callbacks in @m _sizeChangedCallbacks in the order they were added.

api.getDesktop ( )

api.unload ( )

📁 draw     Nasal/canvas/draw/

📄 compass     Nasal/canvas/draw/compass.nas

compass.CompassRose

canvas.draw library - compass rose module

created 12/2018 by jsb

WARNING: this is still under development, interfaces may change

compass.CompassRose.new ( )

compass.CompassRose.setMarkCount ( value )

compass.CompassRose.setLabelCount ( value )

compass.CompassRose.setLabelDivisor ( value )

divide course by this value before creating text label. (try 10, 1 or 0)

compass.CompassRose.setFontSize ( value )

compass.CompassRose.draw ( cgroup, radius, style=nil )

draw a compass rose

cgroup canvas group, marks and lables will be created as children

📄 draw     Nasal/canvas/draw/draw.nas

draw.draw

canvas.draw library

created 12/2018 by jsb

based on plot2D.nas from the oscilloscope add-on by R. Leibner

Contains functions to draw path elements on an existing canvas group.

- basic shapes

- grids

- scale marks

Basic shapes:

These are macros calling existing API command for path elements.

They return a path element, no styling done. You can easily do by passing

the returned element to other existing functions like setColor, e.g.

var myCircle = canvas.circle(myCanvasGroup, 10, 30, 30).setColor(myColor)

Grids:

draw horizontal and vertical lines

from the Oscilloscope add-on by rleibner with a few modifications

Scale marks:

Draw equidistant lines ("marker", "ticks") perpendicular to a baseline.

Baseline can be a horizontal or vertical line or a part of a circle.

This is a building block for compass rose and tapes.

draw.draw.line ( cgroup, from, to )

draw line; from and to must be vectors [x,y]

draw.draw.hline ( cgroup, length, from = nil )

draw horizontal line;

from: optional, vector, defaults to [0,0]

or scalar

draw.draw.vline ( cgroup, length, from = nil )

draw vertical line;

from: optional, vector, defaults to [0,0]

or scalar

draw.draw.circle ( cgroup, radius, center_x = nil, center_y = nil )

if center_x is given as vector, its first two elements define the center

and center_y is ignored

draw.draw.ellipse ( cgroup, radius_x, radius_y, center_x = nil, center_y = nil )

if center_x is given as vector, its first two elements define the center

and center_y is ignored

draw.draw.arc ( cgroup, radius, center, from_deg = nil, to_deg = nil )

draw part of a circle

radius as integer (for circle) or [rx,ry] (for ellipse) in pixels.

center vector [x,y]

from_deg begin of arc in degree (0 = north, increasing clockwise)

to_deg end of arc

draw.draw.rectangle ( cgroup, width, height, x = 0, y = 0, rounded = nil )

x, y is top, left corner

draw.draw.square ( cgroup, length, center_x = 0, center_y = 0, cfg = nil )

x, y is top, left corner

draw.draw.deltoid ( cgroup, dx, dy1, dy2, x = 0, y = 0 )

deltoid draws a kite (dy1 > 0 and dy2 > 0) or a arrow head (dy2 < 0)

dx = width

dy1 = height of "upper" triangle

dy2 = height of "lower" triangle, < 0 draws an arrow head

x, y = position of tip

draw.draw.rhombus ( cgroup, dx, dy, center_x = 0, center_y = 0 )

draw a "diamond"

dx: width

dy: height

draw.draw.new ( )

draw.draw.set ( key, value )

set value of existing(!) key

draw.draw.get ( key )

draw.draw.setColor ( )

draw.draw.getColor ( )

draw.draw.setColorFill ( )

draw.draw.setStrokeLineWidth ( )

draw.draw.new ( )

draw.draw.setBaselineWidth ( value )

draw.draw.setMarkLength ( value )

draw.draw.setMarkOffset ( value )

position of mark relative to baseline, call this with MARK_* defined above

-1 = left, 0 = center, 1 = right

draw.draw.setMarkWidth ( value )

draw.draw.setSubdivisions ( value )

draw.draw.setSubdivisionLength ( value )

draw.draw.marksLinear ( cgroup, orientation, num_marks, interval, style )

draw.marksLinear: draw marks for a linear scale on a canvas group, e.g. speed tape

mark lines are draws perpendicular to baseline

orientation of baseline; "up", "down", "left", "right"

num_marks number of marks to draw

interval distance between marks (pixel)

style marksStyle hash with more parameters

draw.draw.marksCircular ( cgroup, radius, interval, phi_start = 0, phi_stop = 360, style = nil )

radius of baseline (circle)

interval distance of marks in degree

phi_start position of first mark in degree (default 0 = north)

phi_stop position of last mark in degree (default 360)

draw.draw.grid ( cgroup )

draw.grid

1) (cgroup, [sizeX, sizeY], dx, dy, border = 1)

2) (cgroup, nx, ny, dx, dy, border = 1)

size [width, height] in pixels.

nx, ny number of lines in x/y direction

dx tiles width in pixels.

dy tiles height in pixels.

border optional as boolean, True by default.

draw.draw.arrow ( cgroup, length, origin_center=0 )

📄 scales     Nasal/canvas/draw/scales.nas

scales.Scale

canvas.draw library - scale module for speed tape etc.

created 12/2018 by jsb

The Scale class combines draw.marks* with text labels to create scales/gauges

to build speed tape, compass etc.

scales.Scale.new ( )

scales.Scale.setOrientation ( value )

the 'draw direction' for a linear scale (up, down, left, right)

scales.Scale.setFontSize ( value )

scales.Scale.setSpacing ( value )

scales.Scale.setLabelInterval ( value )

draw one text label every <value> marks

scales.Scale.setLabelDistanceAbs ( value )

Distance of text label to mark in pixel (be careful when resizing).

See also setLabelDistanceRel()

scales.Scale.setLabelDistanceRel ( value )

Distance of text label to mark in %mark_length (easy scaling).

scales.Scale.getAlignmentString ( )

get alignment of text label for linear scales based on style params

scales.Scale.draw ( cgroup, start, count, increment, style=nil )

draw a scale on canvas group

start first value of scale

count number of values to draw

increment value to add (can be negative)

📄 transform     Nasal/canvas/draw/transform.nas

transform.transform

canvas.transform library

created 12/2018 by jsb

based on plot2D.nas from the oscilloscope add-on by R. Leibner

Contains functions to transform existing canvas elements.

transform.transform._xy ( elem, uv )

transform.transform.move ( elem, dx, dy )

transform.transform.rotate ( elem, deg, center )

transform.transform.flipX ( elem, xaxis = 0 )

transform.transform.flipY ( elem, yaxis = 0 )

transform.transform.alignX ( elem, ref, alignment )

Aligns the element, moving it horizontaly to ref.

params:

elem element to be moved.

ref reference may be an integer or another element.

alignment as string: may be 'left-left', 'left-center', 'left-right',

'center-left', 'center-center', 'center-right',

'right-left', 'right-center', 'right-right'.

If ref is a single number, the 2nd word is ignored.

transform.transform.alignY ( elem, ref, alignment )

Aligns the element, moving it vertically to ref.

params:

elem element to be moved.

ref reference may be an integer or another element.

alignment as string: may be 'top-top', 'top-center', 'top-bottom',

'center-top', 'center-center', 'center-bottom',

'bottom-top', 'bottom-center', 'bottom-bottom'.

text elements also accept 'baseline' as reference.

If ref is a single number, the 2nd word is ignored.

transform.transform.rotate180 ( elem, center = nil )

center as [x,y] in pixels, otherwise in place

transform.transform.scaleX ( elem, factor, ref = )

Stretch element horizontally

params:

elem element to be stretched.

factor the <new-width>/<old-width> ratio.

ref the relative point to keep inplace. May be 'left', 'center' or 'right'.

transform.transform.scaleY ( elem, factor, ref = )

strech element vertically

params:

elem element to be stretched.

factor the <new-height>/<old-height> ratio.

ref the relative point to keep inplace. May be 'top', 'center' or 'bottom'.

transform.transform.resize ( elem, factors, ref = )

factors as [Xfactor, Yfactor] .

ref the relative point to keep inplace:

may be 'left-top', 'left-center', 'left-bottom',

'center-top', 'center-center', 'center-bottom',

'right-top', 'right-center', 'right-bottom'.

📄 draw     Nasal/canvas/draw.nas

draw._canvas_draw_load

canvas_draw loader

03/2020 by jsb

if you add files to the draw subdirectory, add corresponding lines below in

the main() function

draw._canvas_draw_load.load ( filename )

draw._canvas_draw_load.main ( )

📄 ErrorNotification     Nasal/canvas/ErrorNotification.nas

ErrorNotification.showErrorNotification ( node )

ErrorNotification.unloadErrorNotification ( )

called from unload() in api.nas

📁 gui     Nasal/canvas/gui/

📄 Config     Nasal/canvas/gui/Config.nas

Config.Config

Config.Config.new ( cfg )

Config.Config.get ( key, default = nil )

Config.Config.set ( key, value )

📁 dialogs     Nasal/canvas/gui/dialogs/

📄 AircraftCenter     Nasal/canvas/gui/dialogs/AircraftCenter.nas

AircraftCenter.AircraftCenter

AircraftCenter.AircraftCenter.new ( )

AircraftCenter.AircraftCenter.addPage ( name, filter )

AircraftCenter.AircraftCenter.fillList ( packages )

AircraftCenter.AircraftCenter._addPackageEntries ( packages, begin, end )

@param packages

@param begin index of first package

@param end index after last package

📄 InputDialog     Nasal/canvas/gui/dialogs/InputDialog.nas

InputDialog.InputDialog

InputDialog.InputDialog.new ( title = label = "", text = "" )

InputDialog.InputDialog.setTitle ( title )

InputDialog.InputDialog.setLabel ( label )

InputDialog.InputDialog.setText ( text )

InputDialog.InputDialog.exec ( cb = nil )

InputDialog.InputDialog.getText ( title, label, cb, text = )

Show an input dialog to get a text string

@param title

@param label

@param cb Dialog close callback

@param text Default text

📄 MessageBox     Nasal/canvas/gui/dialogs/MessageBox.nas

MessageBox.MessageBox

MessageBox.MessageBox.new ( )

MessageBox.MessageBox.setTitle ( title )

MessageBox.MessageBox.setImage ( img )

MessageBox.MessageBox.setText ( text )

MessageBox.MessageBox.setStandardButtons ( mask )

MessageBox.MessageBox.exec ( cb = nil )

MessageBox.MessageBox.show ( title, text, icon = nil, cb = nil, buttons = nil )

MessageBox.MessageBox.critical ( title, text, cb = nil, buttons = nil )

Show an error/critical message in a message box

@param title

@param text

@param cb Dialog close callback

@param buttons Mask indicating the buttons to show

(default: MessageBox.Ok)

MessageBox.MessageBox.warning ( title, text, cb = nil, buttons = nil )

Show a warning message in a message box

@param title

@param text

@param cb Dialog close callback

@param buttons Mask indicating the buttons to show

(default: MessageBox.Ok)

MessageBox.MessageBox.information ( title, text, cb = nil, buttons = nil )

Show an informative message in a message box

@param title

@param text

@param cb Dialog close callback

@param buttons Mask indicating the buttons to show

(default: MessageBox.Ok)

MessageBox.MessageBox.question ( title, text, cb = nil, buttons = nil )

Show a question in a message box

@param title

@param text

@param cb Dialog close callback

@param buttons Mask indicating the buttons to show

(default: MessageBox.Yes | MessageBox.No)

MessageBox.MessageBox._loadSelection ( )

MessageBox.MessageBox._saveSelection ( sel )

📄 PropertyTreeBrowser     Nasal/canvas/gui/dialogs/PropertyTreeBrowser.nas

PropertyTreeBrowser.PropertyTreeBrowser

PropertyTreeBrowser.PropertyTreeBrowser.new ( node = nil )

PropertyTreeBrowser.PropertyTreeBrowser.clone ( )

PropertyTreeBrowser.PropertyTreeBrowser.onClose ( )

PropertyTreeBrowser.PropertyTreeBrowser.show ( )

PropertyTreeBrowser.PropertyTreeBrowser.hide ( )

PropertyTreeBrowser.PropertyTreeBrowser.del ( )

PropertyTreeBrowser.PropertyTreeBrowser.getWindowTitle ( node )

📄 WidgetsFactoryDialog     Nasal/canvas/gui/dialogs/WidgetsFactoryDialog.nas

WidgetsFactoryDialog.WidgetsFactoryDialog

WidgetsFactoryDialog.WidgetsFactoryDialog.new ( )

WidgetsFactoryDialog.WidgetsFactoryDialog.benchmark_widget ( widget, proc_func=nil, amount=50, cfg=nil )

WidgetsFactoryDialog.WidgetsFactoryDialog.benchmark_radio_button ( proc_func=nil, amount=50, cfg= nil )

WidgetsFactoryDialog.WidgetsFactoryDialog.del ( )

📄 Menu     Nasal/canvas/gui/Menu.nas

📄 MenuBar     Nasal/canvas/gui/MenuBar.nas

📄 Overlay     Nasal/canvas/gui/Overlay.nas

📄 Popup     Nasal/canvas/gui/Popup.nas

📄 Style     Nasal/canvas/gui/Style.nas

📁 styles     Nasal/canvas/gui/styles/

📄 DefaultStyle     Nasal/canvas/gui/styles/DefaultStyle.nas

DefaultStyle.DefaultStyle

DefaultStyle.DefaultStyle.new ( name, name_icon_theme )

DefaultStyle.DefaultStyle.createWidget ( parent, type, cfg )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.setText ( model, text )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.setText ( model, text )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setText ( )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.setText ( model, text )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.setText ( model, text )

DefaultStyle.DefaultStyle.setImage ( model, img )

DefaultStyle.DefaultStyle.setBackground ( model, bg )

@description Set or clear the background color of the label

@param bg scalar CSS color or 'none'

DefaultStyle.DefaultStyle.setColor ( model, color )

DefaultStyle.DefaultStyle.heightForWidth ( w )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle._createElement ( name, type )

protected:

DefaultStyle.DefaultStyle._deleteElement ( name )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.setText ( model, text )

DefaultStyle.DefaultStyle.setPlaceholder ( model, placeholder )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setColorBackground ( )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle._newScroll ( el, orient )

private:

DefaultStyle.DefaultStyle._updateScrollMetrics ( model, dir )

Calculate size and limits of scroller

@param model

@param dir 0 for horizontal, 1 for vertical

@return [scroller_size, min_pos, max_pos]

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.setText ( model, text )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setText ( )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.setText ( model, text )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle._createElement ( name, type )

protected:

DefaultStyle.DefaultStyle._deleteElement ( name )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle._createElement ( name, type )

protected:

DefaultStyle.DefaultStyle._deleteElement ( name )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle._updateLayoutSizes ( model )

DefaultStyle.DefaultStyle.setNormValue ( model, normValue )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle._drawTicks ( model )

DefaultStyle.DefaultStyle._createElement ( name, type )

protected:

DefaultStyle.DefaultStyle._deleteElement ( name )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle._updateLayoutSizes ( model )

DefaultStyle.DefaultStyle.setSize ( model, length )

DefaultStyle.DefaultStyle._drawTicks ( model )

DefaultStyle.DefaultStyle._updateMaxValueWidth ( model )

DefaultStyle.DefaultStyle.setValue ( model, value )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle._updateLayoutSizes ( model )

DefaultStyle.DefaultStyle.setText ( model, text )

DefaultStyle.DefaultStyle.setShortcut ( model, shortcut )

DefaultStyle.DefaultStyle.setIcon ( model, icon )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.setText ( model, text )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle._updateLayoutSizes ( model )

DefaultStyle.DefaultStyle.setText ( model, text )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle.new ( parent, cfg )

DefaultStyle.DefaultStyle.setSize ( model, w, h )

DefaultStyle.DefaultStyle.update ( model )

DefaultStyle.DefaultStyle._updateLayoutSizes ( model )

📄 Widget     Nasal/canvas/gui/Widget.nas

📁 widgets     Nasal/canvas/gui/widgets/

📄 Button     Nasal/canvas/gui/widgets/Button.nas

📄 CdlgWidgets     Nasal/canvas/gui/widgets/CdlgWidgets.nas

CdlgWidgets.cdlg_widget_box

generic widgets for canvas dialogs

Thorsten Renk 2018

widget definitions ##############################################################

CdlgWidgets.cdlg_widget_box.new ( root, width, height, color, fill_color )

CdlgWidgets.cdlg_widget_box.setTranslation ( x, y )

CdlgWidgets.cdlg_widget_box.setPercentageHt ( x )

CdlgWidgets.cdlg_widget_box.setContextHelp ( f )

CdlgWidgets.cdlg_widget_tank

tank gauge ##############################################################

CdlgWidgets.cdlg_widget_tank.new ( root, radius, color, fill_color )

CdlgWidgets.cdlg_widget_tank.setTranslation ( x, y )

CdlgWidgets.cdlg_widget_tank.setPercentage ( x )

CdlgWidgets.cdlg_widget_tank.setContextHelp ( f )

CdlgWidgets.cdlg_widget_property_label

property display labels ##############################################################

CdlgWidgets.cdlg_widget_property_label.new ( root, text, text_color = nil, color = nil, fill_color = nil )

CdlgWidgets.cdlg_widget_property_label.setTranslation ( x, y )

CdlgWidgets.cdlg_widget_property_label.updateText ( text )

CdlgWidgets.cdlg_widget_property_label.setText ( text )

CdlgWidgets.cdlg_widget_property_label.setValue ( value )

CdlgWidgets.cdlg_widget_property_label.formatValue ( value )

CdlgWidgets.cdlg_widget_property_label.formatFunction ( value )

CdlgWidgets.cdlg_widget_property_label.setUnit ( unit )

CdlgWidgets.cdlg_widget_property_label.setLimits ( lLower, lUpper )

CdlgWidgets.cdlg_widget_property_label.check_limits ( value )

CdlgWidgets.cdlg_widget_property_label.setFont ( font )

CdlgWidgets.cdlg_widget_property_label.setFontSize ( size )

CdlgWidgets.cdlg_widget_property_label.setScale ( x, y = nil )

CdlgWidgets.cdlg_widget_property_label.setBoxScale ( x, y = nil )

CdlgWidgets.cdlg_widget_property_label.getOffset ( string )

CdlgWidgets.cdlg_widget_infobox

infobox ##############################################################

CdlgWidgets.cdlg_widget_infobox.new ( root, width, title, texts, corner_radius = 0.0, frame_color = nil, title_color = nil, title_fill = nil, text_color = nil, text_fill = nil )

CdlgWidgets.cdlg_widget_infobox.setTranslation ( x, y )

CdlgWidgets.cdlg_widget_infobox.setText ( i, text )

CdlgWidgets.cdlg_widget_infobox.setValueText ( i, text )

CdlgWidgets.cdlg_widget_infobox.setUnit ( unit )

CdlgWidgets.cdlg_widget_infobox.setValue ( i, value )

CdlgWidgets.cdlg_widget_infobox.formatFunction ( value )

CdlgWidgets.cdlg_widget_infobox.getOffset ( string )

CdlgWidgets.cdlg_widget_img_stack

image stack ##############################################################

CdlgWidgets.cdlg_widget_img_stack.new ( root, stack, width, height, button_flag = 0 )

CdlgWidgets.cdlg_widget_img_stack.setTranslation ( x, y )

CdlgWidgets.cdlg_widget_img_stack.increment ( )

CdlgWidgets.cdlg_widget_img_stack.set_index ( index )

CdlgWidgets.cdlg_widget_img_stack.depress ( )

CdlgWidgets.cdlg_widget_img_stack.setContextHelp ( f )

CdlgWidgets.cdlg_widget_img_stack.f ( )

CdlgWidgets.cdlg_widget_analog_gauge

analog gauge ##############################################################

CdlgWidgets.cdlg_widget_analog_gauge.new ( root, gauge_bg, gauge_needle, width, height )

CdlgWidgets.cdlg_widget_analog_gauge.setTranslation ( x, y )

CdlgWidgets.cdlg_widget_analog_gauge.setAngle ( angle )

CdlgWidgets.cdlg_clickspot

clickspots ##############################################################

CdlgWidgets.cdlg_clickspot.new ( x, y, rw, rh, tab, type )

CdlgWidgets.cdlg_clickspot.check_event ( click_x, click_y )

CdlgWidgets.cdlg_clickspot.update_fractions ( click_x, click_y )

CdlgWidgets.cdlg_clickspot.get_fraction_up ( )

CdlgWidgets.cdlg_clickspot.get_fraction_right ( )

CdlgWidgets.cdlg_clickspot.f ( )

📄 CheckBox     Nasal/canvas/gui/widgets/CheckBox.nas

📄 ComboBox     Nasal/canvas/gui/widgets/ComboBox.nas

📄 Dial     Nasal/canvas/gui/widgets/Dial.nas

📄 Frame     Nasal/canvas/gui/widgets/Frame.nas

📄 Label     Nasal/canvas/gui/widgets/Label.nas

📄 LineEdit     Nasal/canvas/gui/widgets/LineEdit.nas

📄 List     Nasal/canvas/gui/widgets/List.nas

📄 MenuBar     Nasal/canvas/gui/widgets/MenuBar.nas

📄 PropertyTree     Nasal/canvas/gui/widgets/PropertyTree.nas

📄 PropertyWidgets     Nasal/canvas/gui/widgets/PropertyWidgets.nas

📄 RadioButton     Nasal/canvas/gui/widgets/RadioButton.nas

📄 Rule     Nasal/canvas/gui/widgets/Rule.nas

📄 ScrollArea     Nasal/canvas/gui/widgets/ScrollArea.nas

📄 Slider     Nasal/canvas/gui/widgets/Slider.nas

📄 Switch     Nasal/canvas/gui/widgets/Switch.nas

📄 TabWidget     Nasal/canvas/gui/widgets/TabWidget.nas

📄 gui     Nasal/canvas/gui.nas

gui.gui

FlightGear canvas gui

Namespace: canvas

Classes:

WindowButton

Window

see also api.nas

gui.loadGUIFile ( file )

gui.loadWidget ( name )

gui.loadDialog ( name )

gui.WindowButton

gui.WindowButton.new ( parent, name )

gui.WindowButton._onStateChange ( )

protected:

gui.Window

gui.Window.new ( size, type = nil, id = nil, allowfocus = 1, destroy_on_close = 1 )

Constructor

@param size ([width, height])

gui.Window.del ( )

Destructor

gui.Window.setTitle ( title )

gui.Window.createCanvas ( )

Create the canvas to be used for this Window

@return The new canvas

gui.Window.setCanvas ( canvas_ )

Set an existing canvas to be used for this Window

gui.Window.getCanvas ( create = 0 )

Get the displayed canvas

gui.Window.getCanvasDecoration ( )

gui.Window.setLayout ( l )

gui.Window.setFocus ( )

gui.Window.clearFocus ( )

gui.Window.setPosition ( left=nil, top=nil, right=nil, bottom=nil )

gui.Window.getPosition ( )

gui.Window.getCSSPosition ( )

gui.Window.centerOnScreen ( )

gui.Window.setSize ( )

gui.Window.getSize ( )

gui.Window.move ( )

gui.Window.raise ( )

Raise to top of window stack

gui.Window.hide ( )

gui.Window.show ( )

gui.Window.toggle ( )

Hide / show the window based on whether it's currently visible

gui.Window.onClose ( )

function to be executed when the close button is pressed

gui.Window.onResize ( )

gui.Window.lockAspectRatio ( lock=1 )

gui.Window._onStateChange ( )

protected:

gui.Window._propCallback ( child, mode )

private:

mode 0 = value changed, +-1 add/remove node

gui.Window._handlePositionAbsolute ( child, mode, name, index )

gui.Window._updatePos ( index, name )

gui.Window._handleResize ( child, name )

gui.Window._updateDecoration ( )

gui.Window._resizeDecoration ( )

gui.Dialog

Provide old 'Dialog' for backwards compatiblity (should be removed for 3.0)

gui.Dialog.new ( size, type = nil, id = nil )

gui.unloadGUI ( )

📄 ImageTest     Nasal/canvas/ImageTest.nas

ImageTest.ImageTest

ImageTest.ImageTest.new ( )

📄 KeyBinding     Nasal/canvas/KeyBinding.nas

KeyBinding.parseShortcut ( s )

These do not seem to be available in OSG events

ModifierKeys.Super = (ModifierKeys.Super_L | ModifierKeys.Super_R);

ModifierKeys.Hyper = (ModifierKeys.Hyper_L | ModifierKeys.Hyper_R);

KeyBinding.findKeyName ( key )

KeyBinding.namesToKeys ( strings... )

📁 map     Nasal/canvas/map/

📁 Airbus     Nasal/canvas/map/Airbus/

📁 Images     Nasal/canvas/map/Airbus/Images/

📁 Images     Nasal/canvas/map/Images/

📄 map     Nasal/canvas/map.nas

map.register_callback ( c )

map.run_callbacks ( foreach )

map.assert ( label, expr )

map.SURFACECOLORS

Mapping from surface codes to colors (shared by runways.draw and taxiways.draw)

map.draw_layer ( layer, callback, lod )

ALL LayeredMap "draws" go through this wrapper, which makes it easy to check what's going on:

map.Runway

Runway

map.Runway.new ( rwy )

Create Runway from hash

@param rwy Hash containing runway data as returned from

airportinfo().runways[ <runway designator> ]

map.Runway.pointOffCenterline ( pos, off = 0 )

Get a point on the runway with the given offset

@param pos Position along the center line

@param off Offset perpendicular to the center line

map.make ( return )

map.LayerModel.new ( make )

map.LayerModel.clear ( me._elements = )

map.LayerModel.push ( e )

map.LayerModel.get ( me._elements )

map.LayerModel.update ( )

map.LayerModel.hasData ( size )

map.LayerModel.setView ( v )

map.LayerModel.setController ( c )

map.Layer

A layer is mapped to a canvas group

Layers are linked to a single boolean property to toggle them on/off

FIXME: this is GUI specific ATM

map.Layer.new ( group, name, model, controller=nil )

map.Layer.hide ( me._view.setVisible )

map.Layer.show ( me._view.setVisible )

map.Layer.toggle ( )

TODO: Unify toggle and update methods - and support lazy drawing (make it optional!)

map.Layer.reset ( )

map.Layer.update ( )

TODO: Unify toggle and update FIXME: GUI specific, not needed for 744 ND.nas

map.Layer.setDraw ( callback )

map.Layer.setController ( c )

map.Layer.setModel ( m )

map.LayeredMap

A layered map consists of several layers

TODO: Support nested LayeredMaps, where a LayeredMap may contain other LayeredMaps

TODO: use MapBehavior here and move the zoom/refpos methods there, so that map behavior can be easily customized

map.LayeredMap.new ( parent, name )

map.LayeredMap.listen ( p, c )

map.LayeredMap.initializeLayers ( )

map.LayeredMap.setRefPos ( lat, lon )

map.LayeredMap.setHdg ( hdg )

map.LayeredMap.updateZoom ( )

map.LayeredMap.updateState ( )

this is a huge hack at the moment, we need to encapsulate the setRefPos/setHdg methods, so that they are exposed to XML space

map.LayeredMap.setupZoom ( dialog )

TODO: this is currently GUI specific and not re-usable for instruments

map.LayeredMap.setZoom ( )

map.LayeredMap.resetLayers ( )

map.LayeredMap.cleanup_listeners ( )

FIXME: listener management should be done at the MVC level, for each component - not as part of the LayeredMap!

map.GenericMap

GenericMap: A generic map is a layered map that puts all supported features on a different layer (canvas group) so that

they can be individually toggled on/off so that unnecessary updates are avoided, there are methods to link layers to boolean properties

so that they can be easily associated with GUI properties (checkboxes) or cockpit hotspots

TODO: generalize the XML-parametrization and move it to a helper class

map.GenericMap.new ( parent, name )

map.GenericMap.setupLayer ( layer, property )

map.GenericMap.setupFeature ( layer, property, init )

features are layers - so this will do layer setup and then register listeners for each layer

map.GenericMap.pickupFeatures ( DIALOG_CANVAS )

This will read in the config and procedurally instantiate all requested layers and link them to toggle properties

FIXME: this is currently GUI specific and doesn't yet support instrument use, i.e. needs to be generalized further

map.GenericMap.setupGUI ( dialog, group )

NOT a method, cmdarg() is no longer meaningful when the canvas nasal block is executed

so this needs to be called in the dialog's OPEN block instead - TODO: generalize

FIXME: move somewhere else, this really is a GUI helper and should probably be generalized and moved to gui.nas

map.LayerModel.notifyView ( )

this is currently "directly" invoked via a listener, needs to be changed

to use the controller object instead

TODO: adopt real MVC here

FIXME: this must currently be explicitly called by the model, we need to use a wrapper to call it automatically instead!

map.MAP_LAYERS

UGLY: disabled for now (probably breaks airport GUI dialog !)

me._map.updateState(); # update the map

TODO: a "MapLayer" is a full MVC implementation that is owned by a "LayeredMap"

map.register_layer ( name, layer )

map.load_modules ( vec, ns= )

map.files_with ( ext )

read in the file names dynamically: *.draw, *.model, *.layer

map.loadMapModules ( )

map.unloadMap ( )

📄 MapDrivers     Nasal/canvas/MapDrivers.nas

MapDrivers.RouteDriver

MapDrivers.RouteDriver.new ( )

MapDrivers.RouteDriver.init ( )

MapDrivers.RouteDriver.update ( )

MapDrivers.RouteDriver.getNumberOfFlightPlans ( )

MapDrivers.RouteDriver.getFlightPlanType ( fpNum )

MapDrivers.RouteDriver.getFlightPlan ( fpNum )

MapDrivers.RouteDriver.getPlanSize ( fpNum )

MapDrivers.RouteDriver.getWP ( fpNum, idx )

MapDrivers.RouteDriver.getPlanModeWP ( plan_wp_idx )

MapDrivers.RouteDriver.hasDiscontinuity ( fpNum, wptID )

MapDrivers.RouteDriver.getListeners ( )

MapDrivers.RouteDriver.shouldUpdate ( 1 )

MapDrivers.MultiRouteDriver

MapDrivers.MultiRouteDriver.new ( )

MapDrivers.MultiRouteDriver.addFlightPlan ( type, plan )

MapDrivers.MultiRouteDriver.removeFlightPlanAtIndex ( idx )

MapDrivers.MultiRouteDriver.removeFlightPlanOfType ( type )

MapDrivers.MultiRouteDriver.getNumberOfFlightPlans ( )

MapDrivers.MultiRouteDriver.getFlightPlanType ( fpNum )

MapDrivers.MultiRouteDriver.getFlightPlan ( fpNum )

MapDrivers.MultiRouteDriver.getPlanSize ( fpNum )

MapDrivers.MultiRouteDriver.getWP ( fpNum, idx )

MapDrivers.MultiRouteDriver.getPlanModeWP ( idx )

MapDrivers.MultiRouteDriver.triggerSignal ( signal )

MapDrivers.MultiRouteDriver.signalPath ( signal )

MapDrivers.MultiRouteDriver.getListeners ( )

📄 MapStructure     Nasal/canvas/MapStructure.nas

MapStructure.makedie ( prefix )

var _MP_dbg_lvl = DEV_ALERT;

MapStructure.try_aux_method ( obj, method_name )

Try to call a method on an object with no arguments. Should

work for both ghosts and hashes; catches the error only when

the method doesn't exist -- errors raised during the call

are re-thrown.

MapStructure.default_hash ( opt, df )

Combine a specific hash with a default hash, e.g. for

options/df_options and style/df_style in a SymbolLayer.

MapStructure.MapStructure_selfTest ( )

to be used for prototyping, performance & stress testing (especially with multiple instance driven by AI traffic)

MapStructure.CachedElement

wrapper for each cached element: keeps the canvas and

texture map coordinates for the corresponding raster image.

MapStructure.CachedElement.new ( canvas_path, name, source, size, offset )

MapStructure.CachedElement.render ( group, trans0=0, trans1=0 )

MapStructure.SymbolCache

MapStructure.SymbolCache.new ( dim... )

MapStructure.SymbolCache.add ( name, callback, draw_mode=0 )

Add a cached symbol based on a drawing callback.

@note this assumes that the object added by callback

fits into the dimensions provided to the constructor,

and any larger dimensionalities are liable to be cut off.

MapStructure.SymbolCache.get ( name )

MapStructure.issym ( string )

MapStructure.internsymbol ( symbol )

MapStructure.tryintern ( symbol )

MapStructure.unescape ( s )

End excerpt

Helpers for below

MapStructure.hashdup ( _, rkeys=nil )

MapStructure.opt_member ( h, k )

MapStructure.member ( h, k )

MapStructure._in ( vec, k )

MapStructure.members ( h, vec=nil )

MapStructure.serialize ( m, others=nil )

MapStructure.call_draw ( draw, style, arg=nil, relevant_keys=nil )

Drawing functions have the form:

func(group) { group.createChild(...).set<Option>(<option>); ... }

The style is passed as (essentially) their local namespace/variables,

while the group is a regular argument.

MapStructure.style_string ( style, relevant_keys=nil )

Serialize a style into a string.

MapStructure.StyleableCacheable

A class to mix styling and caching. Using the above helpers it

serializes style hashes.

MapStructure.StyleableCacheable.new ( name, draw_func, cache, draw_mode=0, relevant_keys=nil )

Construct an object.

@param name Prefix to use for entries in the cache

@param draw_func Function for the cache that will draw the

symbol onto a group using the style parameters.

@param cache The #SymbolCache to use for these symbols.

@param draw_mode See #SymbolCache

@param relevant_keys A list of keys for the style used by the

draw_func. Although it defaults to all

available keys, it is highly recommended

that it be specified.

MapStructure.StyleableCacheable.request ( style )

Note: configuration like active/inactive needs

to also use the passed style hash, unless it is

chosen not to cache symbols that are, e.g., active.

MapStructure.StyleableCacheable.render ( element, style )

MapStructure.StyleableCacheable.draw ( style, s1 )

MapStructure.Symbol

A base class for Symbols placed on a map.

Note: for the derived objects, the element is stored as obj.element.

This is also part of the object's parents vector, which allows

callers to use obj.setVisible() et al. However, for code that

manipulates the element's path (if it is a Canvas Path), it is best

to use obj.element.addSegmentGeo() et al. for consistency.

MapStructure.Symbol.add ( type, class )

MapStructure.Symbol.get ( type )

MapStructure.Symbol.new ( type, group, layer, arg... )

Calls corresonding symbol constructor

@param group #Canvas.Group to place this on.

@param layer The #SymbolLayer this is a child of.

MapStructure.Symbol._new ( m )

Private constructor:

MapStructure.Symbol.update ( )

Update the drawing of this object (position and others).

MapStructure.Symbol.draw ( )

MapStructure.Symbol.del ( )

MapStructure.Symbol.newText ( text=nil, color=nil )

Add a text element with styling

MapStructure.Symbol.formattedString ( frmt, model_props )

Helper method that can be used to create a formatted String using

values extracted from the current model.

SYNOPSIS:

symbol.formattedString(format, model_property_names)

Arguments:

- format: string

- model_property_names: a vector of strings representing the model

property names to be used as arguments

EXAMPLE:

var label = waypoint.formattedString('Waypoint %s: lat %.4f, lng %.4f', [model.id, model.lat, model.lon]);

MapStructure.Symbol.getOption ( name, default = nil )

Wrapper method for accessing options. It allows to pass a default value

if the requested option is not defined.

EXAMPLE:

var ok = (contains(me.options, 'enabled') ? me.options.enabled : 0);

var ok = me.getOption('enabled', 0);

MapStructure.Symbol.getStyle ( name, default = nil )

Wrapper method for accessing style. It allows to pass a default value

if the requested style is not defined.

It also automatically resolves style properties when they're defined as

functions, by calling the corresponding function using the 'me' context

EXAMPLE:

me.style = {

color: [1,1,1],

line_color: func(){

me.model.tuned ? [0,0,1] : [1,1,1]

}

}

var color = me.getStyle('color'); # --> [1,1,1]

me.model.tuned = 1;

var line_color = me.getStyle('line_color'); # --> [0,0,1]

var txt_color = me.getStyle('text_color', [1,1,1]); # --> [1,1,1]

MapStructure.Symbol.getLabelFromModel ( default_val = nil )

MapStructure.Symbol.callback ( name, args... )

Executes callback function specified by the first argument with

variable arguments. The callback is executed within the 'me' context.

Callbacks must be defined inside the options hash.

EXAMPLE:

me.options = {

dump_callback: func(){

print('Waypoint '~ me.model.id);

}

}

me.callback('dump');

MapStructure.Symbol.add ( type, class )

MapStructure.Symbol.get ( type )

MapStructure.Symbol.new ( type, symbol, model, arg... )

Calls corresonding symbol controller constructor

@param model Model to control this object (position and other attributes).

MapStructure.Symbol.update ( symbol, model )

Non-static:

Update anything related to a particular model. Returns whether the object needs updating:

MapStructure.Symbol.del ( symbol, model )

Delete an object from this controller (or delete the controller itself):

MapStructure.Symbol.isVisible ( model )

Return whether this model/symbol is (should be) visible:

MapStructure.Symbol.getpos ( model )

Get the position of this symbol/object:

MapStructure.getpos_fromghost ( positioned_g )

MapStructure.is_positioned_ghost ( obj )

MapStructure.register_supported_ghost ( name )

MapStructure.assert_m ( hash, member )

MapStructure.assert_ms ( hash, members... )

MapStructure.DotSym

Implementation for a particular type of symbol (for the *.symbol files)

to handle details.

MapStructure.DotSym.makeinstance ( name, hash )

Static/singleton:

MapStructure.DotSym.new ( group, layer, model, controller=nil )

For the instances returned from makeinstance:

@param group The #Canvas.Group to add this to.

@param layer The #SymbolLayer this is a child of.

@param model A correct object (e.g. positioned ghost) as

expected by the .draw file that represents

metadata like position, speed, etc.

@param controller Optional controller "glue". Each method

is called with the model as the only argument.

MapStructure.DotSym.del ( )

MapStructure.DotSym.init ( )

Default wrappers:

MapStructure.DotSym.deinit ( )

MapStructure.DotSym.update ( )

MapStructure.SVGSymbol

Small wrapper for DotSym: parse a SVG on init().

MapStructure.SVGSymbol.init ( )

MapStructure.SVGSymbol.draw ( )

MapStructure.RasterSymbol

wrapper for symbols based on raster images (i.e. PNGs)

TODO: generalize this and port WXR.symbol accordingly

MapStructure.RasterSymbol.init ( )

MapStructure.RasterSymbol.draw ( )

MapStructure.LineSymbol

MapStructure.LineSymbol.makeinstance ( name, hash )

Static/singleton:

MapStructure.LineSymbol.new ( group, layer, model, controller=nil )

For the instances returned from makeinstance:

MapStructure.LineSymbol.draw ( )

Non-static:

MapStructure.LineSymbol.del ( )

MapStructure.LineSymbol.init ( )

Default wrappers:

MapStructure.LineSymbol.deinit ( )

MapStructure.LineSymbol.update ( )

MapStructure.SymbolLayer

Base class for a SymbolLayer, e.g. MultiSymbolLayer or SingleSymbolLayer.

MapStructure.SymbolLayer.add ( type, class )

MapStructure.SymbolLayer.get ( type )

MapStructure.SymbolLayer.new ( type, group, map, controller=nil, style=nil, options=nil, visible=1, arg... )

Calls corresonding layer constructor

@param group #Canvas.Group to place this on.

@param map The #Canvas.Map this is a member of.

@param controller A controller object.

@param style An alternate style.

@param options Extra options/configurations.

@param visible Initially set it up as visible or invisible.

MapStructure.SymbolLayer._new ( m, style, controller, options )

Private constructor:

MapStructure.SymbolLayer.del ( )

For instances:

MapStructure.SymbolLayer.update ( )

MapStructure.SymbolLayer.add ( type, class )

MapStructure.SymbolLayer.get ( type )

MapStructure.SymbolLayer.new ( type, layer, arg... )

Calls corresonding controller constructor

@param layer The #SymbolLayer this controller is responsible for.

MapStructure.SymbolLayer.searchCmd ( )

Default implementations for derived classes:

@return List of positioned objects.

MapStructure.SymbolLayer.addVisibilityListener ( )

MapStructure.SymbolLayer.getModel ( me._model )

Default implementations for derived objects:

For SingleSymbolLayer: retreive the model object

MapStructure.MultiSymbolLayer

A layer that manages a list of symbols (using delta positioned handling

with a searchCmd to retreive placements).

MapStructure.MultiSymbolLayer.new ( group, map, controller=nil, style=nil, options=nil, visible=1 )

Default implementations/values:

@param group A group to place this on.

@param map The #Canvas.Map this is a member of.

@param controller A controller object (parents=[SymbolLayer.Controller])

or implementation (parents[0].parents=[SymbolLayer.Controller]).

@param style An alternate style.

@param options Extra options/configurations.

@param visible Initially set it up as visible or invisible.

MapStructure.MultiSymbolLayer.update ( )

MapStructure.MultiSymbolLayer.del ( )

MapStructure.MultiSymbolLayer.delsym ( model )

MapStructure.MultiSymbolLayer.searchCmd ( )

MapStructure.MultiSymbolLayer.onAdded ( model )

Adds a symbol.

MapStructure.MultiSymbolLayer.onRemoved ( model )

Removes a symbol.

MapStructure.NavaidSymbolLayer

A layer that manages a list of statically-positioned navaid symbols (using delta positioned handling

with a searchCmd to retrieve placements).

This is not yet supposed to work properly, it's just there to help get rid of all the identical boilerplate code

in lcontroller files, so needs some reviewing and customizing still

MapStructure.NavaidSymbolLayer.make ( query )

static generator/functor maker:

MapStructure.SingleSymbolLayer

TODO: wrappers for Horizontal vs. Vertical layers ?

MapStructure.SingleSymbolLayer.new ( group, map, controller=nil, style=nil, options=nil, visible=1 )

Default implementations/values:

@param group A group to place this on.

@param map The #Canvas.Map this is a member of.

@param controller A controller object (parents=[SymbolLayer.Controller])

or implementation (parents[0].parents=[SymbolLayer.Controller]).

@param style An alternate style.

@param options Extra options/configurations.

@param visible Initially set it up as visible or invisible.

MapStructure.SingleSymbolLayer.update ( )

MapStructure.SingleSymbolLayer.del ( )

MapStructure.OverlayLayer

Base class for a OverlayLayer, e.g. a TileLayer

MapStructure.OverlayLayer.add ( type, class )

MapStructure.OverlayLayer.get ( type )

MapStructure.OverlayLayer.new ( type, group, map, controller=nil, style=nil, options=nil, visible=1, arg... )

Calls corresonding layer constructor

@param group #Canvas.Group to place this on.

@param map The #Canvas.Map this is a member of.

@param style An alternate style.

@param options Extra options/configurations.

@param visible Initially set it up as visible or invisible.

MapStructure.OverlayLayer._new ( m, style, controller, options )

Private constructor:

MapStructure.OverlayLayer.del ( )

For instances:

MapStructure.OverlayLayer.update ( )

MapStructure.TileLayer

MapStructure.TileLayer.new ( group, map, controller=nil, style=nil, options=nil, visible=1 )

Default implementations/values:

@param group A group to place this on.

@param map The #Canvas.Map this is a member of.

@param controller A controller object (parents=[OverlayLayer.Controller])

or implementation (parents[0].parents=[OverlayLayer.Controller]).

@param style An alternate style.

@param options Extra options/configurations.

@param visible Initially set it up as visible or invisible.

MapStructure.TileLayer.updateLayer ( )

MapStructure.TileLayer.update ( )

MapStructure.TileLayer.del ( )

MapStructure.TileLayer.add ( type, class )

MapStructure.TileLayer.get ( type )

MapStructure.TileLayer.new ( type, layer, arg... )

Calls corresponding controller constructor

@param layer The #OverlayLayer this controller is responsible for.

MapStructure.TileLayer.updateLayer ( )

Default implementations for derived classes:

@return List of positioned objects.

MapStructure.TileLayer.addVisibilityListener ( )

MapStructure.TileLayer.addRangeListener ( )

MapStructure.TileLayer.addScreenRangeListener ( )

MapStructure.MapStructure

MapStructure.MapStructure.loadFile ( file, name )

Generalized load methods used to load various symbols, layer controllers,...

MapStructure.load_MapStructure ( )

MapStructure.MapStructure.add ( type, class )

MapStructure.MapStructure.get ( type )

MapStructure.MapStructure.new ( type, map, arg... )

Calls corresonding controller constructor

@param map The #SymbolMap this controller is responsible for.

MapStructure.MapStructure.get_position ( )

Default implementations:

MapStructure.MapStructure.query_range ( )

MapStructure.MapStructure.in_range ( lat, lon, alt=0 )

📄 MFD_Generic     Nasal/canvas/MFD_Generic.nas

📁 PFD     Nasal/canvas/PFD/

📄 DataEntryElement     Nasal/canvas/PFD/DataEntryElement.nas

📄 DefaultStyle     Nasal/canvas/PFD/DefaultStyle.nas

DefaultStyle.DefaultStyle

Default Styles for the MFD Elements

📄 GroupElement     Nasal/canvas/PFD/GroupElement.nas

📄 HighlightElement     Nasal/canvas/PFD/HighlightElement.nas

📄 HighlightTimer     Nasal/canvas/PFD/HighlightTimer.nas

HighlightTimer.HighlightTimer

Timer used for highlight UI elements

HighlightTimer.HighlightTimer.startHighlight ( element, period )

Start highlighting an element for period time. Use -1 period argument to

highlight until explicitly stopped by a call to stopHighlight.

HighlightTimer.HighlightTimer.stopHighlight ( element )

HighlightTimer.HighlightTimer.flashElements ( )

📄 PointerElement     Nasal/canvas/PFD/PointerElement.nas

📄 RotatingElement     Nasal/canvas/PFD/RotatingElement.nas

📄 ScrollElement     Nasal/canvas/PFD/ScrollElement.nas

📄 TextElement     Nasal/canvas/PFD/TextElement.nas

📄 UIElement     Nasal/canvas/PFD/UIElement.nas

📄 PropertyElement     Nasal/canvas/PropertyElement.nas

PropertyElement._makeNode ( n )

helper functions

==============================================================================

creates (if necessary) and returns a property node from arg[0],

which can be a property node already, or a property path

PropertyElement.PropertyElement

PropertyElement

==============================================================================

Baseclass for all property controlled elements/objects

PropertyElement.PropertyElement.new ( node, id )

Constructor

@param node Node to be used for element or vector [parent, type] for

creation of a new node with name type and given parent

@param id ID/Name (Should be unique)

PropertyElement.PropertyElement.del ( )

Destructor (has to be called manually!)

PropertyElement.PropertyElement.set ( key, value )

PropertyElement.PropertyElement.setBool ( key, value )

PropertyElement.PropertyElement.setDouble ( key, value )

PropertyElement.PropertyElement.setInt ( key, value )

PropertyElement.PropertyElement.get ( key, default = nil )

PropertyElement.PropertyElement.getBool ( key )

PropertyElement.PropertyElement.update ( )

Trigger an update of the element

Elements are automatically updated once a frame, with a delay of one frame.

If you wan't to get an element updated in the current frame you have to use

this method.

📄 svg     Nasal/canvas/svg.nas

svg.parsesvg ( group, path, options = nil )

Parse an xml file into a canvas group element

@param group The canvas.Group instance to append the parsed elements to

@param path The path of the svg file (absolute or relative to FG_ROOT)

@param options Optional hash of options

font-mapper func

parse_images bool

📄 tooltip     Nasal/canvas/tooltip.nas

tooltip.Tooltip

tooltip.Tooltip.new ( size, id = nil )

Constructor

@param size ([width, height])

tooltip.Tooltip.del ( )

Destructor

tooltip.Tooltip.createCanvas ( )

Create the canvas to be used for this Tooltip

@return The new canvas

tooltip.Tooltip.setLabel ( msg )

tooltip.Tooltip.setProperties ( properties )

tooltip.Tooltip.setWidthText ( txt )

specify a string used to compute the width of the tooltip

tooltip.Tooltip._updateText ( )

tooltip.Tooltip._updateBounds ( )

tooltip.Tooltip._remapValue ( val )

tooltip.Tooltip.setMapping ( mapping, f = nil )

tooltip.Tooltip.setTooltipId ( tipId )

tooltip.Tooltip.getTooltipId ( )

tooltip.Tooltip.getCanvas ( )

Get the displayed canvas

tooltip.Tooltip.setPosition ( x, y )

tooltip.Tooltip.isMessage ( )

tooltip.Tooltip.show ( )

tooltip.Tooltip.showMessage ( timeout = nil, node = nil )

tooltip.Tooltip._haveNode ( node, key )

tooltip.Tooltip.hide ( )

tooltip.Tooltip.hideNow ( )

tooltip.Tooltip.isVisible ( )

tooltip.Tooltip.fadeIn ( )

tooltip.Tooltip.fadeOut ( )

tooltip.Tooltip._hideTimeout ( )

private:

tooltip.innerSetTooltip ( node )

tooltip.setTooltip ( node )

tooltip.showTooltip ( node )

don't actually show here, we do that response to tooltip-timeout

so this is just getting ready

tooltip.updateHover ( node )

tooltip.showMessage ( node )

tooltip.clearMessage ( node )

tooltip.unloadTooltips ( )

called by the module unload callback in api.nas

📄 checklist     Nasal/checklist.nas

checklist.convert_checklists ( )

Nasal functions for handling the checklists present under /sim/checklists

Convert checklists into full tutorials.

📁 console     Nasal/console/

📄 repl     Nasal/console/repl.nas

repl.REPL

var _REPL_dbg_level = LOG_ALERT;

repl.REPL.new ( placement, name= )

repl.REPL.execute ( )

repl.REPL._is_str_char ( char )

repl.REPL._handle_level ( level, str, line_number )

repl.REPL.get_input ( )

repl.CanvasPlacement

repl.CanvasPlacement.new ( name= )

repl.CanvasPlacement.del ( )

repl.CanvasPlacement.add_char ( char, reset_view=0 )

repl.CanvasPlacement.add_text ( text, reset_view=0 )

repl.CanvasPlacement.remove_char ( reset_view=0 )

repl.CanvasPlacement.clear_input ( reset_view=0 )

repl.CanvasPlacement.replace_line ( replacement, replace_input=1, reset_view=0 )

repl.CanvasPlacement.add_line ( text, reset_text=1, reset_view=0 )

repl.CanvasPlacement.new_prompt ( )

repl.CanvasPlacement.continue_line ( reset_text=1 )

repl.CanvasPlacement.reset_input_from_history ( reset_view=0 )

repl.CanvasPlacement.reset_view ( )

repl.CanvasPlacement.set_line_color ( color )

repl.CanvasPlacement.set_line_font ( font )

repl.CanvasPlacement.clear ( )

repl.CanvasPlacement.create_msg ( )

repl.CanvasPlacement.create_line ( reset_text=1 )

repl.CanvasPlacement.update ( )

repl.CanvasPlacement.handle_key ( key, modifiers, keyCode )

repl.CanvasPlacement.get_line ( )

repl.CanvasPlacement.display_result ( res=nil )

repl.CanvasPlacement.handle_runtime_error ( err )

repl.CanvasPlacement.handle_parse_error ( msg, file, line )

repl.CanvasPlacement.gettranslation ( k )

repl.print2 ( i )

📄 contrail     Nasal/contrail.nas

📄 controls     Nasal/controls.nas

controls.startEngine ( v = 1, which... )

controls.selectEngine ( which )

controls.selectEngines ( state, which... )

Selects (state=1) or deselects (state=0) a list of engines, or all

engines if no list is specified. Example: selectEngines(1, 1, 3, 5);

controls.selectAllEngines ( )

controls.stepMagnetos ( change )

controls.centerFlightControls ( )

controls.throttleMouse ( )

controls.reverserTogglePosition ( )

controls.axisHandler ( pre, post )

Joystick axis handlers (use cmdarg). Shouldn't be called from

other contexts. A non-null argument reverses the axis direction.

controls.perIndexAxisHandler ( pre, post )

Joystick axis handler for controlling subsets of similar properties.

Shouldn't be called from other contexts.

The argument engine can be either an index number or a list of

index numbers.

Use only when perEngineSelectedAxisHandler() below will not do.

controls._axisMode

Joystick axis handler for controlling a selected axis on specific engines.

Shouldn't be called from other contexts.

The argument mode can be

0 - throttle

1 - mixture

2 - propeller-pitch

3 - condition

The argument engine to the returned function can be either an

engine number or a list of engine numbers.

Usage example (controlling the mixture of engines 0 and 1):

<script>

controls.perEngineSelectedAxisHandler(1)([0,1]);

</script>

controls.perEngineSelectedAxisHandler ( mode )

controls.flapsDown ( step )

Wrapper around stepProps() which emulates the "old" flap behavior for

configurations that aren't using the new mechanism.

controls.wingSweep ( step )

controls.wingsDown ( v )

controls.stepSpoilers ( step )

controls.stepSlats ( step )

controls.stepProps ( dst, array, delta )

Steps through an "array" of property settings. The first argument

specifies a destination property. The second is a string containing

a global property tree. This tree should contain an array of

indexed <setting> children. This function will maintain a

<current-setting> child, which contains the index of the currently

active setting. The third argument specifies an integer delta,

indicating how many steps to move through the setting array.

Note that because of the magic of the property system, this

mechanism works for all scalar property types (bool, int, double,

string).

TODO: This interface could easily be extended to allow for wrapping,

in addition to clamping, allowing a "cycle" of settings to be

defined. It could also be hooked up with the interpolate() call,

which would allow the removal of the transition-time feature from

YASim. Finally, other pre-existing features (the views and engine

magnetos, for instance), work similarly but not compatibly, and

could be integrated.

controls.slewProp ( prop, delta )

"Slews" a property smoothly, without dependence on the simulator

frame rate. The first argument is the property name. The second is

a rate, in units per second. NOTE: this modifies the property for

the current frame only; it is intended to be called by bindings

which repeat each frame. If you want to cause motion over time, see

interpolate(). Returns new value.

controls.elevatorTrim ( speed )

Handlers. These are suitable for binding to repeatable button press

events. They are *not* good for binding to the keyboard, since (at

least) X11 synthesizes its own key repeats.

controls.aileronTrim ( speed )

controls.rudderTrim ( speed )

controls.adjThrottle ( speed )

controls.adjMixture ( speed )

controls.adjCondition ( speed )

controls.adjPropeller ( speed )

controls.adjEngControl ( prop, speed )

controls.incThrottle ( )

arg[0] is the throttle increment

arg[1] is the auto-throttle target speed increment

controls.incAileron ( )

arg[0] is the aileron increment

arg[1] is the autopilot target heading increment

controls.incElevator ( )

arg[0] is the elevator increment

arg[1] is the autopilot target altitude increment

controls.elevatorTrimAxis ( )

Joystick axis handlers. Don't call from other contexts.

controls.aileronTrimAxis ( )

controls.rudderTrimAxis ( )

controls.gearTogglePosition ( v )

to avoid clash with "gearToggle"; this will only toggle when

given a parameter of 1; as the controls button binding will pass 0 when the button is pressed and

1 when the button is released.

controls.gearDown ( v )

Gear handling.

- parameter v is either 1 (down), -1 up (retracted)

controls.gearToggle ( )

controls.applyBrakes ( v, which = 0 )

controls.applyPickle ( v )

controls.applyParkingBrake ( v )

controls.parkingBrakeToggle ( v )

controls.toggleNWS ( v )

controls.applyApplicableBrakes ( v, which = 0 )

allows one binding to do airbrakes and wheel brakes

controls.autopilotDisconnect ( )

controls.deployChute ( v )

1: Deploy, -1: Release

controls.trigger ( b )

Weapon handling.

controls.weaponSelect ( d )

controls.ptt ( b )

Communication.

controls.toggleLights ( )

Lighting.

controls.replaySkip ( skip_time )

controls.speedup ( speed_up )

controls.cycleMouseMode ( node )

mouse-mode handling

controls.setMouseFlightControlsSensitivity ( sensitivity )

📁 debug     Nasal/debug/

📄 emesary.deb     Nasal/debug/emesary.deb.nas

emesary.deb.__setup ( )

📄 debug     Nasal/debug.nas

debug._title ( s, color=nil )

SPDX-License-Identifier: GPL-2.0-or-later

NOTE! This copyright does *not* cover user models that use these Nasal

services by normal function calls - this is merely considered normal use

of the code, and does *not* fall under the heading of "derived work."

Copyright (C) 2003-2007 by andy

Copyright (C) 2005-2008 by mfranz

Copyright (C) 2012-2014 by Thomas Geymayer

Copyright (C) 2017-2019 by Stuart Buchanan

Copyright (C) 2019-2020 by Henning Stahlke

debug.nas -- debugging helpers

------------------------------------------------------------------------------

debug.dump(<variable>) ... dumps contents of variable to terminal;

abbreviation for print(debug.string(v))

debug.local([<frame:int>]) ... dump local variables of current

or given frame

debug.backtrace([<comment:string>], [<dump:bool=1>], [<skip_level:int=0>]}

... writes backtrace (similar to gdb's "bt full)

dump=0: only call stack

dump=1 (default): with local variables

skip_level: remove this many levels from

call stack

debug.proptrace([<property [, <frames>]]) ... trace property write/add/remove

events under the <property> subtree for

a number of frames. Defaults are "/" and

2 frames (of which the first one is incomplete).

debug.tree([<property> [, <mode>]) ... dump property tree under property path

or props.Node hash (default: root). If

<mode> is unset or 0, use flat mode

(similar to props.dump()), otherwise

use space indentation

debug.bt() ... abbreviation for debug.backtrace()

debug.string(<variable>) ... returns contents of variable as string

debug.attributes(<property> [, <verb>]) ... returns attribute string for a given property.

<verb>ose is by default 1, and suppressed the

node's refcounter if 0.

debug.isnan() returns 1 if argument is an invalid number (NaN),

0 if it's a valid number, and nil in all other cases

debug.benchmark(<label:string>, <func> [, <repeat:int> [, <output:vector>]])

... runs function <repeat> times (default: nil)

and prints total execution time in seconds,

prefixed with <label>, while adding results

to <output>, or returning the only result

if <repeat> is nil.

debug.benchmark_time(<func> [, <repeat:int> [, <output:vector>]])

... like debug.benchmark, but returns total

execution time and does not print anything.

debug.rank(<list:vector> [, <repeat:int>])

... sorts the list of functions based on execution

time over <repeat> samples (default: 1).

debug.print_rank(<result:vector>, <names:int>)

... prints the <result> of debug.rank with <names>

(which can be a vector of [name, func] or

[func, name], or a hash of name:func).

debug.printerror(<err-vector>) ... prints error vector as set by call()

debug.warn(<message>, <level>) ... generate debug message followed by caller stack trace

skipping <level> caller levels (default: 0).

debug.propify(<variable>) ... turn about everything into a props.Node

debug.Probe class ... base class to collect stats; details below

debug.Breakpoint class ... conditional backtrace; details below

debug.addProbeToFunc(label, func) ... wraps a function with a probe

debug.findFunctions(ns, recursive=0) ... find all functions in a hash (namespace)

debug.addProbesToNamespace(ns, label="", recursive=0)

... combines findFunctions and addProbeToFunc

CAVE: this file makes extensive use of ANSI color codes. These are

interpreted by UNIX shells and MS Windows with ANSI.SYS extension

installed. If the color codes aren't interpreted correctly, then

set property /sim/startup/terminal-ansi-colors=0

ANSI color code wrappers (see $ man console_codes)

debug._section ( s, color=nil )

debug._error ( s, color=nil )

debug._bench ( s, color=nil )

debug._nil ( s, color=nil )

debug._string ( s, color=nil )

debug._num ( s, color=nil )

debug._bracket ( s, color=nil )

debug._brace ( s, color=nil )

debug._angle ( s, color=nil )

debug._vartype ( s, color=nil )

debug._proptype ( s, color=nil )

debug._path ( s, color=nil )

debug._internal ( s, color=nil )

debug._varname ( s, color=nil )

debug.propify ( p, create = 0 )

Turn p into props.Node (if it isn't yet), or return nil.

debug.tree ( n = )

debug._tree ( n, graph = 1, prefix = )

debug.attributes ( p, verbose = 1, color=nil )

debug._dump_prop ( p, color=nil )

debug._dump_var ( v, color=nil )

debug._dump_string ( str, color=nil )

debug._dump_key ( s, color=nil )

dump hash keys as variables if they are valid variable names, or as string otherwise

debug.string ( o, color=nil, ttl=5 )

debug.dump ( vars... )

debug.local ( frame = 0 )

debug.funcname ( f )

According to the Nasal design doc funtions do not have unique internal names.

Nevertheless you can sometimes find a matching symbol, so funcname may help to

make debug output more helpful, but unfortunately you cannot rely on it.

debug.backtrace ( desc = nil, dump_vars = 1, skip_level = 0, shorten = 50 )

Write backtrace information.

desc:

Text to write in first line.

dump_vars:

If true, show info about variables.

skip_level:

How many top-level stack frames to skip.

shorten:

If greater than 10, max filename length before being trimmed.

debug.proptrace ( root = )

debug.benchmark ( label, fn, repeat = nil, output=nil )

Executes function fn "repeat" times and prints execution time in seconds. If repeat

is an integer and an optional "output" argument is specified, each test's result

is appended to that vector, then the vector is returned. If repeat is nil, then

the function is run once and the result returned. Otherwise, the result is discarded.

Examples:

var test = func { getprop("/sim/aircraft"); }

debug.benchmark("test()/1", test, 1000);

debug.benchmark("test()/2", func setprop("/sim/aircraft", ""), 1000);

var results = debug.benchmark("test()", test, 1000, []);

print(" Results were:");

print(" ", debug.string(results));

debug.benchmark_time ( fn, repeat = 1, output = nil )

debug.rank ( list, repeat = nil )

Executes each function in the list and returns a sorted vector with the fastest

on top (i.e. first). Each position in the result is a vector of [func, time].

debug.print_rank ( label, list, names )

debug.printerror ( err )

print error vector as set by call(). By using call() one can execute

code that catches "exceptions" (by a die() call or errors). The Nasal

code doesn't abort in this case. Example:

var possibly_buggy = func { ... }

call(possibly_buggy, nil, var err = []);

debug.printerror(err);

debug.warn ( msg, level = 0 )

like die(), but code execution continues. The level argument defines

how many caller() levels to omit. One is automatically omitted, as

this would only point to debug.warn(), where the event in question

didn't happen.

debug.isnan ( )

debug.Probe

Probe class - collect statistics; controlled via property tree

Data can be viewed / modified in the prop tree /_debug/nas/probe/<myLabel>/*

./enable bool,

./reset bool, reset hit counters to 0 and _start_time to now

./hits[i] number of hits, by default i=0 -> hits

secondary counters can be added under the same path

with addCounter()

./time after generateStats() show how long the probe was enabled

./hps after generateStats() show avg. hits/second

./hitratio after generateStats() if two counters: hits[1]/hits[0]

== Example ==

var myProbe = debug.Probe.new("myLabel").enable();

var cnt2 = myProbe.addCounter(); # create a 2nd counter

#at the place of interest (e.g. in some loop or class method) insert:

myProbe.hit(); # count how often this place in the code is hit

if (condition)

myProbe.hit(cnt2); # count how often condition is true

print(myProbe.getHits());

print(myProbe.getHits(cnt2)/myProbe.getHits()); # print hit ratio

debug.Probe._uid ( label, class )

debug.Probe.new ( label, class = )

label: Used in property path

prefix: Optional

debug.Probe.del ( )

debug.Probe.reset ( )

debug.Probe.setTimeout ( seconds )

set timeout, next hit() after timeout will disable()

debug.Probe.enable ( )

enable counting

debug.Probe.disable ( )

disable counting, write time and hit/s to property tree

debug.Probe.generateStats ( )

debug.Probe.getHits ( counter_id = 0 )

debug.Probe.addCounter ( )

add secondary counter(s)

returns counter id

debug.Probe.hit ( counter_id = 0, callback = nil )

increment counter (if enabled)

use addCounter() before using counter_id > 0

debug.Breakpoint

Breakpoint (BP) - do conditional backtrace (BT) controlled via property tree

* count how often the BP was hit

* do only a limited number of BT, avoid flooding the log / console

Data can be viewed / modified in the prop tree /_debug/nas/bp/<myLabel>/*

* tokens: number of backtraces to do; each hit will decrement this by 1

* hits: total number of hits

== Example ==

var myBP = debug.Breakpoint.new("myLabel", 0);

myBP.enable(4); # allow 4 hits, then be quiet

#at the place of interest (e.g. in some loop or class method) insert:

myBP.hit(); # do backtrace here if tokens > 0, reduce tokens by 1

myBP.hit(myFunction); # same but call myFunction instead of backtrace

print(myBP.getHits()); # print total number of hits

debug.Breakpoint.new ( label, dump_locals = 0, skip_level=0 )

label: Used in property path and as text for backtrace.

dump_locals: bool passed to backtrace. Dump variables in BT.

skip_level: int passed to backtrace.

debug.Breakpoint.enable ( tokens = 1 )

enable BP and set hit limit;

tokens: int > 0; default: 1 (single shot); 0 allowed (=disable);

debug.Breakpoint.hit ( callback = nil )

hit the breakpoint, e.g. do backtrace if we have tokens available

debug.Tracer

Tracer - perform conditional backtraces / statistics controlled via property tree

* backtraces are written to property tree

* do only a limited number of BT, avoid flooding the log / console

* trace statistics can be dumped to XML file

Data can be viewed / modified in the prop tree /_debug/nas/trc/<myLabel>/*

* tokens: number of backtraces to do; each hit will decrement this by 1

* hits: total number of hits

== Example ==

var myBP = debug.Tracer.new("myLabel", 0);

myBP.enable(4); # allow 4 hits, then be quiet

#at the place of interest (e.g. in some loop or class method) insert:

myBP.hit(); # do backtrace here if tokens > 0, reduce tokens by 1

myBP.hit(myFunction); # same but call myFunction instead of backtrace

print(myBP.getHits()); # print total number of hits

debug.Tracer.new ( label, dump_locals = 0, skip_level=0 )

label: Used in property path and as text for backtrace.

dump_locals: bool passed to backtrace. Dump variables in BT.

skip_level: int passed to backtrace.

debug.Tracer.enable ( tokens = 1 )

enable BP and set hit limit;

tokens: int > 0; default: 1 (single shot); 0 allowed (=disable);

debug.Tracer.disableTracing ( )

debug.Tracer.resetTrace ( )

debug.Tracer.hit ( callback = nil )

debug.Tracer._trace ( skip=0 )

write backtrace to prop tree with counters

debug.Tracer.dumpTrace ( path = nil )

debug.addProbeToFunc ( f, label )

addProbeToFunc - wrap a function with a debug probe

f: function to wrap with a debug probe (hit counter)

label: description, passed to probe

WARNING: call() currently breaks the call stack which affects backtrace and

the use of caller(i>0). Do not use addProbeToFunc on functions which rely on

caller (which is probably bad coding style, but allowed).

debug.addTracerToFunc ( f, label )

addTracerToFunc - wrap a function with a debug breakpoint for tracing

f: function to wrap with a tracer

label: description, passed to breakpoint

WARNING: call() currently breaks the call stack which affects backtrace and

the use of caller(i>0). Do not use addTracerToFunc on functions which rely on

caller (which is probably bad coding style, but allowed).

debug.findFunctions ( ns, recursive = 0 )

scan a hash for function references

ns: the hash to be searched

recursive: if you want to search sub hashes (e.g. classes), set this to 1

debug._probed_ns

add probes to all functions in a namespace for finding hotspots

use property browser at runtime to check /_debug/nas/_stats/

ns: hash

label: description, passed to probe

debug.addProbesToNamespace ( ns, label = )

debug.removeProbesFromNamespace ( ns )

debug.dumpProbeStats ( )

dump a sorted list of hit counters to console

📄 dynamic_view     Nasal/dynamic_view.nas

dynamic_view.sin ( a )

dynamic_view.cos ( a )

dynamic_view.sigmoid ( x )

dynamic_view.nsigmoid ( x )

dynamic_view.pow ( v, w )

dynamic_view.npow ( v, w )

dynamic_view.clamp ( v, min, max )

dynamic_view.normatan ( x )

dynamic_view.normdeg ( a )

dynamic_view.Input

Class that reads a property value, applies factor & offset, clamps to min & max,

and optionally lowpass filters.

dynamic_view.Input.new ( prop = )

dynamic_view.Input.get ( )

dynamic_view.Input.set ( v )

dynamic_view.ViewAxis

Class that maintains one sim/current-view/goal-*-offset-deg property.

dynamic_view.ViewAxis.new ( prop )

dynamic_view.ViewAxis.reset ( )

dynamic_view.ViewAxis.add_offset ( )

dynamic_view.ViewAxis.sub_offset ( )

dynamic_view.ViewAxis.apply ( v )

dynamic_view.ViewAxis.static ( v )

dynamic_view.view_manager

Singleton class that manages a dynamic cockpit view by manipulating

sim/current-view/goal-*-offset-deg properties.

dynamic_view.view_manager.init ( )

dynamic_view.view_manager.reset ( )

dynamic_view.view_manager.add_offset ( )

dynamic_view.view_manager.apply ( )

dynamic_view.view_manager.lookat ( heading, pitch, roll, x, y, z, time, fov )

dynamic_view.view_manager.resume ( )

dynamic_view.view_manager.freeze ( )

dynamic_view.view_manager.unfreeze ( )

dynamic_view.view_manager.default_plane ( )

default calculations for a plane

dynamic_view.view_manager.default_helicopter ( )

default calculations for a helicopter

dynamic_view.main_loop ( id )

Update loop for the whole dynamic view manager. It only runs if

/sim/current-view/dynamic-view is true.

dynamic_view.freeze ( )

dynamic_view.register ( f )

dynamic_view.reset ( )

dynamic_view.lookat ( )

dynamic_view.resume ( )

dynamic_view.fdms

disable menu entry and return for inappropriate FDMs (see Main/fg_init.cxx)

dynamic_view.view.resetView ( )

📄 earthview     Nasal/earthview.nas

earthview.check_lightning_table ( lat, lon )

earthview.start ( )

earthview.stop ( )

earthview.place_earth_model ( path, lat, lon, alt, heading, pitch, roll )

earthview.control_loop ( )

earthview.slow_loop ( )

earthview.lightning_strike ( )

earthview.adjust_cloud_tiles ( )

rotate position of cloud tiles

earthview.clear_cloud_tiles ( )

earthview.load_sector ( i, n )

load of individual tile

earthview.earth_model

earthview.cloudsphere_model

earthview.aurora_model

earthview.boundary

earthview.boundary.new ( bindex, bname )

earthview.atile

earthview.atile.new ( tname, ptind, ptname, arcind, arcname )

earthview.tiling_visibility

📄 emesary     Nasal/emesary.nas

emesary._registerTransmitter ( key, t )

emesary.getTransmitter ( key )

emesary.genericEmesaryGlobalTransmitterTransmit ( node )

genericEmesaryGlobalTransmitterTransmit allowes to use the emesary.GlobalTransmitter via fgcommand

which in turn allows using it in XML bindings, e.g.

<binding>

<command>emesary-transmit</command>

<type>cockpit-switch</type>

<ident>eicas-page-select</ident>

<page>hydraulic</page>

</binding>

📄 emesary_mp_bridge     Nasal/emesary_mp_bridge.nas

📄 emexec     Nasal/emexec.nas

emexec.PerformanceMeasurement

The way that the core measures frame rate gives invalid values after a pause so instead

we will measure specific to our needs.

emexec.PerformanceMeasurement.new ( )

emexec.PerformanceMeasurement.update ( )

emexec.PerformanceMeasurement.start ( )

emexec.EmesaryExecutive

the main exeuctive class.

There will be one of these as emexec.ExceModule however multiple instances could be

created - but only by those who understand scheduling - because it is not necessary

to have more than one - unless we mange to enable some sort of per core threading.

emexec.EmesaryExecutive.new ( _ident= )

emexec.EmesaryExecutive.set_rate ( ratehz )

emexec.EmesaryExecutive.start ( )

emexec.EmesaryExecutive.stop ( )

emexec.EmesaryExecutive.monitor_properties ( input )

request monitoring of a list of hash value pairs.

emexec.EmesaryExecutive.register ( ident, properties_to_monitor, object, rate=1, frame_offset=0 )

ident: String (e.g F-15 HUD)

inputs: hash of properties to monitor

: e.g

{

AirspeedIndicatorIndicatedMach : "instrumentation/airspeed-indicator/indicated-mach",

Alpha : "orientation/alpha-indicated-deg",

}

: object - must have an update(notification) method that will receive a frame notification

: rate is the frame skip update rate (1/update rate). 0 or 1 means full rate

: offset is the offset to permit interleave

- e.g for two objects to interleave we could have a rate of two and an offset of 0 and 1 which

would result in one object being processed per frame

emexec.EmesaryExecutive.timerCallback ( )

emexec.EmesaryExecutive.new ( ident= )

emexec.EmesaryExecutive.log ( text )

emexec.EmesaryExecutive.reset ( )

📄 environment     Nasal/environment.nas

environment.increaseVisibility ( )

environment.nas

Nasal code for implementing environment-specific functionality.

Handler. Increase visibility by one step

environment.decreaseVisibility ( )

Handler. Decrease visibility by one step

environment.adjustVisibility ( factor )

environment.resetVisibility ( )

Handler. Reset visibility to default.

📄 events     Nasal/events.nas

events.LogBuffer

Stores messages in a circular buffer that then can be retrieved at any point.

Messages are time stamped when pushed into the buffer, and the time stamp is

kept by the message.

events.LogBuffer.new ( max_messages = 128, echo = 0 )

events.LogBuffer.push ( message )

events.LogBuffer.clear ( )

events.LogBuffer.get_buffer ( )

Returns a vector with all messages, starting with the oldest one.

Each vector entry is a hash with the format:

{ time: <timestamp_str>, message: <the message> }

📁 FailureMgr     Nasal/FailureMgr/

📄 private     Nasal/FailureMgr/private.nas

private.FailureMode

Failure Manager implementation

Monitors trigger conditions periodically and fires failure modes when those

conditions are met. It also provides a central access point for publishing

failure modes to the user interface and the property tree.

Copyright (C) 2014 Anton Gomez Alvedro

This program is free software; you can redistribute it and/or

modify it under the terms of the GNU General Public License as

published by the Free Software Foundation; either version 2 of the

License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but

WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software

Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Represents one way things can go wrong, for example "a blown tire".

private.FailureMode.new ( id, description, actuator )

id: Unique identifier for this failure mode.

eg: "engine/carburetor-ice"

description: Short text description, suitable for printing to the user.

eg: "Ice in the carburetor"

actuator: Object implementing the FailureActuator interface.

Used by the failure manager to apply a certain level of

failure to the failure mode.

private.FailureMode.set_failure_level ( level )

Applies a certain level of failure to this failure mode.

level: Floating point number in the range [0, 1] zero being no failure

and 1 total failure.

private.FailureMode._set_failure_level ( level )

Internal version that actually does the job.

private.FailureMode.get_failure_level ( me.actuator.get_failure_level )

Returns the level of failure currently being simulated.

private.FailureMode.bind ( path )

Creates an interface for this failure mode in the property tree at the

given location. Currently the interface is just:

path/failure-level (double, rw)

private.FailureMode.unbind ( )

Remove bound properties from the property tree.

private._failmgr

Implements the FailureMgr functionality.

It is wrapped into an object to leave the door open to several evolution

approaches, for example moving the implementation down to the C++ engine.

Additionally, it also serves to isolate implementation details into its own

namespace.

private._failmgr.init ( )

private._failmgr.add_failure_mode ( mode )

private._failmgr.get_failure_modes ( )

private._failmgr.remove_failure_mode ( id )

private._failmgr.remove_all ( )

private._failmgr.repair_all ( )

private._failmgr.set_trigger ( mode_id, trigger )

private._failmgr.get_trigger ( mode_id )

private._failmgr.on_trigger_activated ( trigger )

Observer interface. Called from asynchronous triggers when they fire.

trigger: Reference to the firing trigger.

private._failmgr._enable ( )

Enable the failure manager. Starts the trigger poll timer and enables

all triggers.

Called from /sim/failure-manager/enabled and during a teleport if the

FM was enabled when the teleport was initiated.

private._failmgr._disable ( )

Suspends failure manager activity. Pollable triggers will not be updated

and all triggers will be disabled.

Called from /sim/failure-manager/enabled and during a teleport.

private._failmgr.enabled ( )

private._failmgr.log ( message )

private._failmgr._update ( )

Poll loop. Updates pollable triggers and applies a failure level

when they fire.

private._failmgr._discard_trigger ( trigger )

private._failmgr._on_teleport ( pnode )

Teleport listener. During repositioning, all triggers are disabled to

avoid them firing in a possibly inconsistent state.

private._failmgr.dump_status ( mode_ids=nil )

private._init ( )

Module initialization

📄 public     Nasal/FailureMgr/public.nas

public.events

Nasal modules can subscribe to FailureMgr events.

Each event has an independent dispatcher so modules can subscribe only to

the events they are interested in. This also simplifies processing at client

side by being able to subscibe different callbacks to different events.

Example:

var handle = FailureMgr.events["trigger-fired"].subscribe(my_callback);

public.get_id ( category, failure_mode )

Encodes a pair "category" and "failure_mode" into a "mode_id".

These just have the simple form "category/mode", and are used to refer to

failure modes throughout the FailureMgr API and to create a path within the

sim/failure-manager property tree for the failure mode.

examples of categories:

structural, instrumentation, controls, sensors, etc...

examples of failure modes:

altimeter, pitot, left-tire, landing-light, etc...

public.split_id ( mode_id )

Returns a vector containing: [category, failure_mode]

public.add_failure_mode ( id, description, actuator )

Subscribe a new failure mode to the system.

id: Unique identifier for this failure mode.

eg: "engine/carburetor-ice"

description: Short text description, suitable for printing to the user.

eg: "Ice in the carburetor"

actuator: Object implementing the FailureActuator interface.

Used by the failure manager to apply a certain level of

failure to the failure mode.

public.get_failure_modes ( )

Returns a vector with all failure modes in the system.

Each vector entry is a hash with the following keys:

{ id, description }

public.remove_failure_mode ( id )

Remove a failure mode from the system.

id: FailureMode id string, e.g. "systems/pitot"

public.remove_all ( )

Removes all failure modes from the failure manager.

public.set_trigger ( mode_id, trigger )

Attaches a trigger to the given failure mode. Discards the current trigger

if any.

mode_id: FailureMode id string, e.g. "systems/pitot"

trigger: Trigger object or nil. Nil will just detach the current trigger

public.get_trigger ( mode_id )

Returns the trigger object attached to the given failure mode.

mode_id: FailureMode id string, e.g. "systems/pitot"

public.set_failure_level ( mode_id, level )

Applies a certain level of failure to this failure mode.

mode_id: Failure mode id string.

level: Floating point number in the range [0, 1]

Zero represents no failure and one means total failure.

public.get_failure_level ( mode_id )

Returns the current failure level for the given failure mode.

mode_id: Failure mode id string.

public.repair_all ( )

Restores all failure modes to level = 0

public.get_log_buffer ( )

Returns a vector of timestamped failure manager events, such as the

messages shown in the console when there are changes to the failure conditions.

Each entry in the vector has the following format:

{ time: <time stamp>, message: <event description> }

public.enable ( setprop )

Allows applications to disable the failure manager and restore it later on.

While disabled, no failure modes will be activated from the failure manager.

public.disable ( setprop )

public.Trigger

Encapsulates a condition that when met, will make the failure manager to

apply a certain level of failure to the failure mode it is bound to.

Two types of triggers are supported: pollable and asynchronous.

Pollable triggers require periodic check for trigger conditions. For example,

an altitude trigger will need to poll current altitude until the fire

condition is reached.

Asynchronous trigger do not require periodic updates. They can detect

the firing condition by themselves by using timers or listeners.

Async triggers must call the inherited method on_fire() to let the Failure

Manager know about the fired condition.

See Aircraft/Generic/Systems/failures.nas for concrete examples of triggers.

public.Trigger.new ( )

public.Trigger.on_fire ( 0 )

Async triggers shall call the on_fire() callback when their fire

conditions are met to notify the failure manager.

public.Trigger.update ( 0 )

Forces a check of the firing conditions. Returns 1 if the trigger fired,

0 otherwise.

public.Trigger.to_str ( )

Returns a printable string describing the trigger condition.

public.Trigger.set_param ( param, value )

Modify a trigger parameter. Parameters will take effect after the next

call to reset()

public.Trigger.arm ( )

Load trigger parameters and reset internal state. Once armed, the trigger

will fire as soon as the right conditions are met. It can be called after

the trigger fires to rearm it again.

The "armed" condition survives enable/disable calls.

public.Trigger._arm ( )

public.Trigger.disarm ( )

Deactivate the trigger. The trigger will not fire until rearmed again.

public.Trigger._disarm ( )

public.Trigger.enable ( )

Enables/disables the trigger. While a trigger is disabled, any timer

or listener that could potentially own shall be disabled.

The FailureMgr calls these methods when the entire system is

enabled/disabled. By keeping enabled/disabled state separated from

armed/disarmed allows the FailureMgr to keep its configuration while

disabled, i.e. those triggers that where armed when the system was

disabled will resume when the system is enabled again.

The FailureMgr disables itself during a teleport.

public.Trigger.disable ( )

public.Trigger.bind ( path )

Creates an interface for the trigger in the property tree.

Every parameter in the params hash will be exposed, in addition to

a path/reset property for resetting the trigger from the prop tree.

public.Trigger.unbind ( )

Removes this trigger's interface from the property tree.

public.FailureActuator

FailureActuators encapsulate the actions required for activating the actual

failure simulation.

Traditionally this action was just manipulating a "serviceable" property

somewhere, but the FailureActuator gives you more flexibility, allowing you

to touch several properties at once or call other Nasal scripts, for example.

See Aircraft/Generic/Systems/failure.nas and

Aircraft/Generic/Systems/compat_failures.nas for some examples of actuators.

public.FailureActuator.set_failure_level ( level )

Called from the failure manager to activate a certain level of failure.

level: Target level of failure [0 to 1].

public.FailureActuator.get_failure_level ( 0 )

Returns the level of failure that is currently being simulated.

📄 frame_utils     Nasal/frame_utils.nas

📄 fuel     Nasal/fuel.nas

fuel.update ( )

fuel.loop ( )

📄 geo     Nasal/geo.nas

geo.Coord

class that maintains one set of geographical coordinates

geo.Coord.new ( copy = nil )

geo.Coord._cupdate ( )

geo.Coord._pupdate ( )

geo.Coord.x ( )

geo.Coord.y ( )

geo.Coord.z ( )

geo.Coord.xyz ( )

geo.Coord.lat ( )

geo.Coord.lon ( )

geo.Coord.alt ( )

geo.Coord.latlon ( )

geo.Coord.set_x ( x )

geo.Coord.set_y ( y )

geo.Coord.set_z ( z )

geo.Coord.set_lat ( lat )

geo.Coord.set_lon ( lon )

geo.Coord.set_alt ( alt )

geo.Coord.set ( c )

geo.Coord.set_latlon ( lat, lon, alt = 0 )

geo.Coord.set_xyz ( x, y, z )

geo.Coord.apply_course_distance ( course, dist )

geo.Coord.course_to ( dest )

geo.Coord.distance_to ( dest )

arc distance on an earth sphere; doesn't consider altitude

geo.Coord.direct_distance_to ( dest )

geo.Coord.greatcircle_distance_to ( destA, destB )

arc distance on an earth sphere to the great circle passing by A and B; doesn't consider altitude

geo.Coord.horizon ( )

arc distance on an earth sphere to the horizon

geo.Coord.is_defined ( )

geo.Coord.dump ( )

geo.normdeg ( angle )

normalize degree to 0 <= angle < 360

geo.normdeg180 ( angle )

normalize degree to -180 < angle <= 180

geo.tile_index ( lat, lon )

geo.format ( lat, lon )

geo.tile_path ( lat, lon )

geo.put_model ( path, c, arg... )

geo.put_marker ( label, c, arg... )

geo._put_model ( path, label, lat, lon, elev_m = nil, hdg = 0, pitch = 0, roll = 0 )

geo._put_marker ( label, lat, lon, elev = nil, color = nil, text_height_m = 1, pin_height_m = 1000, pin_tip_height_m = 0 )

geo.elevation ( lat, lon, maxalt = 10000 )

geo.click_position ( )

geo.aircraft_position ( )

geo.viewer_position ( )

geo.PositionedSearch

A object to handle differential positioned searches:

searchCmd executes and returns the actual search,

onAdded and onRemoved are callbacks,

and obj is a "me" reference (defaults to "me" in the

caller's namespace). If searchCmd returns nil, nothing

happens, i.e. the diff is cancelled.

geo.PositionedSearch.new ( searchCmd, onAdded, onRemoved, obj=nil )

geo.PositionedSearch._equals ( a, b )

geo.PositionedSearch.condense ( vec )

geo.PositionedSearch.diff ( old, new )

geo.PositionedSearch.update ( searchCmd=nil )

geo.PositionedSearch.test ( from=640, to=320 )

this is the worst case scenario: switching from 640 to 320 (or vice versa)

📄 glide_slope_tunnel     Nasal/glide_slope_tunnel.nas

glide_slope_tunnel.normdeg ( a )

glide_slope_tunnel.best_runway ( apt )

Find best runway for current wind direction (or 270), also considering length and width.

glide_slope_tunnel.draw_tunnel ( rwy )

Draw 3 degree glide slope tunnel.

glide_slope_tunnel.loop ( id )

📄 globals     Nasal/globals.nas

globals.__

container for local variables, so as not to clutter the global namespace

globals.assert ( condition, message=nil )

Aborts execution if <condition> evaluates to false.

Prints an optional message if present, or just "assertion failed!"

globals.isa ( obj, class )

Returns true if the first object is an instance of the second

(class) object. Example: isa(someObject, props.Node)

globals.fgcommand ( cmd, node=nil )

Invokes a FlightGear command specified by the first argument. The

second argument specifies the property tree to be passed to the

command as its argument. It may be either a props.Node object or a

string, in which case it specifies a path in the global property

tree.

globals.cmdarg ( )

Returns the SGPropertyNode argument to the currently executing

function. Wrapper for the internal _cmdarg function that retrieves

the ghost handle to the argument and wraps it in a

props.Node object.

globals.abs ( v )

Utility. Does what you think it does.

globals.interpolate ( node, val... )

Convenience wrapper for the _interpolate function. Takes a

single string or props.Node object in arg[0] indicating a target

property, and a variable-length list of time/value pairs. Example:

interpolate("/animations/radar/angle",

180, 1, 360, 1, 0, 0,

180, 1, 360, 1, 0, 0,

180, 1, 360, 1, 0, 0,

180, 1, 360, 1, 0, 0,

180, 1, 360, 1, 0, 0,

180, 1, 360, 1, 0, 0,

180, 1, 360, 1, 0, 0,

180, 1, 360, 1, 0, 0);

This will swing the "radar dish" smoothly through 8 revolutions over

16 seconds. Note the use of zero-time interpolation between 360 and

0 to wrap the interpolated value properly.

globals.setlistener ( node, fn, init = 0, runtime = 1 )

Wrapper for the _setlistener function. Takes a property path string

or props.Node object in arg[0] indicating the listened to property,

a function in arg[1], an optional bool in arg[2], which triggers the

function initially if true, and an optional integer in arg[3], which

sets the listener's runtime behavior to "only trigger on change" (0),

"always trigger on write" (1), and "trigger even when children are

written to" (2).

globals.defined ( sym )

Returns true if the symbol name is defined in the caller, or the

caller's lexical namespace. (i.e. defined("varname") tells you if

you can use varname in an expression without a undefined symbol

error.

globals.thisfunc ( caller )

Returns reference to calling function. This allows a function to

reliably call itself from a closure, rather than the global function

with the same name.

globals.printf ( print )

Just what it says it is.

globals.values ( hash )

Returns vector of hash values.

globals.printlog ( level, msg... )

📁 gui     Nasal/gui/

📄 MenuBar     Nasal/gui/MenuBar.nas

MenuBar._addItem ( parent, itemGhost )

MenuBar._addMenu ( parent, menuGhost )

MenuBar._createMenuBar ( menubarGhost )

MenuBar._destroyMenuBar ( menubarGhost )

MenuBar._showMenuBar ( menubarGhost )

MenuBar._hideMenuBar ( menubarGhost )

📄 XMLDialog     Nasal/gui/XMLDialog.nas

XMLDialog.XMLDialog

This is the Nasal peer of a dialog defined by XML

it manages creating some top level Canvas (eg a Window) according

to the XML data

XMLDialog.XMLDialog.init ( dialogProps )

XMLDialog.XMLDialog.didBuild ( )

XMLDialog.XMLDialog.onWindowClosed ( )

this is the callback from the canvas.Window: we request a close of

the dialog, which will end up with us in 'onClosed'

XMLDialog.XMLDialog.onBringToFront ( )

XMLDialog.XMLDialog.onGeometryChanged ( )

XMLDialog.XMLDialog.onClose ( )

XMLDialog._createDialogPeer ( type )

this is the callback function which C++ invokes, to create a peer

for an XML dialog (and its C++ class). In the future, different kinds

of dialog could be created if necessary (eg, with different window frame

styles or frameless / non-draggable)

XMLDialog._getProp ( objectProps, name, def )

XMLDialog._getBoolProp ( objectProps, name, def )

XMLDialog._getDoubleProp ( objectProps, name, def )

XMLDialog.XMLDialog._configValue ( name, def = nil )

XMLDialog.XMLDialog._configDouble ( name, def = 0.0 )

XMLDialog.XMLDialog._configBool ( name, def = 0 )

XMLDialog.XMLDialog._applyLayoutConfig ( )

XMLDialog.XMLDialog.view ( )

XMLDialog.XMLDialog.layoutItem ( )

XMLDialog.XMLDialog.init ( objectProps )

XMLDialog.XMLDialog.show ( viewParent )

XMLDialog.XMLDialog.init ( objectProps )

XMLDialog.XMLDialog.show ( viewParent )

XMLDialog.XMLDialog.update ( )

XMLDialog.XMLDialog.init ( objectProps )

XMLDialog.XMLDialog.show ( viewParent )

XMLDialog.XMLDialog.update ( )

XMLDialog.XMLDialog.init ( objectProps )

XMLDialog.XMLDialog.show ( viewParent )

XMLDialog.XMLDialog.update ( )

XMLDialog.XMLDialog.init ( objectProps )

XMLDialog.XMLDialog.show ( viewParent )

XMLDialog.XMLDialog.update ( )

XMLDialog.XMLDialog.init ( objectProps )

XMLDialog.XMLDialog.show ( viewParent )

XMLDialog.XMLDialog.update ( )

XMLDialog.XMLDialog.init ( objectProps )

XMLDialog.XMLDialog.show ( viewParent )

XMLDialog.XMLDialog.update ( )

XMLDialog.XMLDialog.init ( objectProps )

XMLDialog.XMLDialog.show ( viewParent )

XMLDialog.XMLDialog.update ( )

XMLDialog.XMLDialog.show ( viewParent )

XMLDialog.XMLDialog.update ( )

XMLDialog.XMLDialog.show ( viewParent )

XMLDialog.XMLDialog.init ( objectProps )

XMLDialog.XMLDialog.show ( viewParent )

XMLDialog.XMLDialog.update ( )

XMLDialog.XMLList

XMLDialog.XMLList.show ( viewParent )

XMLDialog.XMLList.update ( )

XMLDialog.XMLList.valueChanged ( )

XMLDialog._createCompatObject ( type )

this is the callback function invoked by C++ to build Nasal peers

for the C++ objects defined by XML (PUICompatObject). It's primarly

a factory method: once the peer object is created, all other behaviour

is passed to it.

📄 gui     Nasal/gui.nas

gui.popupTip ( label, delay = nil, override = nil, position = nil )

Pop up a "tip" dialog for a moment, then remove it. The delay in

seconds can be specified as the second argument. The default is 4

seconds. The third argument can be a hash with override values.

Note that the tip dialog is a shared resource. If someone else

comes along and wants to pop a tip up before your delay is finished,

you lose. :)

gui.showDialog ( name )

gui.menuEnable ( searchname, state )

Enable/disable named menu entry

gui.menuBind ( searchname, command )

Set the binding for a menu item to a Nasal script,

typically a dialog open() command.

gui.setCursor ( x = nil, y = nil, cursor = nil )

Set mouse cursor coordinates and shape (number or name), and return

current shape (number).

Example: var cursor = gui.setCursor();

gui.setCursor(nil, nil, "wait");

gui.findElementByName ( dialog, name )

Find a GUI element by given name.

dialog: dialog root property.

name: name of GUI element to be searched.

Returns GUI element when found, nil otherwise.

gui.fpsDisplay ( n )

Show/hide the fps display dialog.

gui.latencyDisplay ( n )

gui.popdown ( )

Pop down the tip dialog, if it is visible.

gui.Widget

Widgets & Layout Management

A "widget" class that wraps a property node. It provides useful

helper methods that are difficult or tedious with the raw property

API. Note especially the slightly tricky addChild() method.

gui.Widget.set ( name, val )

gui.Widget.prop ( )

gui.Widget.new ( )

gui.Widget.addChild ( type )

gui.Widget.setColor ( r, g, b, a = 1 )

gui.Widget.setFont ( n, s = 13, t = 0 )

gui.Widget.setBinding ( cmd, carg = nil )

gui.Dialog

Dialog class. Maintains one XML dialog.

SYNOPSIS:

(B) Dialog.new(<dialog-name>); ... use dialog from $FG_ROOT/gui/dialogs/

(A) Dialog.new(<prop>, <path> [, <dialog-name>]);

... load aircraft specific dialog from

<path> under property <prop> and under

name <dialog-name>; if no name is given,

then it's taken from the XML dialog

prop ... target node (name must be "dialog")

path ... file path relative to $FG_ROOT

dialog-name ... dialog <name> of dialog in $FG_ROOT/gui/dialogs/

EXAMPLES:

var dlg = gui.Dialog.new("/sim/gui/dialogs/foo-config/dialog",

"Aircraft/foo/foo_config.xml");

dlg.open();

dlg.close();

var livery_dialog = gui.Dialog.new("livery-select");

livery_dialog.toggle();

gui.Dialog.new ( prop, path = nil, name = nil )

gui.Dialog.del ( )

gui.Dialog.load ( )

doesn't need to be called explicitly, but can be used to force a reload

gui.Dialog.namespace ( )

allows access to dialog-embedded Nasal variables/functions

gui.Dialog.open ( )

gui.Dialog.close ( )

gui.Dialog.toggle ( )

gui.Dialog.is_open ( )

gui.OverlaySelector

Overlay selector. Displays a list of overlay XML files and copies the

chosen one to the property tree. The class allows to select liveries,

insignia, decals, variants, etc. Usually the overlay properties are

fed to "select" and "material" animations.

SYNOPSIS:

OverlaySelector.new(<title>, <dir>, <nameprop> [, <sortprop> [, <mpprop> [, <callback>]]]);

title ... dialog title

dirs ... directory or vector of directories where to find the XML overlay files,

relative to FG_ROOT

nameprop ... property in an overlay file that contains the name

The result is written to this place in the

property tree.

sortprop ... property in an overlay file that should be used

as sorting criterion, if alphabetic sorting by

name is undesirable. Use nil if you don't need

this, but want to set a callback function.

mpprop ... property path of MP node where the file name should

be written to

callback ... function that's called after a new entry was chosen,

with these arguments:

callback(<number>, <name>, <sort-criterion>, <file>, <path>)

EXAMPLE:

aircraft.data.add("sim/model/pilot"); # autosave the pilot

var pilots_dialog = gui.OverlaySelector.new("Pilots",

"Aircraft/foo/Models/Pilots",

"sim/model/pilot");

pilots_dialog.open(); # or ... close(), or toggle()

gui.OverlaySelector.new ( title, dirs, nameprop, sortprop = nil, mpprop = nil, callback = nil )

gui.OverlaySelector.reinit ( )

gui.OverlaySelector.del ( )

gui.OverlaySelector.rescan ( )

gui.OverlaySelector.set ( index )

gui.OverlaySelector.select ( name )

gui.OverlaySelector.next ( )

gui.OverlaySelector.previous ( )

gui.FileSelector

FileSelector class (derived from Dialog class).

SYNOPSIS: FileSelector.new(<callback>, <title>, <button> [, <pattern> [, <dir> [, <file> [, <dotfiles>]]]])

callback ... callback function that gets return value as first argument

title ... dialog title

button ... button text (should say "Save", "Load", etc. and not just "OK")

pattern ... array with shell pattern or nil (which is equivalent to "*")

dir ... starting dir ($FG_ROOT if unset)

file ... pre-selected default file name

dotfiles ... flag that decides whether UNIX dotfiles should be shown (1) or not (0)

EXAMPLE:

var report = func(n) { print("file ", n.getValue(), " selected") }

var selector = gui.FileSelector.new(

report, # callback function

"Save Flight", # dialog title

"Save", # button text

["*.sav", "*.xml"], # pattern for displayed files

"/tmp", # start dir

"flight.sav"); # default file name

selector.open();

selector.close();

selector.set_title("Save Another Flight");

selector.open();

gui.FileSelector.new ( callback, title, button, pattern = nil, dir = )

gui.FileSelector.set_title ( title )

setters only take effect after the next call to open()

gui.FileSelector.set_button ( button )

gui.FileSelector.set_directory ( dir )

gui.FileSelector.set_file ( file )

gui.FileSelector.set_dotfiles ( dot )

gui.FileSelector.set_pattern ( pattern )

gui.FileSelector.open ( )

gui.FileSelector.close ( )

gui.FileSelector.del ( )

gui.DirSelector

DirSelector - convenience "class" (indeed using a reconfigured FileSelector)

gui.DirSelector.new ( callback, title, button, dir = )

gui.save_flight ( )

gui.load_flight ( )

gui.set_screenshotdir ( )

gui.property_browser ( dir = nil )

Open property browser with given target path.

gui.dialog_apply ( dialog, objects... )

Apply whole dialog or list of widgets. This copies the widgets'

visible contents to the respective <property>.

gui.dialog_update ( dialog, objects... )

Update whole dialog or list of widgets. This makes the widgets

adopt and display the value of their <property>.

gui.enable_widgets ( node, name, enable = 1 )

Searches a dialog tree for widgets with a particular <name> entry and

sets their <enabled> flag.

gui.nextStyle ( delta=1 )

GUI theming

gui.dialog

Dialog Boxes

gui.setWeight ( wgt, opt )

gui.setWeightOpts ( )

Checks the /sim/weight[n]/{selected|opt} values and sets the

appropriate weights therefrom.

gui.weightChangeHandler ( )

Called from the F&W dialog when the user selects a weight option

gui.showWeightDialog ( )

gui.showHelpDialog ( path, toggle=0 )

Dynamically generates a dialog from a help node.

gui.showHelpDialog([<path> [, toggle]])

path ... path to help node

toggle ... decides if an already open dialog should be closed

(useful when calling the dialog from a key binding; default: 0)

help node

=========

each of <title>, <key>, <line>, <text> is optional; uses

"/sim/description" or "/sim/aircraft" if <title> is omitted;

only the first <text> is displayed

<help>

<title>dialog title<title>

<key>

<name>g/G</name>

<desc>gear up/down</desc>

</key>

<line>one line</line>

<line>another line</line>

<text>text in

scrollable widget

</text>

</help>

gui.debug_keys

gui.basic_keys

gui.common_aircraft_keys

gui.isAutopilotMenuEnabled ( )

gui.set_precip ( setprop )

📁 input_helpers     Nasal/input_helpers/

📄 config_manager     Nasal/input_helpers/config_manager.nas

📄 goflight     Nasal/input_helpers/goflight.nas

goflight.formatFrequencyMHz ( freqMhz, fieldWidth )

goflight.formatFrequencyKHz ( freqKhz, fieldWidth )

goflight.bytesForString ( s, fieldWidth )

goflight.translateTo14Segment

TEST

STBY

OFF

XPDR

TA

TA/RA

goflight.formatFourteenSegment ( s, fieldWidth )

goflight.reverseBytes ( bytes )

goflight.MFRController

goflight.MFRController.new ( prefix )

goflight.mcp

goflight.mcp.init ( )

goflight.mcp.setAltitudeFtProp ( path )

goflight.mcp.doRefresh ( )

goflight.mcp.doRefreshHeading ( )

goflight.mcp.setMachMode ( useMach )

goflight.mcp.altitudeData ( )

goflight.mcp.vsData ( )

goflight.mcp.speedData ( )

goflight.mcp.adjustSpeed ( val )

goflight.mcp.adjustAltitude ( val )

goflight.mcp.headingData ( )

goflight.mcp.course1Data ( )

goflight.mcp.course2Data ( )

goflight.mcp.watchPropertyForLED ( prop, ledName )

goflight.mcp.setLED ( data, b )

📄 honeycomb     Nasal/input_helpers/honeycomb.nas

honeycomb.honeycomb

Helpers for Honeycomb input devices

namespace

honeycomb.honeycomb.new ( cfgnode )

honeycomb.honeycomb.setMagnetos ( value )

honeycomb.honeycomb.setStarter ( value )

honeycomb.honeycomb.adjustView ( binding )

handle the hat button on the yoke

honeycomb.honeycomb.new ( cfgnode )

honeycomb.honeycomb.close ( cfgnode )

honeycomb.honeycomb.enableAnnunciators ( )

honeycomb.honeycomb.disableAnnunciators ( )

honeycomb.honeycomb.setIncDecSelector ( name )

honeycomb.honeycomb.incAPSetting ( )

honeycomb.honeycomb.decAPSetting ( )

📄 io     Nasal/io.nas

io.readfile ( file )

Reads and returns a complete file as a string

io.basename ( path )

basename(<path>), dirname(<path>)

Work like standard Unix commands: basename returns the file name from a given

path, and dirname returns the directory part.

io.dirname ( path )

io.is_directory ( path )

io.is_regular_file ( path )

io.exists ( path )

io.subdirectories ( path )

<path> the path that should be searched for subdirectories

returns a vector of subdirectory names

io.include ( file )

include(<filename>)

Loads and executes a Nasal file in place. The file is searched for in the

calling script directory and in standard FG directories (in that order).

Examples:

io.include("Aircraft/Generic/library.nas");

io.include("my_other_file.nas");

io.load_nasal ( file, module = nil )

Loads Nasal file into namespace and executes it. The namespace

(module name) is taken from the optional second argument, or

derived from the Nasal file's name.

Usage: io.load_nasal(<filename> [, <modulename>]);

Example:

io.load_nasal(getprop("/sim/fg-root") ~ "/Local/test.nas");

io.load_nasal("/tmp/foo.nas", "test");

io.read_properties ( path, target = nil, quiet = 0 )

Load XML file in FlightGear's native <PropertyList> format.

If the second, optional target parameter is set, then the properties

are loaded to this node in the global property tree. Otherwise they

are returned as a separate props.Node tree. Returns the data as a

props.Node on success or nil on error.

Usage: io.read_properties(<filename> [, <props.Node or property-path>, <quiet>]);

Examples:

var target = props.globals.getNode("/sim/model");

io.read_properties("/tmp/foo.xml", target);

var data = io.read_properties("/tmp/foo.xml", "/sim/model");

var data = io.read_properties("/tmp/foo.xml");

io.read_airport_properties ( icao, fname, target = nil, quiet = 0 )

Load XML file in FlightGear's native <PropertyList> format.

file will be located in the airport-scenery directories according to

ICAO and filename, i,e in Airports/I/C/A/ICAO.filename.xml

If the second, optional target parameter is set, then the properties

are loaded to this node in the global property tree. Otherwise they

are returned as a separate props.Node tree. Returns the data as a

props.Node on success or nil on error.

Usage: io.read_airport_properties(<icao>, <filename> [, <props.Node or property-path>]);

Examples:

var data = io.read_properties("KSFO", "rwyuse");

io.write_properties ( path, prop )

Write XML file in FlightGear's native <PropertyList> format.

Returns the filename on success or nil on error. If the source

is a props.Node that refers to a node in the main tree, then

the data are directly written from the tree, yielding a more

accurate result. Otherwise the data need to be copied first,

which may slightly change node types (FLOAT becomes DOUBLE etc.)

Usage: io.write_properties(<filename>, <props.Node or property-path>);

Examples:

var data = props.Node.new({ a:1, b:2, c:{ d:3, e:4 } });

io.write_properties("/tmp/foo.xml", data);

io.write_properties("/tmp/foo.xml", "/sim/model");

io.readxml ( path, prefix = )

The following two functions are for reading generic XML files into

the property tree and for writing them from there to the disk. The

built-in fgcommands (load, save, loadxml, savexml) are for FlightGear's

own <PropertyList> XML files only, as they only handle a limited

number of very specific attributes. The io.readxml() loader turns

attributes into regular children with a configurable prefix prepended

to their name, while io.writexml() turns such nodes back into

attributes. The two functions have their own limitations, but can

easily get extended to whichever needs. The underlying parsexml()

command will handle any XML file.

Reads an XML file from an absolute path and returns it as property

tree. All nodes will be of type STRING. Data are only written to

leafs. Attributes are written as regular nodes with the optional

prefix prepended to the name. If the prefix is nil, then attributes

are ignored. Returns nil on error.

io.writexml ( path, node, indent = )

Writes a property tree as returned by readxml() to a file. Children

with name starting with <prefix> are again turned into attributes of

their parent. <node> must contain exactly one child, which will

become the XML file's outermost element.

📁 jetways     Nasal/jetways/

📄 jetways     Nasal/jetways/jetways.nas

jetways.print_debug ( msg )

Animated Jetway System. Spawns and manages interactive jetway models.

Copyright (C) 2011 Ryan Miller

This file is licensed under the GPL license version 2 or later.

(See http://wiki.flightgear.org/Howto:_Animated_jetways)

Special jetway definition files located in $FG_ROOT/Airports/Jetways/XXXX.xml

for each airport are loaded when the user's aircraft is within 50 nm of the

airport. The script dynamically generates runtime model files, writes them to

$FG_ROOT/Models/Airport/Jetway/runtimeX.xml, and places them into the

simulator using the model manager.

Different jetway models can be defined and are placed under

$FG_ROOT/Models/Airport/Jetway/XXX.xml.

Jetways can be extended/retracted independently either by user operation or

by automatic extension for AI models and multiplayer aircraft.

UTILITY FUNCTIONS

-----------------

print_debug(<message>) - prints debug messages

<message> - message to print

print_error(<messsage>) - prints error messages

<message> - error to print

alert(<message>) - displays an alert message in-sim

<message> - the message

normdeg(<angle>) - normalizes angle measures between -180° and 180°

<angle> - angle to normalize

remove(<vector>, <item>) - removes an element from a vector

<vector> - vector

<index> - item

isin(<vector>, <item>) - checks if an item exists in a vector

<vector> - vector

<item> - item

putmodel(<path>, <lat>, <lon>, <alt>, <hdg>) - add a model to the scene graph (unlike geo.put_model(), models added with this function can be adjusted)

<path> - model path

<lat> - latitude

<lon> - longitude

<alt> - altitude in m

<hdg> - heading

interpolate_table(<table>, <value>) - interpolates a value within a table

<table> - interpolation table/vector, in the format of [[<ind>, <dep>], [<ind>, <dep>], ... ]

<value> - value

get_relative_filepath(<path>, <target>) - gets a relative file path from a directory

<path> - directory path should be relative to

<target> - target directory

find_airports(<max dist>) - gets a list of nearest airports

<max dist> - maximum search distance in nm (currently unused)

JETWAY CLASS

------------

Jetway. - creates a new jetway object/model

new(<airport>, <model>, <gate>, <door>,

<airline>, <lat>, <lon>, <alt>,

<heading>, [, <init_extend>]

[, <init_heading>] [, <init_pitch>]

[, <init_ent_heading>])

<airport> - ICAO of associated airport

<model> - jetway model definition (i.e. Models/Airport/Jetway/generic.xml)

<gate> - gate number (i.e. "A1")

<door> - door number (i.e. 0)

<airline> - airline code (i.e. "AAL")

<lat> - latitude location of model

<lon> - longitude location of model

<alt> - elevation of model in m

<heading> - (optional) heading of model

<init_extend> - (optional) initial extension of tunnel in m

<init_heading> - (optional) initial rotation of tunnel along the Z axis

<init_pitch> - (optional) initial pitch of tunnel (rotation along Y axis)

<init_ent_heading> - (optional) initial rotation of entrance along the Z axis

toggle(<user>, <heading>, <coord> - extends/retracts a jetway

[, <hood>])

<user> - whether or not jetway is toggled by user command (0/1)

<heading> - heading of aircraft to connect to

<coord> - a geo.Coord of the target aircraft's door

<hood> - (optional) amount to rotate jetway hood (only required when <user> != 1)

extend(<user>, <heading>, <coord> - extends a jetway (should be called by Jetway.toggle())

[, <hood>])

<user> - whether or not jetway is toggled by user command (0/1)

<heading> - heading of aircraft to connect to

<coord> - a geo.Coord of the target aircraft's door

<hood> - (optional) amount to rotate jetway hood (only required when <user> != 1)

retract(<user>) - retracts a jetway (should be called by Jetway.toggle())

<user> - whether or not a jetway is toggled by user command (0/1)

remove() - removes a jetway object and its model

reload() - reloads a jetway object and its model

setpos(<lat>, <lon>, <heading>, <alt>) - moves a jetway to a new location

<lat> - new latitude

<lon> - new longitude

<heading> - new heading

<alt> - new altitude in m

setmodel(<model>, <airline>, <gate>) - changes the jetway model

<model> - new model

<airline> - new airline sign code

<gate> - new gate number

INTERACTION FUNCTIONS

---------------------

dialog() - open settings dialog

toggle_jetway(<id>) - toggles a jetway by user command (should be called by a pick animation in a jetway model)

<id> - id number of jetway to toggle

toggle_jetway_from_coord(<door>, <hood>, - toggles a jetway with the target door at the specified coordinates

<heading>, [<lat>,

<lon>] [<coord>])

<door> - door number (i.e. 0)

<hood> - amount to rotate jetway hood

<lat> - (required or <coord>) latitude location of door

<lon> - (required or <coord>) longitude location of door

<coord> - (required or <lat>, <lon>) a geo.Coord of the door

toggle_jetway_from_model(<model node>) - toggles a jetway using an AI model instead of the user's aircraft

<model node> - path of AI model (i.e. /ai/models/aircraft[0])- can be the path in a string or a props.Node

INTERNAL FUNCTIONS

------------------

load_airport_jetways(<airport>) - loads jetways at an airport

<airport> - ICAO of airport

unload_airport_jetways(<airport>) - unloads jetways at an airport

<airport> - ICAO of airport

update_jetways() - interpolates model animation values

load_jetways() - loads new jetway models and unloads out-of-range models every 10 seconds; also connects AI and MP aircraft

Utility functions

prints debug messages

jetways.print_error ( msg )

prints error messages

jetways.alert ( msg )

alerts the user

jetways.normdeg ( x )

normalizes headings between -180 and 180

jetways.remove ( vector, item )

deletes an item in a vector

jetways.isin ( vector, v )

checks if an item is in a vector

jetways.putmodel ( path, lat, lon, alt, hdg )

adds a model

jetways.interpolate_table ( table, v )

interpolates a value

jetways.get_relative_filepath ( path, target )

gets a relative file path

jetways.find_airports ( max_distance )

gets a list of nearest airports

TODO: Don't use /sim/airport/nearest-airport-id, which restricts the list to 1 airport

jetways.loadids

jetways.loadids.new ( airport, model, gate, door, airline, lat, lon, alt, heading, init_extend = 0, init_heading = 0, init_pitch = 0, init_ent_heading = 0 )

jetways.loadids.toggle ( user, heading, coord, hood = 0 )

jetways.loadids.extend ( user, heading, door_coord, hood = 0 )

jetways.loadids.retract ( user )

jetways.loadids.remove ( )

jetways.loadids.reload ( )

jetways.loadids.setpos ( lat, lon, hdg, alt )

jetways.loadids.setmodel ( model, airline, gate )

jetways.dialog ( )

Interaction functions

jetways.toggle_jetway ( n )

jetways.toggle_jetway_from_coord ( door, hood, heading, lat, lon = nil )

jetways.toggle_jetway_from_model ( model )

jetways.load_airport_jetways ( airport )

Internal functions

loads jetways at an airport

jetways.unload_airport_jetways ( airport )

unloads jetways at an airport

jetways.restart ( )

restarts the main update loop

jetways.update_jetways ( loopid )

main update loop (runs when jetways are enable and actived)

jetways.load_jetways ( loopid )

loading/unloading loop (runs continuously)

📁 jetways_edit     Nasal/jetways_edit/

📄 jetways_edit     Nasal/jetways_edit/jetways_edit.nas

jetways_edit.click ( pos )

jetways_edit.delete ( )

jetways_edit.adjust ( name, value )

jetways_edit.export ( )

jetways_edit.convert_stg ( )

var report = func(n) { print("file ", n.getValue(), " selected") }

jetways_edit.convert_stg2 ( n )

selector.close();

jetways_edit.flash ( jetway )

jetways_edit.dialog ( )

jetways_edit.print_help ( )

📄 joystick     Nasal/joystick.nas

joystick.custom_bindings

Hash of the custom axis/buttons

joystick.Axis

Class for an individual joystick axis binding

joystick.Axis.new ( name, prop, invertable )

joystick.Axis.clone ( )

joystick.Axis.match ( prop )

joystick.Axis.parse ( prop )

joystick.Axis.readProps ( props )

joystick.Axis.getName ( )

joystick.Axis.getBinding ( axis )

joystick.Axis.isInvertable ( )

joystick.Axis.isInverted ( )

joystick.Axis.getPower ( )

joystick.Axis.setPower ( v )

joystick.Axis.setInverted ( b )

joystick.CustomAxis

joystick.CustomAxis.new ( )

joystick.CustomAxis.clone ( )

joystick.CustomAxis.match ( prop )

joystick.CustomAxis.getBinding ( axis )

joystick.UnboundAxis

joystick.UnboundAxis.new ( )

joystick.UnboundAxis.clone ( )

joystick.UnboundAxis.match ( prop )

joystick.UnboundAxis.getBinding ( axis )

joystick.PropertyScaleAxis

joystick.PropertyScaleAxis.new ( name, prop, factor=1, offset=0, power=1 )

joystick.PropertyScaleAxis.clone ( )

joystick.PropertyScaleAxis.match ( prop )

joystick.PropertyScaleAxis.parse ( p )

joystick.PropertyScaleAxis.getBinding ( axis )

joystick.NasalScaleAxis

joystick.NasalScaleAxis.new ( name, script, prop )

joystick.NasalScaleAxis.clone ( )

joystick.NasalScaleAxis.match ( prop )

joystick.NasalScaleAxis.getBinding ( axis )

joystick.NasalLowHighAxis

joystick.NasalLowHighAxis.new ( name, lowscript, highscript, prop, repeatable )

joystick.NasalLowHighAxis.clone ( )

joystick.NasalLowHighAxis.match ( prop )

joystick.NasalLowHighAxis.getBinding ( axis )

joystick.ButtonBinding

Button bindings

joystick.ButtonBinding.new ( name, binding, repeatable )

joystick.ButtonBinding.clone ( )

joystick.ButtonBinding.match ( prop )

joystick.ButtonBinding.getName ( )

joystick.ButtonBinding.getBinding ( button )

joystick.ButtonBinding.isRepeatable ( )

joystick.CustomButton

joystick.CustomButton.new ( )

joystick.CustomButton.clone ( )

joystick.CustomButton.match ( prop )

joystick.CustomButton.getBinding ( button )

joystick.UnboundButton

joystick.UnboundButton.new ( )

joystick.UnboundButton.clone ( )

joystick.UnboundButton.match ( prop )

joystick.UnboundButton.getBinding ( button )

joystick.PropertyToggleButton

joystick.PropertyToggleButton.new ( name, prop )

joystick.PropertyToggleButton.clone ( )

joystick.PropertyToggleButton.match ( prop )

joystick.PropertyToggleButton.getBinding ( button )

joystick.PropertyAdjustButton

joystick.PropertyAdjustButton.new ( name, prop, step )

joystick.PropertyAdjustButton.clone ( )

joystick.PropertyAdjustButton.match ( prop )

joystick.PropertyAdjustButton.getBinding ( button )

joystick.NasalButton

joystick.NasalButton.new ( name, script, repeatable )

joystick.NasalButton.clone ( )

joystick.NasalButton.match ( prop )

joystick.NasalButton.getBinding ( button )

joystick.NasalHoldButton

joystick.NasalHoldButton.new ( name, script, scriptUp )

joystick.NasalHoldButton.clone ( )

joystick.NasalHoldButton.match ( prop )

joystick.NasalHoldButton.getBinding ( button )

joystick.readConfig ( dialog_root= )

Parse config from the /input tree and write it to the

dialog_root.

joystick.writeConfig ( dialog_root= )

joystick.resetConfig ( dialog_root= )

📄 lag_adjust     Nasal/lag_adjust.nas

lag_adjust.mpCheck ( )

the compensatelag value are used like that by AIMultiplayer.cxx:

1 : old behaviour, trying to keep the plane without doing prediction

2 : predict the plane position in the futur

3 : display more in the past to avoid predictions

lag_adjust.mpInit ( )

lag_adjust.mpClean ( )

lag_adjust.mpStart ( )

lag_adjust.masterSwitch ( )

📁 local_weather     Nasal/local_weather/

📄 cloud_definitions     Nasal/local_weather/cloud_definitions.nas

cloud_definitions.select_cloud_model ( type, subtype )

routines to set up, transform and manage local weather

Thorsten Renk, August 2011

function purpose

select_cloud_model to define the cloud parameters, given the cloud type and subtype

define various cloud models

cloud_definitions.cloudAssembly

hash for assembling hard-coded clouds

📄 cloud_placement_lowlevel     Nasal/local_weather/cloud_placement_lowlevel.nas

cloud_placement_lowlevel.create_undulatus ( type, blat, blong, balt, alt_var, nx, xoffset, edgex, x_var, ny, yoffset, edgey, y_var, und_strength, direction, tri )

routines to set up, transform and manage advanced weather

Thorsten Renk, April 2012

function purpose

create_undulatus to create an undulating cloud pattern

create_cumulus_alleys to create an alley pattern of Cumulus clouds

create_layer to create a cloud layer with optional precipitation

place an undulatus pattern

cloud_placement_lowlevel.create_adv_undulatus ( arg )

place an advanced undulatus pattern

cloud_placement_lowlevel.sgn ( x )

place a stick bundle pattern

cloud_placement_lowlevel.create_stick_bundle ( arg )

cloud_placement_lowlevel.create_domains ( arg )

place a nested domains pattern

cloud_placement_lowlevel.create_cumulus_alleys ( blat, blon, balt, alt_var, nx, xoffset, edgex, x_var, ny, yoffset, edgey, y_var, und_strength, direction, tri )

place a Cumulus alley pattern

cloud_placement_lowlevel.create_developing_cumulus_alleys ( blat, blon, balt, alt_var, nx, xoffset, edgex, x_var, ny, yoffset, edgey, y_var, und_strength, direction, tri )

place a Cumulus alley pattern

cloud_placement_lowlevel.create_layer ( type, blat, blon, balt, bthick, rx, ry, phi, density, edge, rainflag, rain_density )

place a cloud layer

cloud_placement_lowlevel.cumulus_exclusion_layer ( blat, blon, balt, n, size_x, size_y, alpha, s_min, s_max, n_ex, exlat, exlon, exrad )

place a Cumulus layer with excluded regions

to avoid placing cumulus underneath a thunderstorm

📄 compat_layer     Nasal/local_weather/compat_layer.nas

compat_layer.setDefaultCloudsOff ( )

compat_layer.setVisibility ( vis )

set visibility to given value

compat_layer.setVisibilitySmoothly ( vis )

compat_layer.visibility_loop ( )

compat_layer.setLift ( lift )

set thermal lift to given value

compat_layer.setRain ( rain )

set rain properties

compat_layer.setRainDropletSize ( size )

compat_layer.setSnow ( snow )

set snow properties

compat_layer.setSnowFlakeSize ( size )

compat_layer.setTurbulence ( turbulence )

set turbulence to given value

compat_layer.setTemperature ( T )

set temperature to given value

compat_layer.setPressure ( p )

set pressure to given value

compat_layer.setDewpoint ( D )

set dewpoint to given value

compat_layer.setLight ( s )

set light saturation to given value

compat_layer.setLightSmoothly ( s )

compat_layer.light_loop ( )

compat_layer.setScattering ( s )

set horizon scattering

compat_layer.setOvercast ( o )

set overcast haze

compat_layer.setSkydomeShader ( r, m, d )

set skydome scattering parameters

compat_layer.setWind ( dir, speed )

set wind to given direction and speed

compat_layer.smoothDirection ( dir0, dir1, factor )

set wind smoothly to given direction and speed

interpolating across several frames

compat_layer.setWindSmoothly ( dir, speed )

compat_layer.create_cloud ( path, lat, long, alt, heading )

setWind(dir, speed);

place a single cloud

compat_layer.create_impostor ( path, lat, long, alt, heading )

place an impostor sheet

compat_layer.place_model ( path, lat, lon, alt, heading, pitch, yaw )

place a model

compat_layer.place_model_controlled ( string, path, lat, lon, alt, heading, pitch, roll )

place a model with control properties

compat_layer.create_cloud_new ( c )

return model;

place a single cloud using hard-coded system

compat_layer.create_cloud_array ( i, clouds_path, clouds_lat, clouds_lon, clouds_alt, clouds_orientation )

place a cloud layer from arrays, split across frames

compat_layer.create_new_cloud_array ( i, cloudArray )

compat_layer.get_elevation ( lat, lon )

get terrain elevation

compat_layer.get_elevation_array ( lat, lon )

get terrain elevation vector

compat_layer.set_wxradarecho_storm ( lat, lon, base, top, radius, ref, turb, type )

set the wxradar echo of a storm

compat_layer.remove_wxradar_echos ( )

remove unused echos

compat_layer.features

available hard-coded support

📄 local_weather     Nasal/local_weather/local_weather.nas

local_weather.calc_geo ( clat )

routines to set up, transform and manage local weather

Thorsten Renk, June 2011

thermal model by Patrice Poly, April 2010

function purpose

calc_geo to compute the latitude to meter conversion

calc_d_sq to compute a distance square in local Cartesian approximation

effect_volume_loop to check if the aircraft has entered an effect volume

assemble_effect_array to store the size of the effect volume array

add_vectors to add two vectors in polar coordinates

wind_altitude_interpolation to interpolate aloft winds in altitude

wind_interpolation to interpolate aloft winds in altitude and position

get_slowdown_fraction to compute the effect of boundary layer wind slowdown

interpolation_loop to continuously interpolate weather parameters between stations

thermal_lift_start to start the detailed thermal model

thermal_lift_loop to manage the detailed thermal lift model

thermal_lift_stop to end the detailed thermal lift model

wave_lift_start to start the detailed wave lift model

wave_lift_loop to manage the detailed wave lift model

wave_lift_stop to end the detailed wave lift model

effect_volume_start to manage parameters when an effect volume is entered

effect_volume_stop to manage parameters when an effect volume is left

ts_factor (helper function for thermal lift model)

tl_factor (helper function for thermal lift model)

calcLift_max to calculate the maximal available thermal lift for given altitude

calcLift to calculate the thermal lift at aircraft position

calcWaveLift to calculate wave lift at aircraft position

create_cloud_vec to place a single cloud into an array to be written later

clear_all to remove all clouds, effect volumes and weather stations and stop loops

create_detailed_cumulus_cloud to place multiple cloudlets into a box based on a size parameter

create_cumulonimbus_cloud to place multiple cloudlets into a box

create_cumulonimbus_cloud_rain to place multiple cloudlets into a box and add a rain layer beneath

create_cumosys (wrapper to place a convective cloud system based on terrain coverage)

cumulus_loop to place 25 Cumulus clouds each frame

create_cumulus to place a convective cloud system based on terrain coverage

recreate_cumulus to respawn convective clouds as part of the convective dynamics algorithm

cumulus_exclusion_layer to create a layer with 'holes' left for thunderstorm placement

create_rise_clouds to create a barrier cloud system

create_streak to create a cloud streak

create_hollow_layer to create a cloud layer in a hollow cylinder (better for performance)

create_cloudbox to create a sophisticated cumulus cloud with different textures (experimental)

terrain_presampling_start to initialize terrain presampling

terrain_presampling_loop to sample 25 terrain points per frame

terrain_presampling to sample terrain elevation at a random point within specified area

terrain_presampling_analysis to analyze terrain presampling results

wave_detection_loop to detect if and where wave lift should be placed (currently unfinished)

get_convective_altitude to determine the altitude at which a Cumulus cloud is placed

manage presampling to take proper action when a presampling call has been finished

set_wind_model_flag to convert the wind model string into an integer flag

set_texture_mix to determine the texture mix between smooth and rough cloud appearance

create_effect_volume to create an effect volume

set_weather_station to specify a weather station for interpolation

set_atmosphere_ipoint to specify an interpolation point for visibility, haze and shading in the atmosphere

set_wind_ipoint to set an aloft wind interpolation point

set_wind_ipoint_metar to set a wind interpolation point from available ground METAR info where aloft is modelled

showDialog to pop up a dialog window

readFlags to read configuration flags from the property tree into Nasal variables at startup

streak_wrapper wrapper to execute streak from menu

convection wrapper wrapper to execute convective clouds from menu

barrier wrapper wrapper to execute barrier clouds from menu

single_cloud_wrapper wrapper to create single cloud from menu

layer wrapper wrapper to create layer from menu

box wrapper wrapper to create a cloudbox (experimental)

set_aloft wrapper wrapper to create aloft winds from menu

set_tile to call a weather tile creation from menu

startup to prepare the package at startup

test to serve as a testbed for new functions

object purpose

weatherStation to store info about weather conditions

atmopshereIpoint to store info about haze and light propagation in the atmosphere

windIpoint to store an interpolation point of the windfield

effectVolume to store effect volume info and provide methods to move and time-evolve effect volumes

thermalLift to store thermal info and provide methods to move and time-evolve a thermal

waveLift to store wave info

geospatial helper functions

local_weather.calc_d_sq ( lat1, lon1, lat2, lon2 )

local_weather.effect_volume_loop ( index, n_active )

effect volume management loop

local_weather.assemble_effect_array ( )

assemble effect volume array

local_weather.add_vectors ( phi1, r1, phi2, r2 )

vector addition

local_weather.wind_altitude_interpolation ( altitude, w )

windfield altitude interpolation

local_weather.wind_interpolation ( lat, lon, alt )

windfield spatial interpolation

local_weather.get_slowdown_fraction ( )

boundary layer computations

local_weather.interpolation_loop ( )

interpolation management loop

local_weather.thermal_lift_start ( ev )

thermal lift loop startup

local_weather.thermal_lift_loop ( )

thermal lift loop

local_weather.thermal_lift_stop ( )

thermal lift loop stop

local_weather.wave_lift_start ( ev )

wave lift loop startup

local_weather.wave_lift_loop ( )

wave lift loop

local_weather.wave_lift_stop ( )

wave lift loop stop

local_weather.effect_volume_start ( ev )

action taken when in effect volume

local_weather.effect_volume_stop ( ev )

local_weather.ts_factor ( t, alt, height )

compute thermal lift in detailed model

local_weather.tl_factor ( t, alt, height )

local_weather.calcLift_max ( alt, max_lift, height )

local_weather.calcLift ( d, alt, R, height, cn, sh, max_lift, f_lift_radius, t )

local_weather.calcWaveLift ( x, y, alt )

compute wave lift in detailed model

local_weather.create_cloud_vec ( path, lat, lon, alt, heading )

place a single cloud into a vector to be processed

separately

local_weather.clear_all ( )

clear all clouds and effects

local_weather.create_detailed_cumulus_cloud ( lat, lon, alt, size )

detailed Cumulus clouds created from multiple cloudlets

local_weather.create_cumulonimbus_cloud ( lat, lon, alt, size )

detailed small Cumulonimbus clouds created from multiple cloudlets

local_weather.create_cumulonimbus_cloud_rain ( lat, lon, alt, size, rain )

create_cloudbox = func (type, blat, blon, balt, dx,dy,dz,n, f_core, r_core, h_core, n_core, f_bottom, h_bottom, n_bottom)

detailed small Cumulonimbus and rain created from multiple cloudlets

local_weather.create_cumosys ( blat, blon, balt, nc, size )

wrappers for convective cloud system to distribute

call across several frames if needed

local_weather.cumulus_loop ( blat, blon, balt, nc, size )

local_weather.create_cumulus ( blat, blon, balt, nc, size )

place a convective cloud system

local_weather.recreate_cumulus ( blat, blon, balt, alpha, nc, size, tile_index )

respawn convective clouds to compensate for decay

the difference being that new clouds get zero fractional

lifetime and are placed based on terrain with a different weight

local_weather.create_rise_clouds ( blat, blon, balt, nc, size, winddir, dist )

place a barrier cloud system

local_weather.create_streak ( type, blat, blong, balt, alt_var, nx, xoffset, edgex, x_var, ny, yoffset, edgey, y_var, direction, tri )

place a cloud streak

local_weather.create_hollow_layer ( type, blat, blon, balt, bthick, rx, ry, phi, density, edge, gap_fraction )

place a cloud layer with a gap in the middle

(useful to reduce cloud count in large thunderstorms)

local_weather.create_cloudbox ( type, blat, blon, balt, dx, dy, dz, n, f_core, r_core, h_core, n_core, f_bottom, h_bottom, n_bottom )

place a cloud box

local_weather.terrain_presampling_start ( blat, blon, nc, size, alpha )

terrain presampling initialization

local_weather.terrain_presampling_loop ( blat, blon, nc, size, alpha )

terrain presampling loop

local_weather.terrain_presampling ( blat, blon, ntries, size, alpha )

terrain presampling routine

local_weather.terrain_presampling_analysis ( )

terrain presampling analysis

local_weather.wave_detection_loop ( blat, blon, nx, alpha )

wave conditions search

local_weather.get_convective_altitude ( balt, elevation, tile_index, grad )

detailed altitude determination for convective calls

clouds follow the terrain to some degree, but not excessively so

local_weather.get_terrain_gradient ( lat, lon, elevation1, phi, dist )

detailed terrain gradient determination in wind direction

local_weather.get_gradient_factor ( grad )

enhancement of the placement altitude due to terrain

local_weather.get_lee_bias ( grad, tile_index )

suppression of placement in lee terrain

local_weather.get_terrain_altitude_factor ( tile_index, balt, elevation )

enhancement of Cumulus in above average altitude

local_weather.get_terrain_strength_factor ( terrain_altitude_factor )

local_weather.manage_presampling ( )

terrain presampling listener dispatcher

local_weather.manage_hardcoded_presampling ( )

hardcoded terrain presampling listener dispatcher

local_weather.set_wind_model_flag ( )

set wind model flag

local_weather.set_texture_mix ( )

set texture mix for convective clouds

local_weather.create_effect_volume ( geometry, lat, lon, r1, r2, phi, alt_low, alt_high, vis, rain, snow, turb, lift, lift_flag, sat )

create an effect volume

local_weather.set_weather_station ( lat, lon, alt, vis, T, D, p )

set a weather station for interpolation

local_weather.set_atmosphere_ipoint ( lat, lon, vis_aloft, vis_alt1, vis_ovcst, ovcst, ovcst_alt_low, ovcst_alt_high, scatt, scatt_alt_low, scatt_alt_high )

set an atmosphere condition point for interpolation

local_weather.set_wind_ipoint ( lat, lon, d0, v0, d1, v1, d2, v2, d3, v3, d4, v4, d5, v5, d6, v6, d7, v7, d8, v8 )

set a wind interpolation point

local_weather.set_wind_ipoint_metar ( lat, lon, d0, v0 )

set a wind interpolation point from ground METAR data

local_weather.showDialog ( name )

helper to show additional dialogs

local_weather.readFlags ( )

helper to transfer configuration flags in menu to Nasal

local_weather.streak_wrapper ( )

wrappers to call functions from the local weather menu bar

local_weather.convection_wrapper ( )

local_weather.barrier_wrapper ( )

local_weather.single_cloud_wrapper ( )

local_weather.layer_wrapper ( )

local_weather.box_wrapper ( )

local_weather.set_aloft_wrapper ( )

local_weather.set_tile ( )

tile setup call wrapper

local_weather.startup ( )

Anything that needs to run at startup goes here

local_weather.test ( )

Standard test call (for development and debug only)

local_weather.weatherStation

var info = {};

for (var i = 0; i< 100000; i=i+1)

{

info = geodinfo(lat, lon);

}

object classes

local_weather.weatherStation.new ( lat, lon, alt, vis, T, D, p )

local_weather.weatherStation.move ( )

local_weather.atmosphereIpoint

local_weather.atmosphereIpoint.new ( lat, lon, vis_aloft, vis_alt1, vis_ovcst, ovcst, ovcst_alt_low, ovcst_alt_high, scatt, scatt_alt_low, scatt_alt_high )

local_weather.atmosphereIpoint.move ( )

local_weather.windIpoint

local_weather.windIpoint.new ( lat, lon, d0, v0, d1, v1, d2, v2, d3, v3, d4, v4, d5, v5, d6, v6, d7, v7, d8, v8 )

local_weather.windVec

local_weather.windVec.new ( d, v )

local_weather.effectVolume

local_weather.effectVolume.new ( geometry, lat, lon, r1, r2, phi, alt_low, alt_high, vis, rain, snow, turb, lift, lift_flag, sat )

local_weather.effectVolume.move ( )

local_weather.effectVolume.correct_altitude ( )

local_weather.effectVolume.correct_altitude_and_age ( )

local_weather.effectVolume.get_distance ( )

local_weather.thermalLift

local_weather.thermalLift.new ( lat, lon, radius, height, cn, sh, max_lift, f_lift_radius )

local_weather.thermalLift.move ( )

local_weather.thermalLift.correct_altitude ( )

local_weather.thermalLift.correct_altitude_and_age ( )

local_weather.waveLift

local_weather.waveLift.new ( lat, lon, x, y, phi, height, max_lift )

local_weather.thermal

global weather hashes

local_weather.wave

local_weather.interpolated_conditions

local_weather.current_conditions

local_weather.tracerAssembly

local_weather.updateMenu ( )

📄 sea_colors     Nasal/local_weather/sea_colors.nas

sea_colors.seaColorPoint

object classes

sea_colors.seaColorPoint.new ( lat, lon, weight, deep_r, deep_g, deep_b )

sea_colors.init_sea_colors ( )

functions

sea_colors.sea_color_loop ( index )

📄 weather_dynamics     Nasal/local_weather/weather_dynamics.nas

weather_dynamics.get_windfield ( tile_index )

routines to simulate cloud wind drift and evolution

Thorsten Renk, October 2010

function purpose

get_windfield to get the current wind in the tile

timing_loop to provide accurate timing information for wind drift calculations

quadtree_loop to manage drift of clouds in the field of view

weather_dynamics_loop to manage drift of weather effects, tile centers and interpolation points

convective_loop to regularly recreate convective clouds

generate_quadtree_structure to generate a quadtree data structure used for managing the visual field

sort_into_quadtree to sort objects into a quadtree structure

sorting_recursion to recursively sort into a quadree (helper)

quadtree_recursion to search the quadtree for objects in the visual field

check_visibility to check if a quadrant is currently visible

move_tile to move tile coordinates in the wind

get_cartesian to get local Cartesian coordinates out of coordinates

get the windfield for a given location and altitude

(currently constant, but supposed to be local later)

weather_dynamics.get_wind_direction ( tile_index )

weather_dynamics.get_wind_speed ( tile_index )

weather_dynamics.timing_loop ( )

timing loop

this gets the accurate time since the start of weather dynamics

and hence the timestamps for cloud evolution since

the available elapsed-time-sec is not accurate enough

weather_dynamics.quadtree_loop ( )

quadtree loop

the quadtree loop is a fast loop updating the position

of visible objects in the field of view only

weather_dynamics.weather_dynamics_loop ( index, cindex )

weather_dynamics_loop

the weather dynamics loop is a slow loop updating

position and state of invisible objects, currently

effect volumes and weather stations

weather_dynamics.convective_loop ( )

convective evolution loop

weather_dynamics.generate_quadtree_structure ( depth, tree_base_vec )

generate quadtree structure

weather_dynamics.sort_into_quadtree ( blat, blon, alpha, lat, lon, tree, object )

sort into quadtree

weather_dynamics.sorting_recursion ( x, y, tree, object, depth )

weather_dynamics.quadtree_recursion ( tree, depth, flag, qx, qy )

quadtree recursive search

weather_dynamics.check_visibility ( qx, qy, length_scale )

quadrant visibility test

weather_dynamics.move_tile ( t )

move a tile

weather_dynamics.get_cartesian ( blat, blon, alpha, lat, lon )

get local Cartesian coordinates

📄 weather_tile_management     Nasal/local_weather/weather_tile_management.nas

weather_tile_management.tile_management_loop ( )

routines to set up, transform and manage weather tiles

Thorsten Renk, March 2011

function purpose

tile_management_loop to decide if a tile is created, removed or considered current

generate_tile to decide on orientation and type and set up all information for tile creation

remove_tile to delete a tile by index

change_active_tile to change the tile the aircraft is currently in and to generate neighbour info

copy_entry to copy tile information from one node to another

create_neighbour to set up information for a new neighbouring tile

create_neighbours to initialize the 8 neighbours of the initial tile

buffer_loop to manage the buffering of faraway clouds in an array

housekeeping_loop to shift clouds from the scenery into the buffer

remove_impostors to delete a ring of impostors to mimick distant clouds

create_impostors to create a ring of impostors to mimick distant clouds

shadow_management_loop to manage cloud shadow information

thunderstorm_management_loop to manage information on thunderstorm position

lightning_strike to get the timing for a lightning strike to the property tree

watchdog loop (debug helping structure)

calc_geo to get local Cartesian geometry for latitude conversion

get_lat to get latitude from Cartesian coordinates

get_lon to get longitude from Cartesian coordinates

relangle to compute the relative angle between two directions, normalized to [0:180]

norm_relangle to compute the relative angle between two directions, normalized to [0:360]

delete_from_vector to delete an element 'n' from a vector

object purpose

cloud to provide the data hash for the new cloud rendering system

cloudBuffer to store a cloud in a Nasal buffer, to provide methods to move it

cloudScenery to store info for clouds in scenery, to provide methods to move and evolve them

cloudImpostor to provide the hash data for an impostor cloud sheet

tile management loop

weather_tile_management.generate_tile ( code, lat, lon, dir_index )

tile generation call

weather_tile_management.remove_tile ( index )

tile removal call

weather_tile_management.change_active_tile ( index )

active tile change and neighbour

recomputation

weather_tile_management.rotate_tile_scheme ( angle )

rotate tile scheme

weather_tile_management.copy_entry ( from_index, to_index )

copy tile info in neighbour matrix

weather_tile_management.create_neighbour ( blat, blon, index, alpha )

create adjacent tile coordinates

weather_tile_management.create_neighbours ( blat, blon, alpha )

find the 8 adjacent tile coordinates

after the initial setup call

weather_tile_management.housekeeping_loop ( index, index1 )

housekeeping loop

weather_tile_management.remove_impostors ( )

weather_tile_management.create_impostors ( )

weather_tile_management.thunderstorm_management_loop ( )

Thunderstorm positon management

weather_tile_management.lightning_strike ( )

weather_tile_management.shadow_management_loop ( index )

Cloud shadow management

weather_tile_management.watchdog_loop ( )

watchdog loop for debugging

weather_tile_management.cloudBuffer

weather_tile_management.cloudBuffer.new ( lat, lon, alt, path, orientation, index, type )

weather_tile_management.cloudBuffer.get_distance ( )

weather_tile_management.cloudBuffer.get_course ( )

weather_tile_management.cloudBuffer.show ( )

weather_tile_management.cloudBuffer.move ( )

weather_tile_management.cloudImpostor

weather_tile_management.cloudImpostor.new ( modelNode )

weather_tile_management.cloudImpostor.removeNodes ( )

weather_tile_management.cloudShadow

weather_tile_management.cloudShadow.new ( lat, lon, size, strength )

weather_tile_management.thunderstormHash

weather_tile_management.thunderstormHash.new ( lat, lon, alt, size, strength )

weather_tile_management.cloudScenery

weather_tile_management.cloudScenery.new ( index, type, cloudNode, modelNode )

weather_tile_management.cloudScenery.removeNodes ( )

weather_tile_management.cloudScenery.to_buffer ( )

weather_tile_management.cloudScenery.get_distance ( )

weather_tile_management.cloudScenery.get_course ( )

weather_tile_management.cloudScenery.get_altitude ( )

weather_tile_management.cloudScenery.correct_altitude ( )

weather_tile_management.cloudScenery.correct_altitude_and_age ( )

weather_tile_management.cloudScenery.to_target_alt ( )

weather_tile_management.cloudScenery.move ( )

weather_tile_management.cloudScenery.show ( )

weather_tile_management.cloud

weather_tile_management.cloud.new ( type, subtype )

weather_tile_management.cloud.remove ( )

weather_tile_management.cloud.move ( )

weather_tile_management.cloud.correct_altitude ( )

weather_tile_management.calc_geo ( clat )

helper functions

weather_tile_management.get_lat ( x, y, phi )

weather_tile_management.get_lon ( x, y, phi )

weather_tile_management.relangle ( alpha, beta )

weather_tile_management.norm_relangle ( alpha, beta )

weather_tile_management.delete_from_vector ( vec, index )

📄 weather_tiles     Nasal/local_weather/weather_tiles.nas

weather_tiles.tile_start ( )

routines to set up weather tiles

Thorsten Renk, June 2011

function purpose

tile_start to execute jobs common for all tiles on startup

tile_finished to execute jobs common for all tiles when tile creation is done

set_NN_tile to set a weather tile of type NN

create_NN to create the cloud configuration NN

adjust_p to make sure pressure variation cannot exceed limits between tiles

calc_geo to get local Cartesian geometry for latitude conversion

get_lat to get latitude from Cartesian coordinates

get_lon to get longitude from Cartesian coordinates

tile setup calls

weather_tiles.tile_finished ( )

weather_tiles.set_4_8_stratus_tile ( )

test tile

weather_tiles.set_high_pressure_core_tile ( )

high pressure core

weather_tiles.set_high_pressure_tile ( )

high pressure

weather_tiles.set_high_pressure_border_tile ( )

high pressure border

weather_tiles.set_low_pressure_border_tile ( )

low pressure border

weather_tiles.set_low_pressure_tile ( )

low pressure

weather_tiles.set_low_pressure_core_tile ( )

low pressure core

weather_tiles.set_cold_sector_tile ( )

cold sector

weather_tiles.set_warm_sector_tile ( )

Warm sector

weather_tiles.set_tropical_weather_tile ( )

Tropical weather

weather_tiles.set_thunderstorms_tile ( )

Thunderstorms

weather_tiles.set_coldfront_tile ( )

Coldfront

weather_tiles.set_warmfront1_tile ( )

Warmfront 1

weather_tiles.set_warmfront2_tile ( )

Warmfront 2

weather_tiles.set_warmfront3_tile ( )

Warmfront 3

weather_tiles.set_warmfront4_tile ( )

Warmfront 4

weather_tiles.set_METAR_tile ( )

METAR

weather_tiles.set_METAR_weather_station ( )

METAR station setup

weather_tiles.create_8_8_tstratus ( lat, lon, alt, alpha )

mid-level cloud setup calls

weather_tiles.create_8_8_cirrostratus ( lat, lon, alt, alpha )

weather_tiles.create_8_8_nimbus ( lat, lon, alt, alpha )

weather_tiles.create_8_8_nimbus_var1 ( lat, lon, alt, alpha )

weather_tiles.create_8_8_nimbus_var2 ( lat, lon, alt, alpha )

weather_tiles.create_8_8_nimbus_var3 ( lat, lon, alt, alpha )

weather_tiles.create_8_8_nimbus_rain ( lat, lon, alt, alpha, rain )

weather_tiles.create_8_8_stratus ( lat, lon, alt, alpha )

weather_tiles.create_8_8_stratus_rain ( lat, lon, alt, alpha, rain )

weather_tiles.create_6_8_stratus ( lat, lon, alt, alpha )

weather_tiles.create_6_8_nimbus_rain ( lat, lon, alt, alpha, rain )

weather_tiles.create_6_8_stratus_rain ( lat, lon, alt, alpha, rain )

weather_tiles.create_6_8_stratus_undulatus ( lat, lon, alt, alpha )

weather_tiles.create_6_8_tstratus_undulatus ( lat, lon, alt, alpha )

weather_tiles.create_6_8_tstratus_mackerel ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_6_8_cirrostratus ( lat, lon, alt, alpha )

weather_tiles.create_6_8_stratocumulus ( lat, lon, alt, alpha )

weather_tiles.create_4_8_stratus ( lat, lon, alt, alpha )

weather_tiles.create_4_8_stratus_patches ( lat, lon, alt, alpha )

weather_tiles.create_4_8_tstratus_patches ( lat, lon, alt, alpha )

weather_tiles.create_4_8_tstratus_domains ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_4_8_sstratus_patches ( lat, lon, alt, alpha )

weather_tiles.create_4_8_cirrostratus_patches ( lat, lon, alt, alpha )

weather_tiles.create_4_8_cirrostratus_undulatus ( lat, lon, alt, alpha )

weather_tiles.create_4_8_stratus_undulatus ( lat, lon, alt, alpha )

weather_tiles.create_4_8_tstratus_undulatus ( lat, lon, alt, alpha )

weather_tiles.create_4_8_sstratus_undulatus ( lat, lon, alt, alpha )

weather_tiles.create_4_8_cirrocumulus_bank ( lat, lon, alt, alpha )

weather_tiles.create_4_8_cirrocumulus_undulatus ( lat, lon, alt, alpha )

weather_tiles.create_4_8_cirrocumulus_streaks ( lat, lon, alt, alpha )

weather_tiles.create_4_8_altocumulus_perlucidus ( lat, lon, alt, alpha )

weather_tiles.create_4_8_alttstratus_streaks ( lat, lon, alt, alpha )

weather_tiles.create_4_8_alttstratus_patches ( lat, lon, alt, alpha )

weather_tiles.create_4_8_stratocumulus ( lat, lon, alt, alpha )

weather_tiles.create_4_8_cumulus_alleys ( lat, lon, alt, alpha )

weather_tiles.create_4_8_small_cumulus_alleys ( lat, lon, alt, alpha )

weather_tiles.create_4_8_cirrus ( lat, lon, alt, alpha )

weather_tiles.create_4_8_sstratus_bundle ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_4_8_sstratus_domains ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_4_8_cirrus_bundle ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_4_8_alttstratus_domains ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_2_8_sstratus_bundle ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_2_8_sstratus_hires_bundle ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_2_8_cirrostratus_mackerel ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_2_8_perlucidus_mackerel ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_2_8_alttstratus_domains ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_2_8_altocumulus_domains ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_2_8_altocumulus_perlucidus_domains ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_2_8_cirrocumulus_domains ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_2_8_stratus ( lat, lon, alt, alpha )

weather_tiles.create_2_8_tstratus ( lat, lon, alt, alpha )

weather_tiles.create_2_8_sstratus ( lat, lon, alt, alpha )

weather_tiles.create_2_8_altocumulus_perlucidus ( lat, lon, alt, alpha )

weather_tiles.create_2_8_sstratus_streak ( lat, lon, alt, alpha )

weather_tiles.create_2_8_cirrostratus ( lat, lon, alt, alpha )

weather_tiles.create_2_8_cirrocumulus ( lat, lon, alt, alpha )

weather_tiles.create_2_8_cirrus ( lat, lon, alt, alpha )

weather_tiles.create_2_8_alttstratus ( lat, lon, alt, alpha )

weather_tiles.create_2_8_altocumulus_streaks ( lat, lon, alt, alpha )

weather_tiles.create_1_8_cirrocumulus_mackerel ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_1_8_alttstratus_domains ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_1_8_altocumulus_scattered ( lat, lon, alt, alpha )

weather_tiles.create_1_8_cirrocumulus ( lat, lon, alt, alpha )

weather_tiles.create_1_8_cirrus ( lat, lon, alt, alpha )

weather_tiles.create_1_8_cirrus_bundle ( lat, lon, alt, alpha )

weather_tiles.arg

weather_tiles.create_1_8_cirrostratus_undulatus ( lat, lon, alt, alpha )

weather_tiles.create_1_8_contrails ( lat, lon, alt, alpha )

weather_tiles.create_thunderstorm_scenario ( lat, lon, alt, alpha )

weather_tiles.create_stratocumulus_bank ( lat, lon, alt, alpha )

weather_tiles.create_detailed_stratocumulus_bank ( lat, lon, alt, alpha )

weather_tiles.create_detailed_small_stratocumulus_bank ( lat, lon, alt, alpha )

weather_tiles.create_cloud_bank ( type, lat, lon, alt, x1, x2, height, n, alpha )

weather_tiles.create_small_thunderstorm ( lat, lon, alt, alpha )

weather_tiles.create_medium_thunderstorm ( lat, lon, alt, alpha )

weather_tiles.create_big_thunderstorm ( lat, lon, alt, alpha )

weather_tiles.create_noctilucent_patch ( lat, lon, alt, alpha )

weather_tiles.create_2_8_cirrocumulus_patches ( lat, lon, alt, alpha )

weather_tiles.create_impostor_ring ( lat, lon, alt, alpha, type, n )

weather_tiles.calc_geo ( clat )

helper functions

weather_tiles.get_lat ( x, y, phi )

weather_tiles.get_lon ( x, y, phi )

weather_tiles.get_n ( strength )

weather_tiles.adjust_p ( p )

continuity condition of pressure

📄 local_weather_auto_init     Nasal/local_weather_auto_init.nas

local_weather_auto_init.autoInit ( )

this routine checks whether the launcher has requested to auto-start AW

we can't do this inside the AW namespace because that is only loaded

on demand, and we want this at Nasal (re-)init, not at AW namespace loading

Thorsten Renk 2018

📄 markerpins     Nasal/markerpins.nas

markerpins.navPins

markerpins.poiPins

markerpins.trafficPins

markerpins.enabled

markerpins.update_pins ( )

markerpins.toggleTrafficPins ( node )

📄 material     Nasal/material.nas

material.colorgroup ( parent, name, base )

material.mat ( parent, name, path, format, min=nil, max=nil )

material.showDialog ( base, title=nil, x=nil, y=nil )

📄 math     Nasal/math.nas

math.abs ( n )

math.sgn ( x )

math.max ( x )

math.min ( x )

math.avg ( )

math.clamp ( value, min, max )

this follows std::clamp for argument order, as opposed to

qBound which uses (min, value, max)

math.mod ( n, m )

note - mathlib defines an fmod function (added after this was written)

It uses C-library fmod(), which has different rounding behaviour to

this code (eg, fmod(-5, 4) gives -1, whereas this code gives 3)

math.log10 ( x )

math.approx_eq ( a, b, d = 0.000001 )

📁 modules     Nasal/modules/

📁 canvas_efis     Nasal/modules/canvas_efis/

📄 display-unit     Nasal/modules/canvas_efis/display-unit.nas

📄 efis-canvas     Nasal/modules/canvas_efis/efis-canvas.nas

efis-canvas.EFISCanvas

------------------------------------------

efis-canvas.nas - Canvas EFIS framework

author: jsb

created: 12/2017

------------------------------------------

-- EFISCanvas - base class to create canvas displays / pages --

* manages a canvas

* can load a SVG file and create clipping from <name>_clip elements

* allows to register multiple update functions with individual update intervals

* update functions can be en-/disabled by a single property that should

reflect the visibility of the canvas

* several listener factories for common animations

efis-canvas.EFISCanvas.unload ( )

efis-canvas.EFISCanvas.del ( )

destructor

efis-canvas.EFISCanvas.new ( name )

efis-canvas.EFISCanvas.setUpdateN ( n )

set node that en-/dis-ables canvas updates

efis-canvas.EFISCanvas.addUpdateFunction ( f, interval, f_me = nil )

register an update function with a certain update interval

f: function

f_me: if there is any "me" reference in "f", you can set "me" with this

defaults to EFISCanvas instance calling this method, useful if "f"

is a member of the EFISCanvas instance

efis-canvas.EFISCanvas.startUpdates ( )

start all registered update functions

efis-canvas.EFISCanvas.stopUpdates ( )

stop all registered update functions

efis-canvas.EFISCanvas.getInstr ( sys, prop, default=0, id=nil )

getInstr - get props from /instrumentation/<sys>[i]/<prop>

creates prop node objects for efficient access

sys: the instrument name (path) (me.id is appended as index!!)

prop: the property(path)

📄 efis-framework     Nasal/modules/canvas_efis/efis-framework.nas

📄 efis     Nasal/modules/canvas_efis/efis.nas

efis.EFIS

-------------------------------------------------------------------------------

efis.nas

author: jsb

created: 12/2017

-------------------------------------------------------------------------------

class EFIS

manage cockpit displays (=outputs) and sources (image generators for PFD, MFD, EICAS...)

allow redirection of sources to alternate displays (allow for simulated display fault)

efis.EFIS.unload ( )

efis.EFIS.del ( )

efis.EFIS.new ( display_names, object_names, canvas_settings=nil )

create EFIS object

display_names: vector of display names, one DisplayUnit per entry will be

created

object_names: vector of same size and order as display_names, containing

3D object names for canvas placement of the DisplayUnits

efis.EFIS._setDisplaySource ( du_id, source_id )

-- private methods ----------------------

_setDisplaySource - switch display unit du_id to source source_id

count how often a source is displayed, sources not displayed stop updating themselves

efis.EFIS._activateRouting ( mapping )

mapping can be either:

- vector of source ids, size must equal size(display_units)

values nil = do nothing, 0..N select source, -1 no source

- hash {<unit_name>: source_id}

efis.EFIS._powerOnOff ( power )

Start/stop updates on all sources

efis.EFIS.setPowerProp ( path, minimum_power = 1 )

-- public methods -----------------------

set power prop and add listener to start/stop all registered update functions

e.g. power up will start updates, loss of power will stop updates

efis.EFIS.setWindowSize ( window_size )

efis.EFIS.boot ( )

efis.EFIS.setDUPowerProps ( power_props, minimum_power=0 )

efis.EFIS.addSource ( efis_canvas )

add a EFISCanvas instance as display source

EFIS controls updating by tracking how often source is used

returns source ID that can be used in mappings

efis.EFIS.addDisplaySwapControl ( ctrl, mappings, callback=nil )

ctrl: property path to integer prop

mappings: vector of display mappings

callback: optional function that will be called with current ctrl value

efis.EFIS.addSourceSelector ( selected, target, sources=nil )

selected: property (node or path) containing source number (integer)

target: contains the DU number to which the source will be mapped

sources: optional vector, selected -> source ID (as returned by addSource)

defaults to all registered sources

efis.EFIS.setDefaultMapping ( mapping )

efis.EFIS.getDU ( i )

efis.EFIS.getDisplayName ( id )

getSources: func() { return me.source_records; },

efis.EFIS.getDisplayID ( name )

efis.EFIS.displayWindow ( id )

open a canvas window for display unit <id>

📄 eicas-message-sys     Nasal/modules/canvas_efis/eicas-message-sys.nas

eicas-message-sys.Pager

EICAS message system

initial version by jsb 05/2018

simple pager to get a sub vector of messages

eicas-message-sys.Pager.new ( page_length, prop_path )

eicas-message-sys.Pager.pageChanged ( )

eicas-message-sys.Pager.setPageLength ( n )

eicas-message-sys.Pager.setPage ( p )

eicas-message-sys.Pager.getPageCount ( )

eicas-message-sys.Pager.getCurrentPage ( )

eicas-message-sys.Pager.page ( lines )

lines: vector of all messages

returns lines of current page; sticky lines will not be paged

eicas-message-sys.MessageClass

eicas-message-sys.MessageClass.new ( name, paging, prio=0 )

eicas-message-sys.MessageClass.setColor ( color )

eicas-message-sys.MessageClass.setPrio ( prio )

eicas-message-sys.MessageClass.enable ( )

eicas-message-sys.MessageClass.disable ( bool = 1 )

eicas-message-sys.MessageClass.isDisabled ( )

eicas-message-sys.Message

eicas-message-sys.MessageSystem

eicas-message-sys.MessageSystem.new ( page_length, prop_path )

eicas-message-sys.MessageSystem.setPowerProp ( p, min_power = 1 )

setRootNode: func(n) {

me.rootN = n;

},

set power prop and add listener to start/stop all registered update functions

eicas-message-sys.MessageSystem.addMessageClass ( class_name, paging, color = nil )

class_name: identifier for msg class

paging: true = normal paging, false = msg class is sticky at top of list

returns class id (int)

eicas-message-sys.MessageSystem.addMessages ( class, messages )

addMessages creates a new msg class and add messages to it

class: class id returned by addMessageClass();

messages: vector of message objects (hashes)

eicas-message-sys.MessageSystem.setSoundPath ( path )

eicas-message-sys.MessageSystem.addAuralAlert ( id, filename, volume=1.0, path=nil )

eicas-message-sys.MessageSystem.addAuralAlerts ( alert_hash )

eicas-message-sys.MessageSystem._updateList ( )

check per class queues and create list of all active messages not inhibited

eicas-message-sys.MessageSystem._remove ( class, msg )

eicas-message-sys.MessageSystem._isActive ( class, msg )

eicas-message-sys.MessageSystem.setMessage ( class, msg_id, visible=1 )

(de-)activate message

eicas-message-sys.MessageSystem.auralAlert ( aural )

eicas-message-sys.MessageSystem.init ( )

-- check for active messages and set new-msg flags.

can be used on power up to trigger new-msg events.

eicas-message-sys.MessageSystem.hasUpdate ( )

eicas-message-sys.MessageSystem.setPageLength ( p )

eicas-message-sys.MessageSystem.getPageLength ( )

eicas-message-sys.MessageSystem.getFirstUpdateIndex ( )

eicas-message-sys.MessageSystem.getActiveMessages ( )

returns message queue and clears the hasUpdate flag

eicas-message-sys.MessageSystem.getMessageID ( class, msgtext )

find message text, return id

eicas-message-sys.MessageSystem.disableMessage ( class, id = nil )

inhibit message id (or all messages in class if no id is given)

eicas-message-sys.MessageSystem.enableMessage ( class, id = nil )

re-enable message id (or all messages in class if no id is given)

eicas-message-sys.MessageSystem.setCanvasGroup ( group )

-- following methods are for message output on a canvas --

pass an existing canvas group to create text elements on

eicas-message-sys.MessageSystem.createCanvasTextLines ( left, top, line_spacing, font_size )

create text elements for message lines in canvas group; call setCanvasGroup() first!

eicas-message-sys.MessageSystem.createPageIndicator ( left, top, font_size, format_string = nil )

create text element for "page i of N"; call setCanvasGroup() first!

returns the text element

eicas-message-sys.MessageSystem.updateCanvas ( )

call this regularly to update text lines on canvas

eicas-message-sys.MessageSystem.updatePageIndicator ( current, total )

📄 main     Nasal/modules/canvas_efis/main.nas

main.unload ( module )

main.main ( module )

📄 dummy     Nasal/modules/dummy.nas

📄 repair_config     Nasal/modules/repair_config.nas

repair_config.printNodeInfo ( n )

repair_config.printConfig ( name, cfg )

repair_config.loadDefaultsNasal ( )

repair_config.compareConfigs ( ref_cfg, check_cfg )

repair_config.repairUserArchiveFlag ( ref_cfg, check_cfg )

📄 modules     Nasal/modules.nas

modules._modules_available

modules._instances

Hash storing Module objects; keep this outside Module to avoid stack overflow

when using debug.dump

modules.Module

Class Module

to handle a re-loadable Nasal module at runtime

modules.Module.new ( id, ns = )

id: must be a string without special characters or spaces

ns: optional namespace name

node: optional property node for module management

modules.Module.getNode ( )

modules.Module.getNamespaceName ( )

modules.Module.getNamespace ( )

modules.Module.getFilePath ( )

modules.Module.get ( var_name )

return variable from module namespace

modules.Module.setDebug ( debug = 1 )

modules.Module.setFilePath ( path )

modules.Module.setMainFile ( filename )

modules.Module.setNamespace ( ns )

modules.Module.setlistenerRuntimeDefault ( i )

to change the default setlistener behaviour regarding 'runtime' argument

i: int 0..2 passed to setlistener as 4th parameter if not specified explicitly

modules.Module.load ( myargs... )

load module

if no arguments are given, the Module object will be passed to main()

modules.Module.unload ( )

unload a module and remove its tracked resources

modules.Module.reload ( )

modules.Module.printTrackedResources ( loglevel = LOG_INFO )

modules.Module._redirect_setlistener ( )

redirect setlistener() for module

modules.Module._redirect_maketimer ( )

redirect maketimer for module

modules.Module._redirect_settimer ( )

modules.isAvailable ( name )

modules._getInstance ( name )

modules.setDebug ( name, debug=1 )

modules.load ( name, ns= )

modules.commandModuleReload ( node )

}

_findModules();

📄 mp_broadcast     Nasal/mp_broadcast.nas

mp_broadcast.EventChannel

A message based information broadcast for the multiplayer network.

Copyright (C) 2008 - 2013 Anders Gidenstam (anders(at)gidenstam.org)

This file is licensed under the GPL license version 2 or later.

Event broadcast channel using a MP enabled string property.

Events from users in multiplayer.ignore are ignored.

EventChannel.new(mpp_path)

Create a new event broadcast channel. Any MP user with the same

primitive will receive all messages sent to the channel from the point

she/he joined (barring severe MP packet loss).

NOTE: Message delivery is not guaranteed.

mpp_path - MP property path : string

EventChannel.register(event_hash, handler)

Register a handler for the event identified by the hash event_hash.

event_hash - hash value for the event : a unique 4 character string

handler - a handler function for the event : func (sender, msg)

EventChannel.deregister(event_hash)

Deregister the handler for the event identified by the hash event_hash.

event_hash - hash value for the event : a unique 4 character string

EventChannel.send(event_hash, msg)

Sends the event event_hash with the message msg to the channel.

event_hash - hash value for the event : a unique 4 character string

msg - text string with Binary data encoded data : string

EventChannel.die()

Destroy this EventChannel instance.

mp_broadcast.EventChannel.new ( mpp_path )

mp_broadcast.EventChannel.register ( event_hash, handler )

mp_broadcast.EventChannel.deregister ( event_hash )

mp_broadcast.EventChannel.send ( event_hash, msg )

mp_broadcast.EventChannel._process ( n, msg )

Internals.

mp_broadcast.BroadcastChannel

Broadcast primitive using a MP enabled string property.

Broadcasts from users in multiplayer.ignore are ignored.

BroadcastChannel.new(mpp_path, process)

Create a new broadcast primitive. Any MP user with the same

primitive will receive all messages sent to the channel from the point

she/he joined (barring severe MP packet loss).

NOTE: Message delivery is not guaranteed.

mpp_path - MP property path : string

process - handler called when receiving a message : func (n, msg)

n is the base node of the senders property tree

(i.e. /ai/models/multiplay[x])

send_to_self - if 1 locally sent messages are : int {0,1}

delivered just like remote messages.

If 0 locally sent messages are not delivered

to the local receiver.

accept_predicate - function to select which : func (p)

multiplayers to listen to.

p is the multiplayer entry node.

The default is to accept any multiplayer.

on_disconnect - function to be called when an : func (p)

accepted MP user leaves.

enable_send - Set to 0 to disable sending.

BroadcastChannel.send(msg)

Sends the message msg to the channel.

msg - text string with Binary data encoded data : string

BroadcastChannel.die()

Destroy this BroadcastChannel instance.

mp_broadcast.BroadcastChannel.new ( mpp_path, process, send_to_self = 0, accept_predicate = nil, on_disconnect = nil, enable_send=1 )

mp_broadcast.BroadcastChannel.send ( msg )

mp_broadcast.BroadcastChannel.die ( )

mp_broadcast.BroadcastChannel.start ( )

print("BroadcastChannel[" ~ me.mpp_path ~ "] ... destroyed.");

mp_broadcast.BroadcastChannel.stop ( )

mp_broadcast.BroadcastChannel.set_state ( )

mp_broadcast.BroadcastChannel.update ( )

mp_broadcast.BroadcastChannel._loop_ ( id )

mp_broadcast.LamportClock

Lamport clock. Useful for creating a total order for events or messages.

The users' callsigns are used to break ties.

LamportClock.new()

Creates a new lamport clock for this user.

LamportClock.merge(sender, sender_timestamp)

Merges the timestamp from the sender with the local clock.

sender : base node of the senders property tree

sender_timestamp : the timestamp received from the sender.

Returns 1 if the local clock was advanced; 0 otherwise.

LamportClock.advance()

Advances the local clock one tick.

LamportClock.timestamp()

Returns an encoded 4 character long timestamp from the local clock.

mp_broadcast.LamportClock.new ( )

LamportClock.new()

Creates a new lamport clock for this user.

mp_broadcast.LamportClock.merge ( sender, sender_timestamp )

mp_broadcast.LamportClock.advance ( )

mp_broadcast.LamportClock.timestamp ( )

mp_broadcast.Binary

Some routines for encoding/decoding values into/from a string.

NOTE: MP is picky about what it sends in a string propery.

Encode 7 bits as a printable 8 bit character.

mp_broadcast.Binary.encodeInt ( int )

mp_broadcast.Binary.decodeInt ( str )

mp_broadcast.Binary.encodeByte ( int )

mp_broadcast.Binary.decodeByte ( str )

mp_broadcast.Binary.encodeInt28 ( int )

mp_broadcast.Binary.decodeInt28 ( str )

mp_broadcast.Binary.encodeDouble ( d )

mp_broadcast.Binary.decodeDouble ( str )

mp_broadcast.Binary.encodeCoord ( coord )

mp_broadcast.Binary.decodeCoord ( str )

Decodes an encoded geo.Coord object.

mp_broadcast.Binary.stringHash ( str )

mp_broadcast.Binary.readHash ( str )

Decodes an encoded geo.Coord object.

mp_broadcast.MessageChannel

Detects incomming messages encoded in a string property.

n - MP source : property node

process - action : func (v)

NOTE: This is a low level component.

The same object is seldom used for both sending and receiving.

mp_broadcast.MessageChannel.new ( n = nil, process = nil )

mp_broadcast.MessageChannel.update ( )

mp_broadcast.MessageChannel.send ( msg )

mp_broadcast.MessageChannel.new_message_handler ( handler, arg1 )

📄 multikey     Nasal/multikey.nas

multikey.start ( )

multikey.stop ( )

multikey.handle_key ( key )

multikey.Dialog

multikey.Dialog.new ( )

multikey.Dialog.del ( )

multikey.Dialog.update ( cmd, title, options )

multikey.help ( )

multikey.find_entry ( str, data, result )

multikey.init ( )

📄 multiplayer     Nasal/multiplayer.nas

multiplayer.lastmsg

Multiplayer

===========

1) Display chat messages from other aircraft to

the screen using screen.nas

2) Display a complete history of chat via dialog.

3) Allow chat messages to be written by the user.

multiplayer.ignore

multiplayer.check_messages ( loop_id )

multiplayer.echo_message ( callsign, msg )

multiplayer.timeout_handler ( )

multiplayer.chat_listener ( n )

multiplayer.my_kbd_listener ( event )

multiplayer.capture_kbd ( )

multiplayer.release_kbd ( )

multiplayer.compose_message ( msg = )

multiplayer.end_compose_message ( )

multiplayer.view_select ( callsign )

multiplayer.handle_key ( key )

multiplayer.dialog

multiplayer.dialog.init ( x = nil, y = nil )

multiplayer.dialog.create ( )

multiplayer.dialog.update_view ( )

multiplayer.dialog.update ( id )

multiplayer.dialog._redraw_ ( )

multiplayer.dialog.toggle_unit ( )

multiplayer.dialog.toggle_ignore ( callsign )

multiplayer.dialog.close ( )

multiplayer.dialog.del ( )

multiplayer.dialog.show ( )

multiplayer.dialog.toggle ( )

multiplayer.dialog.IDCode ( code )

multiplayer.model

Autonomous singleton class that monitors multiplayer aircraft,

maintains data in various structures, and raises signal

"/sim/signals/multiplayer-updated" whenever an aircraft

joined or left. Available data containers are:

multiplayer.model.data: hash, key := /ai/models/~ path

multiplayer.model.callsign hash, key := callsign

multiplayer.model.list vector, sorted alphabetically (ASCII, case insensitive)

All of them contain hash entries of this form:

{

callsign: "BiMaus",

path: "Aircraft/bo105/Models/bo105.xml", # relative file path

root: "/ai/models/multiplayer[4]", # root property

node: {...}, # root property as props.Node hash

model: "bo105", # model name (extracted from path)

sort: "bimaus", # callsign in lower case (for sorting)

}

multiplayer.model.init ( )

multiplayer.model.update ( n = nil )

multiplayer.model.remove_suffix ( s, x )

multiplayer.mp_mode_changed ( n )

📄 notifications     Nasal/notifications.nas

📄 orbital_target     Nasal/orbital_target.nas

orbital_target.orbitalTarget

simulation of a faraway orbital target (needs handover to spacecraft-specific

code for close range)

SPDX-License-Identifier: GPL-2.0-or-later

NOTE! This copyright does *not* cover user models that use these Nasal

services by normal function calls - this is merely considered normal use

of the code, and does *not* fall under the heading of "derived work."

Thorsten Renk 2016-2019

orbital_target.orbitalTarget.new ( altitude, inclination, node_longitude, anomaly )

orbital_target.orbitalTarget.set_anomaly ( anomaly )

orbital_target.orbitalTarget.set_delta_lon ( dl )

orbital_target.orbitalTarget.list ( )

orbital_target.orbitalTarget.evolve ( )

orbital_target.orbitalTarget.get_inertial_pos ( )

orbital_target.orbitalTarget.get_inertial_pos_at_time ( time )

orbital_target.orbitalTarget.get_inertial_speed ( )

orbital_target.orbitalTarget.get_inertial_speed_at_time ( time )

orbital_target.orbitalTarget.compute_inertial_pos ( anomaly_rad, nl_rad )

orbital_target.orbitalTarget.get_latlonalt ( )

orbital_target.orbitalTarget.start ( )

orbital_target.orbitalTarget.stop ( )

orbital_target.orbitalTarget.run ( )

orbital_target.orbitalTarget.test_suite ( )

📁 performance_monitor     Nasal/performance_monitor/

📄 monitor     Nasal/performance_monitor/monitor.nas

monitor.dialog

monitor.dialog.init ( x = nil, y = nil )

monitor.dialog.create ( )

monitor.dialog.update ( id )

monitor.dialog._redraw_ ( )

monitor.dialog.close ( )

monitor.dialog.del ( )

monitor.dialog.show ( )

monitor.dialog.toggle ( )

📄 prop_key_handler     Nasal/prop_key_handler.nas

prop_key_handler.listeners_children

prop_key_handler.start ( )

prop_key_handler.stop ( save_history = 0 )

prop_key_handler.handle_key ( key, shift )

prop_key_handler.parse_input ( expr )

prop_key_handler.build_completion ( in )

prop_key_handler.complete ( in, step )

print(debug.string([completion_pos, completion]), "\n");

prop_key_handler.set_history ( step )

prop_key_handler.set_color ( r, g, b )

prop_key_handler.print_prop ( n )

prop_key_handler.search ( n, s )

📄 props     Nasal/props.nas

props.Node

Node class definition. The class methods simply wrap the

low level extension functions which work on a "ghost" handle to a

SGPropertyNode object stored in the _g field.

Not all of the features of SGPropertyNode are supported. There is

no support for ties, obviously, as that wouldn't make much sense

from a Nasal context. The various get/set methods work only on the

local node, there is no equivalent of the "relative path" variants

available in C++; just use node.getNode(path).whatever() instead.

props.Node.getNode ( wrap )

props.Node.getParent ( wrap )

props.Node.getChild ( wrap )

props.Node.getChildren ( wrap )

props.Node.setChildren ( wrap )

props.Node.addChild ( wrap )

props.Node.addChildren ( wrap )

props.Node.removeChild ( wrap )

props.Node.removeChildren ( wrap )

props.Node.removeAllChildren ( wrap )

props.Node.getAliasTarget ( wrap )

props.Node.getName ( _getName )

props.Node.getIndex ( _getIndex )

props.Node.getType ( _getType )

props.Node.isNumeric ( _isNumeric )

props.Node.isInt ( _isInt )

props.Node.getAttribute ( _getAttribute )

props.Node.setAttribute ( _setAttribute )

props.Node.getValue ( _getValue )

props.Node.setValue ( _setValue )

props.Node.setValues ( _setValues )

props.Node.setIntValue ( _setIntValue )

props.Node.setBoolValue ( _setBoolValue )

props.Node.toggleBoolValue ( _toggleBoolValue )

props.Node.setDoubleValue ( _setDoubleValue )

props.Node.adjustValue ( _adjustValue )

adjustValue works like setDoubleValue but adds the argument to the

current value of the node

props.Node.unalias ( _unalias )

props.Node.alias ( n, chainListener = 0 )

props.Node.equals ( n )

props.Node.clearValue ( _alias )

props.Node.getPath ( )

props.Node.getBoolValue ( )

props.Node.getIntValue ( defaultValue = 0 )

props.Node.getDoubleValue ( defaultValue = 0.0 )

props.Node.remove ( )

props.Node.resolveAlias ( p = nil )

follow alias links to "real" node (e.g. where the data is stored)

optional argument: property node or prop path to resolve

if no argument is given, operate on current obj ("me")

props.Node.add ( n, max = nil, range = nil )

add to numeric property

n: value to add

optional:

max: if not nil, clamp value to max

range: if not nil, if exceeding max, wrap around

example: headingProp.add(1, 360, 360)

props.Node.sub ( n, min = nil, range = nil )

subtract from numeric property

n: value to subtract

optional:

min: if not nil, clamp value to min

range: if not nil, if reducing below min, wrap around

example: headingProp.sub(1, 0, 360)

props.Node.increment ( n = 1 )

add n to int property, do nothing, if prop type is not int

n shall be integer and defaults to 1

props.Node.decrement ( n = 1 )

sub n from int property, do nothing, if prop type is not int

n shall be integer and defaults to 1

props.Node.isValidPropName ( s )

checks if a string can be used as a prop name

returns 0 (invalid) or 1 (valid)

as string operations are expensive, use this only when necessary,

especially do not use in update loops

props.Node.makeValidPropName ( s )

replaces any invalid char by "_"

as string operations are expensive, use this only when necessary,

especially do not use in update loops

props.Node.new ( values = nil )

Static constructor for a Node object. Accepts a Nasal hash

expression to initialize the object a-la setValues().

props.Node.getValues ( )

Counter piece of setValues(). Returns a hash with all values

in the subtree. Nodes with same name are returned as vector,

where the original node indices are lost. The function should

only be used if all or almost all values are needed, and never

in performance-critical code paths. If it's called on a node

without children, then the result is equivalent to getValue().

props.Node.initNode ( path = nil, value = 0, type = nil, force = 0 )

Initializes property if it's still undefined. First argument

is a property name/path. It can also be nil or an empty string,

in which case the node itself gets initialized, rather than one

of its children. Second argument is the default value. The third,

optional argument is a property type (one of "STRING", "DOUBLE",

"INT", or "BOOL"). If it is omitted, then "DOUBLE" is used for

numbers, and STRING for everything else. Returns the property

as props.Node. The fourth optional argument enforces a type if

non-zero.

props.dump ( )

Useful debugging utility. Recursively dumps the full state of a

Node object to the console. Try binding "props.dump(props.globals)"

to a key for a fun hack.

props.copy ( src, dest, attr = 0 )

Recursively copy property branch from source Node to

destination Node. Doesn't copy aliases. Copies attributes

if optional third argument is set and non-zero.

props.wrap ( node )

Utility. Turns any ghosts it finds (either solo, or in an

array) into Node objects.

props.wrapNode ( node )

Utility. Returns a new object with its superclass/parent set to the

Node object and its _g (ghost) field set to the specified object.

Nasal's literal syntax can be pleasingly terse. I like that. :)

props.getNode ( return call )

Shortcut for props.globals.getNode().

props.setAll ( base, child, value )

Sets all indexed property children to a single value. arg[0]

specifies a property name (e.g. /controls/engines/engine), arg[1] a

path under each node of that name to set (e.g. "throttle"), arg[2]

is the value.

props.createNodeObjectsFromHash ( property_list, namespace = nil )

createNodeObjectsFromHash - create nasal node objects from hash

property_list: hash; where keys are variable names and values are

property paths

{ foo: "/some/prop/foo", bar: "/some/other/prop", }

namespace: optional; variables (objects) are created in this namespace

defaults to namespace of caller, e.g. after calling this

you can use foo.getValue() or bar.addChild()

props.nodeList ( )

Turns about anything into a list of props.Nodes, including ghosts,

path strings, vectors or hashes containing, as well as functions

returning any of the former and in arbitrary nesting. This is meant

to be used in functions whose main purpose is to handle collections

of properties.

props.compileCondition ( p )

Compiles a <condition> property branch according to the rules

set out in $FG_ROOT/Docs/README.conditions into a Condition object.

The 'test' method of the returend object can be used to evaluate

the condition.

The function returns nil on error.

props.condition ( p )

Evaluates a <condition> property branch according to the rules

set out in $FG_ROOT/Docs/README.conditions. Undefined conditions

and a nil argument are "true". The function dumps the condition

branch and returns nil on error.

props._cond_and ( p )

props._cond_or ( p )

props._cond ( p )

props._cond_cmp ( p, op )

props.runBinding ( node, module = nil )

Runs <binding> as described in $FG_ROOT/Docs/README.commands using

a given module by default, and returns 1 if fgcommand() succeeded,

or 0 otherwise. The module name won't override a <module> defined

in the binding.

props.swapValues ( left, right )

Swaps the value of two property nodes, like the property-swap command

props.Node._updateProperty ( _property )

props.Node.FromProperty ( _propname, _delta, _changed_method )

Monitor a property for a change more than the delta.

- type of the property is used to determine if a delta change

can be detected or whether to fire on every value change (strings)

props.Node.IsNumeric ( hashkey )

Determine if specifc property is a numeric (false usually means a string)

props.Node.FromPropertyHashList ( _keylist, _delta, _changed_method )

Monitor list of properties for a change more than the delta.

- type of the property is used to determine if a delta change

can be detected or whether to fire on every value change (strings)

props.Node.FromHashValue ( _key, _delta, _changed_method )

Monitor an individual hash value for a change more than the delta.

- when the hash value is a string use nil as the delta to indicate that

a simple value changed comparison is required.

- can also use nil to detect any change; e.g. in

props.Node.FromHashList ( _keylist, _delta, _changed_method )

Monitor a list of hash values for a change more than the delta.

- when the hash value is a string use nil as the delta to indicate that

a simple value changed comparison is required.

- can also use nil to detect any change; e.g. in

📄 redout     Nasal/redout.nas

redout.run ( )

📄 route_manager     Nasal/route_manager.nas

route_manager.RouteManagerDelegate

SPDX-License-Identifier: GPL-2.0-or-later

NOTE! This copyright does *not* cover user models that use these Nasal

services by normal function calls - this is merely considered normal use

of the code, and does *not* fall under the heading of "derived work."

Copyright (C) 2012-202 by James Turner

route_manager.nas - FlightPlan delegate(s) corresponding to the built-

in route-manager dialog and GPS. Intended to provide a sensible default behaviour,

but can be disabled by an aircraft-specific FMS / GPS system.

This delegate corresponds to functionality of the built-in route-manager dialog.

if you disable it, the built-in route-manager dialog may not work as expected.

Especially, this dialog is responsible for building departure, approach and

arrival waypoints corresponding to the requested SID/STAR/approach,

and replacing them when the inputs change (eg, user seelcted a different

destination or STAR while enroute)

You can disable the default GPS behaviour *without* touching this delegate : they are

kept seperate since this first one is less likely to need changes

route_manager.RouteManagerDelegate.new ( fp )

route_manager.RouteManagerDelegate.departureChanged ( )

route_manager.RouteManagerDelegate.arrivalChanged ( )

route_manager.RouteManagerDelegate.cleared ( )

route_manager.RouteManagerDelegate.endOfFlightPlan ( )

route_manager.DefaultGPSDeleagte

this delegate corresponds to the default behaviour of the built-in GPS.

depending on the real GPS/FMS you are modelling, you probably need to

replace this with your own.

To do that, just set /autopilot/route-manager/disable-fms to true, which

will block creation of this delegate.

Of course you are then responsible for many basic FMS functions, such as

route sequencing and activation

route_manager.DefaultGPSDeleagte.new ( fp )

route_manager.DefaultGPSDeleagte._landingCheckTimeout ( )

route_manager.DefaultGPSDeleagte._captureCurrentCourse ( )

route_manager.DefaultGPSDeleagte._selectOBSMode ( )

route_manager.DefaultGPSDeleagte.waypointsChanged ( )

route_manager.DefaultGPSDeleagte.activated ( )

route_manager.DefaultGPSDeleagte.deactivated ( )

route_manager.DefaultGPSDeleagte.endOfFlightPlan ( )

route_manager.DefaultGPSDeleagte.cleared ( )

route_manager.DefaultGPSDeleagte.sequence ( )

route_manager.DefaultGPSDeleagte.currentWaypointChanged ( )

route_manager.mod ( n, m )

=============================

Extra time-processing methods

=============================

route_manager.update_time_string ( )

📄 scenery     Nasal/scenery.nas

scenery.sharedDoor

An extended aircraft.door that transmits the door events over MP using the

scenery.events channel.

Use only for single instance objects (e.g. static scenery objects).

Note: Currently toggle() is the only shared event.

scenery.sharedDoor.new ( node, swingtime, pos = 0 )

scenery.sharedDoor.toggle ( )

scenery.sharedDoor.destroy ( )

scenery.sharedDoor._process ( sender, msg )

scenery.sharedDoor._loop ( id )

scenery._set_state ( )

📄 screen     Nasal/screen.nas

screen.sanitize ( s, newline = 0 )

on-screen displays

==============================================================================

convert string for output; replaces tabs by spaces, and skips

delimiters and the voice part in "{text|voice}" constructions

screen.window

screen.window

------------------------------------------------------------------------------

Class that manages a dialog with fixed number of lines, where you can push in

text at the bottom, which then (optionally) scrolls up after some time.

simple use:

var window = screen.window.new();

window.write("message in the middle of the screen");

advanced use:

var window = screen.window.new(nil, -100, 3, 10);

window.fg = [1, 1, 1, 1]; # choose white default color

window.align = "left";

window.write("first line");

window.write("second line (red)", 1, 0, 0);

arguments:

x ... x coordinate

y ... y coordinate

positive coords position relative to the left/lower corner,

negative coords from the right/upper corner, nil centers

maxlines ... max number of displayed lines; if more are pushed into the

screen, then the ones on top fall off

autoscroll ... seconds that each line should be shown; can be less if

a message falls off; if 0 then don't scroll at all

screen.window.new ( x = nil, y = nil, maxlines = 10, autoscroll = 10 )

screen.window.write ( msg, r = nil, g = nil, b = nil, a = nil )

screen.window.clear ( )

screen.window.show ( )

screen.window.close ( )

screen.window._write_ ( )

screen.window._timeout_ ( )

screen.window._redraw_ ( )

screen.display

screen.display

------------------------------------------------------------------------------

Class that manages a dialog, which displays an arbitrary number of properties

periodically updating the values. Property names are abbreviated to the

shortest possible unique part.

Example:

var dpy = screen.display.new(20, 10); # x/y coordinate

dpy.setcolor(1, 0, 1); # magenta (default: white)

dpy.setfont("SANS_12B",12); # see $FG_ROOT/gui/styles/*.xml

dpy.add("/position/latitude-deg", "/position/longitude-deg");

dpy.add(props.globals.getNode("/orientation").getChildren());

The add() method takes one or more property paths or props.Nodes, or a vector

containing those, or a hash with properties, or vectors with properties, etc.

Internal "public" parameters may be set directly:

dpy.interval = 0; # update every frame

dpy.format = "%.3g"; # max. 3 digits fractional part

dpy.tagformat = "%-12s"; # align prop names to 12 spaces

dpy.redraw(); # pick up new settings

The open() method should only be used to undo a close() call. In all other

cases this is done implicitly. redraw() is automatically called by an add(),

but can be used to let the dialog pick up new settings of internal variables.

Methods add(), setfont() and setcolor() can be appended to the new()

constructor (-> show big yellow frame rate counter in upper right corner):

screen.display.new(-15, -5, 0).setfont("TIMES_24").setcolor(1, 0.9, 0).add("/sim/frame-rate");

screen.display.new ( x, y, show_tags = 1 )

screen.display.setcolor ( r, g, b, a = 1 )

screen.display.setfont ( font, size=13 )

screen.display._create_ ( )

screen.display.open ( )

add() opens already, so call open() explicitly only after close()!

screen.display.close ( )

screen.display.toggle ( )

screen.display.reset ( )

screen.display.redraw ( )

screen.display.add ( p... )

screen.display.update ( )

screen.display._loop_ ( id )

screen.display.nameof ( n )

screen.listener

screen.search_name_in_msg ( msg, call )

screen.msg_mp ( n )

functions that make use of the window class (and don't belong anywhere else)

highlights messages with the multiplayer callsign in the text

screen.msg_repeat ( )

📄 screenshot     Nasal/screenshot.nas

screenshot.rotatescreen ( heading_deg, pitch_deg, roll_deg )

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2009 by Torsten Renk

Copyright (C) 2013 by penta

Copyright (C) 2022 by Erik Hofman

Based on:

https://forum.flightgear.org/viewtopic.php?f=6&t=6380&p=53863#p53681

https://forum.flightgear.org/viewtopic.php?f=19&t=7713&start=15#p180816

screenshot.takescreen ( heading_deg, pitch_deg )

screenshot.cube_screen_ticks ( )

screenshot.panorama_screen_ticks ( )

screenshot.make_cubemap ( )

screenshot.make_panorama ( )

📄 seaport     Nasal/seaport.nas

📁 std     Nasal/std/

📄 algorithm     Nasal/std/algorithm.nas

algorithm.all ( obj, key=nil )

SPDX-FileCopyrightText: (C) 2023 Frederic Croix <thefgfseagle@gmail.com>

SPDX-License-Identifier: GPL-2.0-or-later

algorithm.any ( obj, key=nil )

algorithm.map ( function, obj )

algorithm.filter ( function, obj )

📄 hash     Nasal/std/hash.nas

📄 string     Nasal/std/string.nas

string.String

string.String.new ( str )

public:

string.String.compare ( )

compare(s)

compare(pos, n, s)

@param s String to compare to

@param pos Position of first character used to compare

@param n Number of characters to compare

string.String.find_first_of ( s, pos = 0 )

returns index (zero based) of first occurrence of s

searching from pos

string.String.find ( s, pos = 0 )

string.String.find_first_not_of ( s, pos = 0 )

string.String.substr ( pos, len = nil )

string.String.starts_with ( s )

string.String.size ( )

string.String._eq ( pos, s )

private:

string.String._find ( first, last, s, eq )

string.string.new ( )

string.stoul ( str, base = 10 )

converts a string to an unsigned integer

📄 Vector     Nasal/std/Vector.nas

Vector.Vector

Vector.Vector.new ( vector=nil, name= )

Vector.Vector._callback ( )

Vector.Vector.addCallback ( f )

add callback for writes (insert() and append())

will be called as f(index, item), compare insert() below

Vector.Vector.getName ( )

Vector.Vector.size ( )

Vector.Vector.clear ( )

Vector.Vector.append ( item )

Vector.Vector.extend ( other_vector )

Vector.Vector.insert ( index, item )

Vector.Vector.pop ( index=nil )

Vector.Vector.index ( item )

Vector.Vector.contains ( item )

Vector.Vector.remove ( item )

📄 std     Nasal/std.nas

std.min ( a, b )

std.max ( a, b )

📄 string     Nasal/string.nas

string.iscntrl ( c )

string.isascii ( c )

string.isupper ( c )

string.islower ( c )

string.isdigit ( c )

string.isblank ( c )

string.ispunct ( c )

string.isxdigit ( c )

string.isspace ( c )

string.isalpha ( c )

string.isalnum ( c )

string.isgraph ( c )

string.isprint ( c )

string.toupper ( c )

string.tolower ( c )

string.isxspace ( c )

string.trim ( s, lr = 0, istrim = nil )

trim spaces at the left (lr < 0), at the right (lr > 0), or both (lr = 0)

An optional function argument defines which characters should be trimmed:

string.trim(a); # trim spaces

string.trim(a, 1, string.isdigit); # trim digits at the right

string.trim(a, 0, func(c) c == `\\` or c == `/`); # trim slashes/backslashes

string.truncateAt ( src, match )

truncate at the first match

string.truncateAt("file.xml", ".xml"); # "file.xml" -> "file"

string.truncateAt("file.xml", ".txt"); # "file.xml" -> "file.xml"

string.lc ( str )

return string converted to lower case letters

string.uc ( str )

return string converted to upper case letters

string.icmp ( a, b )

case insensitive string compare and match functions

(not very efficient -- converting the array to be sorted

first is faster)

string.imatch ( a, b )

string.compileTemplate ( template, type=nil )

Get a function out of a string template for fast insertion of template

parameters. This allows to use the same templates as with most available tile

mapping engines (eg. Leaflet, Polymaps). Return a callable function object on

success, and nil if parsing the templated fails. See string._template_getargs

for more on calling a compile object.

Example (Build MapQuest tile url):

var makeUrl = string.compileTemplate(

"http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg"

);

print( makeUrl({x: 5, y: 4, z: 3}) );

Output:

http://otile1.mqcdn.com/tiles/1.0.0/map/3/5/4.jpg

string._template_getargs ( )

Private function used by string.naCompileTemplate. Expands any __ENV parameter

into the locals of the caller. This allows both named arguments and manual hash

arguments via __ENV.

Examples using (format = func(__ENV) {string._template_getargs()}):

Pass arguments as hash:

format({a: 1, "b ":2});

Or:

format(__ENV:{a: 1, "b ":2});

Pass arguments as named:

format(a: 1, "b ":2);

Pass arguments as both named and hash, using

__ENV to specify the latter:

format(a: 1, __ENV:{"b ": 2});

string.Scan

Simple scanf function. Takes an input string, a pattern, and a

vector. It returns 0 if the format didn't match, and appends

all found elements to the given vector. Return values:

-1 string matched format ending with % (i.e. more chars than format cared about)

0 string didn't match format

1 string matched, but would still match if the right chars were added

2 string matched, and would not if any character would be added

var r = string.scanf("comm3freq123.456", "comm%ufreq%f", var result = []);

The result vector will be set to [3, 123.456].

string.Scan.new ( s )

string.Scan.getc ( )

string.Scan.ungetc ( )

string.Scan.rest ( )

string.scanf ( test, format, result )

string.setcolors ( enabled )

ANSI colors (see $ man console_codes)

string.color ( color, s, enabled=nil )

string.squeeze ( s, length )

shorten sting s to length by replacing characters in the middle by '...'

📄 tanker     Nasal/tanker.nas

tanker.oclock ( bearing )

--------------------------------------------------------------------------------------------------

tanker.tanker_msg ( setprop )

tanker.pilot_msg ( setprop )

tanker.atc_msg ( setprop )

tanker.skip_cloud_layer ( alt )

tanker.identity

tanker.identity.get ( )

tanker.Tanker

tanker.Tanker.new ( aiid, callsign, tacan, type, model, kias, maxfuel, pattern, contacts, heading, coord )

tanker.Tanker.del ( )

tanker.Tanker.update ( )

tanker.Tanker.identify ( )

tanker.Tanker.report ( )

tanker.create_tanker ( tanker_node, course )

Factory methods

Create a tanker based on a given /sim/ai/tankers/tanker property node

tanker.request_new ( tanker_node=nil )

Request a new tanker

tanker.request ( tanker_node=nil )

tanker.request_random ( tanker_node=nil )

tanker.report ( )

tanker.reinit ( )

📁 towing     Nasal/towing/

📄 hitch     Nasal/towing/hitch.nas

hitch.check_or_create ( name, value, type )

hitch.load_prop ( property, cnfg_p )

hitch.config

hitch.write_config ( )

hitch.aircraft_settings

hitch.check_aircraft_tow_settings ( )

hitch.aerotow_hash

yasim properties for aerotow (should be already defined for yasim aircraft but not for JSBSim aircraft

hitch.winch_hash

yasim properties for winch (should already be defined for yasim aircraft but not for JSBSim aircraft

hitch.write_message ( type, message )

hitch.set_force_apply ( hash, hitchname )

hitch.loss_of_power ( )

hitch.towing ( )

######################################################################################################################

main function

######################################################################################################################

hitch.findBestAIObject ( )

######################################################################################################################

find best AI object

######################################################################################################################

hitch.aerotow ( open )

######################################################################################################################

aerotow function

######################################################################################################################

hitch.winch ( open )

######################################################################################################################

winch function

######################################################################################################################

hitch.createTowrope ( device )

######################################################################################################################

create towrope

######################################################################################################################

hitch.getFreeModelID ( )

######################################################################################################################

get the next free id of "models/model" members

######################################################################################################################

hitch.closeHitch ( )

######################################################################################################################

close aerotow hitch

######################################################################################################################

hitch.releaseHitch ( device )

######################################################################################################################

release hitch

######################################################################################################################

hitch.removeTowrope ( device )

######################################################################################################################

remove/delete towrope

######################################################################################################################

hitch.pull_in_rope ( )

hitch.setAIObjectDefaults ( )

######################################################################################################################

set some AI-object default values

######################################################################################################################

hitch.setWinchPositionAuto ( )

######################################################################################################################

place winch model

######################################################################################################################

hitch.runWinch ( )

######################################################################################################################

clutch / un-clutch winch

######################################################################################################################

hitch.releaseWinch ( )

######################################################################################################################

release winch

######################################################################################################################

hitch.assignHitchLocations ( device )

######################################################################################################################

assignHitchLocations

######################################################################################################################

hitch.PointRotate3D ( x, y, z, xr, yr, zr, alpha_deg, beta_deg, gamma_deg )

######################################################################################################################

point transformation

######################################################################################################################

hitch.auto_winch_driver_init ( )

hitch.auto_winch_driver ( )

hitch.winch_faster ( d = 0.1 )

hitch.winch_slower ( d = 0.1 )

📄 track_target     Nasal/track_target.nas

track_target.TrackInit ( )

Initialize target tracking

track_target.TrackUpdate ( loop_id )

If enabled, update our AP target values based on the target range,

bearing, and speed

📁 tutorial     Nasal/tutorial/

📄 tutorial     Nasal/tutorial/tutorial.nas

tutorial.startTutorial ( )

tutorial.stopTutorial ( )

tutorial.step_tutorial ( id )

- Gets the current step node from the tutorial

- If this is the first time the step is entered, it displays the instruction message

- Otherwise, it

- Checks if the exit conditions have been met. If so, it increments the step counter.

- Checks for any error conditions, in which case it displays a message to the screen and

increments an error counter

- Otherwise display the instructions for the step.

tutorial.do_group ( node, default_msg = nil )

Do the stuff that's shared by <init>, <step>, <error>, <exit>, and <abort>.

<end> doesn't use it.

tutorial.read_int ( node, child, default )

tutorial.set_properties ( node )

scan all <set> blocks and set their <property> to <value> or

the value of a property that <property n="1"> points to

<set>

<property>/foo/bar</property>

<value>woof</value>

</set>

tutorial.set_targets ( node )

For each <target><*><longitude-deg|latitude-deg> calculate and update

/sim/tutorials/targets/*/...

heading-deg ... absolute heading to target (0 -> North)

direction-deg ... relative angle to target (0 -> ahead, 90 -> to the right)

distance-m ... distance in meters

eta-min ... estimated time of arrival (assuming aircraft flies in

in current speed towards target)

tutorial.set_models ( node )

tutorial.remove_models ( )

tutorial.set_view ( node = nil )

tutorial.set_marker ( node = nil )

tutorial.is_running ( which = nil )

Set and return running state. Disable/enable stop menu.

tutorial.say_message ( node, default = nil )

tutorial.shuffle ( vec )

tutorial.run_nasal ( node )

tutorial.say ( what, who = )

tutorial.init_nasal ( )

Set up namespace "__tutorial" for embedded Nasal.

tutorial.dialog ( )

tutorial.load ( file, index = 0 )

Tutorial loader for development purposes.

Usage: tutorial.load("Aircraft/bo105/Tutorials/foo.xml", 1)

Loads this file to tutorial slot #1 (/sim/tutorials/tutorial[1])

📄 video     Nasal/video.nas

video.save ( )

print("A");

📄 view     Nasal/view.nas

view.str ( x, prefix= )

view.nas

Nasal code for implementing view-specific functionality.

ATTENTION:

/sim/current-view/view-number is in the range 0..viewCount, it is NOT

the index used in aircraft XML files (e.g. <view n="100">).

For the latter, use /sim/current-view/view-number-raw.

For debugging. Returns string containing description of <x>.

view.indices

view.setView ( n )

view.setViewByIndex ( i )

activate view by index number used in XML definition (e.g. >100)

view.hasmember ( class, member )

view.calcMul ( )

view.increase ( )

Handler. Increase FOV by one step

view.decrease ( )

Handler. Decrease FOV by one step

view.resetFOV ( )

Handler. Reset FOV to default.

view.resetViewPos ( )

view.resetViewDir ( )

view.stepView ( step, force = 0 )

Handler. Step to the next (force=1) or next enabled view.

view.indexof ( name )

Get view index by name.

view.panViewDir ( step )

Pans the view horizontally. The argument specifies a relative rate

(or number of "steps" -- same thing) to the standard rate.

view.panViewPitch ( step )

Pans the view vertically. The argument specifies a relative rate

(or number of "steps" -- same thing) to the standard rate.

view.resetView ( )

Reset view to default using current view manager (see default_handler).

view.default_handler

Default view handler used by view.manager.

view.default_handler.reset ( )

view.set_default ( from, path, to )

If <from>/<path> exists and <to>/<path> doesn't, copy the former to the

latter.

view.manager

View manager. Administrates optional Nasal view handlers.

Usage: view.manager.register(<view-id>, <view-handler>);

view-id: the view's name (e.g. "Chase View") or index number

view-handler: a hash with any combination of the functions listed in the

following example, or none at all. Only define the interface

functions that you really need! The hash may contain local

variables and other, non-interface functions.

Example:

var some_view_handler = {

init : func {}, # called only once at startup

start : func {}, # called when view is switched to our view

stop : func {}, # called when view is switched away from our view

reset : func {}, # called with view.resetView()

update : func { 0 }, # called iteratively if defined. Must return

}; # interval in seconds until next invocation

# Don't define it if you don't need it!

view.manager.register("Some View", some_view_handler);

view.manager.init ( )

view.manager.register ( which, handler = nil )

view.manager.set_view ( which = nil )

view.manager.reset ( )

view.manager._loop_ ( id )

view.manager.multiplayer_callback ( data )

view.fly_by_view_handler

view.fly_by_view_handler.init ( )

view.fly_by_view_handler.start ( )

view.fly_by_view_handler._set_multiplayer_root ( )

Sets me.root to node with path given by the value of property

/sim/view[6]/config/root (which will be /ai/models/multiplayer[N]

where N is the index of the multiplayer aircraft]. Note that this

node sometimes doesn't yet exist, in which case we return with

me.root = nil.

view.fly_by_view_handler.aircraft_position ( )

view.fly_by_view_handler.reset ( )

view.fly_by_view_handler.setpos ( force = 0 )

view.fly_by_view_handler.update ( )

view.model_view_handler_class

Helper for views that can show multiplayer aircaft as well as the user's

aircraft. Used by <manager> above.

view.model_view_handler_class.new ( )

view.model_view_handler_class.start ( )

view.model_view_handler_class.stop ( )

view.model_view_handler_class.reset ( )

view.model_view_handler_class.find ( callsign )

view.model_view_handler_class.select ( which, by_callsign=0 )

view.model_view_handler_class.next ( step )

view.model_view_handler_class._update_ ( )

view.model_view_handler_class.setup ( data )

view.pilot_view_limiter

Note that gui/dialogs/model-view.xml expects to be able to call

view.model_view_handler.next() etc.

view.pilot_view_limiter.new ( )

view.pilot_view_limiter.init ( )

view.pilot_view_limiter.start ( )

view.pilot_view_limiter.update ( )

view.panViewDir ( step )

view.normdeg ( a )

------------------------------------------------------------------------------

Saves/restores/moves the view point (position, orientation, field-of-view).

Moves are interpolated with sinusoidal characteristic. There's only one

instance of this class, available as "view.point".

Usage:

view.point.save(); ... save current view and return reference to

saved values in the form of a props.Node

view.point.restore(); ... restore saved view parameters

view.point.move(<prop> [, <time>]);

... set view parameters from a props.Node with

optional move time in seconds. <prop> may be

nil, in which case nothing happens.

A parameter set as expected by set() and returned by save() is a props.Node

object containing any (or none) of these children:

<heading-offset-deg>

<pitch-offset-deg>

<roll-offset-deg>

<x-offset-m>

<y-offset-m>

<z-offset-m>

<field-of-view>

<move-time-sec>

The <move-time> isn't really a property of the view, but is available

for convenience. The time argument in the move() method overrides it.

Normalize angle to -180 <= angle < 180

view.ViewAxis

Manages one translation/rotation axis. (For simplicity reasons the

field-of-view parameter is also managed by this class.)

view.ViewAxis.new ( prop )

view.ViewAxis.reset ( )

view.ViewAxis.target ( v )

view.ViewAxis.move ( blend )

view.point

view.point: handles smooth view movements

view.point.init ( )

view.point.save ( )

view.point.restore ( )

view.point.move ( prop, time = nil )

view.point._loop_ ( id, time )

view.screenWidthCompens

view.ScreenWidthCompens: optional FOV compensation for wider screens.

It keeps an equivalent of 55° FOV on a 4:3 zone centered on the screen

whichever is the screen width/height ratio. Works only if width >= height.

view.screenWidthCompens.getStatus ( me.statusNode.getValue )

view.screenWidthCompens.setStatus ( state )

view.screenWidthCompens.getDimensions ( )

view.screenWidthCompens.calcNewFov ( fov=55, oldW=nil, oldH=nil, w=nil, h=nil )

view.screenWidthCompens.init ( )

view.screenWidthCompens.toggle ( )

view.screenWidthCompens.update ( opt=nil, force=0 )

📄 volcano     Nasal/volcano.nas

volcano.volcano

volcano management routines

Thorsten Renk 2017

volcano.volcano.new ( name, lat, lon )

volcano.volcano_manager

volcano.volcano_manager.init ( )

volcano.volcano_manager.start ( )

volcano.volcano_manager.init_state ( )

volcano.volcano_manager.set_state ( )

volcano.volcano_manager.run ( index )

volcano.set_kilauea ( )

setter functions for volcano sceneries

volcano.set_stromboli ( )

volcano.set_etna ( )

volcano.set_beerenberg ( )

volcano.set_eyjafjallajokull ( )

volcano.set_katla ( )

volcano.set_surtsey ( )

📄 weather_scenario     Nasal/weather_scenario.nas

weather_scenario.initialize_weather_scenario ( )

📄 windsock     Nasal/windsock.nas

windsock.windsock ( )