@tfdidesign/fsuipc-typescript-client
v0.9.52
Published
fsuipc api using koise10 fsuipc wrapper
Downloads
662
Readme
fsuipc-typescript-client
fsuipc-typescript-client is a node dependency wirtten to allow easy access to the FSUIPC API.
This package offers:
- Read offset
- Write offset*
- Ability to get raw fsuipc data
- Error handling/disconnect handling
- Easily controllable update interval
*Write support is only supported for Bit
and Numbers
offset types.
Disclamer
This package is a modifided version of fsuipc-node
(fsuipc-node) and built off fsuipc
(fsuipc)
Requirements
In order for fsuipc
(fsuipc-node) and @tfdidesign/fsuipc-typescript-client
to work, and and therefore, this API, you must have on your machine:
- Windows 10 64bit or Windows 11 64bit
- Node 12+
- Python 3.7 (don't forget to add it to your PATH)
- Visual Studio 2017+ with desktop C++ package
- FSUIPC installed as flight simulator plugin
Node API usage requirements:
rxjs
>= 6.5.0
Get Started
Download the dependency using the following options: npm :
npm i --save @tfdidesign/fsuipc-typescript-client
or yarn:
yarn add @tfdidesign/fsuipc-typescript-client
After import, you can use FsuipcClient
to listen to provided values.
Import
new FsuipcClient()
takes one argument:
options
[{interval : number, simulator: ?Simulator, closeOnError : ?boolean, includeRaw: ?boolean}]:
import { FsuipcClient, Simulator } from '@tfdidesign/fsuipc-typescript-client';
const fsuipcClient = new FsuipcClient({ interval : 1000, simulator : Simulator.FSX, closeOnError : false, includeRaw : false });
options:
- Interval type
Number
: time inms
passed after each stream update. - Simulator is type
Simulator
: targeted simulator. - closeOnError type
boolean
: if the client need to close connection with the simulator if error accours down the stream. - includeRaw type
boolean
: this will include raw data on each stream update.
Init
FsuipcClient.connect()
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
FsuipcClient.listen()
method take 1 argument :
offsetsList
[string[]]: a list of string representing offsets you want to subscribe This method returns aConvertedOffsetValues
observable. You can subscribe to this observable to handle values polled from stream.
Complete example
import { FsuipcClient } from '@tfdidesign/fsuipc-typescript-client';
const fsuipcClient = new FsuipcClient({ interval : 1000, simulator : Simulator.FSX, closeOnError : false, includeRaw : false });
fsuipcClient.connect().then(() => {
fsuipcClient.listen([
'gs',
'altitude',
'comFreq',
'lights',
]).subscribe((result) => {
// Use the result here
console.log(JSON.stringify(result));
});
}).catch((e) =>
console.error(e)
);