XPlaneConnector 1.3.0

dotnet add package XPlaneConnector --version 1.3.0                
NuGet\Install-Package XPlaneConnector -Version 1.3.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XPlaneConnector" Version="1.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XPlaneConnector --version 1.3.0                
#r "nuget: XPlaneConnector, 1.3.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install XPlaneConnector as a Cake Addin
#addin nuget:?package=XPlaneConnector&version=1.3.0

// Install XPlaneConnector as a Cake Tool
#tool nuget:?package=XPlaneConnector&version=1.3.0                

XPlaneConnector

UPDATE TO VERSION 1.3

Some bug fixes in this release and library separation.

All DataRefs and Commands definitions has been migrated to a separate library XPlaneConnector.DataRefs

In this way the library itself keep its size as low as possible, while DataRefs can be references only if needed.

DataRefs versioning is now consistent with X-Plane version for easier matching, and it will be easier to update DataRefs and Commands definitions separately from the Connector itself.

In the future further libraries can be added (i.e. Zibo DataRefs or other add-ons specific DataRefs).

UPDATE TO VERSION 1.2

This version include support for .NET Standard 2.0 and .NET 4.6 in a single package

Read data and send commands to XPlane via UDP

XPlaneConnector can run on a raspberry or similar using .Net Core. You can send commands and subscribe to DataRef. An event OnDataRefReceived is fired every time the value of a subscribed DataRef changes. Should XPlane crash and restart, this connector can detect that DataRefs aren't being updated and will automatically request a new subscription.

Usage

NOTE: Every DataRef is always a float, even if the data type is different (int, bool, double, string, array). So if you need a bool you will obtain a float that is either 0 or 1.

Create the connector

The constructor takes the XPlane IP and port as parameters, default is 127.0.0.1 on port 49000

var connector = new XPlaneConnector(); // Default IP 127.0.0.1 Port 49000
var connector = new XPlaneConnector("192.168.0.100"); 
var connector = new XPlaneConnector("192.168.0.100", 49010); 

Sending a command

Just pass the command. A list of all the available commands has been created on XPlaneConnector.Commands Each command has a Description property with a brief description of its meaning.

connector.SendCommand(XPlaneConnector.Commands.ElectricalBattery1On);

Subscribe to a DataRef

You can subscribe to as many DataRef you want. In either way you have to call:

connector.Start();

In order to begin communication with X-Plane. Subscribing to DataRef can happen before or after calling Start.

A list of all managed DataRefs has been created inside:

XPlaneConnector.DataRefs

Each DataRef has a Description property with a brief description of its meaning.

To obtain DataRef value use the DataRef event: For DataRef "sim/cockpit/radios/com1_stdby_freq_hz" use XPlaneConnector.DataRefs.CockpitRadiosCom1FreqHz

connector.Subscribe(XPlaneConnector.DataRefs.CockpitRadiosCom1FreqHz, 5, (e, v) => {

    Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - {e.DataRef} - {v}");
});

Strings (NEW)

If you need a string (example: sim/aircraft/view/acf_tailnum) it is managed as an array of floats containing an ASCII code on each value. Subscribing to sim/aircraft/view/acf_tailnum won't give you the tailnumber. In order to get the complete string it's necessary to subscribe to each character individually. Subscribing to sim/aircraft/view/acf_tailnum[0], sim/aircraft/view/acf_tailnum[1]... and so on (this DataRef is 40 byte long). A new class StringDataRefElement has been created to automatically manage this process. See below for usage.

// XPlaneConnector.DataRefs.AircraftViewAcfTailnum is a StringDataRef, in this case value is a string, not a float
connector.Subscribe(XPlaneConnector.DataRefs.AircraftViewAcfTailnum, 5, (element, value) =>
{

    Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - {e.DataRef} - {v}"); // v is a string
});

NOTE: You must have already subscribed to a DataRef using the Subscribe method.

Press&Hold Commands (NEW 2020)

For commands that have a Press&Hold behaviour like the Ignite command, multiple calls of the SendCommand method is required. To simplify this, there's a new method StartCommand that handle the required code in a parallel Task. It returns a CancellationTokenSource, to stop the Command just call Cancel on this token.


var token = connector.StartCommand(XPlaneConnector.Commands.EnginesEngageStarters);
// Do other things 
// ...
// When you want it to stop
token.Cancel();

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on XPlaneConnector:

Package Downloads
XPlaneConnector.DataRefs

Add-on library containing DataRefs and Commands definition to interact with X-Plane

CoSimCockpitManager

API for CoSim .Net interface

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 3,473 5/26/2021
1.2.0 3,328 3/8/2020
1.1.6673.28421 1,457 4/9/2018
1.0.0 1,344 11/6/2017