• 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.

C-130 Project

Messages
53
Country
us-hawaii
Gents,

I am a Coast Guard C-130 pilot working on a home cockpit to stay proficient and keep my programming skills active. I am fine with connecting to SimConnect I am just curious how to retrieve specific variables such as a Torque value, do I create a struct that only contains the Torque variable as defined in the SDK, or can I create my own struct that lists all the engine variables I need and retrieve it that way, thank you very much for your help.

Matthew Chase
C-130 Pilot, Air Station Barbers Point
 
Hello:

Your USCG Air Station has an interesting and accomplished history ! :cool:

http://www.uscg.mil/history/stations/airsta_barberspoint.asp



While I am not an experienced programmer (least of all with SimConnect :o), based on what I've heard "through the grapevine", I can recommend keeping an eye on up coming developments with SimConnect by the team at Lockheed-Martin for the future development of that core functionality on the Prepar3D (aka "P3D") platform variant of FSX.


It may be worth looking at the present P3D version of the FSX SDK docs to see what if anything is thus far extended or changed compared to the original FSX (ESP) SDK Docs: :idea:


Lockheed-Martin Prepar3D "P3D":

http://www.prepar3d.com/sdk/Core Utilities Kit/SimConnect SDK/SimConnect.htm

http://www.prepar3d.com/sdk/Core Utilities Kit/Variables/Simulation Variables.html


Microsoft FSX / ESP:

http://msdn.microsoft.com/en-us/library/cc526983.aspx

http://msdn.microsoft.com/en-us/library/cc526981.aspx



A quick Google search turned up these hits and linked posts related to SimConnect+Torque:

http://www.google.com/#sclient=psy-...14,d.aWc&fp=e30aec55194699dc&biw=1355&bih=641



An alternative option is the former ACES team member Tim Gregson (aka "Beatle") Managed SimConnect SDK:

http://fsandm.wordpress.com/

http://cid-0b48b0194c5456f5.office.live.com/self.aspx/.Public/BeatlesBlog.SimConnect.SDK.Beta3.zip

http://www.fsdeveloper.com/forum/showthread.php?t=394932

(NOTE: Tim now works on the P3D team at Lockheed-Martin)




It may also be worthwhile to bear in mind that nearly all (but not all) SimConnect accessed FS offset variables are also accessible via Pete Dowson's FSUIPC utility:

http://forum.simflight.com/forum/30-fsuipc-support-pete-dowson-modules/

http://fsuipc.simflight.com/beta/Revised_List_of_FSX_Controls.pdfvarious ways to ac



FYI: There are various programming languages which can access SimConnect via FSUIPC ex:

Visual Basic.NET (aka "VB.NET")

RealBasic FSUIPC SDK


FSUIPC Client DLL for .NET

http://forum.simflight.com/topic/40989-fsuipc-client-dll-for-net-version-20/page__st__320

http://forum.simflight.com/forum/142-download-links/



BTW: Some functions not directly accessible via FSUIPC may be accessible via the LUA scripting method.

http://forum.simflight.com/topic/63146-tutorial-how-to-get-lua-vars-or-commands-out-of-fs/

http://forum.simflight.com/topic/68257-latest-lua-package-for-fsuipc-and-wideclient/



A quick Google search turned up these hits and linked posts related to FSUIPC+Torque:

http://www.google.com/#sclient=psy-...14,d.aWc&fp=e30aec55194699dc&biw=1355&bih=641


http://forum.simflight.com/topic/53383-accessing-token-variables/

http://forum.simflight.com/topic/73...m-settings-like-p-factor-via-fsuipc-possible/


Hmmm... "C-130 Project" sounds like fun... please keep us posted on how your project is coming along. ;)


Hope these leads might help ! :)

GaryGB
 
Last edited:
Hi Matthew

SimConnect does require the use of structs. So if you only want to retrieve a single variable via RequestDataOnSimObject you would create a struct with just one member however your associated DataDefinition enumeration should only have 1 FSX variable added to it.

However i would recommend grouping as many related variables as possible into a single struct and data definition. Also, in order to make things more reliable (im going to copy from the ESP GDI+ example here), I would not recommend copying from the returned data to the struct in the following manner:

Code:
SimConnectData->NavData = (NavData*)&pObjData->dwData;

The reason being is that the data in the address which you have just assigned to that struct will be erased very quickly and you may run into issues when using it in a gauge. Rather use memcpy like this:

Code:
memcpy(SimConnectData->NavData, &pObjData->dwData, sizeof(NavData));

That way your data will persist in memory until you delete it (if it is a instanciated as a pointer) or until the dll shuts down.
 
Thank you for your help guys, I'm actually coding for Prepar3D, and just found the examples to be a little verbose. And again I really appreciate the help.
 
As far as i can tell, most of the P3D examples are identical to the FSX ones (except where P3D has added new functionality). Not too much of a suprise since P3D Simconnect and FSX Simconnect are identical except where P3D has added new functionality...
 
Another way to retain data is by defining your own variables

Code:
// My Simulation variables
double Alt;
double Lat;
double Lon;

your own structures

Code:
// Structures to hold received data
//  Aircraft Data
struct AIRCRAFT_DATA
{
double Altitude;
double Longitude;
double Latitude;
};
AIRCRAFT_DATA AD;
and extract the data


Code:
// Cast void pointer to point to new aircraft data structure
 AIRCRAFT_DATA *pS = (AIRCRAFT_DATA *)&pObjData->dwData;

// Extract data from structure
Alt = pS->Altitude;
Lat = pS->Latitude;
Lon = pS->Longitude;
which is a more convenient way than

Code:
Alt = ((AIRCRAFT_DATA *)&pObjData->dwData)->Altitude;
 ...etc
 
That looks like a rather verbose way of managing sim data....surely it is easier to have a global struct for this and just use memcpy from &pObjData->dwData to AIRCRAFT_DATA *pS?
 
As I understand it you are copying the returned data to a new structure and will then extract individual items to use them, which you didn't include the code for. I am extracting the data and copying it to individual variables with meaningful names for subsequent use.

I don't see any significant performance difference either way.
 
no there isnt a change in performance(after all its still pretty much the same number of cpu cycles). I am just thinking of the number of lines of code.
 
It's a matter of choice. I prefer verbose to cryptic with plenty of comments. Also I've found the hard way that it makes life much easier if I have to re-visit the code after a year or so.
 
Back
Top