-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add readme and documentation on the events
- Loading branch information
1 parent
db96e44
commit 30322fa
Showing
2 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Overview | ||
|
||
This document outlines the events used for communication with the WASM module. All data exchanged via these events is in the form of JSON strings. Remember to correctly stringify and parse this data for proper communication! | ||
|
||
## Listener Events | ||
|
||
Listener events are designed for monitoring and response. **Do not call these events**. Instead, set up listeners to handle them as they get called. | ||
|
||
### NAVIGRAPH_Heartbeat | ||
|
||
- **Type**: Listener | ||
- **Description**: Triggered every 5 seconds to indicate the WASM module's operational status. Monitoring the first heartbeat is important for verifying module initialization and activity. | ||
- **Data**: None | ||
|
||
### NAVIGRAPH_DownloadFailed | ||
|
||
- **Type**: Listener | ||
- **Description**: Triggered on a failure in the navdata package download process. | ||
- **Data**: JSON string with an "error" key detailing the failure. | ||
- **Example**: | ||
```json | ||
{ | ||
"error": "Request timed out" | ||
} | ||
``` | ||
|
||
### NAVIGRAPH_UnzippedFilesRemaining | ||
|
||
- **Type**: Listener | ||
- **Description**: Triggered during navdata package unzipping, useful for displaying download/extraction progress. | ||
- **Data**: JSON string with "total" (total files in archive) and "unzipped" (number of files already unzipped) keys. | ||
- **Example**: | ||
```json | ||
{ | ||
"total": 100, | ||
"unzipped": 50 | ||
} | ||
``` | ||
|
||
### NAVIGRAPH_NavdataDownloaded | ||
|
||
- **Type**: Listener | ||
- **Description**: Triggered on the completion of navdata package download and extraction. | ||
- **Data**: None | ||
|
||
## Callable Events | ||
|
||
Callable events are to be actively invoked to interact with the WASM module. | ||
|
||
### NAVIGRAPH_DownloadNavdata | ||
|
||
- **Type**: Callable | ||
- **Description**: Triggers the download of a navdata package. **Note: there will be a temporary freeze and drop in frames (this can be mitigated by setting download options) due to the downloading and unzipping process. Once it's complete, performance returns to normal** | ||
- **Data**: JSON string with "url" (package URL) and "folder" (target extraction directory under `work/navdata/`) keys. | ||
- **Example**: | ||
```json | ||
{ | ||
"url": "totallyvalidpackageurl", | ||
"folder": "avionics" | ||
} | ||
``` | ||
|
||
### NAVIGRAPH_SetDownloadOptions | ||
|
||
- **Type**: Callable | ||
- **Description**: Configures download options, specifically the unzipping batch size to avoid simulation freezing. | ||
- **Data**: JSON string with "batchSize" key (number of files to unzip per frame). | ||
- **Example**: | ||
```json | ||
{ | ||
"batchSize": 10 | ||
} | ||
``` | ||
|
||
### NAVIGRAPH_DeleteAllNavdata | ||
|
||
- **Type**: Callable | ||
- **Description**: Erases all downloaded navdata packages. | ||
- **Data**: None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,49 @@ | ||
# Navigraph Navdata Interface in MSFS | ||
|
||
This is a barebones implementation to be able to download up-to-date Navigraph navdata into the sim (more specifically into the `work` folder of the aircraft). | ||
|
||
## Repository Structure | ||
|
||
Here's an overview on the structure of this repository, which is designed to be as simple as possible to use | ||
|
||
- `examples/` | ||
- Contains sample implementations for using the navdata interface | ||
- `aircraft/` includes a base aircraft to test in the sim | ||
- `gauge/` includes a very simple TypeScript instrument to communicate with the WASM module | ||
- `src/` | ||
- Contains the source for the navdata interface (and soon the JS library) | ||
- `wasm_navdata_interface` includes the Rust source code for the WASM module | ||
|
||
## Including in Your Aircraft | ||
|
||
1. You'll need to either build the WASM module yourself (not recommended, but documented further down) or download it from [the latest release](https://github.com/Navigraph/msfs-navdata-interface/releases). | ||
2. Add the WASM module into your `panel` folder in `PackageSources` | ||
3. Add the following entry into `panel.cfg` (make sure to replace `NN` with the proper `VCockpit` ID): | ||
``` | ||
[VCockpitNN] | ||
size_mm=0,0 | ||
pixel_size=0,0 | ||
texture=NO_TEXTURE | ||
htmlgauge00=WasmInstrument/WasmInstrument.html?wasm_module=navdata_interface.wasm&wasm_gauge=navdata_interface,0,0,1,1 | ||
``` | ||
- Note that if you already have a `VCockpit` with `NO_TEXTURE` you can just add another `htmlgauge` to it, while making sure to increase the index | ||
4. Everything is set! All you need to do now is make sure you provide the module with a proper download link. More on that [here](/DOCS.md) | ||
|
||
## Building the Sample Aircraft | ||
|
||
Before building, make sure you have properly created and set an `.env` file in `src/gauge`! An example can be found in the `.env.example` file in that directory. Replace with your credentials | ||
|
||
1. [Download](https://nodejs.org/en/download) Node.js | ||
2. Open the `src/gauge` folder in a terminal | ||
3. Run `npm i` the first time you build, in order to install dependencies | ||
4. Run `npm run build` to build into the `PackageSources` folder of the aircraft sample (or `npm run dev` to build into the `Packages` folder of the aircraft and listen to changes in the source). | ||
5. Make sure the WASM module is included in the `panel` folder! Look at either [Including in Your Aircraft](#including-in-your-aircraft) or [Building the WASM Module Yourself](#building-the-wasm-module-yourself) for info on that | ||
6. Open the `examples/aircraft/NavdataInterfaceAircraftProject.xml` file in the simulator and build there | ||
|
||
## Building the WASM Module Yourself | ||
|
||
1. [Download](https://www.docker.com/products/docker-desktop/) Docker Desktop | ||
2. Open the `src/wasm_navdata_interface` folder in a terminal | ||
3. Run `.\build.bat` (must be on Windows) | ||
- This will take a while to download and build the first time, but subsequent runs will be quicker | ||
4. The compiled WASM module will be copied to `src/wasm_navdata_interface/out` **and** `examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navdata_Interface_Aircraft/panel` |