ZIBO speed breaks

Support for Arduino in combination with Air Manager and Air Player

Moderators: russ, Ralph

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

Re: ZIBO speed breaks

#41 Post by Keith Baxter »

Gilles,

I asked Corjan for a dataref throttle to restrict the amount of dataref fires and force calls. He provided this very useful bit of code which i manipulate and use in many instruments. Mostly CAS systems and instruments that need |dampening. :D

https://www.forums.siminnovations.com/v ... 769#p31769

So what happens is the callback fires the dataref call every 1000 ms. You can change that. Very useful bit of code for large dataref busses

Keith
Last edited by Keith Baxter on Mon Nov 21, 2022 1:04 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 

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: ZIBO speed breaks

#42 Post by SimPassion »

Thanks Keith, I've missed this parts
I will try to figure out what's involved

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

Re: ZIBO speed breaks

#43 Post by Keith Baxter »

SimPassion wrote: Mon Nov 21, 2022 1:04 am Thanks Keith, I've missed this parts
I will try to figure out what's involved
No worries Gilles,

Just a bit of simple explanation for all on what we talk....
I know after reading you understand

https://www.mendix.com/blog/asynchronou ... ogramming/


So our standard coding is Synchronous (single threading) {blocking} . When we use "inline functions" ""as we call them"" then that is Asynchronous coding (multi threading) {non-blocking }

Do we see a difference in AM ? I think that depends on ones system and size of the instrument/panel.

Anyway, nice discussion and lots to think about when coding and creating one's dreams.
And sorry for taking this thread OT, :oops:



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 

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: ZIBO speed breaks

#44 Post by SimPassion »

Just to be aware @Corjan, on AM insights, did you made it working on any platform for AM ?

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

Re: ZIBO speed breaks

#45 Post by jph »

Keith Baxter wrote: Mon Nov 21, 2022 1:12 am
So our standard coding is Synchronous (single threading) {blocking} . When we use "inline functions" ""as we call them"" then that is Asynchronous coding (multi threading) {non-blocking }

Keith
There is no logic or reason to what you are saying. It makes no sense in an AM coding context. ;) You appear to be taking small snippets from various places and adding 2 + 2 to become 5. Mixing and matching non related terms that are out of context :lol:
Definitely need more water with it :mrgreen:
Joe. CISSP, MSc.

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

Re: ZIBO speed breaks

#46 Post by Keith Baxter »

Joe,

I can assure you what I say is fact.

Take some time to read this. :mrgreen:

https://siminnovations.com/wiki/index.p ... _data_load

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
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: ZIBO speed breaks

#47 Post by jph »

:shock: :? ;)
Hi Keith
You have linked to a file load example that is fairly standard - yet out of context. .... what about your
"inline functions" ""as we call them"" then that is Asynchronous coding (multi threading)
in relation to
our standard coding is Synchronous (single threading)
Are you getting into the realms of lua coroutines being in play here.. ? - if so, where are they in play in your example above and how do you differentiate the two ?
Joe. CISSP, MSc.

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

Re: ZIBO speed breaks

#48 Post by Keith Baxter »

Joe.

Lets look at this bit of code. This is Synchronous coding, The loading of <map_boundrys_data> will not start until <map_level1_data> has finished loading.

Code: Select all

map_level1_data = static_data_load("110_world.json")
if map_level1_data ~= nil then
	print("The Map level 1 data has loaded")
end

map_boundrys_data = static_data_load("110_country_boundries.json")
if map_boundrys_data ~= nil then
	print("The Country Boundries data has loaded")
end

water_data = static_data_load("110_lakes.json")
if water_data ~= nil then
	print("The Water data has loaded")
end
Now lets look a a simple HW switch. This is also Synchronous coding and is the standard code method that AM uses. So while this switch code is running then all other processes will be halted

Code: Select all

-- This function is called every time the switch has a new position
function switch_callback(position)
  print("The switch got changed to position " .. position)
end

-- Create a new 3 position switch with Synchronous coding
hw_switch_add("Ignition", 3, switch_callback)

Now lets look at that same simple HW switch but this time using Asynchronous coding. While this switch code is running in the background then other processes will NOT be halted.

Code: Select all

-- This function is called every time the switch has a new position

-- Create a new 3 position switch with Asynchronous coding.
hw_switch_add("Ignition", 3, function(position)
  print("The switch got changed to position " .. position)
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
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: ZIBO speed breaks

#49 Post by jph »

Hi Keith,
Due to the action of the main AM program then I can accept that the first example of the choice of mode of background loading of data is non blocking.

As for the other examples of the switch then I do not see how they would be any different apart from a more convenient (to some people) way of writing the script.
I would imagine the operation of the two switch examples at code level is identical.
Perhaps @Corjan could comment ?

Joe
Joe. CISSP, MSc.

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

Re: ZIBO speed breaks

#50 Post by Keith Baxter »

jph wrote: Mon Nov 21, 2022 2:15 pm Hi Keith,
Due to the action of the main AM program then I can accept that the first example of the choice of mode of background loading of data is non blocking.

As for the other examples of the switch then I do not see how they would be any different apart from a more convenient (to some people) way of writing the script.
I would imagine the operation of the two switch examples at code level is identical.
Perhaps @Corjan could comment ?

Joe
Joe,

For one or two switches you are correct. There would be very little or no benefit at all.
However, when we start talking of large instruments that are loading and reading sim data then Asynchronous is very much the method of choice.

If you have been privileged to have Corjan help you with some coding he has mostly used Asynchronous coding. I asked him why and he told me what I tell you.

This image enplanes how the two work. Synchronous (left side) has to step through where as Asynchronous (right side) does not wait and communication happens in the background.

ice_screenshot_20221121-162544.png
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