Inter Instrument API functions

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
User avatar
Sling
Posts: 5239
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Inter Instrument API functions

#1 Post by Sling »

I have used the AM variables a few times before but always as one way communication ( 1 instrument creates and writes, the other(s) subscribe to the var).

Now I have a need to use the same var both ways (any instrument can read or write the var)
The wiki example only demonstrates the first case.

Code: Select all

-- Create a new AM variable
var_id = am_variable_create("my_variable", "FLOAT", 1.5)

-- Changed my mind, I want it to be 2.5
am_variable_write(var_id, 2.5)
To get this to work I have to create the same var in each instrument to get the ability to write working. I think this is because we can't use the var name ("my_variable" in the example) within the am_variable_write function as it requires an id. so to write, each instrument needs to create its own id for the same variable.

This seems a little weird as I was expecting it to behave in a similar fashion to writing a sim variable such as xpl_dataref_write where the creation is already done within the sim and we write directly to it or subscribe to it for a read. IMHO It would simplify things if we could do this.

Code: Select all

am_variable_write("my_variable", 2.5)

User avatar
Sling
Posts: 5239
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Inter Instrument API functions

#2 Post by Sling »

Anyone have any thoughts on this?

User avatar
Corjan
Posts: 2939
Joined: Thu Nov 19, 2015 9:04 am

Re: Inter Instrument API functions

#3 Post by Corjan »

Hi,


Sorry for not responding.

Like you said, the 'am_variable_write' function behaves different then a normal xpl_dataref_write.

The 'xpl_dataref_write' is a stateless function, this means that a write packet will be sent to the X-plane plugin. If there is no connection to X-plane at that time, this message is lost.

The 'am_variable_write' is different. The written value will stay cached in Air Manager itself, even when there is non flight sim connection. Air Manager will constantly try to get that value to the plugin.
This does mean that there should only be one instrument that determines every variable.
The big upside is that you don't have to worry about flight simulation connection in the instrument.


Hope this makes sense,

Corjan

Post Reply