Sign in to follow this  
Guest JeanLuc_

Detecting current view in a gauge

Recommended Posts

Is there a way to detect if we are inside or outside the plane with a gauge ? (to switch cockpit sound off/on)I counted on the predraw callback while I think that fs2002 should make a difference and not draw the gauge if the panel isn't displayedbut no luck on this one.Thanks Dan

Share this post


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

I haven't tried recently, but PRE_DRAW is accessed only when the panel is visible, whereas PRE_UPDATE is accessed all the time (18 times per second), but I'm not sure. If this is the case you might be able to detect outside view with differences in counters running on both occasions,Arne Bartels

Share this post


Link to post
Share on other sites

I tried to drop a sound playing into the PRE_DRAW functionbut the sound was always played meaning that it was called even when not displayed.I tried also to put a sound into the MAKE_STRING callback of one gauge but same result: sound always played even if gauge not on screen.It seem that ms love to process useless function :-)Any idea ?Dan

Share this post


Link to post
Share on other sites

PANEL_SERVICE_PANEL_OPENandPANEL_SERVICE_PANEL_CLOSEWork well for the main panel (all 2d panel) when you go to main panel it call once panel_open and when you set another view it call once panel_close.howewer this is useless while this doesn't work at all for virtual cockpit.for virtual cockpit I tried all the panel service testing also extra_data but if service are called they are called everytimeeven when the VC isn't displayed and if they are not they'll never.Well, after all we just need to say that instrument sound can travel trought 8 cm aluminium and 120 feet air at 300 knots."As real as it get...in fourth dimension" :-)Thanks for replyDan

Share this post


Link to post
Share on other sites

I haven't tried the OPEN CLOSE constants, and also not in the VC view, but PANEL_SERVICE_PRE_DRAW is definetely a lot less called in outside view (or not-panel view) then in panel view. Maybe ther is a bit to tinker with.Arne Bartels

Share this post


Link to post
Share on other sites

by my test the pre draw is called frequently but the POST_DRAW is effectively called at apparently 18hz when in view and about 0.25 hz when not in view. (every four second)I didn't test this in VS thought. Unless there is another method (ie: tokenvar or a "solid" var showing inside/outside view)I will let this down for sound cut when outside cockpit.But as an idea the OPEN CLOSE method can be perhaps usefull to discardsome gauge code for big project (vector drawing?) when the gauge isn't in view. it as proven to be 100% reliable when the gauge is in a 2d panel.Arne can you point me where to search to control Meteo within a gauge ?connecting to a modul ? (I had see some code in the fs2kgauge that seem related to external modul ?) fsuipc ? another ?any info welcome .ThanksDaniel

Share this post


Link to post
Share on other sites

Oops, I never looked at the POST_... events, always on the PRE_... so I didn't notice any differences, thanks for the info anyway. I also never noticed the OPEN CLOSE events before, but I made intense tests with FS2000 and only some little adjustments, if the gauges didn't work as expected in FS2002, and the use of OPEN CLOSE seems to be new in FS2002.To the meteo interface, there is no direct access via tokens possible, but you can "hook" the fsuipc module to a gauges as far as I know, just like the use of fsuipc from an external C program. I would assume you need to link the fsuipc.lib and include fsuipc.h to your gauge code and then use the fsuipc SDK features.If you plan siomething like a weather radar things might be a bit difficult, since FS2002 doesn't "know" different weather in different areas (it does load the local weather, but there is no info of the surrounding weather), also the clouds are not locateable, so detecting strom cells would be difficult.Arne Bartels

Share this post


Link to post
Share on other sites

Great ! Just downloaded the fsuipc sdk it seem promising.Fortunately I just want to control the weather within a gauge notdisplay a weather map.Thanks a lotDan

Share this post


Link to post
Share on other sites

Hi Dan,you are right, I just tested it out too. There is a flaw (or is it an intentional design choice) in FS2002 and its main gauge callback events while deling with the VC and the 2D panel. in 2D, everything is pretty well bracketed (open / close) and pre_draw / pre_update cycles are right. Switch to VC with the same gauge on both panels, then the VC gauge receives its pre_draw and pre_update correctly (and the 2D panel attached instance of the same gauge only gets a close to 0.125 Hz pre_draw event). Still, no open / close on the VC. But switch back to 2D, and then, both instances of the same gauge receive steady pre_draw events eventhough the VC instance is not in view anymore. With a sample gauge I've made, this basically change the refresh rate in the pre_draw event loop from 50ms to 120ms. So this might be one of the reasons some get poor performances with their system, and I could only recommand to either fly in the 2D, or fly in the VC, but to avoid switching back on forth.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this