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

Using C# for motion platform

Messages
3
Country
ca-alberta
Let me first give you a bit of background. I'm new to the development world of FSX and flight sims in general. I'm actually a web developer who is quite proficient at javascript, actionscript, etc. So OOP is something I do everyday.

I have been going down the road of creating a motion platform and would like to create the control system in managed code (C#). I have already created some small applications based on the SDK examples that will grab the landing gear status and some location info (long, lat, altitude) of the aircraft.

Where I'm having the problem, is having simconnect stream the data to my application on a constant basis. Do I setup a "simconnect_OnRecvEvent" that will continually send the data? None of the C# examples seems to show how to do this. If anyone has any examples, or can help me in any way, I would really appreciate it.

I have also setup a full time website for my project that will outline my progress. So far I don't have anything up there, but will soon.
The site URL is http://www.simulatormotion.com/

Thanks, and I look forward to being able to contribute to this awesome forum.

Torin
 
Continuous stream of data

Not sure if this is what you are after but there is a parameter when you request data that can be changed. Below is the structure.

SIMCONNECT_PERIOD
The SIMCONNECT_PERIOD enumeration type is used with the SimConnect_RequestDataOnSimObject call to specify how often data is to be sent to the client.

Syntax
enum SIMCONNECT_PERIOD{
SIMCONNECT_PERIOD_NEVER,
SIMCONNECT_PERIOD_ONCE,
SIMCONNECT_PERIOD_VISUAL_FRAME,
SIMCONNECT_PERIOD_SIM_FRAME,
SIMCONNECT_PERIOD_SECOND,
};

What is rather unfortunate (and frustrating) is that SimConnect_RequestDataOnSimObject has three optional parameters one of which sets the frequency (e.g. every 10 or 20 seconds). But in their great wisdom, MS has not made those available to the managed code (C#/VB.NET). So you would have to create your own loop. Or better still if you can, is to use C++ as everything in the SimConnect API is available then.

Jerry
 
Thanks Jerry

Thanks for your help Jerry. I finally figured it out last night. This the the request I'm sending simconnect:

simconnect.RequestDataOnSimObject(DATA_REQUESTS.REQUEST_1,
DEFINITIONS.Struct1, SimConnect.SIMCONNECT_OBJECT_ID_USER,
SIMCONNECT_PERIOD.VISUAL_FRAME, 0, 0, 0, 0);

Then I just monitor the messages from simconnect and run code when anything in Stuct1 changes. Works great, although I'm not sure how efficient it is.

Thanks again,

Torin
 
Every 10 seconds

One other thing. I did try and have it respond every 10 seconds like so:

simconnect.RequestDataOnSimObject(DATA_REQUESTS.REQUEST_1,
DEFINITIONS.Struct1, SimConnect.SIMCONNECT_OBJECT_ID_USER,
SIMCONNECT_PERIOD.SECOND, 0, 0, 10, 0);

And it works with SP1. Every 10 seconds the data is sent.

Torin
 
Back
Top