npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fspm-node-simconnect

v1.0.0

Published

Wrapper for the SimConnect SDK for Microsoft Flight Simulator (Windows 64bit only)

Downloads

14

Readme

fspm-node-simconnect :airplane:

Find the original repo here

Wrapper for the SimConnect SDK for Microsoft Flight Simulator 2020 (Windows only)

This project is at a very early stage and wraps only a few basic SimConnect function calls. Feel free to join the development at the source! :)

Installation 📦

node-simconnect is a native NodeJS addon written in C++ and must be compiled to a dynamic C++ library before it can be loaded as a module in NodeJS. Included in this repository is a prebuilt binary built with SimConnect 10.0.61259.0 (FSX SP2), which is compatible with FSX SP2, FSX:SE and all versions of Prepar3D. Because SimConnect 10.0.61259.0 is a 32 bit library, you must use the 32 bit version of NodeJS in order to import the module.

To install node-simconnect using the included binary:

npm install fspm-node-simconnect

Note: The included binary requires the 32 bit version of NodeJS.

Usage :grey_question:

Import the module:

const simConnect = require('node-simconnect');

The available functions are described below. Please refer to example.js for more help.

open

open(connectedCallback, simExitedCallback, exceptionCallback, errorCallback)

Open connection and provide callback functions for handling critical events. Returns false if it failed to call open (eg. if sim is not running).

Example

var success = simConnect.open("MyAppName", 
    (name, version) => {
        console.log("Connected to: " + name + "\nSimConnect version: " + version);
        // Safe to start interacting with SimConnect here (request data, etc)
    }, () => {
        console.log("Simulator exited by user");
    }, (exception) => {
        console.log("SimConnect exception: " + exception.name + " (" + exception.dwException + ", " + exception.dwSendID + ", " + exception.dwIndex + ", " + exception.cbData + ")");
    }, (error) => {
        console.log("Undexpected disconnect/error: " + error); // Look up error code in ntstatus.h for details
});

requestDataOnSimObject

requestDataOnSimObject(reqData, callback, objectId, period, dataRequestFlag)

Request one or more Simulation Variables and set a callback function to later handle the received data. See SDK Reference for more details.

Each simulation variable is defined by an array.

Example:

[
    "Plane Latitude",              // Datum name
    "degrees",                     // Units name
    simConnect.datatype.FLOAT64,   // Datum type (optional, FLOAT64 is default and works for most data types)
    0                              // Epsilon (optional, 0 is default)
]    

Full example:

simConnect.requestDataOnSimObject([
        ["Plane Latitude", "degrees"],
        ["Plane Longitude", "degrees"],  
        ["PLANE ALTITUDE", "feet"]
    ], (data) => {
        // Called when data is received
        console.log(
            "Latitude:  " + data["Plane Latitude"] + "\n" +
            "Longitude: " + data["Plane Longitude"] + "\n" +
            "Altitude:  " + data["PLANE ALTITUDE"] + " feet"
        );
    }, 
    simConnect.objectId.USER,               // User aircraft
    simConnect.period.SIM_FRAME,            // Get data every sim frame...
    simConnect.dataRequestFlag.CHANGED      // ...but only if one of the variables have changed
);

requestDataOnSimObjectType

requestDataOnSimObjectType(reqData, callback, radius, simobjectType)

Similar to requestDataOnSimObject. Used to retrieve information about simulation objects of a given type that are within a specified radius of the user's aircraft. See SDK Reference for more details.

Example: This will receive info about the user's aircraft. For this, a radius of 0 is used. Notice that when STRINGV is requested, the unit should be null.

simConnect.requestDataOnSimObjectType([
    ["NAV IDENT:1", null, simConnect.datatype.STRINGV],
    ["NAV NAME:1", null, simConnect.datatype.STRINGV],
    ["NAV DME:1","Nautical miles"],
], (data) => {
    console.log(data);
}, 0 /* radius=0 */, simConnect.simobjectType.USER);

Example: This will receive info about all aircraft within a 10 km radius. The callback will run one time for each identified aircraft.

simConnect.requestDataOnSimObjectType([
    ["ATC MODEL",null,simConnect.datatype.STRINGV],
    ["Plane Latitude", "degrees"],
    ["Plane Longitude", "degrees"]
], (data) => {
    console.log(data);
}, 10000, simConnect.simobjectType.AIRCRAFT);

createDataDefinition

createDataDefinition(reqData)

Used to create a data definition. Returns an id which can be used with requestDataOnSimObjectType in place of the array. This should be used when you have multiple requests for the same data - otherwise the app will crash after receiving too many requests.

Example:

var navInfoDefId = simConnect.createDataDefinition([
    ["NAV DME:1", "Nautical miles"],
    ["NAV GLIDE SLOPE ERROR:1", "Degrees"],
    ["NAV RADIAL ERROR:1", "Degrees"],
]);

setInterval(() => {
    simConnect.requestDataOnSimObjectType(navInfoDefId, (data) => {
        console.log(data)
    }, 0, simConnect.simobjectType.USER)
},100)

setDataOnSimObject

setDataOnSimObject(variableName, unit, value)

Set a single Simulation Variable on user aircraft. First parameter is the datum name, second is the units name and last is the value.

Example:

simConnect.setDataOnSimObject("GENERAL ENG THROTTLE LEVER POSITION:1", "Percent", 50);

subscribeToSystemEvent

subscribeToSystemEvent(eventName, callback)

Subscribe to a system event. See SDK Reference for available events.

Example:

simConnect.subscribeToSystemEvent("Pause", (paused) => { 
    // Called when the system event occurs
    console.log(paused ? "Sim paused" : "Sim un-paused");
});

close

close()

Manually close the connection to SimConnect. Returns false if it fails.

Example:

var success = simConnect.close();

Manual build 🔨

You might wish to build node-simconnect manually. Due to the licensing of the SimConnect SDK (is this still valid?) the library files are not included in this repository, so you must provide these yourself.

Requirements

  • Node.js (64 bit)
  • MS Visual Studio 2019

Build

You must provide your own copy of the SDK files. For FSX:SE, these can be found under C:\MSFS SDK\SimConnect SDK. Follow these steps carefully:

  • Copy the SimConnect SDK folder here
  • Run $npm run build

Licence

MIT

Code contributors :trophy: