King Air C90 Annunciator Panel

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Message
Author
Ccard3dev
Posts: 4
Joined: Thu Oct 31, 2019 2:41 pm

King Air C90 Annunciator Panel

#1 Post by Ccard3dev »

Hello!

I am making a King Air C90 cockpit and the only instrument I couldn't find in AirManager is the annunciator panel. I would like to replicate the annunciator panel exactly as shown in the attachment. I am good with graphic design, however I have no experience with programming or Lua. If anyone has any tips on how to get started with coding this project, I would appreciate it. I can also pay if someone was willing to do the coding for me.

Thanks!
C90 Annunciator.png

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

Re: King Air C90 Annunciator Panel

#2 Post by Keith Baxter »

hI,


Yes we can put you on the road to making your own instruments.

Have you been through these tutorials?

viewtopic.php?t=2787


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 

JackZ
Posts: 2266
Joined: Mon Feb 22, 2016 1:02 pm

Re: King Air C90 Annunciator Panel

#3 Post by JackZ »

An annunciation panel is quite complicated to achieve.
This as because it acts like a finite state machine with lots of conditions for each :lighted, unlighted, test, and of course the presence of power.
And it has to be tied to the master warning light as well.
If you have all the data refs available for all of the functions it’s slightly easier otherwise it can be a nightmare.

I had done one last year a similar panel for the GA73 based on an FSX C406 from Carenado, with most of the functions not implemented at all or not available through Lvars. Was quite an endeavour.
Ended up by using Binary operations on an 8 digit byte that represented the current status of each light, so a new failure would “add” to the failure queue and the warning light would still be on, while retaining its state even if one of the failure was not longer active.
With 8 digits one could handle up to 256 annunciator lights.

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

Ccard3dev
Posts: 4
Joined: Thu Oct 31, 2019 2:41 pm

Re: King Air C90 Annunciator Panel

#4 Post by Ccard3dev »

Keith Baxter wrote: Sat Jan 08, 2022 1:15 am hI,


Yes we can put you on the road to making your own instruments.

Have you been through these tutorials?

viewtopic.php?t=2787


Keith
Thank you very much for sharing! I was not aware of the tutorials, it helped immensely!

Ccard3dev
Posts: 4
Joined: Thu Oct 31, 2019 2:41 pm

Re: King Air C90 Annunciator Panel

#5 Post by Ccard3dev »

JackZ wrote: Sun Jan 09, 2022 8:41 am An annunciation panel is quite complicated to achieve.
This as because it acts like a finite state machine with lots of conditions for each :lighted, unlighted, test, and of course the presence of power.
And it has to be tied to the master warning light as well.
If you have all the data refs available for all of the functions it’s slightly easier otherwise it can be a nightmare.

I had done one last year a similar panel for the GA73 based on an FSX C406 from Carenado, with most of the functions not implemented at all or not available through Lvars. Was quite an endeavour.
Ended up by using Binary operations on an 8 digit byte that represented the current status of each light, so a new failure would “add” to the failure queue and the warning light would still be on, while retaining its state even if one of the failure was not longer active.
With 8 digits one could handle up to 256 annunciator lights.

Jacques
I did some digging in the files for the Laminar Research King Air C90B and under /King Air C90B/plugins/xlua/scripts/C90sys/c90sys.lua it lists every data ref for the annunciator panel. This made it super easy, much less complicated than I was expecting. Thank you Laminar for taking the guesswork out! Anyways I was able to finish it in a few hours, here's a pic of the finished product connected to X-Plane. Went with a different style, similar to what is installed on the King Airs at the company I work for.
IMG_1121.jpeg

JackZ
Posts: 2266
Joined: Mon Feb 22, 2016 1:02 pm

Re: King Air C90 Annunciator Panel

#6 Post by JackZ »

Nice!
If the individual Datarefs were already available, then the inner logic is way simpler, that was not the case in my previous project based on FSX.
XPlane is in general way more advanced/user friendly in terms of interfacing for a home cockpit.

Guess that you’ve included the test switch and the dim/bright version of the annunciators.
There’s nothing better than your own developed product. Good work, looking forward to see your finished instrument in the store.

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
jph
Posts: 2853
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: King Air C90 Annunciator Panel

#7 Post by jph »

Hi @Ccard3dev and @JackZ
Firstly, to Ccard3dev, nice work !
I don't, and never have professed for one minute to be a competent LUA programmer compared, by any metric, to some of the guys here - so thanks for pointing out the LUA files within the aircraft folders in X-Plane - Most excellent and extremely useful. I had previously never actually considered looking at those valuable resources to assist in formulating a programming plan in AM, and, also for the data references both standard and custom that are used. Excellent !

Can I just ask a few questions about this line ? - PLEASE NOTE - this is just one line picked at random - simply as an example to help my understanding.

Code: Select all

-- DC GEN L
C90.warning.dc_gen_L = C90_ternary(simDR_annun_gnerator_off[0] > 0, 1, 0)
Can you clarify or otherwise explain the following please. (I am talking about the X-P lua - and realise the logic / values have to be translated / adapted to your AM code)

I presume there is a function somewhere called C90_ternary and that the simDR_annun_gnerator_off[0] is a custom dataref ? - with the [0] being engine 1 ? and that the > 0,1,0 is a return from function value based on evaluation of relationship of the 1st of the three values - of which (the first of the values) is the return from the dataref - and that the following 2 values are the value to be assigned to the variable C90.warning.dc_gen_L depending on the value of the such return. so >0 = 1 and not>0 = 0
Would this be correct ? - and if so, where is the function for C90_ternary(......) ? - which would appear to be 'FIF' or FIF like ? (afaik Lua does not have a native ternary ?) - so one must be being emulated as per logical operators such as 'and' 'or' etc - or - indeed a FIF like operation within a function etc.

Many thanks and apologies if I am being clueless as it would be nothing new :)
Joe
Joe. CISSP, MSc.

Ccard3dev
Posts: 4
Joined: Thu Oct 31, 2019 2:41 pm

Re: King Air C90 Annunciator Panel

#8 Post by Ccard3dev »

Hello!

I am brand new to Lua, so I don't have any idea what that code is you sent lol.

What I can say though is in the C90_sys.lua file there is a section called:
"CREATE READ-ONLY CUSTOM DATAREFS"

If you scroll down there is a section with all the annunciators listed as such:
C90DR_lighting_annun_dc_gen_L = create_dataref("laminar/c90/lighting/annun/dc_gen_L", "number")

So here is an example of how to use this in AirManager (and bear in mind I'm sure there are more efficient ways to program this but I am a beginner so I did what I could lol):

Code: Select all

--defines background image with all annunciators off
offimg = img_add_fullscreen("OFF.PNG")

--defines illuminated image, cropped to just the L DC Gen
lgenimg = img_add("ON.PNG", 0, 0, 1280, 90)
viewport_rect(lgenimg, 0,31,85,28)
visible(lgenimg, false)

--turns on the illuminated image for L DC Gen when the sim says it should be on
-- for this aircraft all the annunciators are 0 = off 1 = on
 function lgen_callback(lgen)
     if (lgen == 1) then visible(lgenimg, true) else visible(lgenimg, false) end
 end

-- links to data ref
  xpl_dataref_subscribe("laminar/c90/lighting/annun/dc_gen_L", "int", lgen_callback)

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

Re: King Air C90 Annunciator Panel

#9 Post by Keith Baxter »

Hi,

@Ccard3dev This is another way of doing it.
I know that your dataref returns a value of 0 or 1 but sometimes one has the option to dim the annunciator at night because it is too bright. For that we use opacity()

Try this code and see if it works for you. It is optimized.

You can remove the opacity if you want and use visible ,but opacity works just as well.

Code: Select all

--defines background image with all annunciators off
offimg        = img_add_fullscreen("OFF.PNG")

--defines illuminated image, cropped to just the L DC Gen
lgenimg       = img_add("ON.PNG", 0, 0, 1280, 90) opacity(lgenimg, 0)   --visible(lgenimg,false)
Rgenimg       = img_add(nil     , 0, 0, 1280, 90) opacity(Rgenimg, 0)   --visible(Rgenimg,false)
APimg         = img_add(nil     , 0, 0, 1280, 90) opacity(APimg, 0)     --visible(APimg,false)

viewport_rect(lgenimg, 0,31,85,28)

--turns on the illuminated image for any annunciator when the sim says it should be on
xpl_dataref_subscribe("laminar/c90/lighting/annun/dc_gen_L","INT",
                      "laminar/c90/lighting/annun/dc_gen_R","INT",
                      "laminar/c90/lighting/annun/ap_fail","INY",function(dc_gen_L,dc_gen_R,ap_fail)
    opacity(lgenimg, dc_gen_L)
    opacity(Rgenimg, dc_gen_R)
    opacity(APimg, ap_fail)

--visible(lgenimg,dc_gen_L == 1)
--visible(Rgenimg,dc_gen_R == 1)
--visible(APimg,ap_fail == 1)
end)

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
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: King Air C90 Annunciator Panel

#10 Post by Keith Baxter »

Hi,

I did the basic coding (and tested) of one of the ways i would do this type of instrument, (There are other ways) so that you can get the gist of how the coding could be.

Feel free to use and you can alter and add extra graphics should you want.
C90 - Annunciator Panel.siff
(52.71 KiB) Downloaded 121 times

Keith
Last edited by Keith Baxter on Tue Jan 11, 2022 6:48 am, edited 1 time in total.
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 

Post Reply