Current SPAD.neXt Release: 0.9.12.123

This forum has closed. Please join our Discord Community.

SPAD.neXt online services are no longer available for SPAD.neXt Versions < 0.9.11.5

Event Condition Evaluation (QUICK POLL)

Discussions about new feature ideas.
To request a new feature please open a ticket
Locked

How should Event Conditions be evaluated

Poll ended at 12 May 2017, 01:03

Always use the most current value (Current behavior)
1
8%
Use the value of when the event was triggered
1
8%
Make it an option
10
77%
I don't care
1
8%
 
Total votes: 13

User avatar
c0nnex
Site Admin
Posts: 5469
Joined: 10 Mar 2015, 21:52
Location: Munich, Germany
Contact:
Status: Offline

Event Condition Evaluation (QUICK POLL)

Post by c0nnex » 10 May 2017, 01:03

Today I was starting to program a profile for the TFDI 717 and stumbled across an "unexpected" behavior.
Let me know what you think about it.

What i wanted to do:
On Master Battery ON execute a sequence of commands. No problem normally, as i can put the sequence just into one "Switched ON" event.
However, the TFDI only supports toggle commands, so for each command (eg. GPU connect, EXT Power ) i need to check if it already switched on.
So I programmed 3 "Switched ON" events with according conditions:

Code: Select all

1) If Battery is off turn it on
2) if battery is off and gpu is disconnected , wait one sec and connect gpu
3) if battery is off and ext power is off , wait two sec and turn ext power on
(Delay to mimic manual switching by pilot)

While testing, the 3 events where sometimes executed and sometimes only 2 or even 1.
So i was debugging why this is the case.
It turned out , that SPAD.neXt behaves as coded:

Code: Select all

a) Turn Master Battery-Switch to ON -> all 3 events are "raised" in parallel
b) first event executes , set battery to on
c) second event checks it's conditions and  executes if it matches
d) third event checks it's conditions and executes  if it matches
Now, depending on the load of FSX and SPAD.neXt , sometimes the "Battery = ON" will arrive at SPAD.neXt before all 3 events are done, so eventually when SPAD.neXt comes to execute the 3rd event, the condition will no longer match as the battery is on now.
I could drop the "if battery is off" part of the conditions, but i don't want to send a "connect gpu" command, when i e.g. turn on the battery switch while i am not on the ground or battery was not turned off before. (e.g. loading a midflight )

Long story short:

Currently Conditions are checked with the actual values of data that are valid at that moment in time when it is executed. (Means it might happen a value has changed before the event is executed and the event therefor not executing anymore)

Should that be changed to:
Conditions are checked when the event raises with the values that are current in that moment of time. (Means events might check values that are not current anymore, if they are delayed for any reason)

Note this is a QUICK POLL for 2 days only.
Comments welcome.

lesoreilly
Captain
Posts: 272
Joined: 31 Jul 2015, 01:07
Status: Offline

Re: Event Condition Evaluation (QUICK POLL)

Post by lesoreilly » 10 May 2017, 03:00

I care :) but think that you might want it to be an option depending on what your working with and attempting to do.

krono
First Officer
Posts: 94
Joined: 13 Sep 2015, 04:55
Status: Offline

Re: Event Condition Evaluation (QUICK POLL)

Post by krono » 10 May 2017, 08:30

I would have to agree with making it an option to suite your programing, and yep I care

Ken

aeronauta
Betatester
Posts: 556
Joined: 13 Mar 2015, 03:06
Location: Melbourne Australia YMMB
Status: Offline

Re: Event Condition Evaluation (QUICK POLL)

Post by aeronauta » 10 May 2017, 08:52

I also care but an option makes it for more choice.
Jorge

User avatar
c0nnex
Site Admin
Posts: 5469
Joined: 10 Mar 2015, 21:52
Location: Munich, Germany
Contact:
Status: Offline

Re: Event Condition Evaluation (QUICK POLL)

Post by c0nnex » 10 May 2017, 13:18

OK added that as poll-option and restarted the voting.

jschr
Passenger
Posts: 1
Joined: 17 Jan 2017, 13:23
Status: Offline

Re: Event Condition Evaluation (QUICK POLL)

Post by jschr » 10 May 2017, 13:54

Hi Ullrich, due to the situation that I can´t look into my profiles and how I set my conditions and events at the moment because of this "This is a limited Beta Version and requires a..." -failure it´s hard for me to give a valid answer.
As soon as I got a solution to start Spad.neXt again I will come back with an answer.

Cheers,
Juergen

User avatar
Oz Flyer
Betatester
Posts: 741
Joined: 23 Sep 2015, 10:10
Location: YMMB, Melbourne, Australia
Contact:
Status: Offline

Re: Event Condition Evaluation (QUICK POLL)

Post by Oz Flyer » 10 May 2017, 15:11

I think it would be best as an option.
If not then use the actual values as each event in the sequence is run.
That way if event 2 needs to use a value from event 1 it will have the updated value.
Having said that there would need to be a way to have a time delay so the the data from event 1 is fully updated.
David
OZ Flyer
Near YMMB
40+ year of Flight Siming.
Sim: subLOGIC/Microsoft Flight Sim's/DTG FSX, Microsoft Flight, DTG Filght School/FSW/Train Sim/TSW, ETS2 & ATS.
Hardware: Logitech, Saitek, Arduino 2560's & Leo's, BBI-32, PAC LED.

User avatar
c0nnex
Site Admin
Posts: 5469
Joined: 10 Mar 2015, 21:52
Location: Munich, Germany
Contact:
Status: Offline

Re: Event Condition Evaluation (QUICK POLL)

Post by c0nnex » 10 May 2017, 18:31

Oz Flyer wrote:I think it would be best as an option.
If not then use the actual values as each event in the sequence is run.
That way if event 2 needs to use a value from event 1 it will have the updated value.
Having said that there would need to be a way to have a time delay so the the data from event 1 is fully updated.
That is literally not possible. Because one of the key features of SPAD.neXt is, that everything is asynchronous. SPAD.neXt does simply not know when and if a data change is completed.

How do events work:

First of all a SPAD.neXt event is always triggered by an external event. This can either be a hardware device (Switch turned to on) or a data value, which is used in a condition, changes. You can picture the "Switched on"-Event as an invisible "if SwitchVariable equals 1"-Condition.
1. At this moment in time, nothing is evaluated. SPAD.neXt just recognizes "it changed".
2. SPAD.neXt will tell all programmed events that use that changed data: "Hey you need to evaluate your conditions".
3. The events evaluate their condition in the priority order. They will use the values that are current, when the evaluation takes place. SPAD.neXt Events bound to different triggers will evaluate parallel. (e.g. 2 different Script-Events using SIMCONNECT:HEADING LOCK DIR, will execute at the same time, not in sequence!)
(for a general sequence of what is happening see this: http://www.spadnext.com/wiki/manual:events_execution )
4. If now any of the actions changes SIMCONNECT:HEADING LOCK DIR, all starts from the beginning as soon as the change arrives at SPAD.neXt.. So changing SIMCONNECT:HEADING LOCK DIR will do
* SPAD.neXt sends new value to FSX. (SPAD.neXt will internally still work with the old value!)
* FSX updates SIMCONNECT:HEADING LOCK DIR
* FSX send update of SIMCONNECT:HEADING LOCK DIR to SPAD.neXt
* SPAD.neXt recognized change of SIMCONNECT:HEADING LOCK DIR and starts at 1. again

Btw this explains, why sometimes the Multipanel shows something different than the aircraft: SPAD.neXt did not get the value change for any reason. All but LOCAL will always make the roundtrip through the simulation. Using this approach SPAD.neXt ensures it's not working with invalid/outdated/different data.

To have something like "wait until the change is done" local variables can be used. As the change of the local variable and the data change from the sim will both trigger the event.
So actions with a condition
if LOCAL:DoThis == 1 AND SIMCONNECT:HEADING LOCK DIR > 100
will only be executed if DOthis and SIMCONNECT:HEADING LOCK DIR match the values, but will be evaluated every time any of those two changes.

Due to the nature of the asynchronous execution, it might happen that one programmed action sequence is executing while another is not, because the condition-trigger changed meanwhile. Instead of changing the time when the conditions is evaluated, i might decide to introduce "subevents" that will be executed if their main event triggered.

A good example is the new LOCAL:SPAD_AIRCRAFTCHANGED data value. If you monitor this, you will see it always has the value "1" as soon as a simulation is connected. Nevertheless actions bound to it will be executed if the aircraft changes, because SPAD.neXt will just set it to 1 again (no change in value, but as stated above (1.) , SPAD.neXt does not care).

Constraint:
All external data values have an epsilon. SPAD.neXt will only trigger the "it changed" if the new value and the "last changed trigger value" differ more than this epsilon. This is simply to spare CPU. Some values (e.g. the fuel capacity or RPM) change 60 times a second with a difference of like 0.000000000001 gallon. To evaluate all conditions 60 times a second would mean to have a 8-Core 200GhZ Cpu just for SPAD.neXt. To prevent this, "it changed" is only triggered if the fuel capacity changed since the last trigger by at least 0.01 gallons.

Big wall of text, but it hope it explains understandable how events work.

User avatar
Oz Flyer
Betatester
Posts: 741
Joined: 23 Sep 2015, 10:10
Location: YMMB, Melbourne, Australia
Contact:
Status: Offline

Re: Event Condition Evaluation (QUICK POLL)

Post by Oz Flyer » 11 May 2017, 00:31

Hi Ulrich,
Thank for the info explains better why I some time get an error.

With the comment about time delay I was talking about the "Delay Next Action" between event.
To let the data make the round trip to the SIM and back to SPAD.neXt.
Which you already have in SPAD.neXt.
David
OZ Flyer
Near YMMB
40+ year of Flight Siming.
Sim: subLOGIC/Microsoft Flight Sim's/DTG FSX, Microsoft Flight, DTG Filght School/FSW/Train Sim/TSW, ETS2 & ATS.
Hardware: Logitech, Saitek, Arduino 2560's & Leo's, BBI-32, PAC LED.

Sircrashalot
Passenger
Posts: 2
Joined: 28 Jun 2016, 18:17
Status: Offline

Re: Event Condition Evaluation (QUICK POLL)

Post by Sircrashalot » 14 May 2017, 18:08

I agree with making it optional as this provides more versatility depending on the situation.

Locked