Board index FlightGear Development Nasal

[Help Request] Vectors, Hashes

Nasal is the scripting language of FlightGear.

[Help Request] Vectors, Hashes

Postby legoboyvdlp » Mon Apr 09, 2018 3:43 pm

Hi there,
I'm developing the ECAM system for the Airbus.

I have no problem with actually making the messages and displaying them, but I have not a clue how to start with prioritizing and displaying them below each other if multiple messages are active, based on priority!
Image

Essentially, what I need is a hash as far as I know:
Code: Select all
active_messages = [];


I already have a hash that lists all the possible messages, e.g.:
Code: Select all
messages = [
message.new(name: "RAM AIR P/B ON", text: "RAM AIR ON", priority: 5, logic_prop: "/controls/pneumatic/switches/ram-air", color: 4, display: 2),
message.new(name: "EMERGENCY GENERATOR", text: "EMER GEN", priority: 5, logic_prop: "/controls/electrical/switches/emer-gen", color: 4, display: 2),
message.new(name: "GROUND SPOILERS ARMED", text: "GND SPLRS ARMED", priority: 5, logic_prop: "/controls/flight/speedbrake-arm", color: 4, display: 1)];

There is probably a more efficient way to add the messages to that list, but for now, that isn't important

I want to ADD any message from the messages list to the active_messages lsit if the logic_prop is TRUE, and REMOVE it if it is no longer true. I need to be able to display them in order: for example,
Code: Select all
setprop("/ECAM/line[" ~ active_messages.id ~ "]", "b");

That is, for the first active message, sorted by priority, I want to setprop it to the first line. Then the next one in active_messages is setproped to the second line.

I would appreciate any advice or hints as to how to even start!
Please ask me for more information if you do not understand what I am asking or describing ;)
Jonathan

PS. In future I am not working on such a complex aircraft as the Airbus :mrgreen:

3736 pages of documentation of the ECAM logic alone...

Image
User avatar
legoboyvdlp
 
Posts: 7981
Joined: Sat Jul 26, 2014 2:28 am
Location: Northern Ireland
Callsign: G-LEGO
Version: next
OS: Windows 10 HP

Re: [Help Request] Vectors, Hashes

Postby Thorsten » Mon Apr 09, 2018 5:21 pm

There's several ways to skin the cat - you could make one array of each priority and when you have to display loop through the highest priority one till it's empty of active messages and all have been moved to the active array, then proceed to the next array.

Or you could loop once through the whole array, find the highest active priority, do a second pass through the array and display the matching messages, then repeat. Less efficient of course...

I'd probably go for the 'one array for every priority class' solution.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: [Help Request] Vectors, Hashes

Postby legoboyvdlp » Tue Apr 10, 2018 12:46 am

The second might work best, since there can be multiple priorities visible at once, depending on the length of the troubleshooting steps displayed...

Thanks for your advice, researching arrays!
User avatar
legoboyvdlp
 
Posts: 7981
Joined: Sat Jul 26, 2014 2:28 am
Location: Northern Ireland
Callsign: G-LEGO
Version: next
OS: Windows 10 HP

Re: [Help Request] Vectors, Hashes

Postby jsb » Thu Apr 26, 2018 10:41 pm

Hi
I almoste finished the EFIS/EICAS for the CRJ700. You may want to have a look at the EICAS message system I wrote. I guess it will not fit 100% but might give you some hints.
jsb
 
Posts: 285
Joined: Sat Oct 25, 2014 9:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: [Help Request] Vectors, Hashes

Postby legoboyvdlp » Fri Apr 27, 2018 1:01 am

Hi there,
Thank you very much! Would you mind linking your repository?

Best,
Lego
User avatar
legoboyvdlp
 
Posts: 7981
Joined: Sat Jul 26, 2014 2:28 am
Location: Northern Ireland
Callsign: G-LEGO
Version: next
OS: Windows 10 HP


Return to Nasal

Who is online

Users browsing this forum: No registered users and 2 guests