User Tools

Site Tools


aircraft:tmd:events

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
aircraft:tmd:events [2019/07/12 22:10] jhaircraft:tmd:events [2019/07/20 15:30] jh
Line 26: Line 26:
   * Events can trigger other events   * Events can trigger other events
  
-===== Events =====+===== Event Generation =====
  
-==== DEV0 ==== +==== input_event ====
- +
-The do-nothing placeholder is triggered with ''DEV0.Trigger'' whenever no action is desired. +
- +
-<code>            <[event_sound][DEV0][] +
-            > +
-</code> +
- +
-==== input_event====+
  
 The input_event receives messages from the [[aircraft:controls|controls]] or key and button inputs just like any other [[aircraft:tmd:inputs|TMD input]]. The input_event receives messages from the [[aircraft:controls|controls]] or key and button inputs just like any other [[aircraft:tmd:inputs|TMD input]].
Line 80: Line 72:
                 <[float64][Value][0.0]>                 <[float64][Value][0.0]>
                 <[float64][Threshold][0.5]>                 <[float64][Threshold][0.5]>
 +            >
 +</code>
 +
 +===== Event Value Manipulation =====
 +
 +When a button, key command or joystick button are pressed they all generate messages and these messages carry a certain value. Most of them are 1.0, some are -1.0 (e.g. when rotated in the other direction) but other values can also exist. In the [[aircraft:controls]] the value of the message can be set as needed.
 +
 +When the message is received by an ''input_event'' the message value is passed on to any subsequently triggered events. And the event objects that are triggered in turn hand the value over to the next objects. The only exceptions are the event_linear, which scales the value and adds an offset, and the event_value which overwrites the value with its' own input.
 +
 +The value is therefor carried from one event object to the next most of the time and we still have access to the original value way down the event chain.
 +
 +> When a ''Variable.Set'' function is called the variable then uses the value carried by the event call.
 +
 +==== event_linear ====
 +
 +<code>            <[event_linear][StepSomething][]
 +                <[string8][Events][ DEV0.Trigger ]>
 +                <[float64][Scaling][1.0]>
 +                <[float64][Offset][0.0]>
 +            >
 +</code>
 +
 +==== event_value ====
 +
 +<code>            <[event_value][SetSomethingToSomeValue][]
 +                <[string8][Input][SomeValue.Output]>
 +                <[string8][Events][ Something.Set ]>
 +            >
 +</code>
 +
 +===== Basic Events =====
 +
 +==== DEV0 ====
 +
 +The do-nothing placeholder is triggered with ''DEV0.Trigger'' whenever no action is desired.
 +
 +<code>            <[event_sound][DEV0][]
 +            >
 +</code>
 +
 +==== event_sound ====
 +
 +Normally an event_sound object is used to generate a switch or button sound. Using the trigger function (in this case SwitchSound.Trigger) causes the event_sound to briefly output 1.0 to the sound section of the [[aircraft:tmd|TMD]]. Then a short sound can be played.
 +
 +<code>            <[event_sound][SwitchSound][]
             >             >
 </code> </code>
Line 85: Line 122:
 ==== event_pulse ==== ==== event_pulse ====
  
-When the pulse is triggered (function ''Pulse.Trigger'' is called) the pulse outputs (''Output'') 1.0 for the given ''Duration'' in seconds. Re-triggering it just resets the timer back to the duration. When the time has run out the ''Output'' drops back to 0.0.+When the pulse is triggered (function ''Pulse.Trigger'' is called) the pulse outputs (''Output'') 1.0 for the given ''Duration'' in seconds. Re-triggering it just resets the timer back to the duration value. When the time has run out the ''Output'' drops back to 0.0.
  
 <code>            <[event_pulse][Pulse][] <code>            <[event_pulse][Pulse][]
Line 91: Line 128:
             >             >
 </code> </code>
 +
 +==== Variables ====
 +
 +The variable class isn't an event class as such, it cannot trigger any further events. But events can manipulate the value of a ''variable''.
 +
 +Available functions are:
 +  * Variable.Set - Changes the value of the variable to the value carried by the event (Value = event_value)
 +  * Variable.Step - The value is increased or decreased by the value carried by the event (Value += event_value)
 +  * Variable.Reset - The value is set to 0.0 (Value = 0.0)
 +
 +<code>            <[variable][Variable][]
 +                <[string8][Value][0.0]>
 +            >
 +</code>
 +
 +The value of the variable is available to other tmd objects as ''Variable.Output'' and behaves similar to a constant or input_discrete value.
 +
 +===== Event Value Checks =====
 +
 +Depending on the value carried by the event decisions can be made.
  
 ==== event_sequence ==== ==== event_sequence ====
  
-==== event_range ====+Creates a chain of events that are executed one after another. This allows objects like the autopilot, that only trigger a single ''Event'' and not multiple ''Events'' (note the s at the end!). It also allows events to be reused or multiple things to happen after a decision is made with an ''event_select'' or ''event_demultiplexer''.
  
-==== event_select ====+<code>            <[event_sequence][Sequence][] 
 +                <[string8][Events][ DEV0.Trigger DEV0.Trigger ]> 
 +            > 
 +</code>
  
 ==== event_demultiplexer ==== ==== event_demultiplexer ====
  
-==== event_linear ====+<code>            <[event_demultiplexer][TriggerIf][] 
 +                <[string8][InputSelect][Condition.Output]> 
 +                <[string8][Events][ DEV0.Trigger DoSomething.Trigger ]> 
 +            > 
 +</code>
  
-==== event_value ====+==== event_select ==== 
 + 
 +When triggered the event_select checks the value of the event call and casts it into an integer. Depending on the integer it selects one of the events from the ''Events'' list based on the calculated index. The list starts at index 0 and increases. 
 + 
 +This is useful to have when there is a row of buttons, e.g. like a bezel select on an multifunction display and there is only one message name to be used. With an input_event you can receive that message and then call this event_select to do something specific based on the value of the original button message. 
 + 
 +> Similar logic can be achieved with the ''InputValue'' property of the ''input_event'' class. 
 + 
 +> When you are not interested in the value carried with the event then use the ''event_demultiplexer'' class. 
 + 
 +<code>            <[event_select][EventValueSelect][] 
 +                <[string8][Events][ DoSomethingIfValueIs0.Trigger 
 +                                    DoSomethingIfValueIs1.Trigger 
 +                                    DoSomethingIfValueIs2.Trigger ]> 
 +            > 
 +</code> 
 + 
 +==== event_range ==== 
 + 
 +When the event range is triggered it checks the value of the event call against the range and triggers either the list of events when inside or outside of the range. E.g. a button could generate a message with value 1.0 which is received by an input_event and then the input_event triggers this event_range. Depending on what the button value was the event_range does one thing within a set range but does something different when the value is outside that range. 
 + 
 +<code>            <[event_range][StepWhenValueInRange][] 
 +                <[tmvector2d][Range][ -5.0 5.0 ]> 
 +                <[string8][EventsIn][ StepSomething.Trigger ]> 
 +                <[string8][EventsOut][ DEV0.Trigger ]> 
 +            > 
 +</code> 
 + 
 +===== Other Event Objects =====
  
-==== event_sound ==== 
  
 ==== event_timeout ==== ==== event_timeout ====
 +
 +<code>            <[event_timeout][EventDelay][]
 +                <[float64][Duration][1.0]>
 +                <[string8][Events][ DEV0.Trigger ]>
 +            >
 +</code>
  
 ==== event_repeat ==== ==== event_repeat ====
 +
 +<code>            <[event_repeat][DirectionalGyroCorrectionSwitchFunction][]
 +                <[string8][Input]      [DirectionalGyroCorrectionSwitch.Output]>
 +                <[string8][InputEnable][DirectionalGyroSlaveModeSwitch.Output]>
 +                <[string8][EventsUp]   [ DirectionalGyroCorrection.Step ]>
 +                <[string8][EventsDown] [ DirectionalGyroCorrection.Step ]>
 +                <[float64][Scaling][0.1]>
 +            >
 +</code>
  
 ==== event_swap ==== ==== event_swap ====
  
-==== event_crash ====+<code>            <[event_swap][NAV1ManualFrequencySwap][] 
 +                <[string8][Input0][NAV1ManualFrequency.Output]> 
 +                <[string8][Input1][NAV1FrequencyStandby.Output]> 
 +                <[string8][Event0][NAV1ManualFrequency.Set]> 
 +                <[string8][Event1][NAV1FrequencyStandby.Set]> 
 +            > 
 +</code>
  
aircraft/tmd/events.txt · Last modified: 2022/07/19 21:07 by jh