Jump to content
Sign in to follow this  
sas737

I really need help

Recommended Posts

Hello!I've tried for days to get this code to work but I simply can't see the problem with it. :( All other sections of the XML gauge works but not this one.<Element><Select><Value>(A:SPOILERS HANDLE POSITION,percent) 10 < if{ 0 (>G:Var3) }</Value></Select></Element><Element><Select><Value>(A:SPOILERS ARMED, bool) (A:SIM ON GROUND, bool) && if{ (G:Var3) ! (A:SPOILERS HANDLE POSITION,percent) 10 > && if{ 1 (>L:SPOILER_SOUND,number) 1 (>G:Var3) } } els{ 0 (>L:SPOILER_SOUND,number) }</Value></Select></Element>It's supposed to play the "spoiler arm whine" sound when the spoilers are armed, the aircraft is on the ground and the spoiler handle is above 10%. I wanted this sound to be played only once so therefore I tried to store a 1 in G:Var3 after the code was executed. In order for the code to be executed, G:Var3 must be equal to 0.To make it happen, I added a reset code that sets G:Var3 to 0 after the spoiler handle is below 10%.I would be very grateful if I could get some help with this.

Share this post


Link to post
Share on other sites

Klas,I dunno but this may be redundent - spoilers armed & handle pos 10 > Maybe try 1 of the 2, the second taking care of the redundency -

<Element><Select><Value>(A:SPOILERS ARMED, bool) (A:SIM ON GROUND, bool) (A:SPOILERS HANDLE POSITION,percent) 10 > (G:Var3) ! & & & if{ 1 (>L:SPOILER_SOUND,number) 1 (>G:Var3) } els{ (G:Var3) 1 == if{ 0 (>G:Var3) } }</Value></Select></Element>

<Element><Select><Value>(G:Var3) ! (A:SIM ON GROUND, bool) & (A:SPOILERS ARMED, bool) (A:SPOILERS HANDLE POSITION,percent) 10 > || & if{ 1 (>L:SPOILER_SOUND,number) 1 (>G:Var3) } els{ (G:Var3) 1 == if{ 0 (>G:Var3) } }</Value></Select></Element>

Not tested, but hope this input can help.Roman


20AUG21_Avsim_Sig.png?dl=1  FS RTWR   SHRS F-111   JoinFS   Little Navmap 
 

 

Share this post


Link to post
Share on other sites

Klas, Please disregard the above post, as that code would've resulted in repeating sounds even if it did work. :( :( The following code(s) are very similar to the above except they use a Macro for brevity."I dunno but this may be redundent - spoilers armed & handle pos 10 &gt" - A little more explanation. I donot think that the spoilers can be armed and handle greater than 10% at the same time, I believe they can be this OR that though. Again I provided 2 examples the 1st ANDed and the 2nd ORd. The only difference between the 2 codes are in the Macro.Just FYI, if you are using DSD_XML_Sound3 gauge for your sounds. Setting a 1 to the trigger variable will play the sound only once, setting the variable to 2 will continually play the sound until the variable is forced back to 0.Ex.1

<Macro Name="SP_ARM_COND">(A:SIM ON GROUND, bool)(A:SPOILERS ARMED, bool)(A:SPOILERS HANDLE POSITION,percent) 10 >  & & </Macro> <Element Name="Play Spoiler Sound"><Select><Value>@SP_ARM_COND (G:Var3) ! & if{ 1 (>L:SPOILER_SOUND,number) 1 (>G:Var3) }</Value></Select></Element><Element Name="Reset Spoiler Sound"><Select><Value>@SP_ARM_COND ! (G:Var3) & if{ 0 (>G:Var3) }</Value></Select></Element>

Ex.2

<Macro Name="SP_ARM_COND"> (A:SIM ON GROUND, bool)(A:SPOILERS ARMED, bool)(A:SPOILERS HANDLE POSITION,percent) 10 > || & </Macro> <Element Name="Play Spoiler Sound"><Select><Value>@SP_ARM_COND (G:Var3) ! & if{ 1 (>L:SPOILER_SOUND,number) 1 (>G:Var3) }</Value></Select></Element><Element Name="Reset Spoiler Sound"><Select><Value>@SP_ARM_COND ! (G:Var3) & if{ 0 (>G:Var3) }</Value></Select></Element>

I hope you haven't tried my previous post and are still having troubles, hopefully this will get you going. Again it is not tested. Good luck & happy coding! Roman


20AUG21_Avsim_Sig.png?dl=1  FS RTWR   SHRS F-111   JoinFS   Little Navmap 
 

 

Share this post


Link to post
Share on other sites

Thank you for your help, on second thought, I think I'll make use of my "FSUIPC offset to XML translator" instead.Then I can read the spoiler armed offset and send it to XML.

Share this post


Link to post
Share on other sites

Very unlikely that's the problem, but did you monitor what values (A:SPOILERS HANDLE POSITION,percent) returns?I'm pretty much completely new to XML gauges, but I had the problem that (A:GEAR TOTAL PCT EXTENDED,percent) returns values from 0 to 1, and not from 0 to 100 as one would expect.I can tell you, I banged my head on that...Question: What's "FSUIPC offset to XML translator"? Interested... :( Gunter

Share this post


Link to post
Share on other sites

I'm not an expert but I think it depends on if the FSUIPC offset is a read or write offset.

Share this post


Link to post
Share on other sites
Head gets dizzy looking at this, but, properly set up, would it be possible to set parameters like GENERAL_ENGINE1_OIL_TEMP via FSUIPC???
GENERAL ENG OIL TEMPERATURE:index (XML tag) is listed in the FSX SDK as "Settable" via SimConnect, so if you are coding for FSX, then yes, you should be able to set this normally "read only" variable via either SimConnect or FSUIPC.All you need to do is look through the list of variables in the FSX SDK. They are plainly listed as Y or N in the "Settable" column.

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
GENERAL ENG OIL TEMPERATURE:index (XML tag) is listed in the FSX SDK as "Settable" via SimConnect, so if you are coding for FSX, then yes, you should be able to set this normally "read only" variable via either SimConnect or FSUIPC.All you need to do is look through the list of variables in the FSX SDK. They are plainly listed as Y or N in the "Settable" column.
Bill, thanks for the feedback. I had seen that the variable is settable in the FSX SDK.Q: Is this variable also settable in FS2004?But I had no idea on how to do it, in particular from an xml gauge. I've not seen any tool like that before. That's why I got all excited. :( If I understand right, the C code by Johan Nordqvist that sas737 referenced is just the code needed, that allows to read/write(?) any variable (write what is writable) from/to FS, with the interface to xml gauges by an L: variable. And just requiring changes to a few lines in the code to address the wanted variables, and not write all code anew.I'm a bloody beginner with xml, would not even have dreamed to start an endeavour like learning/writing something like that in C. But here the code is almost all done. With a little learning I feel I could cope with that, maybe even change to my needs.I'm still not sure my understanding of what Johan's code does is correct though, in particular whether it's possible to really write to FS, or rather only read.But the foundations seems to be there.Q: Could somebody confirm?I'm sure that I'll need Johan and you guys if ever I get around to jump into this... :( **Sas, sorry for kind of hijacking your thread. :( Did you get your code to work in the end?Spokes' ex.2 at least should run, even if maybe not doing exactly what you want. Q: Does the bit operator & work the same as the logic operator && in this case?Gunter

Share this post


Link to post
Share on other sites

Yepp I got it working, I don't know what the problem was but I managed to solve it in some way using the FSUIPC code.To use the code Johan wrote, you need some understanding of C programming ( No need to read 5 books about C programming though ). Just download the FS Panel SDK and look at the files and try to find a pattern about the structure.If you need any help feel free to send me a message.

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  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...