1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using C# for motion platform

Discussion in 'SimConnect' started by Torin, 2/6/07.

  1. Torin

    Torin

    Joined:
    2/6/07
    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
  2. jrwillim

    jrwillim

    Joined:
    4/6/07
    Messages:
    3
    Country:
    australia
    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
  3. Torin

    Torin

    Joined:
    2/6/07
    Messages:
    3
    Country:
    ca-alberta
    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
  4. Torin

    Torin

    Joined:
    2/6/07
    Messages:
    3
    Country:
    ca-alberta
    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

Share This Page