#Calculator code to update multiple simvars / A-type variables

1 messages · Page 1 of 1 (latest)

red arch
#

I am having an issue defining an axis-input type preset to update multiple simvars. The following preset works as expected, for single throttle control:
One Engine Throttle#@ 16383 + 32767.0 / (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100)
However, when I extend this to multiple throttles, e.g. for two throttles
Two Engine Throttle#@ 16383 + 32767.0 / (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100) @ 16383 + 32767.0 / (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent over 100)
then this causes throttle 2 to jump to max straight away, with no other movement and nothing on throttle 1.
How can I send the axis input value to both (or multiple) simvars?
Is there something wrong with the calc code syntax for updating multiple a-vars? Note the parameter ('@') is being correctly substituted in both locations before being executed.

I want to do this to define a preset for 6-engine aircraft, as there don't seem to be any events/k-type vars for throttles 5 and 6.

Any ideas?

next pollen
#

I wonder if those things being on a single line, the second piece of code gets its initial values from the first part?

@restive schooner might know some more, but the stack operators come to mind, whether you could duplicate the calculated value to two registers and then read back from each to a their respective A-vars?

restive schooner
#

I just checked and apparently that A: var is settable although I have never set throttle that way.

next pollen
#

I know in MobiFlight you can have just two lines, but I guess the FSUIPC wasm stuff uses the events.txt format which is just one line?

#

ie, could you do @ 16383 + 32767.0 / d s0 s1 ...

#

?

#

I am not at all familiar with registers unfortunately

restive schooner
#

I suggest trying (>K:THROTTLE1_SET) (>K:THROTTLE2_SET)

#

I think @ only works in Mobiflight as placeholder. Not sure anywhere else.

#

Afaik events.txt never supported axis input

next pollen
#

John said the issue is the THROTTLE_SET only exists for engines 1-4 and he needs to make something that works for 5 and 6

restive schooner
#

Remember analog input started with the custom input box sending code in real time to the Sim, bypassing events.txt

#

I think someone needs to go into Dev Mode with a six engine aircraft to see how it is done.

#

Is there any default aircraft with 6 engines?

next pollen
#

the spruce goose?

#

no wait it has two engines coupled together so it is 4 levers

red arch
#

I wonder if those things being on a single line, the second piece of code gets its initial values from the first part?
That was my initial thought, but there are plenty of presets doing the same, for A-vars and lvars, although I haven't actually testef these...

I know in MobiFlight you can have just two lines, but I guess the FSUIPC wasm stuff uses the events.txt format which is just one line?
ie, could you do @ 16383 + 32767.0 / d s0 s1 ...
?
I am not at all familiar with registers unfortunately
Yes, just one line. I am also not familiar with registers and how they are used.

Is there any default aircraft with 6 engines?
No need really - can try with a 2 or 4 engine aircraft.

The SDK states that only indices 1-4 are supported, but 5 & 6 work for throttle, but not mixture or prop.

#

I think @ only works in Mobiflight as placeholder. Not sure anywhere else.
I use $Param in FSUIPC as a parameter placeholder in calc. code strings, but later I saw that MF used the @ symbol so added support for that as well.

#

...and the Hercules H4 has 8 engines..,

next pollen
#

yeah the @ is getting the value from potentiometers, its otherwise like $

#

but just updates continuously and does not have OnPress and OnRelease events

restive schooner
#

here is the code I used in Mobiflight and Simconnect event
@ 20 - 10 / 0 max 100 min s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent)

#

Right lever
@ 20 - 10 / 0 max 100 min s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:3, percent) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:4, percent)

#

what device are you using to test? definitely not a potentiometer connected to arduino, as that would have an input range of 0 to 1023 to begin with, which is what I am using for my tests.

restive schooner
#

@red arch question, if the K:event support is only for up to four engines, why would there be an expectation that the A: variable support is different?

restive schooner
#

I couldn't find where it says throttle indices 5 and 6 would work. Only that 1-4 are allowed.

next pollen
#

spruce goose has 8 engines mapped to 4 throttles, 1+2,3+4,5+6,7+8

red arch
#

assigned throttles 1 and 2 to my left lever and 3 and 4 to my right lever. It works ok.
here is the code I used in Mobiflight and Simconnect event
Are you sending those as separate lines? Doesn't work here on one line, just the 2nd a-var is changed (i.e. throttle 2 or 4). I can send the lines individually, that works, but sending as one string on one line then the first a-var update is ignored.

if the K:event support is only for up to four engines, why would there be an expectation that the A: variable support is different?
There isn't, but it does - as you have found out! As I said, the documentation explicitly states for engines/indices 1-4. However throttle works for 5 & 6, but not prop or mixture.

what device are you using to test?
Just a standard joystick axis. But this is immaterial - the question is really about setting the value to multiple A-type variables in a one line calc. code string.

restive schooner
#

In Mobiflight it is irrelevant if I use one or more lines. In this case they are two lines but I am confident it works just the same with one line code.

#

I can understand that the events.txt forces you to one line only.

#

Could it be your implementation of the @ placeholder?

#

Maybe only the last one is taken

#

Just shooting ideas

red arch
#

I am confident it works just the same with one line code.
I wouldn't be so confident...

Maybe only the last one is taken
Yes, this seems to be the case.

Try this: this works, sending individual or separate lines, moving throttles 1 & 2 to 50% (no placeholders):

0.5 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100)
0.5 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent over 100)

With this, only the last one is taken:

0.5 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100) 0.5 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent over 100)

restive schooner
#

OK, I can test that in about one hour as I am out of the house right now.

red arch
#

Ok, thanks. This may have implications for the presets in the events.txt file, as they are single lines. There are several that update multiple a-vars that may not work....

#

Multiple lvar updates on a single line doesn't seem to be an issue.

next pollen
#

can you try with a static number?

#

I wonder if it is how @ is handled?

red arch
#

I have - see above...

next pollen
#

as it was added later

#

would it work if you duplicate the value and then put the avars there?

#

ie, use the d

#

and I would assume you then get two outputs?

#

and if you give two simvars to set them into? would that work?

#

ie, @ d (>a:simvar1) (>a:simvar2)

#

?

restive schooner
#

I know that one line code worked in events.txt just fine, but I haven't used events.txt type of commands in almost two years.

#

I once tested a one line RPN code that had more than 40,000 characters and it worked.

red arch
#

ie, use the d
and I would assume you then get two outputs?
and if you give two simvars to set them into? would that work?
ie, @ d (>a:simvar1) (>a:simvar2)
?
Tried that - neither changed. Its also the same simvar, different index - but not sure if that is relevant.

restive schooner
restive schooner
#

@ 20 - 10 / 0 max 100 min s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent)

#

Now tested assigning a fixed number and it also works
50 s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent)

#

Changing units to "percent over 100" also worked ok
0.20 s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent over 100)

red arch
#

Ok, that now works, and extending to 4 (or 6, not tested though) engines also works using a placeholder/parameter. Thanks,
I do have one final strange related issue. These two strings seem exactly the same, but the second only moves throttle 2 and not throttle 1:

0.5 s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent over 100)

0.5 s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent over 100)
Can you see a difference there? Can you try them to see if you get the same (via copy and paste)?

restive schooner
red arch
#

Ok - they should do really, as they are exactly the same as far as I can tell, its very strange. Thanks for testing.
I am using the FSUIPC WASM module - the strings are just executed using the gauge execute_calculator_code function. Just driving me a bit crazy as I can't understand why one fails - this is the log from the WASM:
Thu Jun 22 08:42:18 2023 [DEBUG]: Calculator code executed: '0.5 s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent over 100)' Thu Jun 22 08:42:19 2023 [DEBUG]: Calculator code executed: '0.5 s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent over 100)'
Both strings identical (no hidden characters), one works on both throttles, the other only moves throttle 2.... I would like to know why this fails but its not an issue.
Thanks for checking anyway.

restive schooner
#

in one input

next pollen
#

weird

#

does sim Console show anything?

restive schooner
#

I think it has something to do with using events.txt. If I remember well, this method was not designed to send live parameters to the sim.