Jump to content
Sign in to follow this  
Guest Peyroteo

XML Gauge to simulate a failure

Recommended Posts

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
Guest Peyroteo

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
Guest Peyroteo

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
Guest Peyroteo

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
Guest Peyroteo

>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
Guest Peyroteo

Thanks Jan, I will try it.RegardsPeyroteo

Share this post


Link to post
Share on other sites
Guest Peyroteo

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
Guest

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

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...