koesie10 / fsuipc-node

Native Node module for interfacing with FSUIPC
MIT License
17 stars 14 forks source link

Event Listeners/Emitters #32

Closed Ben-LucaKoerber closed 10 months ago

Ben-LucaKoerber commented 10 months ago

Hey Koesi10 :) I wanted to use the fsuipc-node in a custom tracking project which final goal is to build a flight tracking software for a virtual airline. Polling data in given intervalls works great, but the functionality is a little limited if there are no event listeners (Fsuipc SDK calls it event.offset) for offsets available. Is there any way to implement this in your module?

Thanks for your answer in advance. Merry christmas.

Ben-LucaKoerber commented 10 months ago

I found a source in the fsuipc forum where a simple lua script starts eventdriven:

function logvs(off, val) if val ~= 0 then -- if on ground flag just set, get VS, convert it and log it vs = ipc.readSD(0x030C) vs = vs 60 3.28084 / 256 ipc.log("Vertical speed at touchdown = " .. vs) end end

-- set to call above routine whenever "on ground" flag changes event.offset(0x0366, "UW", "logvs")

koesie10 commented 10 months ago

As far as I am aware, there is no functionality for event listeners outside of Lua scripts. See also this comment on the FSUIPC forum. The only way to respond to changes is by keeping track of the old value and checking if thas changed when you call process(). The ValueChanged property mentioned on the forum is specific to the C# library and does not exist within FSUIPC itself.

If you want to use event listeners and do not need to support older simulators, SimConnect does support notifications on changes.