• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FS2004 C++. Don't working update

Messages
10
Country
belarus
Hi.

I make gauge, where Logic and Visual code in difference files .cpp.
File gau_logic.cpp have this structure:
Code:
void FSAPI logic_gauge_cb(PGAUGEHDR pgauge, int service_id, UINT32 extra_data) {
	switch(service_id)	{	//  LOADING AIRCRAFT
		case PANEL_SERVICE_PANEL_OPEN:
			Logic_Level.Init();
			break;
			// "install_routine()" 
		case PANEL_SERVICE_PRE_INSTALL:
			break;
		case PANEL_SERVICE_POST_INSTALL:
			break;
		// "initialize_routine()"
		case PANEL_SERVICE_PRE_INITIALIZE:
			break;
		// "update_routine()" 
		case PANEL_SERVICE_PRE_UPDATE:
			Logic_Level.Update(); 
			break;
		// "draw_routine()" 
		case PANEL_SERVICE_PRE_DRAW:
			break;
		// "kill_routine()" 
		case PANEL_SERVICE_PRE_KILL:
			break;
		case PANEL_SERVICE_DISCONNECT:
			break;
	}
}
but Logic_Level.Update() don't call and breakpoints don't work.

Where is mistake?
 
I don't think PANEL_SERVICE_PANEL_OPEN gets called unless you access the 2D panel.
Try using PANEL_SERVICE_CONNECT_TO_WINDOW, or PANEL_SERVICE_PRE_QUERY

Doug
 
Sorry...

Code:
#include <fs9sdk.h>
#include "cl_logic.h"
#include "resource.h"

#define GAUGE_NAME				"Logic"
#define GAUGEHDR_VAR_NAME		gauge_logic
#define GAUGE_W					1

char	logic_gauge_name[]	= GAUGE_NAME;
extern PELEMENT_HEADER			logic_list;
extern MOUSERECT				logic_mouse[];
/*GAUGE_CALLBACK					logic_gauge_cb;*/
Refuel Logic_Level;

void FSAPI logic_gauge_cb(PGAUGEHDR pgauge, int service_id, UINT32 extra_data) {
	switch(service_id)	{	//  LOADING AIRCRAFT
	case PANEL_SERVICE_CONNECT_TO_WINDOW:
		__asm int 3;
		Logic_Level.Init();
		break;
		// "install_routine()" 
	case PANEL_SERVICE_PRE_INSTALL:
		break;
	case PANEL_SERVICE_POST_INSTALL:
		break;
		// "initialize_routine()"
	case PANEL_SERVICE_PRE_INITIALIZE:
		break;
		// "update_routine()" 
	case PANEL_SERVICE_PRE_UPDATE:
		__asm int 3;
		Logic_Level.Update(); // Здесь производится вызов метода Update 18 раз в секунду (таймер сима)
		break;
		// "draw_routine()" 
	case PANEL_SERVICE_PRE_DRAW:
		break;
		// "kill_routine()" 
	case PANEL_SERVICE_PRE_KILL:
		break;
	case PANEL_SERVICE_DISCONNECT:
		break;
	}
}

GAUGE_HEADER_FS700(GAUGE_W, logic_gauge_name, &logic_list, logic_mouse, logic_gauge_cb, 0, 0, 0);

MOUSE_BEGIN(logic_mouse, HELP_NONE, 0, 0)
MOUSE_END

MAKE_STATIC(logic_bg, BMP_PIXEL, NULL, NULL, IMAGE_USE_TRANSPARENCY|IMAGE_HIDDEN, 0, 0, 0)
	PELEMENT_HEADER logic_list = &logic_bg.header;

#undef GAUGE_NAME
#undef GAUGEHDR_VAR_NAME
#undef GAUGE_W

cl_logic.h
Code:
#ifndef _LOGIC_
#define _LOGIC_

#include <fs9sdk.h>

#define TANKS_NUM					6						
#define MAIN_TANKS					5						
#define REFUEL_MAIN_VALUE			15050					
#define REFUEL_FOUR_VALUE			2025					
#define MAX_MAIN_REFUEL				33247					
#define MAX_FOUR_REFUEL				6625					

static bool logic_inited = false;


#define SPEED_REFUEL_MAIN			1.8518					
#define SPEED_REFUEL_TANK3			0.5555				

#define BAK_1						3313					

// Макросы
#define REF_VALUE(a)				((a)-3300-2*1725)/4		
#define LBS_TO_KG(a)				(a)/2.205				
#define KG_TO_LBS(a)				(a)*2.205				

typedef struct {
	bool Valve;					
	bool Lamp;					
	double *Fuel;				
}TRefuelTank;

typedef struct {
	bool Tumbler;
	bool Lamp;
	bool RefStart;
}TMainTumbler;

typedef struct {
	bool State;
	bool Control;
	bool Timer;
}TContrButton;

typedef struct {
	double RefValue;
	int Day_Icon;
	int Night_Icon;
	double Tank2;
	double Tank3;
}TMainSelector;

typedef struct {
	double RefValue;
	int Day_Icon;
	int Night_Icon;
}TFourSelector;

class Refuel {
public:
	Refuel(void);
	~Refuel(void);

	void Update();
	void Init();
	void Deinit();

	// === Интерфейс ===
	bool GetMainState() {return MainTumbler.Tumbler;}							
	bool GetRefState() {return MainTumbler.RefStart;}							
	bool GetNightState() {return Night;}										
	int GetIcon(int SelectorNum/*, bool lighting = false*/) {
		if (SelectorNum == 1) return (!Night) ? MainSelector.Day_Icon : MainSelector.Night_Icon;
		if (SelectorNum == 2) return (!Night) ? FourSelector.Day_Icon : FourSelector.Night_Icon;
		// 		} else {
		// 			if (SelectorNum == 1) return MainSelector.Night_Icon;
		// 			if (SelectorNum == 2) return FourSelector.Night_Icon;
		// 		}
		// 
		// 		return -1;
	}
	bool GetContrState() {return ContrButton.State;}							
	bool GetControl() {return ContrButton.Control;}
	bool GetValveState(int TankNum) {return RefuelTank[TankNum].Valve;}			
	bool GetLampState(int TankNum) {return RefuelTank[TankNum].Lamp;}			
	double GetFuelValue(int TankNum) {return (*RefuelTank[TankNum].Fuel);}		

	bool ChangeNightState() {
		Night = (Night) ? false : true;		
		return false;
	}
	bool ChangeTankSet(int TankNum, bool both = false, int TankNumBoth = -1) {
		RefuelTank[TankNum].Valve = (RefuelTank[TankNum].Valve) ? false : true;
		RefuelTank[TankNum].Lamp = (RefuelTank[TankNum].Valve) ? true : false;
		if (both) {
			RefuelTank[TankNumBoth].Valve = (RefuelTank[TankNumBoth].Valve) ? false : true;
			RefuelTank[TankNumBoth].Lamp = (RefuelTank[TankNumBoth].Valve) ? true : false;
		}

		return false;
	}

	bool ChangeMainRef(bool Flag) {
		if (!Flag) {
			if (MainSelector.RefValue == MAX_MAIN_REFUEL) {
				MainSelector.RefValue -= 8100;
				MainSelector.Day_Icon -= 2;
				MainSelector.Night_Icon -= 2;
			} else {
				if (MainSelector.RefValue > REFUEL_MAIN_VALUE) {
					MainSelector.RefValue -= 5000;
					MainSelector.Day_Icon -= 2;
					MainSelector.Night_Icon -= 2;
				}
			}
		} else {
			if (MainSelector.RefValue < 25025) {
				MainSelector.RefValue += 5000;
				MainSelector.Day_Icon += 2;
				MainSelector.Night_Icon += 2;
			} else {
				if (MainSelector.RefValue == 25025) {
					MainSelector.RefValue += 8100;
					MainSelector.Day_Icon += 2;
					MainSelector.Night_Icon += 2;
				}
			}
		}
		
		if (!Flag) {
			if (MainSelector.RefValue == MAX_MAIN_REFUEL) {
				MainSelector.RefValue = 25050;
				MainSelector.Day_Icon = 4;
				MainSelector.Night_Icon = 5;
			}
			else{
				if (MainSelector.RefValue == 25050) {
					MainSelector.RefValue = 20050;
					MainSelector.Day_Icon = 2;
					MainSelector.Night_Icon = 3;
				} else {
					if (MainSelector.RefValue == 20050) {
						MainSelector.RefValue = 15050;
						MainSelector.Day_Icon = 0;
						MainSelector.Night_Icon = 1;
					}
				}
			}
		} else {
			if (MainSelector.RefValue == REFUEL_MAIN_VALUE) {
				MainSelector.RefValue = 20050;
				MainSelector.Day_Icon = 2;
				MainSelector.Night_Icon = 3;
			}
			else{
				if (MainSelector.RefValue == 20050) {
					MainSelector.RefValue = 25050;
					MainSelector.Day_Icon = 4;
					MainSelector.Night_Icon = 5;
				} else {
					if (MainSelector.RefValue == 25050) {
						MainSelector.RefValue = MAX_MAIN_REFUEL;
						MainSelector.Day_Icon = 6;
						MainSelector.Night_Icon = 7;
					}
				}
			}
		}

		return false;
	}
	bool ChangeRefuelState() {
		MainTumbler.RefStart = (MainTumbler.RefStart) ? false : true;
		return false;	
	}
	bool ChangeFourRef(bool Flag) {
		if (!Flag) {
			if (FourSelector.RefValue == MAX_FOUR_REFUEL) {
				FourSelector.RefValue -= 2600;
				FourSelector.Day_Icon -= 2;
				FourSelector.Night_Icon -= 2;
			}
			else if (FourSelector.RefValue > REFUEL_FOUR_VALUE) {
				FourSelector.RefValue -= 2000;
				FourSelector.Day_Icon -= 2;
				FourSelector.Night_Icon -= 2;
			}
		} else {
			if (FourSelector.RefValue < 4025) {
				FourSelector.RefValue += 2000;
				FourSelector.Day_Icon += 2;
				FourSelector.Night_Icon += 2;
			}
			else if (FourSelector.RefValue == 4025) {
				FourSelector.RefValue += 2600;
				FourSelector.Day_Icon += 2;
				FourSelector.Night_Icon += 2;
			}
		}

		return false;
	}
	
	bool ChangeMainState() {
		MainTumbler.Tumbler = (MainTumbler.Tumbler) ? false : true;
		MainTumbler.Lamp = (MainTumbler.Tumbler) ? false : true;
		MainTumbler.RefStart = false;

		int i;
		for (i = 0; i < TANKS_NUM; i++) {
			if (!MainTumbler.Tumbler) { RefuelTank[i].Lamp = false;}
		}

		return false;
	}
	bool ChangeContrState() {
		ContrButton.State = (ContrButton.State) ? false : true;
		return FALSE;
	}

private:
	TRefuelTank RefuelTank[TANKS_NUM];
	TMainTumbler MainTumbler;
	TContrButton ContrButton;
	TMainSelector MainSelector;
	TFourSelector FourSelector;

	bool Night;												
	int RefValueMain;											
	int RefValueFour;											
	int ControlTimer;											
};

#endif //_LOGIC_
 
Where I can read about PANEL_SERVICE_PANEL_OPEN, PANEL_SERVICE_CONNECT_TO_WINDOW and PANEL_SERVICE_PRE_QUERY? In Panel SDK docs I can't find it.
 
Where I can read about PANEL_SERVICE_PANEL_OPEN, PANEL_SERVICE_CONNECT_TO_WINDOW and PANEL_SERVICE_PRE_QUERY? In Panel SDK docs I can't find it.

They are defined in gauges.h
CONNECT_TO_WINDOW and PRE_QUERY are called only when the gauge is first loaded.
PANEL_OPEN is called whenever the view is changed to the 2D or 3D panel.

What is it that you are expecting Logic_Level.Update() to do.
There is no definition for it in your class declaration.

Also, are you sure the gauge itself is being loaded?

Doug
 
Back
Top