From X-Plane SDK
Jump to: navigation, search

Processing APIs

About the Processing APIs

X-Plane's processing APIs allow the registration of callbacks that are run periodically while X-Plane flies.

Processing callbacks run between the flight model computing and the drawing happening. We may not draw from a processing callback. (If we do the results will not be seen.) To draw, register a drawing callback, explained in the user interface and graphics chapters. Unlike drawing callbacks, processing callbacks are always called no matter what view the user is looking at. Processing callbacks run when the sim is paused but do not run when an X-Plane modal window is visible.

Processing callbacks can be scheduled by time in fractional seconds (independent of simulator frame rate) or in terms of simulator cycles. Simulator cycles may fluctuate; scheduling in cycles gaurantees synchronization with the simulator, while scheduling in seconds gaurantees consistent timing. We cannot receive callbacks faster than the simulators frame rate even if we schedule a shorter callback time. Time-based callbacks run at the first simulator cycle at or after their scheduled time.

The plugin schedules processing time by registering a _processing callback _ and specifying the interval that it should run at. Positive durations indicate scheduling in seconds. Negative durations indicate the negative of the number of simulator frames. A scheduling period of zero stops the callback from processing.

The callback may call any SDK functions from the processing callback except for drawing functions and functions to change the callbacks period. To change the callbacks period from inside the callback, return the new preferred callback time.

Using the Processing APIs

To use the processing APIs, we must write a processing callback and register it.

< Sample Code: a start routine that registers a callback, finds a dataref, opens a file, and a callback to write the file. A shutdown routine to clean up.>

Processing API Reference

For more information, see the XPLMProcessing API reference.