Git Product home page Git Product logo

esimconnect's Introduction

ESimConnect

A simple library to connect and work with SimConnect, a library allowing to communicate with Flight Simulators (e.g., FS2020).

The aim of this library is to provide a simple interface to work with FS2020 over .NET/C# without no deep knowledge of SimConnect. On the other side, only the basic operations are supported. This library is not covering all the possibilities of original SimConnect library.

Requirements

The library needs Windows .NET Core 6.0 runtime to be installed (it is included in Windows 10+ instalation by default).

Instalation

Just unpack the required release to a target project run folder and link ESimConnect.dll + other provided libraries to your project. Note: To work, a file SimConnect.dll must be also included in your project output directory. This file will not be referenced in your .NET project, but must be present to be loaded for library usage.

Simple testing application

A simple example application ESimConnectDemo is available in the project.

When running FS2020, start ESimConnectDemo.exe. In the window, select Connect/Disconnect button. In SimVars tab, enter SimVar name and press Add. You should immediatelly see the value of the SimVar in the window.

Note: For specific SimVar names, look to FS202 SimVar documentation. At the beginning, you can try to enter PLANE ALTITUDE SimVar.

Usage in your project

Referencing libraries

  1. Create a new project based on .NET 6.
  2. In your project, add references to assemblies ESimConnect.dll and all the assemblies from the DLLs folder except SimConnect.dll. However, file SimConnect.dll must be present in the output folder, otherwise error on the startup will be raised.

Example of a simple usage

For a simple SimVar readout (e.g., PLANE ALTITUDE), you need to:


// create ESimConnect instance
ESimConnect.ESimConnect eSimCon = new();

// register as a listener for incoming data messages
eSimCon.DataReceived += ESimCon_DataReceived;  // see below for the definition

// open a connection to FS2020
eSimCon.Open();

// register a SimVar - tell FS2020 that you are interested in this SimVar
var typeId = eSimCon.Values.Register<double>("PLANE ALTITUDE");

// and request the value once
RequestId requestId = eSimCon.Values.Request(typeId);

// or request value repeatedly every second, only when value has changed
RequestId repeatedRequestId = eSimCon.Values.RequestRepeatedly(typeId, SimConnectPeriod.SECOND, true);

// now you are ready
// once some data has arrived, the following handler is invoked:
private static void ESimCon_DataReceived(ESimConnect.ESimConnect sender, ESimConnect.ESimConnect.ESimConnectDataReceivedEventArgs e)
{
  Console.WriteLine($"ESimCon - DataReceived - requestId={e.RequestId}, simVar={relatedSimVar}, type={e.Type}, data={e.Data}");
}

For more detailed info, see ESimConnectDemo or ESimConnectTest projects for inspiration.

Issues

If anything does not work, feel free to report it as an issue. Please provide as many details as possible.

FAQ

(nothing yet)

License

See LICENSE file.

Credits

Thanks to RandFailuresFS2020 original repo for being an initial motivation and a study source.

Thanks to George Barlow for his help with resolving unregistering issues.

Contact

Marek Vajgl https://github.com/Engin1980/ESimConnect

esimconnect's People

Contributors

engin1980 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

georgebarlow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.