Giter VIP home page Giter VIP logo

fsuipc-node-api's Introduction

@fsuipc/api - FSUIPC Node API

Tooling to use FSUIPC external application interface, with nodeJS.

Coverage Status npm version branch-master

Disclamer

This API is a wrapper around fsuipc-node adapter by koesie10 meant to create a simple API around all available fsuipc offsets.

Please find any information about FSUIPC on their website.

Requirements

In order for fsuipc (fsuipc-node) and @fsuipc/api (this package) to work, and so this API, you must have on your machine:

  • Windows 10 64bits
  • node 12+
  • python 3.7 (don't forget to add it to your PATH)
  • visualstudio 2017+ with desktop C++ package
  • fsuipc installed as flight simulator plugin

Node API usage requirements:

  • rxjs >= 6.5.0

Installation

npm i --save @fsuipc/api
or
yarn add @fsuipc/api

API Usage

After import, you can use FsuipcApi to listen to provided values.

Import

import { FsuipcApi } from '@fsuipc/api';

Instantiate

const fsuipcApi = new FsuipcApi(Simulator.FSX);

Init

FsuipcApi.init() returns a promise when you are properly connected to FSUIPC stream. In case your flight simulator isn't running, this will throw an error.

Listen to offsets values

FsuipcApi.listen() methods takes 2-3 arguments:

  • interval [number]: interval at which values will be polled from FSUIPC stream
  • offsetsList [string[]]: a list of string representing offsets you want to subscribe on
  • terminateOnError [boolean = true]: if set to true, if any value is errored, you will be disconnected from FSUIPC stream

This method returns a ConvertedOffsetValues observable. You can subscribe to this observable to handle values polled from stream.

Complete example

import { FsuipcApi } from '@fsuipc/api';

const fsuipcApi = new FsuipcApi(Simulator.FSX);

fsuipcApi.init().then(() => {
  fsuipcApi.listen(1000, [
    'gs',
    'altitude',
    'comFreq',
    'lights',
  ]).subscribe((result) => {
    // Use the result here
    console.log(JSON.stringify(result));
  });
}).catch((e) =>
  console.error(e)
);

fsuipc-node-api's People

Contributors

blackholegalaxy avatar flusinerd avatar

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.