XPlaneConnector 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package XPlaneConnector --version 1.0.0
NuGet\Install-Package XPlaneConnector -Version 1.0.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.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XPlaneConnector --version 1.0.0
#r "nuget: XPlaneConnector, 1.0.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.0.0

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

XPlaneConnector

Read data and send commands to XPlane via UDP

XPlaneConnector can run on a raspberry or similar using Mono. 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

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

connector.SendCommand("sim/electrical/battery_1_on");

Subscribe to a DataRef

You can subscribe to as many DataRef you want. You can handle the values in three ways:

DataRef event

connector.Subscribe("sim/cockpit/radios/com1_stdby_freq_hz", 5, (e, v) => {

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

Connector event

connector.OnDataRefReceived += (dataref, value) =>
{
    Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - {dataref}={value}");
};

Direct query

var value = connector.GetDataRefValue("sim/cockpit/radios/com1_stdby_freq_hz");

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

Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has 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 (1)

Showing the top 1 popular GitHub repositories that depend on XPlaneConnector:

Repository Stars
MobiFlight/MobiFlight-Connector
MobiFlight is an open source project that allows you to create your own home cockpit for your favorite flight simulator in a flexible, affordable and extremely user-friendly way.
Version Downloads Last updated
1.3.0 2,946 5/26/2021
1.2.0 3,157 3/8/2020
1.1.6673.28421 1,409 4/9/2018
1.0.0 1,312 11/6/2017

This version suports CMND commands and RREF DataRefs.