This is an old revision of the document!
Table of Contents
Events Inside The TMD
A very powerful tool in Aerofly FS 2 aircraft programming in the TMD file are events. Though not needed for any conventional aircraft with basic on/off switches, actuators and instruments, the events open the door for more complex avionics. Be it a multi-function display controller, where each button serves a different purpose on each page or a detecting changes in the system, e.g. the disconnection of the autopilot.
Events are usually only triggered every once in a while and are certainly not intended for constant state logic. Inherently the event logic is state-less. Events cannot replace an underlying logic circuit shouldn't be allowed to continue to run for more than one execution. Their purpose is to execute a one time function, reset a timer to zero, play a sound once, change a digital state, etc.
None of the event objects have anOutput
.
So what are events then?
An event in the tmd is a function execution, a function that has one input value that is passed on from one element to the next and that returns nothing. The function that is executed and weather or not additional events can be fired depend on the specific element. Such a function is typically called Trigger
, Set
, Step
or Reset
.
void Trigger( double a ) { // do sth. }
How are they triggered
The events are triggered by one of three means:
- input_event - A button press triggers an event.
- event_edge - A system change is detected, e.g. in the q400 the system senses that the power levers are advanced for takeoff and then sets the spoiler switch to flight mode automatically. This is also used for many lever sounds.
- Events can trigger other events
DEV0
The do-nothing placeholder is triggered with DEV0.Trigger
whenever no action is desired.
<[event_sound][DEV0][] >
event_edge
The event_edge object constantly monitors the input. When the input passes through the Threshold
on either the rising or falling edge it triggers all of the functions listed in the Events
list.
Rising
- when set to true: The input is increasing and passes from below the threshold above the threshold then theEvents
are fired.Falling
- when set to true: The input is moving from above the threshold below it then theEvents
are fired.
<[event_edge][State_Changed][] <[string8][Input][State.Output]> <[string8][Events][ DEV0.Trigger ]> <[bool][Rising][true]> <[bool][Falling][true]> <[float64][Value][0.0]> <[float64][Threshold][0.5]> >
input_event
The input_event receives messages from the controls or key and button inputs just like any other TMD input.
Depending on the qualifier of the message (event
, step
,toggle
) either the Events
, StepEvents
or ToggleEvents
list of functions is executed.
Adding the line <[float64][InputValue][1.0]>
can filter the incoming messages by exact value.
<[input_event][Button_Pressed][] <[string8][Input][Controls.Button]> <[string8][Events][ DEV0.Trigger ]> > <[input_event][Knob_Stepped][] <[string8][Input][Controls.Button]> <[string8][StepEvents][ DEV0.Trigger ]> > <[input_event][Button_Toggled][] <[string8][Input][Controls.Button]> <[string8][ToggleEvents][ DEV0.Trigger ]> > <[input_event][Button_Clicked][] <[string8][Input][Controls.Button]> <[string8][Events] [ DEV0.Trigger ]> <[string8][StepEvents] [ DEV0.Trigger ]> <[string8][ToggleEvents][ DEV0.Trigger ]> >