Sign in to follow this  
Guest Vorlin

dynamic gauges creation

Recommended Posts

Hi,I'm in the middle of writting a new framework to develop gauges, and I wanted to share with you some informations about the new way gauges can be created with it.The framework is a C++ gauge framework encapsulating the SDK to provide class based gauge developement. This is really convenient as it is of course compared to the C SDK. But more importandly, I've achieved making this entirely programatic. This means that I no longer need to declare lenghtly and cumbersome declarations of MAKE_STATIC() and such. Here is a short code snipet to understand what I mean:1) first, creating a gauge pack is as simple as creating a new DLL project in VS2005, and add the following to the source code:#include "RxpGauges.h" // Include the Reality XP Gauge Frame WorkDECLARE_CREATE_FLIGHTSIM_LINK(FS9LINK_VERSION) // Link to Flight Simulator Panel System#include "RXPTest_Gauges.hpp" // Include the gauge code declarationsRXPTest_Gauges theGauges; // create all the gauges2) declaration of the RXPTest_Gauges class:class RXPTest_Gauges : public IGaugeServices{public: RXPTest_Gauges() { // create the gauges RegisterGauge(new RXPTest_MainGauge()); }; private:};that's it, you create (new) and add the gauges in the contructor! very easy. This is equivalent in the SDK to the GAUGE_TABLE_BEGIN() and GAUGE_TABLE_END() block, but gauges are programatically created instead of statically compiled.3) declaration of the RXPTest_MainGauge class:class RXPTest_MainGauge : public IGauge{public: RXPTest_MainGauge() { Initialize("GaugeNameInPanelCfg", 400, 300, GAUGE_UPDATE_ONCE_ONLY | GAUGE_DRAW_VISIBLE_ONLY); AddElement(new IGaugeStaticImage(IDB_IMAGE_BACKGROUND)); AddElement(new IGaugeStaticImage(IDB_IMAGE_OVER_BACKGROUND, 10, 20, IMAGE_USE_ERASE)); }; virtual void OnDraw(IGaugeInstance& gauge) { //IGaugeStaticImage* theStatic = (IGaugeStaticImage*) gauge.FindElement(1); long timeMili = (GetTickCount() / 50) % 100; gauge.Element(1)->SetPosition(timeMili,15); gauge.Element(0)->Redraw(); };First, all elements in the gauge are also created dynamically: elements, mouse click spots, etc...The neat advantage of the framework is that it also do the garbage collection and house-keeping for you, and given you are using the constructor/destructor, you are garanteed to have a unique initialisation/deinitialisation point for the gauge pack (which FSX broke in changing the CONNECT_TO_WINDOW event).and then all gauge callback are now OnMessage type of functions with a reference to the gauge instance! There are a number of methods for the gauge instance and in this example, I move the second static bitmap over the previous, and I refresh the entire gauge display (equivalent to SET_OFF_SCREEN)you can also see some initialisation flags, that take care for the gauge to prevent having all instances be called for PRE_UPDATE (OnUpdate() in the framework) but only 1 of all instances, as well as to prevent calling OnDraw() (PRE_DRAW in the SDK) if the gauge is not visible at all (bug in FS that calls PRE_DRAW for VC gauges once the VC has been opened, even if you return to the 2D panel....)I'm expanding the framework to permit loading bitmaps from external files instead of gauge. There are already other methods to get the panel.cfg WINDOW name the gauge instance is declared in, and many more in the list to add that used to be in my former C framework.I hope this gave you some inspiration as to where the SDK can be pushed to! needless to say there is no hack in the FS DLLs and code: it is just exploiting the SDK at its best.

Share this post


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

WOW!!!All that sounds wonderfull!!Can you please 'materialize' it in a small working gauge, just for debug through it and see what is going on?ThanksJose

Share this post


Link to post
Share on other sites

"I hope this gave you some inspiration as to where the SDK can be pushed to!"LOL... I was just wondering about the possibility of using C# to write gauge dll's. I imagine that'd push it a bit as well.Once I have a couple more of my outstanding projects cleaned up I may try a few things.Vorlin / Scott

Share this post


Link to post
Share on other sites

It sounds interesting, but perhaps a sample project would be very useful :)

Share this post


Link to post
Share on other sites

When I read the above two replies I can't tell if they're in refercence to my comment or Jean_Luc's original post.Personally, I'd like to be able to do the entire dll in C# and then have the panel.cfg call in the gauge the same old way. Just a "simple" matter of using VC# rather than VC++ to develop the dll.Yea... putting a man or Mars is simple too. Get his butt from here to there. See how simple that is?It's only a matter of time before someone ports the header files into classes that can be used by C# or even VB. I wish I had the skills to pull it off myself but I'm a self taught hobbyist coder. I'm having a hard enough time writing my own classes to use with programs that utilize SAPI 5.1!However, Patrick had mentioned the SimConnect API in another thread about C# (currently on page 3, titles "Is this possible"). Writing a class that could be used to connect any C# authored DLL to SimConnect may be the best way to go. If I understand the idea correctly, SimConnect is basically an interface API that's intended to replace FSUIPC and provide that sort of interface to 3rd party modules regardless of the authoring environment they were created in.Scott / Vorlin

Share this post


Link to post
Share on other sites

Scott, to be more precise, SimConnect is intended to serve modules/programs that run outside the FSX process, i.e., external applications.It is fairly useless for anyone who's coding an in-process module/gauge, since it would introduce severe timing/latency problems.

Share this post


Link to post
Share on other sites

Thanks Bill, now I know not to waste time barking up that tree when the time comes.Scott / Vorlin

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