CAS Messages

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Message
Author
Shimokuta
Posts: 113
Joined: Wed Feb 03, 2021 12:52 pm

Re: CAS Messages

#11 Post by Shimokuta »

jph wrote: Tue Dec 07, 2021 4:16 pm
Keith Baxter wrote: Tue Dec 07, 2021 1:53 pm
BTW I drink Amstel beer if ever you come out to ZAR :lol: :lol:
EachDiligentGoral-size_restricted.gif
i will take some with me from then Netherlands!!
Or even better...Bavaria!!

Shimokuta
Posts: 113
Joined: Wed Feb 03, 2021 12:52 pm

Re: CAS Messages

#12 Post by Shimokuta »

I just did al little test with parking brake CAS messages, great success!!
Didn't know about the table option in LUA but this is great!


Thanks for the help.

(small part of my test)

Code: Select all

function callback_w_cas(pitch_trim, flaps, spoilers, aileron_trim, rudder_trim, parkbrk, N11, N12, gear, oilp1, oilp2)

-- CAS Parking Break

if parkbrk == false then
  CAS_prk_white = false  
  CAS_prk_red = false
else
  CAS_prk_white = true
end

if  (N11 >= 35 or N12 >=35)  and parkbrk == true then
   CAS_prk_red = true
   CAS_prk_white = false
 end
 
 if  (N11 <= 35 or N12 <=35) and parkbrk == true then
    CAS_prk_white = true
	CAS_prk_red = false
 end
 

local casW_list ={}
	if CAS_prk_red == true         then table.insert(casW_list,bell_casW_alerts[1])end --EMER/ PARK BRake red
	if CAS_prk_white == true      then table.insert(casW_list,bell_casW_alerts[2])end ---EMER/ PARK BRake white

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: CAS Messages

#13 Post by Keith Baxter »

Shimokuta wrote: Tue Dec 07, 2021 8:10 pm I just did al little test with parking brake CAS messages, great success!!
Didn't know about the table option in LUA but this is great!


Thanks for the help.

(small part of my test)

Code: Select all

function callback_w_cas(pitch_trim, flaps, spoilers, aileron_trim, rudder_trim, parkbrk, N11, N12, gear, oilp1, oilp2)

-- CAS Parking Break

if parkbrk == false then
  CAS_prk_white = false  
  CAS_prk_red = false
else
  CAS_prk_white = true
end

if  (N11 >= 35 or N12 >=35)  and parkbrk == true then
   CAS_prk_red = true
   CAS_prk_white = false
 end
 
 if  (N11 <= 35 or N12 <=35) and parkbrk == true then
    CAS_prk_white = true
	CAS_prk_red = false
 end
 

local casW_list ={}
	if CAS_prk_red == true         then table.insert(casW_list,bell_casW_alerts[1])end --EMER/ PARK BRake red
	if CAS_prk_white == true      then table.insert(casW_list,bell_casW_alerts[2])end ---EMER/ PARK BRake white
Hi,

Yes that is the idea.
Happy to share my code and ideas, glad the table pointer brought another aspect to your instrument coding. When I first did this code @Sling had a input into the list stacking used in the canvas_draw(). I had a math brain fade issue which eh helped me on. Enjoy the new discovery and produce awesome instruments.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Ralph
Posts: 7924
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: CAS Messages

#14 Post by Ralph »

I'm a bit of a brute force scripter I suppose, not that elegant :) But I would think of an array in an array. The array inside the array would consist of 3 items:
- A tag to refer to (string)
- The warning displayed (string)
- Type of message, warning, caution, etc (integer maybe?)
Maybe as a 4th an importance level for that type, if that exists.

Then you can just add to that list without worrying about the order.

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: CAS Messages

#15 Post by Keith Baxter »

Ralph wrote: Tue Dec 07, 2021 9:31 pm I'm a bit of a brute force scripter I suppose, not that elegant :) But I would think of an array in an array. The array inside the array would consist of 3 items:
- A tag to refer to (string)
- The warning displayed (string)
- Type of message, warning, caution, etc (integer maybe?)
Maybe as a 4th an importance level for that type, if that exists.

Then you can just add to that list without worrying about the order.
100% Ralph. I actually changed the tables to .json file. Might be the next level for some. It can also be done as you say.

Trying to feed the peeps in and let their imagination flow. Depends on coding skills. Your suggestion is an efficient option. The skills level on creating those tables multiple levels and manipulation will come with experience.

Just the beginning of A coding technique for those wanting to venture into some advanced techniques.

I am just a third year apprentice into a five year journeyman ship. 😎

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Ralph
Posts: 7924
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: CAS Messages

#16 Post by Ralph »

You could also create separate arrays for each message. Then inject them on the fly as jph suggested. That might be a more elegant solution.
As Keith said, many possible approaches.

Post Reply