Sign in to follow this  
Guest

Help with Server gauge for XML MCP

Recommended Posts

Hi all,The jsPANELS.com 737 Project Team is working on a new FS2002 Boeing 737-400 project. One of the vital parts of this project is the new MCP, which is progammed in XML. To enable the communication between the FSNavigator System and the new MCP, a gauge which works as an interface between these two is required. This gauge is programmed in C++ using the FS2002 SDK and the FSNAVGauge.h.Roman Stoviak (RS):-------------------The MCP is programmed in such a way that it acts as close as possible to the real 737. Provisions have been made so that the GPS can be incorporated as LNAV with no problems. The panel we are working on also has provisions to use FSNAV as a LNAV and VNAV sections of the MCP. The problem arises when FSNAV is used as the coding inside the MCP will interfere with what FSNAV is trying to accomplish. What is needed is a variable to "tell" the MCP that FSNAV is being used and what mode it is in. In testing we have found that the generator switches for engines 3 & 4 still work even though it is a 2 engine aircraft. The guage to monitor FSNAV will be in C and "control" the GEN 3 & 4 switches, while on the XML MCP we will "monitor" the GEN 3 & 4 switches. The principle is as follows:----------------------------Event IDs used:KEY_TOGGLE_ALTERNATOR3KEY_TOGGLE_ALTERNATOR4 TokenVars:GENERAL_ENGINE3_GENERATOR_SWITCHGENERAL_ENGINE4_GENERATOR_SWITCH The way it needs to be written should be something like: FSNAV_VAR_FLY_FP if true: GENERAL_ENGINE3_GENERATOR_SWITCH if false: KEY_TOGGLE_ALTERNATOR3FSNAV_VAR_FLY_FP if false: GENERAL_ENGINE3_GENERATOR_SWITCH if true: KEY_TOGGLE_ALTERNATOR3FSNAV_VAR_FMC_MODE2 if true: GENERAL_ENGINE4_GENERATOR_SWITCH if false: KEY_TOGGLE_ALTERNATOR4FSNAV_VAR_FMC_MODE2 if false: GENERAL_ENGINE4_GENERATOR_SWITCH if true: KEY_TOGGLE_ALTERNATOR4 Then on the XML side I would monitor : (A:General eng3 generator switch, bool) if true then FSNAV Fly FP is on(A:General eng4 generator switch, bool) if true then FSNAV is in mode 2. And, make one global variable so I would not have to do this over and over.. (A:General eng3 generator switch, bool) 1 == if{ (A:General eng4 generator switch, bool) 1 == if{ 2 (>;L:FSNAVmode, enum) } els{ 1 (>;L:FSNAVmode, enum) } } els{ 0 (>;L:FSNAVmode, enum) } So then I could use (L:FSNAVmode, enum) in all parts of the MCP as such: If equal to: 0 = FSNAV is not in Fly FP1 = FSNAV is in Fly FP and in mode 12 = FSNAV is in Fly FP and in mode 2Jan Harry Sorensen (JHS):-------------------------I have tried to use the exampe as described in the FSNAVGauge.h. The preliminary test code is using FS2002 SDK://--snipped-->// Set up gauge headerchar server_gauge_name[] = GAUGE_NAME;extern PELEMENT_HEADER server_list;extern MOUSERECT server_mouse_rect[];GAUGE_CALLBACK server_update;GAUGE_HEADER_FS700(GAUGE_W, server_gauge_name, &server_list, server_mouse_rect, &server_update, 0, 0, 0);/////////////////////////////////////////////////////////////////////////////FAILURE_RECORD server_fail[] ={ {FAIL_SYSTEM_ELECTRICAL_PANELS, FAIL_ACTION_FREEZE}, {FAIL_NONE, FAIL_ACTION_NONE}};//---------------------------------------------------------------------------MAKE_STATIC ( server_background, BMP_SERVER, NULL, &server_fail, IMAGE_USE_TRANSPARENCY | IMAGE_HIDDEN, 0, 0,0 )PELEMENT_HEADER server_list = &server_background.header;//----------------------------------------------------------------------------//FSNAV function//----------------------------------------------------------------------------PBOOL32 pFlyFlightplanOn = NULL;void FSAPI update_routine(){ MODULE_VAR mvFlyFlightplanOn; if (pFlyFlightplanOn == NULL) { initialize_var_by_name(&mvFlyFlightplanOn, FSNAV_KEY_FLY_FLIGHTPLAN_ON); pFlyFlightplanOn = (PBOOL32)mvFlyFlightplanOn.var_ptr; } element_list_update( server_list );}void FSAPI flightplan_on_routine(){ if (pFlyFlightplanOn != NULL) *pFlyFlightplanOn = TRUE;}//----------------------------------------------------------------------------MODULE_VAR gen3sw = {GENERAL_ENGINE3_GENERATOR_SWITCH}; //Broadcast Variable//----------------------------------------------------------------------------void FSAPI server_update (PGAUGEHDR pgauge, int service_id, UINT32 extra_data){ PBOOL32 pvar = (PBOOL32)gen3sw.var_ptr; //MUST be first line in this section switch(service_id) { case PANEL_SERVICE_PRE_INSTALL: // "install_routine() break; case PANEL_SERVICE_PRE_INITIALIZE: // "initialize_routine() initialize_var_by_name (&gen3sw,"gen3sw"); //Internal & external names break; case PANEL_SERVICE_PRE_UPDATE: // "update_routine() // Broadcast variable if (*pvar == 1); trigger_key_event(KEY_TOGGLE_ALTERNATOR3,0); break; case PANEL_SERVICE_PRE_KILL: /// "kill_routine() unregister_var_by_name("gen3sw"); break; }}/////////////////////////////////////////////////////////////////////////////MOUSE_BEGIN( server_mouse_rect, 0, 0, 0 )MOUSE_END/////////////////////////////////////////////////////////////////////////////#undef GAUGE_NAME#undef GAUGEHDR_VAR_NAME#undef GAUGE_W//--snipped-->The VC++ compiler (6.0 Standard edition) reports these errors:Compiling...mcps.cD:FSJSGAUJSP734SERVINCFSNAVGauge.h(223) : error C2061: syntax error : identifier 'BOOL'D:FSJSGAUJSP734SERVINCFSNAVGauge.h(230) : error C2059: syntax error : '}'Error executing cl.exe.mcps.obj - 2 error(s), 0 warning(s)The main .c file mcps.c is setup like this://--snipped-->#include "stdio.h"#include "stdlib.h"#include "string.h"#include "INCFSNAVGauge.h"#include "INCGAUGES.h"#include "mcps.h"///////////////////////////////////////////////////////////// include the FSSound header file#include "INCFSSound.h"/***************** Global functions ***********************/FLOAT64 val;//PBOOL32 pFlyFlightplanOn = NULL;void FSAPI add_imagedata_to_listelement(PELEMENT_HEADER pelement,UINT32 pos_element,FLAGS image_flags);void FSAPI remove_imagedata_from_listelement(PELEMENT_HEADER pelement,UINT32 pos_element,FLAGS image_flags);#define GAUGE_CHARSET DEFAULT_CHARSET#define GAUGE_WEIGHT_DEFAULT FW_NORMAL#define GAUGE_FONT_ARIAL "ARIAL"#define GAUGE_FONT_COURIER "COURIER_NEW"#define GAUGE_FONT_TIMES "TIMES_NEW_ROMAN"#define GAUGE_FONT_HELV "HELVETICA"#define GAUGE_FONT_QUARTZ "QUARTZ"//-------------------------------------------------------------// Server//-------------------------------------------------------------#define GAUGE_NAME "Server0"#define GAUGEHDR_VAR_NAME gaugehdr_server#define GAUGE_W 100#include "server.c"//-------------------------------------------------------------// Test Switch//------------------------------------------------------------- /*#define GAUGE_NAME "Test Switch0"#define GAUGEHDR_VAR_NAME gaugehdr_gen3sw#define GAUGE_W 100#include "gen3sw.c"*///-------------------------------------------------------------// Gauge table entries//-------------------------------------------------------------GAUGE_TABLE_BEGIN() GAUGE_TABLE_ENTRY(&gaugehdr_server)// GAUGE_TABLE_ENTRY(&gaugehdr_gen3sw)GAUGE_TABLE_END()//--snipped-->The FSSound.h is used for a Test Switch which was REM'ed out at this particular test. We hope that someone can help us with this one!Best regardsRoman Stoviak (RS)Jan Harry Sorensen (JHS)jsPANELS.com 737 Project Teamwww.jspanels.com

Share this post


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

D:FSJSGAUJSP734SERVINCFSNAVGauge.h(223) : error C2061: syntax error : identifier 'BOOL'D:FSJSGAUJSP734SERVINCFSNAVGauge.h(230) : error C2059: syntax error : '}'show that the problem is in the FSNAVGauge.h file, not necessarily in the code you posted (BOOL doesn't seem to be properly #define'd or typedef'd). I have no idea how FSNAVGauge.h looks like, but it is possible that it uses types that aren't defined there, so try to insert a "#include "gauges.h" " in FSNAVGauge.h so that ist is "selfcontained", or exchange the lines#include "INCFSNAVGauge.h"#include "INCGAUGES.h"to#include "INCGAUGES.h"#include "INCFSNAVGauge.h" so gauges.h is included before FSNAVGauge.h is included. Gauges.h contains proper BOOL declarations, FSNAVGauge.h probably not.Arne BartelsP.S. if the first variation gives problems, because the gauges.h is included several times from different files, try the fs2k2gauges.h from the sd2gau13.zip, it is protected against multiple include errors.

Share this post


Link to post
Share on other sites

Hi Arne,Thank you! When including FS2K2Gauges.h first the Server test code was compiled and built without errors! I also moved the global functions to mcps.c://-- snip -->#include "stdio.h"#include "stdlib.h"#include "string.h"#include "INCFS2K2GAUGES.h"#include "INCFSNAVGauge.h"#include "mcps.h"///////////////////////////////////////////////////////////// include the FSSound header file#include "INCFSSound.h"/***************** Global functions ***********************/FLOAT64 val;MODULE_VAR gen3sw = {GENERAL_ENGINE3_GENERATOR_SWITCH}; //Broadcast VariableMODULE_VAR gen4sw = {GENERAL_ENGINE4_GENERATOR_SWITCH}; //Broadcast Variable//--snip --> Now remains to setup the server gauge to work as Roman has described above. Best regardsJan Harry Sorensenwww.jspanels.com

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