Archived

This topic is now archived and is closed to further replies.

n4gix

CAS Message Text - XML

Recommended Posts

I need to script a set of CAS Messages that will auto-scroll their position in real-time, based on which are currently active.Something like:AUTOPILOT DISCPARKING BRAKE SETAUTOTHROTTLE DISCFUEL LOW LEFTFUEL LOW RIGHTSPOILERS EXTENDEDSLATS EXTENDEDALTITUDE LOWPAX DOORS UNLOCKEDAs messages are removed, all text scrolls to the top:PARKING BRAKE SETAUTOTHROTTLE DISCPAX DOORS UNLOCKEDWhat would be the most flexible way of scripting this? Please :)

Share this post


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

>What would be the most flexible way of scripting this? Please>>Bill, is XML mandatory here? Because as you know doing it in C++ or C++/XML mix is a piece of cake.:-)Anyway, in XML is simple as well but the script being rather complex if you want efficiency -forget about tons of nested if{}els{}s :-eek; you REALLY need efficiency in this case!.I'll try to translate to pseudocode an example from what I've done in a proprietary project, so I can post it here.Tom

Share this post


Link to post
Share on other sites

>Bill, is XML mandatory here? Because as you know doing it in>C++ or C++/XML mix is a piece of cake.:-)>>Anyway, in XML is simple as well but the script being rather>complex if you want efficiency -forget about tons of nested>if{}els{}s :-eek; you REALLY need efficiency in this case!.>>I'll try to translate to pseudocode an example from what I've>done in a proprietary project, so I can post it here.Unfortunately, it must be XML since the ND/EICAS display is entirely XML driven, since it requires the map etc. from fs9gps.dll be incorporated into it as well.Although I could have done the entire project in GDI+ (including the pesky fs9gps.dll map & flightplan, etc., the customer simply wasn't willing to spend that much for this project... :)It would be SO much easier if we could use L:var,number for Y=nn positioning in formatted text... :-lol

Share this post


Link to post
Share on other sites

Hi Bill,I haven't tried this, but could imagine that it works:What about using text elements beeing visible or not - to decide which of the messages to show up. Then add a shift to decide where each message is placed (the order from top to bottom). This shift can be driven by a L-variable. Now all you need is a bit math to calculate the required shift-L-vars. For this the case-statement should be helpful.Let me know if you got it working... But I'll also try to find a solution. This would be a nice piece of code for general purposes, I guess.Best,Herbert

Share this post


Link to post
Share on other sites

Found this. Works OK in Formatted text. %((A:Brake parking position,percent) 50 > )%{if}PARKING BRAKEn%{end}%((A:TURB ENG1 N1, percent) 71.0 > (A:TURB ENG2 N1, percent) 71.0 > || (A:Sim on ground,bool) & (A:GENERAL ENG1 THROTTLE LEVER POSITION, percent) 15 > & )%{if}%((A:Autopilot master,bool))%{if}CONFIG APn%{end}%( 1 3 (A:FLAPS HANDLE INDEX,enum) rng ! )%{if}CONFIG FLAPSn%{end}%((A:Spoilers Left Position,percent) (A:Spoilers Right Position,percent) + 10 > )%{if}CONFIG SPLRSn%{end}%{end}{clr2}%((A:Brake parking position,percent) 0 == (A:Spoilers Left Position,percent) (A:Spoilers Right Position,percent) + 10 < & (A:Autopilot master,bool) ! & 1 3 (A:FLAPS HANDLE INDEX,enum) rng & (L:FlapsSetTOwarn, bool) ! & (A:Sim on ground,bool) & )%{if}T/O CONFIG OKn%{end}{clr}%((A:Exit Open:0,bool) (A:Sim On Ground,bool) &)%{if}ENTRY DOORn%{end}%((L:oilWarning1,bool))%{if}L ENG OIL PRESSn%{end}%((L:oilWarning2,bool))%{if}R ENG OIL PRESSn%{end}%((L:Gear_Warning,bool))%{if}GEARn%{end}%((L:FuelImbalance_Caution,bool))%{if}FUEL IMBALANCEn%{end}%((L:FuelXFeed_Caution,bool))%{if}FUEL XFLOn%{end}%((L:BrakeAcumPress_Caution,bool))%{if}BRAKE ACUM PRESSn%{end}%((A:General eng1 throttle lever position, part) 0 < )%{if}L REV OPENn%{end}%((A:General eng2 throttle lever position, part) 0 < )%{if}R REV OPENn%{end}%((L:Eng overspeed,bool))%{if}ENG OVERSPDn%{end}{clr3}%((L:genWarning1,bool))%{if}GEN 1 OFFn%{end}%((L:genWarning2,bool))%{if}GEN 2 OFFn%{end}%((L:fuelWarning1,bool))%{if}L FUEL LO PRESSn%{end}%((L:fuelWarning2,bool))%{if}R FUEL LO PRESSn%{end}%((L:LowFuelWarning,bool))%{if}FUEL QTY LOWn%{end}etc etc.

Share this post


Link to post
Share on other sites

>Unfortunately, it must be XML since the ND/EICAS display is>entirely XML driven, since it requires the map etc. from>fs9gps.dll be incorporated into it as well.>>Although I could have done the entire project in GDI+>(including the pesky fs9gps.dll map & flightplan, etc., the>customer simply wasn't willing to spend that much for>this project... :)>>It would be SO much easier if we could use L:var,number>for Y=nn positioning in formatted text... :-lol Bill,I know what you're talking about (and I think I know the "customer" you're talking about). Anyway, keep in mind you can use C++ on top of the map provided by the GPS. This is exactly what I have done for my ATC Radar (see here: http://emarciano.free.fr/ATCRadar). It may be the best solution to use here ;)Eric

Share this post


Link to post
Share on other sites

You're guess is probably right, Eric... ;) That's a nice looking radar you've done there!The leftside and rightside MCP's and the AP are in a C gauge anyway, so it'd not be that difficult to accomplish this way if necessary.

Share this post


Link to post
Share on other sites

That might be a workable approach. I'm looking for something that's flexible enough to keep such a list easily maintainable and comprehensible...

Share this post


Link to post
Share on other sites

I noticed that the Lear45 has a "scrolling CAS" but I haven't looked at the script yet. I would imagine that it's using a similar formatted text display.I suspect I'll wind up using this approach, but it's hardly what I'd call universal or easily maintainable... ;)

Share this post


Link to post
Share on other sites

Well, I believe the Lear45 could be a good approach for a simple CAS, and the code is very understandable (You wouldn't want to read the one I used in my gauge :7, which needs to handle 80+msgs, multiple pages,etc)Anyway, I for you would choose the C++ option if possible; I've done a similar multiline CDU with the C++/XML mix and is far more simpler and supportable.Tom

Share this post


Link to post
Share on other sites

>Well, I believe the Lear45 could be a good approach for a>simple CAS, and the code is very understandable (You wouldn't>want to read the one I used in my gauge :7, which needs to>handle 80+msgs, multiple pages,etc)Since this project is for a well-known "Toy Maker" simple is good. In fact both KISS and KIIC are guiding principles! (Keep It Simple Stupid and Keep It It Cheap) :)

Share this post


Link to post
Share on other sites

what's easy... I thought about this:Imagine you have 10 strings (text elements) each with its unique text, colour and so on.Now you first need to decide the position of these 10 element in case all are active, so which will be the most top and which the most bottom one.Now to calculate the position of one certain element you only need to count the numbers of active elements above it. As the conditions which decide if one element is active or not will be boolean, you simply have to add them. Now multiply that result by the distance between the elements (20 pixels or whatever) and you're done. This calculation of course needs to be done for each text element.To let this work as a general piece of code, I'd work with L-vars rather with the actual variables and put at the top of the gauge an update element where the L-vars get their values from the actual A:-variables.So for usage with other A:variables you'll only need to change that update element and of course the string to be displayed.Attached a working example with 4 string elements only (Battery, Pitot, Landing Light, Taxi Light).Herbert

Share this post


Link to post
Share on other sites

Clever. Thanks for the sample! When I get back to that project I'll take it onboard for further evaluation/testing. ;)

Share this post


Link to post
Share on other sites

Well, as it turns out using <FormattedText> is the simplest approach one can use. The following is an example of a dynamic, autoscrolling EICAS message box.First we set up some conditional <Macro>s

<!-- XXXXXXXXXXXXXXXXXXXXXXXXX EICAS CONDITIONAL MACROS XXXXXXXXXXXXXXXXXXXXXXXXXXXX --><Macro Name="Condition1">((A:AUTOPILOT MASTER,bool) 0 ==)</Macro><Macro Name="Condition2">((A:Eng1 On Fire, bool))</Macro><Macro Name="Condition3">((A:Eng2 On Fire, bool))</Macro><Macro Name="Condition4">((A:Apu On Fire Detected,bool))</Macro><Macro Name="Condition5">((A:Eng1 Oil Pressure, PSF))</Macro><Macro Name="Condition6">((A:Eng2 Oil Pressure, PSF))</Macro><Macro Name="Condition7">((A:AUTOPILOT AIRSPEED HOLD,bool) 0 ==)</Macro><Macro Name="Condition8">((A:General Eng Fuel Pressure:1, PSF) 720 <)</Macro><Macro Name="Condition9">((A:General Eng Fuel Pressure:2, PSF) 720 <)</Macro><Macro Name="Condition10">((A:Spoilers Left Position,percent) 							(A:Spoilers Right Position,percent) + 0 >							(A:Sim On Ground,bool) 							and s0							(A:General Eng Throttle Lever Position:1,percent) 							(A:General Eng Throttle Lever Position:2,percent) + 2 /							82.0 > l0							and							)	</Macro><Macro Name="Condition11">((L:Gear_Warning))</Macro><Macro Name="Condition12">((A:Spoilers Armed,bool))</Macro><Macro Name="Condition13">((A:Exit Open:0,bool)							(A:Sim On Ground,bool) 							and							)	</Macro>

Next we need to set up some "Message" <Macro>s

	<!-- XXXXXXXXXXXXXXXXXXXXXXXXX EICAS MESSAGE MACROS XXXXXXXXXXXXXXXXXXXXXXXXXXXX --><!-- RED TEXT --><Macro Name="Message1">AUTOPILOT DISC</Macro><Macro Name="Message2">L FIRE</Macro><Macro Name="Message3">R FIRE</Macro><Macro Name="Message4">APU FIRE DET</Macro><Macro Name="Message5">L OIL PRESS LOW</Macro><Macro Name="Message6">R OIL PRESS LOW</Macro><!-- ORANGE TEXT --><Macro Name="Message7">AUTOTHROTTLE DISC</Macro><Macro Name="Message8">L FUEL PRESS LOW</Macro><Macro Name="Message9">R FUEL PRESS LOW</Macro><Macro Name="Message10">SPOILERS EXT</Macro><Macro Name="Message11">GEAR</Macro><!-- WHITE TEXT --><Macro Name="Message12">AUTOSPLR ARMED</Macro><Macro Name="Message12">ENTRY DOOR</Macro>

Finally, we set up the <FormattedText> section where all the magic happens!

<!-- XXXXXXXXXXXXXXXXXXXXXXXXX EICAS MESSAGES XXXXXXXXXXXXXXXXXXXXXXXXXX --><Element>	<Position X="730" Y="56"/>	<FormattedText X="182" Y="210" Font="Arial Bold" FontSize="16" Adjust="Left" Color="#DE243B" Bright="Yes">		<Color Value="#ECB226"/>		<Color Value="#FFFFFF"/>						<String>			<!-- RED TEXT -->			%@Condition1%{if}@Message1\n%{end}			%@Condition2%{if}@Message2\n%{end}			%@Condition3%{if}@Message3\n%{end}			%@Condition4%{if}@Message4\n%{end}			%@Condition5%{if}@Message5\n%{end}			%@Condition6%{if}@Message6\n%{end}			<!-- ORANGE TEXT -->			\{clr2}			%@Condition7%{if}@Message7\n%{end}			%@Condition8%{if}@Message8\n%{end}			%@Condition9%{if}@Message9\n%{end}			%@Condition10%{if}@Message10\n%{end}			%@Condition11%{if}@Message11\n%{end}			<!-- WHITE TEXT -->			\{clr3}			%@Condition12%{if}@Message12\n%{end}		</String>	</FormattedText></Element>

Each section of a line begins with a percent sign (%). The % symbol means "evaluate what follows and execute it."%@Condition1 // evaluate the contents of the @Condition1 macro and execute%{if}@Message1\n // if the results of the previous is TRUE, then print the contents of @Message1 then create a new line%{end} // we are done with this operation, move on to the next operation\{clr2} // use the first "alternate color"\{clr3} // use the second "alternate color"

Share this post


Link to post
Share on other sites

Fr. BillI use something similar, only to have the conditions in an <update> section.In total there are over 200 possibility's divided in different sections like "elec", "hyd", "pneum" etc. etc. so easy for maintanance.In the Formattedtext I add Linewidth, so the total length of the text section is known.Now when disasters, and thus messages, overflow. you can <shift> the whole textsection with a knob (in the 767 the "repeat and cancel buttons") so that it looks like you see different pages.I add per shift page1, page2, page3 etc.The amount of <Shift> depends of the amount of textlines you want to have visible at one time on the Eicas. Say max lines visible is 10 and linewidth=15, then you have to shift 10*15 forth and back.Add a <Clip> to hide the text outside the MFD screen.Works very satisfactory.Hope it helps,Jan

Share this post


Link to post
Share on other sites