Sign in to follow this  
Guest Peyroteo

XML Gauge to simulate a failure

Recommended Posts

Help AVSIM continue to serve you!
Please donate today!

Hi, Use the "Search function" in the forum and type failure.A lot of stuff you can use!Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

Thanks for that tip, I have allready search, but the problem is to make this failure random and how can I start a time counter when in some conditions.Peyroteo

Share this post


Link to post
Share on other sites

At random seems impossible to me.An event, engine-failure, needs a trigger or situation.Eg. after station passage of a VOR (HSI TF FLAG), or oiltemp>200 etc, or exceeding speed and altitude etc. you know already.Using a timer: look at the p:vars in the xml sdk of Arne Bartels.I use them in some switches, which need a delay of seconds or minutes eg. warming up the IRS system or starting the APU.You also need a switch to reset the failure but that is not difficult.Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

Hi JanI write something like this:*********************** // *****************************(P:Local time,seconds) 20 / near (L:Overheat,number) +(L:Overheat,number) 1 == (A:GENERAL ENG1 FAILED,bool) != (L:Eng1 Hot,number) 0 <= && if{ (>K:TOGGLE_ENGINE1_FAILURE) 150 (>L:Eng1 Hot,number) } (L:Eng1 Hot,number) -- (>L:Eng1 Hot,number) (L:Overheat,number) 1 == (A:GENERAL ENG2 FAILED,bool) != (L:Eng2 Hot,number) 0 <= && if{ (>K:TOGGLE_ENGINE2_FAILURE) 150 (>L:Eng2 Hot,number) } (L:Eng2 Hot,number) -- (>L:Eng2 Hot,number) (L:Overheat,number) 1 == (A:GENERAL ENG3 FAILED,bool) != (L:Eng3 Hot,number) 0 <= && if{ (>K:TOGGLE_ENGINE3_FAILURE) 150 (>L:Eng3 Hot,number) } (L:Eng3 Hot,number) -- (>L:Eng3 Hot,number) (L:Overheat,number) 1 == (A:GENERAL ENG4 FAILED,bool) != (L:Eng4 Hot,number) 0 <= && if{ (>K:TOGGLE_ENGINE4_FAILURE) 150 (>L:Eng4 Hot,number) } (L:Eng4 Hot,number) -- (>L:Eng4 Hot,number) (L:Overheat,number)*******************************//***************************this is to try a random failure (the trigger is the

Share this post


Link to post
Share on other sites

Rookie myself, but isn't there a wrong syntax? After value 3 there isn't a and after 4 there are 2 May be the cause?Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

Yes, I made a mistake.But now, with the correction, only the engine 4 stops!!!It's not easy for me to understand how this works! I supose that the variable

Share this post


Link to post
Share on other sites

I had the same problem with changing enum values, always the last one was chosen.Change eng 3 and 4 in the value section and see what happens, probably an eng 3 failure.If so you have to change the variables.Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

>I had the same problem with changing enum values, always the>last one was chosen.>Change eng 3 and 4 in the value section and see what happens,>probably an eng 3 failure.>If so you have to change the variables.>>Jan>>"Procul Negotiis"Yes, the last one is choosen.What do you mean with

Share this post


Link to post
Share on other sites

May be it is better to make different sets of values like: (var1) (var2) && if{ (>K:TOGGLE_ENGINE1_FAILURE) } (var1) (var2) (var3) && && if{ (>K:TOGGLE_ENGINE2_FAILURE) } etc. You can choose all kinds of variables and times.Of course you need a toggle to get the engines running again!Perhaps better is choosing another k-event, which eg. cuts the throttle or shut the fuel-valves, so you can fire-up , when the var's are normalized.Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

Hi,I follow your sugestions and all works well, but.... (P:Local time,seconds) 20 / near (>L:EngNumFailed,number)This peace of code don

Share this post


Link to post
Share on other sites

Try something like this:It is a code from Spokes2112 (Roman), also here in the forum; you could ask/mail him. (G:Var1) 2 == if{ (A: or L: value...) 0 == if{ (>K:TOGGLE_ENGINE1-4_FAILURE) } } els{ (A: or L: value...) 1 == if{ (>K:TOGGLE_ENGINE1-4_FAILURE) } } (G:Var1) 3 == if{ (P:Local Time, seconds) (G:Var2) > if{ 1 (>G:Var1) + (P:Local Time, seconds) 15 (As many seconds you need..) + (>G:Var2) } } (G:Var1) 1 == if{ (P:Local Time, seconds) (G:Var2) > if{ 2 (>G:Var1) } }It is a code for a 3 way switch with inbuild delays.Probably you need a click somewhere, but even that you can automate: (G:Var1) 0 == if{ 3 (>G:Var1) + (P:Local Time, seconds) 0.65 + (>G:Var2) } els{ 0 (>G:Var1) } Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

There are two possible ways to do "randoms". The obvious is to store a variable at aircraft load, derive it and compare it against time in the gauge doing the failure system. The other, and is the way I prefer to use it, is by presetting the randomness at aircraft load; check against time when the cockpit is entered, preset a few random-variables and prevent them from being set again at that flight.Microsoft, please give us an easy-to-use RND variable :)Although the following example does quite different failures, maybe you'll be able to drag something useful from them.The following code is from the startup gauge, I've included it in full for reference and maybe put some ideas into peoples heads :)--- BEGIN ---(L:WeightSet,bool) if{ quit } els{ (*ADJUST THIS NUMBER to match number of people on board, affects oxygen depletion rate*)6(*ADJUST THIS NUMBER to match summed weight of all loading stations from aircraft.cfg. Affects ice calculations*)1530.6(*ADJUST THIS NUMBER to match empty weight from aircraft.cfg. Affects ice calculations*)4558 (*ADJUST THIS NUMBER to set personal preference of timer operations. Affects fast or slow clickrates*)0.1 (*seconds will be valid delay for fast adjustment*)(>L:TimeRate,enum) + (>L:SummedWeight,enum) (>L:Souls,enum)(*Init for electrical master guard, if aircraft is dead upon startup*)(A:GENERAL ENG1 MASTER ALTERNATOR,bool) ! (A:Electrical master battery,bool) ! (A:GENERAL ENG2 MASTER ALTERNATOR,bool) ! && &&if{ 1 (>L:AllMastersOff,bool) }(*Init for magnetos guard, if aircraft is dead upon startup*)(A:RECIP ENG1 LEFT MAGNETO,bool) ! (A:RECIP ENG1 RIGHT MAGNETO,bool) ! (A:RECIP ENG2 LEFT MAGNETO,bool) ! (A:RECIP ENG2 RIGHT MAGNETO,bool) ! && && &&if{ 1 (>L:AllMagsOff,bool) }(*Determine a random factor for brake lockups, which brake to lock up if any*)(P:Absolute Time, seconds) 4 % int d s0 2 < if{ 0 (*no lockups half of the time*) (>L:Gear LeftOrRight,enum) } els{ l0 2 == if{ 1 (*left lockup*) (>L:Gear LeftOrRight,enum) } l0 3 == if{ 2 (*right lockup*) (>L:Gear LeftOrRight,enum) } } (*Determine a random factor for engine failure, which engine to fail if any*)(P:Absolute Time, seconds) 5 + 4 % int d s0 2 < if{ 0 (*no failures half of the time*) (>L:Eng LeftOrRight,enum) } l0 2 == if{ 1 (*left engine will fail*) (>L:Eng LeftOrRight,enum) }l0 3 == if{ 2 (*right engine will fail*) (>L:Eng LeftOrRight,enum) }(*Set fuelpumps off to syncronize with graphics, which is not saved*)(A:General eng1 fuel pump switch,bool) 1 == if{ 0 (>K:TOGGLE_ELECT_FUEL_PUMP1) 0 (>L:FPump1,enum) }(A:General eng2 fuel pump switch,bool) 1 == if{ 0 (>K:TOGGLE_ELECT_FUEL_PUMP2) 0 (>L:FPump2,enum) }(*Set panelvariables based on which panel is used*)(L:Paneltype,enum) 0 == if{ 1 (>L:HasAC,bool) }1 (>L:WeightSet,bool) }---END---The first operation checks the status of the variable that is set at the end, so it will only compute once.The gauge that does some of the magic concerning failures looks like this, again (almost) in full - some nonrelevant things removed. This is a very complex "gauge" (no graphics, only computes "stuff"), and obviously it might contain bad, nonlogical, beginners-code, and plain ugly bugs :)--- BEGIN ---(*various drag components to spoiler*)(P:Absolute time,seconds) 2 (*every 2 seconds*) % 10 * int 5 (*5/10 of a second*) < ! if{ (A:Airspeed select indicated or true,knots) 50.0 < if{ quit } els{ (A:INCIDENCE BETA,radians) abs 1.16 (*maybe too much*) * (A:GEAR TOTAL PCT EXTENDED,enum) 157.0796 * 2 * sin 0.4 * + (A:RECIP ENG3 COWL FLAP POSITION,position) 0.01 * + (*not included 1 (A:GENERAL ENG1 THROTTLE LEVER POSITION,position) 0.3 min - 0.7 - 1 (A:GENERAL ENG2 THROTTLE LEVER POSITION,position) 0.3 min - 0.7 - min 0.5 * + not included*) 16384 * (>K:SPOILERS_SET) } }(*deice boot controller*)(L:Boot Sequence,enum) 0 == if{ quit } els{(P:Absolute time, seconds) (L:Boot timer, seconds) 6 + > (L:Boot Sequence,enum) 1 == && if{ 0 (>K:TOGGLE_STRUCTURAL_DEICE) 0 (>K:COWLFLAP4_SET) 2 (>L:Boot Sequence,enum) }(P:Absolute time, seconds) (L:Boot timer, seconds) 10 + > (L:Boot Sequence,enum) 2 == && if{ 0 (>K:TOGGLE_STRUCTURAL_DEICE) 3 (>L:Boot Sequence,enum) }(P:Absolute time, seconds) (L:Boot timer, seconds) 12 + > (L:Boot Sequence,enum) 3 == && if{ 0 (>L:Boot Sequence,enum) }}(P:Absolute time,seconds) 30 (*every 30 seconds*) % 10 * int 5 (*5/10 of a second*) < ! if{ quit }els{ (*perform slaving action*)(L:GyroSlave,bool) (A:PARTIAL PANEL HEADING,bool) ! && (A:Circuit general panel on, bool) && if{ 0 (>K:HEADING_GYRO_SET) }(*Fail the electrical system if overloaded and max realism*) (A:Electrical genalt1 bus amps,amps) (A:Electrical genalt2 bus amps,amps) + (L:Amps Total,amps) + 110.0 (*allow 10 amp overload*) > (A:Realism,enum) 1 == && (A:PARTIAL PANEL ELECTRICAL,bool) ! && (A:Electrical genalt1 bus voltage,volts) 0 == (A:Electrical genalt2 bus voltage,volts) 0 == || && if{ 0 (>K:TOGGLE_ELECTRICAL_FAILURE) }(*fail engine 1 or 2 based on engine select, general realism setting, and failure amount*)(L:Eng has failed,bool) 1 != if{ (*begin engine fail*) (A:Realism,enum) 0.90 > (L:Fail Amount,enum) 100.0 > && (L:Eng LeftOrRight,enum) 0 == ! && (*prevent calculated failure if already failed otherwise*) (A:ENG1 FAILED,bool) (A:ENG2 FAILED,bool) || ! &&if{ (*now select which engine to fail*) (L:Eng LeftOrRight,enum) 1 == if{ 0 (>K:TOGGLE_ENGINE1_FAILURE) 1 (>L:Eng has failed,bool) } els{ 0 (>K:TOGGLE_ENGINE2_FAILURE) 1 (>L:Eng has failed,bool) } }(*end engine fail*) } (*fuel dependancy settings, booleans set by fuel selector. Will cause aux fuelpump failure on a failed engine*)(A:GENERAL ENG1 FUEL VALVE,bool) (L:Eng1 Eng2 Dependant,bool) && (A:GENERAL ENG2 RPM, rpm) 500 < && (A:GENERAL ENG1 FUEL VALVE,bool) ! (L:Eng1 Eng2 Dependant,bool) ! && || if{ 0 (>K:TOGGLE_FUEL_VALVE_ENG1) }(A:GENERAL ENG2 FUEL VALVE,bool) (L:Eng2 Eng1 Dependant,bool) && (A:GENERAL ENG1 RPM, rpm) 500 < && (A:GENERAL ENG2 FUEL VALVE,bool) ! (L:Eng2 Eng1 Dependant,bool) ! && || if{ 0 (>K:TOGGLE_FUEL_VALVE_ENG2) }(*set ice amount to cowlflap4 which is used on aircraft model*)(A:Total Weight,pounds) (A:FUEL TOTAL QUANTITY WEIGHT,pounds) - (L:SummedWeight,enum) (*5923.6*) (*derived from empty weight + all station loads*) - 16384 * 100 / (*100 pounds equal max animated ice*) (>K:COWLFLAP4_SET)(*re-allow booting if ice has melted off naturally*)(L:Boot Sequence,enum) 4 == if{ (A:RECIP ENG4 COWL FLAP POSITION,position) 0.1 (*allow for error*) < if{ 0 (>L:Boot Sequence,enum) } } (*sound ice bangs if appropriate by prop icing*)(L:Propeller Deice,bool) ! if{ quit }els{ (P:Absolute Time,seconds) (L:IceTime,seconds) > ! if{ quit } els{ (A:RECIP ENG4 COWL FLAP POSITION,position) 0.0025 - (L:PreviousIce,enum) > if{ (A:RECIP ENG4 COWL FLAP POSITION,position) (>L:PreviousIce,enum) (P:Absolute Time,seconds) 10 + (>L:IceTime,seconds) 0 (>K:TOGGLE_AFTERBURNER3) } els{ (A:RECIP ENG4 COWL FLAP POSITION,position) (>L:PreviousIce,enum) (P:Absolute Time,seconds) 10 + (>L:IceTime,seconds) } }(*end icetimer*) }(*end deice check*)}(*end time*)(A:SIM ON GROUND,bool) ! if{ quit } els{ (P:Absolute time,seconds) 2 (*every 2 seconds*) % 10 * int 5 (*5/10 of a second*) < ! if{ quit }els{ (*display warning if panel is having right wing auxtank AND air conditioner*)(L:HasAC,bool) (*temporarily set in adjustments.xml*) (A:FUEL TANK RIGHT TIP QUANTITY,gallon) 0.1 > && if{ (P:Absolute Time,seconds) 5 + (>L:Windcheck Timer,seconds) 5 (>L:Windcheck Opened,enum) 75 (>K:PANEL_ID_OPEN) }(*smoke based on surface type and conditions*)(A:SURFACE CONDITION, enum) 1 == (A:SURFACE CONDITION, enum) 3 == || (A:LEFT WHEEL RPM,rpm) 450 > (A:RIGHT WHEEL RPM,rpm) 450 > || && (A:SURFACE TYPE, enum) 0 == (A:SURFACE TYPE, enum) 4 == || (A:SURFACE TYPE, enum) 23 == || && if{ 0 (>K:SMOKE_ON) } els{ 0 (>K:SMOKE_OFF) }}(*end timer*) }(*end ground*)(A:SIM ON GROUND,bool) if{ quit } els{ (P:Absolute time,seconds) 2 (*every 2 seconds*) % 10 * int 5 (*5/10 of a second*) < ! if{ quit }els{ (*Set Fail Amount,enum based on engine parameters and realism slider*)(A:Eng1 cylinder head temperature,farenheit) 410 > if{ (L:Fail Amount,enum) (A:Realism,enum) 0.1 * + (>L:Fail Amount,enum) } (A:Eng1 manifold pressure,inHg) 39.5 > if{ (L:Fail Amount,enum) (A:Realism,enum) 0.23 * + (>L:Fail Amount,enum) } (*shock cooling detector*)(A:RADIO HEIGHT,feet) 1500 > if{ (L:Eng1 exhaust gas prevtemp,kelvin) (A:Eng1 exhaust gas temperature,kelvin) - 175 (A:AIRSPEED INDICATED,knots) - 10 max > (A:general eng1 propeller lever position,part) 0.25 > (*avoid trigger if due to propeller cycling every thirty minutes*) && if{ 1 (>L:ShockDetect,bool) (L:Fail Amount,enum) (A:Realism,enum) 2.5 * + (>L:Fail Amount,enum) (A:Eng1 exhaust gas temperature,kelvin) (>L:Eng1 exhaust gas prevtemp,kelvin) } els{ 0 (>L:ShockDetect,bool) (A:Eng1 exhaust gas temperature,kelvin) (>L:Eng1 exhaust gas prevtemp,kelvin) } }(*retract water rudder - tie down*)(A:WATER RUDDER HANDLE POSITION,number) 0.5 > if{ 0 (>K:TOGGLE_WATER_RUDDER) }}(*end timer*) }(*end ground*)(*Sound altitude alerter, 200 and 500*)(A:Autopilot altitude lock var, feet) (A:Indicated altitude, feet) - abs s0 498 > l0 502 < && l0 198 > l0 202 < && || (A:Circuit general panel on, bool) && if{ 0 (>K:TOGGLE_AFTERBURNER4) }(*Sound DH*)(L:Decision Height, enum) (A:Radio Height, feet) - abs s0 0 > l0 4 < && (L:RadAlt Test,bool) || (L:RadAlt Audio,bool) && (A:Circuit general panel on, bool) && if{ 0 (>K:TOGGLE_AFTERBURNER4) }(*Brake lockups*)(*Gear LeftOrRight,enum set in Adjustments.xml*) (A:TRAILING EDGE FLAPS0 LEFT PERCENT, percent) 80.0 < if{ quit } els{ (A:REALISM,enum) 0.89 > (A:Airspeed select indicated or true,knots) 20 > && (A:Ambient temperature, celsius) -10 < && (A:LEFT WHEEL RPM,rpm) 500.0 > && (L:Gear LeftOrRight,enum) 0 != && if{ (L:Gear LeftOrRight,enum) 1 == if{ 16384 (>K:AXIS_LEFT_BRAKE_SET) } els{ (*has to be two*) 16384 (>K:AXIS_RIGHT_BRAKE_SET) } } }--- END ---Ok, somewhat more than I intended. The limiter function - at the start of each complex code, is quite badly coded. Obviously it keeps repeating within its timewindow instead of only once per 2 seconds or whatever.IMPORTANT NOTE: USE LIMITING CODE (execute once per second or less) FOR COMPLEX CODE IF YOU EVER PLAN TO SEE GROUND TEXTURES :)Now, the beauty of storing an impending failure to an accumulator may be obvious; subtract a derived value of the failure number and subtract it from the engine gauges. Even though sudden engine failures do happen, the "sneaky" ones are much more common. Learning to read and respect the engine gauges is something this simulator leaves greatly desired (by myself at least).The following is a snippet only from the needles driving the engine gauges.--- BEGIN ---(*OIL PRESS will drop dramatically just before the failure occurs*)(A:Eng1 oil pressure,psi) (L:Eng LeftOrRight,enum) 1 == if{ (L:Fail Amount,enum) 100 / sqr sqr sqr 100 * 100 min 4 / - }(*CHT will rise linearly with impending failure*)(A:Eng1 cylinder head temperature,farenheit) (L:Eng LeftOrRight,enum) 1 == if{ (L:Fail Amount,enum) + }--- END ---If nothing else, I hope some of this proved useful for some of the guys around here. Putting some ideas in I hope :D

Share this post


Link to post
Share on other sites

Karl & Peyoeteo, This quote is pure fact.. ( thanx Karl ) :-)"This is a very complex "gauge" (nographics, only computes "stuff"), and obviously itmight contain bad, nonlogical, beginners-code, and plain uglybugs :)"Never heard it any better :-)It's been along time on since being able to fool around with the FS stuff.. Since Karl gave some code.... AND I will be going thru it with a fine tooth comb LOL!!! Kuzzz that's how to learn new ideas.. I braught out some code too.. Zero warranty.This is totally still in development.. It works as such,, at all time N1 is being monitored to cross a value that can engage a timer. Once the time runs out while still in the range the engine will fail. If the engine fails under the value a reset can occour "after" a cool down period descibed by a fator of "overhaeat time" . During all times a number is being introduced as the "fail", "factor" or "time to fail" . This number is generated by time and the point when the engine went over the limit. The whole key to this gauge is have the refresh rate of the gauge itself set to 1 second.. It saves precious computing power and relieves the need for user vars I.E G:vars to be used in or to facilitate the actual timer. So in this sniipet there a 4 ways to fail an engine. 1--- Instant,, go over this N1 value and its done... 2--- The higher range of N1 values,,, If you reach this it it'll take the least amount of time to fail but require the most amount of time to reset, if it doesn't reset completely but you fall below the trigger N1 it will start giving time back "and/or" if you did get time back or none at all the timer remains at the time either set now,,, or with some time given back.. (that is not worded right :-( ) if you go above the N1 trigger again..Modes 3 and 4 work in the same way but the values get better in the pilots case I.E. The time to fail gets larger while the cooldown reset gets shorter. There are some code in here that don't belong and part of developent so beware.. The gauges use all 9 G:Vars so one will be needed for each engine, that is where 1 of the L:vars comes in to comm with the other ones if needed..The other one is set to 1 for debug and monitoring ( set at 1 ) ... One possible problem...with 4 of these all set to a referesh of 1 second may introduce a stutter... ;-( Fs2000 all over again...Once the idea of the engine 1 gets made the other 3 (if necesssary) can be nearly done by just making copies..I enclosed a zip with 2 bitmaps and the code so if want to peer at it, use it, make it work etc... go for it. Donot have the time as such but it is still is the head LOL!!! IT NEEDS WORK !!! BTW ENG1 is monitored but it will fail ENG2.... just for testing. EDIT -- all the values used are by referencing the stock 737-400 and using DF and other sources from the net to set the failure times/N1 values etc... You'd be surprised how real the .air fie is actually set in the stock 737.. You can get 107% yes... But are you allowed to.... NO !! Means you cannot peg the throttles at T/O LOL!!OK,, nuff rambling...have a good one. Regards,RomanGREEN BAY PACKERS][/i :-ukliam :-beerchug

Share this post


Link to post
Share on other sites

RomanI will analize your code, thank you for that.Next week I

Share this post


Link to post
Share on other sites

He Roman, Karl and Peyroteo,These codes and snippets for me are very "threathening"!If one of you has a good functioning xml, please show it in the forum.As an idea:I use engine, electrical- and hydraulic failures, which are "cured" by the RAT, nothing original, but you can use the RAT to reset the failures.Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

Hi RomanI try your code with some changes (recip engines) and it works well!Something I do not understand:------------********----------(****************************** CASE GENERATOR ***************)(P:Absolute time, minute) (P:Absolute time, minute) int % 10 * int s1 (A:Plane heading degrees magnetic, degree) (A:Plane heading degrees magnetic, degree) int % 10 * int 1 max (A:Plane heading degrees true, degree) (A:Plane heading degrees true, degree) int % 10 * int 1 max s13--------------*******-----------------In the second , lines is'nt a mistake? I think the s12 variable is missing after

Share this post


Link to post
Share on other sites

Hi JanAs soon as I have something working as I want, I put here the xmlRegards,PeyroteoPS: What

Share this post


Link to post
Share on other sites

Peyroteo (i like Portugal very much; what does your name means?),The RAT is the Ram Air Turbine.When everything is gone, this turbine gives you, by windmilling, just enough power (elec/hyd) to get you safe on the ground.Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

Peyroteo,Thanks for the answer and invitation.Since 1974 (Salazar!) i came for holidays to Portugal, mostly by car.Last time was 2001, when we stayed in Silves.Did an ULV-trip from Lagos.More info in profile.Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

Hi everybodyI made some small changes to your code (Roman) just for testing and it works.I could made random failures to recip engines under certain conditions (instant failure at max engine CHT and elapsed time runing above certain manifold pressures). But, Roman, with 4 engines, a stutter occurs. It not afect the frames in FS, but we can see it in the other gauges in the panel.I don

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