Dataref subscribe and timers

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

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

Re: Dataref subscribe and timers

#11 Post by Ralph »

That only makes it more complex in my opinion.
I had a look at your script, but it doesn't make much sense to me :)

If you just explain what needs to happen then I'll make a small example.

erj145sim
Posts: 34
Joined: Mon Feb 10, 2020 1:03 pm

Re: Dataref subscribe and timers

#12 Post by erj145sim »

Yeah, I thought it may be confusing. Add to that my inexperience writing code and you probably have very inefficient code... but here’s what I’m trying to do:

I have an APU indicator on the EICAS.
When the APU switch is in OFF position (Dataref=0), It reads OFF
When the switch is turned to ON (Dataref=1), the indicator changes to yellow and blinks 5 times at a 0.5s rate, then remains steady.
When APU switch is turned to START (Dataref = 2 (temporary), it remains on until APU N1 = 95%, then I turns back green.

That’s what I’m trying to accomplish. Thanks for sticking with me!

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

Re: Dataref subscribe and timers

#13 Post by Ralph »

Okay that's a good description. I'll create a script tonight or tomorrow.

erj145sim
Posts: 34
Joined: Mon Feb 10, 2020 1:03 pm

Re: Dataref subscribe and timers

#14 Post by erj145sim »

Thanks Ralph. I forgot to list the last state, which may impact the script (although it is past the timer piece). Here’s a revised description:

I have an APU indicator on the EICAS.
When the APU switch is in OFF position (Dataref=0), It reads OFF in green.
When the switch is turned to ON (Dataref=1), the indicator changes to yellow and blinks 5 times at a 0.5s rate, then remains steady.
When APU switch is turned to START (Dataref = 2 (temporarily)) the indicator remains on and yellow until APU N1 = 95%, then it turns back green.
Since the START position is momentary, the Dataref will revert back to 1 while the APU spools-up and remains=1 while the APU is running (I.e. Dataref=1 and indicator is steady yellow until APU N1 >= 95% changes the annunciator back to green.

So the conditions I had identified are
If APU N1 = 0 and APU Starter = 0, the APU is OFF
If APU N1 = 0 and APU Starter = 1, the APU is in pre-start (blinking piece)
If APU N1 > 0 and APU Starter = 2, the APU is starting
If APU N1 > 0 and APU Starter = 1, the APU is running

I hope this helps.

Marco

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

Re: Dataref subscribe and timers

#15 Post by Keith Baxter »

Hi Marco,

Did you check if there is a blink dataref for your bird?

I know that the zibo 737 800 has a "laminar/B738/autopilot/blink" dataref. Might be that your bird has something similar. That would be first prize before doing some coding to achieve what you want.

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 

erj145sim
Posts: 34
Joined: Mon Feb 10, 2020 1:03 pm

Re: Dataref subscribe and timers

#16 Post by erj145sim »

Hey Keith!

Thanks for the reply. I went back and checked and it actually does have such a dataref! I will see if I can use that - and see if I can spare from spending his evening trying to figure this out!

I'l report back as soon as I have news.

Thanks again, guys!

Marco

erj145sim
Posts: 34
Joined: Mon Feb 10, 2020 1:03 pm

Re: Dataref subscribe and timers

#17 Post by erj145sim »

I meant I hope to spare RALPH from spending the night working on a solution! (Although I’ll keep trying to figure out how to do it in code using standard datarefs anyway...)

M.

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

Re: Dataref subscribe and timers

#18 Post by Keith Baxter »

Hi Marco,

That is easy if you are blinking and image.
Here play around with this.


Code: Select all

my_image=img_add("my_image",x,y,w,h,)
function blink_callback(blk)
	visible(my_image, blk==1)
end

xpl_dataref_subscribe(your_dataref,blink_callback)


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 

erj145sim
Posts: 34
Joined: Mon Feb 10, 2020 1:03 pm

Re: Dataref subscribe and timers

#19 Post by erj145sim »

Keith - it works like a charm!

I feel so inadequate sometimes - my lack of acumen is revolting! :D
But - hey - I'm learning!

I'll post a video somewhere and share a link here soon. Here are some pics of my work in progress.

Thanks again!

Marco
IMG_4121.jpeg
IMG_4122.jpeg
IMG_4124.jpeg
IMG_4125.jpeg
IMG_4124.jpeg

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

Re: Dataref subscribe and timers

#20 Post by Keith Baxter »

Awesome Marco,

Glad you are winning.

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 

Post Reply