Git Product home page Git Product logo

extplanejs's Introduction

ExtPlaneJs

NPM version NPM version Dependency Status

A JavaScript Client Library for NodeJs that uses the ExtPlane plugin.

Inspired by ExtPlaneInterface for Java and ExtPlaneNet for C#

Prerequisites

  1. You need X-Plane (demo works fine) with the ExtPlane plugin installed.
  2. NodeJs >= 4.0.0

Installation

Install via NPM

$ npm install extplanejs

Connecting to X-Plane

Make sure X-Plane is started and the plugin is installed and active.

ExtPlaneJs Config

Either modify the config.json or modify the config object passed into ExtPlaneJs

{
    "host": "127.0.0.1",
    "port": 51000,
    "broadcast": false,
    "debug": true
}

Running the example connector

  1. Open your terminal
  2. cd to ExtPlaneJs
  3. Install Node.js Dependencies npm install
  4. Run npm start

Watch your terminal as your X-Plane information is streamed on-screen

Running the tests

  1. Make sure X-Plane is running and in a current flight. Not on the QuickFlight screen.
  2. Run npm test

Example

var ExtPlaneJs = require('extplanejs');

var ExtPlane = new ExtPlaneJs({
    host: '127.0.0.1',
    port: 51000,
    broadcast: true
});

ExtPlane.on('loaded', function(){

	ExtPlane.client.interval(0.33);

	// Subscribe to the airspeed
	ExtPlane.client.subscribe('sim/cockpit2/gauges/indicators/airspeed_kts_pilot');

	// Handle all data-ref changes
	ExtPlane.on('data-ref', function(data_ref, value){
		console.log(data_ref+' - '+value);
	});

});

ExtPlaneJS API

ExtPlaneJs(config)

Instantiate ExtPlaneJs and try connect

ExtPlaneJs.on(event)

Assign an event handler to the specific event

ExtPlaneJs.client.*

Access the client API from ExtPlaneJs

Events

  • loaded - No parameters
  • data-ref (data_ref, value) - Receive all data-ref events over one handler. Broadcast: true
  • sim/cockpit2/gauges/indicators/airspeed_kts_pilot (data_ref, value) - Receive individual data-ref events. Broadcast: false

Client API

client.key(key_id)

Press a key

client.once(cmd)

Execute a command

client.begin(cmd)

Begin a command

client.end(cmd)

End a command

client.button(button_id)

Press a button

client.release(button_id)

Release a button

client.set(data_ref, value)

Set a data refs value

client.subscribe(data_ref, [accuracy])

Subscribe to a data ref

client.unsubscribe(data_ref)

Unsubscribe to a data ref

client.interval(value)

Override the data update interval

client.disconnect()

Send the disconnect command

More information ?

See the example connector source in example.js for example subscriptions, methods available and event handlers for data refs

License

MIT License - Copyright © Bluu Interactive

Bluu

extplanejs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

extplanejs's Issues

dataref initial values

First, thanks! now the datarefs initial values are not set upon connection, (there is a open bug on Extplanejs for this) but in the current state the first connection should get the initial dataref values

Connection retry on error

If X-Plane doesn't run when the connector starts the net client throws an error but I was so far unable to build a retry mechanism.

Is there a way to do this outside of the library itself? Could it be integrated into ExtPlaneJs?

cu
Roman

'loaded' event not triggered (X-Plane 11.32)

When running the included example and debug is set to true I get
Connected to 127.0.0.1:51000. However, the loaded-event is not triggered. disconnected from server is printed when X-Plane closes.

When starting X-Plane from the terminal I get
ExtPlane-Plugin: Client connected from "::ffff:127.0.0.1"
when the client connects, so there's obviously a connection.

  • MacOS 10.14.3
  • X-Plane 11.32

Dataref byte[] not possibel

I can not read any datarefs with byte definition.
Example :

sim/aircraft/view/acf_tailnum byte[40] y string Tail number
sim/aircraft/view/acf_author byte[500] y string Author's Name
sim/aircraft/view/acf_descrip byte[260] y string Brief description of the plane. Was 500 chars in older planes.
sim/aircraft/view/acf_notes byte[240] y string Notes on the plane

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.