PDA

View Full Version : Using C# for motion platform


Torin
02 Jun 2007, 12:59
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

jrwillim
04 Jun 2007, 03:34
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

Torin
04 Jun 2007, 12:16
Thanks for your help Jerry. I finally figured it out last night. This the the request I'm sending simconnect:

simconnect.RequestDataOnSimObject(DATA_REQUESTS.RE QUEST_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

Torin
04 Jun 2007, 12:19
One other thing. I did try and have it respond every 10 seconds like so:

simconnect.RequestDataOnSimObject(DATA_REQUESTS.RE QUEST_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