Skip to content

Commit 30322fa

Browse files
committed
docs: add readme and documentation on the events
1 parent db96e44 commit 30322fa

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

DOCS.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Overview
2+
3+
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!
4+
5+
## Listener Events
6+
7+
Listener events are designed for monitoring and response. **Do not call these events**. Instead, set up listeners to handle them as they get called.
8+
9+
### NAVIGRAPH_Heartbeat
10+
11+
- **Type**: Listener
12+
- **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.
13+
- **Data**: None
14+
15+
### NAVIGRAPH_DownloadFailed
16+
17+
- **Type**: Listener
18+
- **Description**: Triggered on a failure in the navdata package download process.
19+
- **Data**: JSON string with an "error" key detailing the failure.
20+
- **Example**:
21+
```json
22+
{
23+
"error": "Request timed out"
24+
}
25+
```
26+
27+
### NAVIGRAPH_UnzippedFilesRemaining
28+
29+
- **Type**: Listener
30+
- **Description**: Triggered during navdata package unzipping, useful for displaying download/extraction progress.
31+
- **Data**: JSON string with "total" (total files in archive) and "unzipped" (number of files already unzipped) keys.
32+
- **Example**:
33+
```json
34+
{
35+
"total": 100,
36+
"unzipped": 50
37+
}
38+
```
39+
40+
### NAVIGRAPH_NavdataDownloaded
41+
42+
- **Type**: Listener
43+
- **Description**: Triggered on the completion of navdata package download and extraction.
44+
- **Data**: None
45+
46+
## Callable Events
47+
48+
Callable events are to be actively invoked to interact with the WASM module.
49+
50+
### NAVIGRAPH_DownloadNavdata
51+
52+
- **Type**: Callable
53+
- **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**
54+
- **Data**: JSON string with "url" (package URL) and "folder" (target extraction directory under `work/navdata/`) keys.
55+
- **Example**:
56+
```json
57+
{
58+
"url": "totallyvalidpackageurl",
59+
"folder": "avionics"
60+
}
61+
```
62+
63+
### NAVIGRAPH_SetDownloadOptions
64+
65+
- **Type**: Callable
66+
- **Description**: Configures download options, specifically the unzipping batch size to avoid simulation freezing.
67+
- **Data**: JSON string with "batchSize" key (number of files to unzip per frame).
68+
- **Example**:
69+
```json
70+
{
71+
"batchSize": 10
72+
}
73+
```
74+
75+
### NAVIGRAPH_DeleteAllNavdata
76+
77+
- **Type**: Callable
78+
- **Description**: Erases all downloaded navdata packages.
79+
- **Data**: None

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
11
# Navigraph Navdata Interface in MSFS
2+
3+
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).
4+
5+
## Repository Structure
6+
7+
Here's an overview on the structure of this repository, which is designed to be as simple as possible to use
8+
9+
- `examples/`
10+
- Contains sample implementations for using the navdata interface
11+
- `aircraft/` includes a base aircraft to test in the sim
12+
- `gauge/` includes a very simple TypeScript instrument to communicate with the WASM module
13+
- `src/`
14+
- Contains the source for the navdata interface (and soon the JS library)
15+
- `wasm_navdata_interface` includes the Rust source code for the WASM module
16+
17+
## Including in Your Aircraft
18+
19+
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).
20+
2. Add the WASM module into your `panel` folder in `PackageSources`
21+
3. Add the following entry into `panel.cfg` (make sure to replace `NN` with the proper `VCockpit` ID):
22+
```
23+
[VCockpitNN]
24+
size_mm=0,0
25+
pixel_size=0,0
26+
texture=NO_TEXTURE
27+
htmlgauge00=WasmInstrument/WasmInstrument.html?wasm_module=navdata_interface.wasm&wasm_gauge=navdata_interface,0,0,1,1
28+
```
29+
- 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
30+
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)
31+
32+
## Building the Sample Aircraft
33+
34+
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
35+
36+
1. [Download](https://nodejs.org/en/download) Node.js
37+
2. Open the `src/gauge` folder in a terminal
38+
3. Run `npm i` the first time you build, in order to install dependencies
39+
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).
40+
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
41+
6. Open the `examples/aircraft/NavdataInterfaceAircraftProject.xml` file in the simulator and build there
42+
43+
## Building the WASM Module Yourself
44+
45+
1. [Download](https://www.docker.com/products/docker-desktop/) Docker Desktop
46+
2. Open the `src/wasm_navdata_interface` folder in a terminal
47+
3. Run `.\build.bat` (must be on Windows)
48+
- This will take a while to download and build the first time, but subsequent runs will be quicker
49+
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`

0 commit comments

Comments
 (0)