Sign in to follow this  
Guest Matthias Lieberecht

mathematical formula in XML

Recommended Posts

Hi All,I've never used a mathematical formula in a XML code yet so I need a little help here with this (normally) simple formula. Here is what I want to have (normal written without parentheses):(L:TMS_N1_Set, percent) - 28 * 166,6 + 1000 (account sequence)The result should be stored (s0) for a later use in the same code. I've tried (the example is an older code without + 1000):(L:TMS_N1_Set, percent) 24 - s0 l0 166,6 * s1 l1 (>K:.......But with this formula I get a wrong result (with or without + 1000). The result seems to be divided by 4. The next one didn't work at all:(L:TMS_N1_Set, percent) 24 - 166,6 * s0 l0 (>K:.......Here I always get 0.How can I put this simple formula correct into my XML code? Hope someone could help.Best RegardsMatthias

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

I'm not sure how using percent as type works with calculations. Also, did you try using . instead of ,? I mean using 166.6 instead of 166,6?I'm assuming what you are trying to get (_with_ paranthesis) is:(((L:TMS_N1_Set, percent) - 28) * 166.6) + 1000?Your code btw uses 24 instead of 28, but I guess you've already spotted that typo. Sometimes, especially during "complex" maths involving subtraction and division, using the s (swap two latest parameters on stack) operator before the parameters does the trick:2 4 / yields 0.52 4 s / yields 2Sorry, not able to spot any obvious mistakes though (rather tired).

Share this post


Link to post
Share on other sites

Hi Karl,Great, thank you!!! It was the ",". If I use 166.6 instead of 166,6 the Gauge does exactly what I want. About 24 and 28: Yes you're write it was a mistake when writing the formula here. The reason was that I need -24 and no +1000 below 57% N1 and -28 and the included +1000 when RPM is above 57% N1 to get the correct result. Mixed it here a little bit :-)Another important question:Arne Bartels informed me that the Throttle_Set value goes from 0 (Idle position) to 16384 (full throttle). Is it possible to read out this value? What unit has to be used here? For example:(A:GENERAL ENG1 THROTTLE LEVER POSITION, ?????)Best RegardsMatthias

Share this post


Link to post
Share on other sites

Throttle_Set (and most of the "axis" type, including spoiler, which in fact *IS* set to whatever you like) has a 0-16384 range, but you can use (A:General Eng1 Throttle Lever Position,enum) which gave me a 0-1 readback (when examined in a string - which is always useful).Be careful on using any _SET type events on "runtime" (as opposed to click) events though.Here is an example of a (somewhat fake, naturally) primer switch for the C421B that utilizes additional throttle whenever the switch is on (it's a three-position one, left engine, off and right engine, this click event is for the left position). The way the FDE is currently built, will require some extra power to get the engines started, and I thought it would make a nice addition. At "low" engine temperatures, the engines will not start without putting the primers on. When engines are hot, the switch is ignored. The throttle panel also reads these variables and subtract the 20% power from the graphic display whenever the switch is active. Just made it, isn't "bulletproofed" yet, so might prove buggy. The usual > makes & g t ; rules apply. Kind of shows how ,enum and _SET operates together. Also see the Baron throttle quadrant for example.0 (>K:TOGGLE_AFTERBURNER1) (L:Primerstate,enum) -1 != if{ (L:Primerstate,enum) 1 - (>L:Primerstate,enum) (A:Eng1 oil temperature,farenheit) 100 < if{ 0.2 (>L:PrimerLThrottle,enum) (A:General Eng1 Throttle Lever Position,enum) 0.2 + 16384.0 * (>K:THROTTLE1_SET) } } (L:Primerstate,enum) 0 == if{ 0 (>L:PrimerLThrottle,enum) 0 (A:General Eng1 Throttle Lever Position,enum) 0.2 - 16384.0 * (>K:THROTTLE1_SET) (>L:PrimerRThrottle,enum) (A:General Eng2 Throttle Lever Position,enum) 0.2 - 16384.0 * (>K:THROTTLE2_SET) }

Share this post


Link to post
Share on other sites

Hi Karl,Thank you very much for this Info. The problem is not to set the Throttle to a value or to move the Throttle to a defined position (this works fine). The problem is to get back the actual position of the Throttle exactly between 0 and 16384 (to synchronise the Engines to a preselected master Engine). Therefor I need the name of the unit. Enum and Number don't give me this value.Best RegardsMatthias

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this