Sign in to follow this  
Guest SRS-103

Can XML and C work together?

Recommended Posts

Hi,I plan to develop gauges that work on logic not implemented in FS. It is custom navigation equipment that performs special calculations based on FS information, random values and real physical equations.I can do that in C quite easy and I am quite convinced that programming the logic of the equipment in C is much more straightforward than doing it in XML. On the other hand I would like to define the gauges connected to this system in XML, as XML is much more convenient for that.I am not experienced in XML programming. I am interested whether it is possibly to read and modify "non standard" variables from within XML gauges. My plan is to build the logic in C, but display the gauges in XML. You can modify some settings (switches etc) in XML and gauges are displaying results via XML, but connection between input and output is calculated in C.The C module is simulating a complex system and there are several gauges modifying and displaying parameters.How can I share the values between the C program (service gauge) and the XML gauges? Should I use something like initialize_var_by_name()? Can I use these variables from XML gauges?Gabor

Share this post


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

Thanks Roman!Unfortunatelly the attachments are deleted already. I sent an email to Arne.Gabor

Share this post


Link to post
Share on other sites

initialize_var_by_name is for inter-gauge communication, but only for C gauges!You can use L: Vars with these functions:check_named_variableregister_named_variableget_named_variable_valueget_named_variable_typed_valueset_named_variable_valueset_named_variable_typed_valueget_name_of_named_variableYou can also use execute_calculator_codeto execute whole XML statements (and L: vars within these)Or you can program the C:xxx:yyy interface as already stated.Arne Bartels

Share this post


Link to post
Share on other sites

Arne,Thanks for the fast reply. Could you help me where can I find info on this C:xxx:yyy interface?Gabor

Share this post


Link to post
Share on other sites

Have a look at Romans post. If you mailed me I can't answer until I'm home again.Arne Bartels

Share this post


Link to post
Share on other sites

Arne,I just mentioned in the mail I sent you that in the topic Roman mentioned all attachments had been already deleted, so I could only check the letters, but not the attached examples.Gabor

Share this post


Link to post
Share on other sites

I'm also interested right now in C <-> XML programming. It'd be great if someone could zip up some of those sample files that have been removed from the forum, and post them to the library.I haven't seen this question addressed: Is it possible to register code in a C gauge as a K:event that can be triggered from XML? As an alternative to polling an L:var, which might work too....(I installed Dev C++ and compiled my first "Hello World" program last night. Lord (and the rest of you guys) have mercy on me....)Douglas

Share this post


Link to post
Share on other sites

Arne posted a list of functions in post #3 in this thread. If you search the forum for a couple of them you should find a few examples of how they are used. You can monitor an L:variable in a C gauge and have it react to changes to that variable.Start with "get_named_variable_value"Doug

Share this post


Link to post
Share on other sites

Thanks Doug, I will do that.By the way - is it possible in XML gauge programming to use the 5th argument from panel.cfg? It is a not frequently used, but very effective programming method in the C gauge programming.//--- Gauge Callback Function -------------------void FSAPI callBack (PGAUGEHDR pgauge, int service_id, UINT32 extra_data){ switch(service_id) { case PANEL_SERVICE_PRE_INITIALIZE: // check 5th parameter (integer) from panel.cfg if( pgauge->parameters ) pgauge->user_data = atoi(pgauge->parameters); ...//--- Element callbacks -------------------------FLOAT64 FSAPI toggle_cb( PELEMENT_ICON pelement ){ UINT32 index; index = pelement->gauge_header->user_data; ...//--- Mouse function ---------------------------BOOL FSAPI toggle_mouse_cb( PPIXPOINT relative_point, FLAGS32 mouse_flags ){ UINT32 index; index = GAUGEHDR_FOR_MOUSE_CALLBACK(relative_point)->user_data; ...Gabor

Share this post


Link to post
Share on other sites

Gabor,You can't do that with an XML gauge, no. If you are looking to set default values for XML gauges, download rcbco-20.zip from the library. Have a look at a gauge called COP_config.gau, and its associated .ini file.It reads L:Variable names and startup values from the .ini file and sets the L:Variables accordingly. Keep in mind that on gauge exit, it writes the current values of the L:Variables back to the .ini file. You can specify up to 100 L:Variables to initialize this way. If you think this might be useful, go ahead and use it, but please rename it so that we don't mess up any of the Carrier Ops users. If you need help with it, e-mail me directly - the address is in the rcbco-20 readme file.Doug

Share this post


Link to post
Share on other sites

Thanks Doug,Reading all these I think I will go with the pure C gauge programming a leave out XML completely. My naive idea was that C fits better for logics and XML fits better for layout, but now I see that the interaction between them is not worked out well (yet).With C I can do all of this, but I was thinking on how I could separate the job of our gauge/panel (bitmap) designer and my logic programming. It seems it is not supported. Whenever he would like to change something, he should ask me to put it into the C code instead of playing with an XML file dealing with pure drawing issues.Anyhow someone who know XML/C interefacing better than me might go on with this idea, perhaps something can be worked out...The goal is that the gauge bitmap designer just plays with simple XML gauges, where XML dose NOT contain real logic only system value to drawing coordinates calculations. Also switches and other hot areas set only status of some system vars defining the state of those switches etc., without doing ANY logic.The gauge/systems logic programmer on the other hand does NOT deal with any graphical representations (no funny macros in C code), just programs the working of the systems based on present state of switches etc., and calculates system values.L:Variable read/write methods are working as I see from these mails, so it might work. A good example for should be written by someone.What I can not see at the moment is how I can deal with "reused" gauges (5th parameter in panel.cfg). I have some 50 switches and 50 lamps with identical graphics, but different functionalities and I can handle them in a simple C gauge. This could be extended to this XML/C method if possible. Doug's idea might work, but too much for me at the moment.Gabor

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