Archived

This topic is now archived and is closed to further replies.

Jofre

Detect plane shutdown/change from gauge

Recommended Posts

Hi,I´m building a gauge using C and I´d like to detect when the user is shooting down the plane.My gauge is open some network connection I´d like to close them properlyIs there a function called when the plane is being shutdown?Thanks in advanceJofre

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

You would have to define conditions for when the plane is shut down and then test them.For example, the plane could be considered shut down when all engines have 0 rpm and the main bus voltage is 0.But maybe you want to test the magnetos or fuelvalve as well.If you want to detect the moment the plane is shut down you can use a variable to record the previous state.You first determine the plane's current state and compare it to the previous state.If they are the same nothing has happened, if they are different the plane has just changed it's state.Then you write the current state into the previous state variable for the next iteration.

Share this post


Link to post
Share on other sites
Hi,I´m building a gauge using C and I´d like to detect when the user is shooting down the plane.My gauge is open some network connection I´d like to close them properlyIs there a function called when the plane is being shutdown?Thanks in advanceJofre
1. There is a dedicated forum for technical questions named MSFS Aircraft and Panel Design Forum, where such questions are best asked. Many folks who are gauge/panel systems developers don't follow this forum all that closely... :( 2. You will need to need to set up a callback to the sim's "Panel_Service" function, and place your "disconnect routine(s)" here:
void FSAPI gaugecall(PGAUGEHDR pgauge, int service_id, UINT32 extra_data){	switch(service_id)	{		case PANEL_SERVICE_CONNECT_TO_WINDOW:			/* START UP STUFF GOES HERE! */		break;		case PANEL_SERVICE_DISCONNECT:			/* SHUT DOWN STUFF GOES HERE! */		break;	}}

See the SDK's gauges.h file for a complete list of Panel_Service case events.

Share this post


Link to post
Share on other sites