A password will be e-mailed to you.

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.

Pages: [1]
Author Topic: Returning Bools and checking Autopilot state
dtudin01
Beginner
Posts: 27
Send Message
Post Returning Bools and checking Autopilot state
on: July 13, 2012, 09:12

Hello,

I'm trying to determine if the user has autopilot enabled via SimConnect, but I'm running into some problems with the bool types of the simvars I'm trying to request.

I'm sending a request for "autopilot available" and "autopilot master", both of which are listed in the simvar doc as being not writable (which is fine, I just want to see them) and of type boolean.

I've created my local structure to have two bool vars, and set up the data definition stuff:

struct AutopilotInfo
{
	bool		available;
	bool		onOff;
};

hr = SimConnect_AddToDataDefinition(hSimConnect, D_AUTOPILOT_INFO, "AUTOPILOT AVAILABLE", "Boolean");
hr = SimConnect_AddToDataDefinition(hSimConnect, D_AUTOPILOT_INFO, "AUTOPILOT MASTER", "Boolean");

However when I request this struct for my user plane, I'm always apparently getting back false. Even when I know it's on (ie: turning it on manually in the virtual cockpit in the Constellation, for example).

The documentation states that bool values are ints, with 0 being false and something else (probably 1 or -1 for true). So I changed my Autopilot struct to have ints. However - whenever I request the data again, I'm getting a result from the 'autopilot available' var as 0 always, and the autopilot master var as 1072693248 all the time - again, regardless of the actual state of the autopilot.

struct AutopilotInfo
{
	int available;
	int onOff;
};

AutopilotInfo *pAI = (AutopilotInfo*)&pObjData->dwData;
printf("\nAutopilot Info:: Avail: %i, On: %i", pAI->available, pAI->onOff);

Am I checking the wrong variables for the state of the autopilot? Am I correctly using an int for these bool variables or should I be using something else?

Also - is there a way on the glass cockpits (such as the default Bravo with G1000) to tell when autopilot is on or off?

Thanks,
david

MikeSchroe-
ter
Lockheed Martin
Posts: 96
Send Message
Post Re: Returning Bools and checking Autopilot state
on: July 13, 2012, 13:44

Hi David,

A couple of things. First, "AUTOPILOT AVAILABLE" only indicates if the aircraft is equipped with an autopilot. It sounds like "AUTOPILOT MASTER" will provide you with what you need. Second, if you look at the prototype for SimConnect_AddToDataDefinition(), you'll notice that that there is an argument for data type. There is a default value of SIMCONNECT_DATATYPE_FLOAT64. With your code, you'll probably want to try SIMCONNECT_DATATYPE_INT32 or SIMCONNECT_DATATYPE_INT64 so that it writes to your vars properly.

Hope this helps,
Mike

dtudin01
Beginner
Posts: 27
Send Message
Post Re: Returning Bools and checking Autopilot state
on: July 13, 2012, 14:37

Hi Mike,

Yes, that certainly did help. It's not returning values as expected. :) I didn't think to try specifying the data type returned!

Yeah I was trying the autopilot available flag as well because I wanted to be sure I was getting something.

Thanks,
david

Pages: [1]
Mingle Forum by cartpauj
Version: 1.0.31 ; Page loaded in: 0.087 seconds.