Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: implement dfd v2 support as well as new package management #7

Open
wants to merge 84 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
bf89dd8
wip: frameworking out new structure
ZigTag Oct 1, 2024
0403ef7
wip: now compiles
ZigTag Oct 1, 2024
0f01537
wip: most of the searching and loading logic written
ZigTag Oct 1, 2024
b860e25
refactor: file formats can now set their own read/database setups
ZigTag Oct 1, 2024
ee45c66
feat: now copies navigation data to hierarchy
ZigTag Oct 2, 2024
f350891
feat: implemented part of the ts interface
ZigTag Oct 2, 2024
0259e00
feat: now loads in sim
ZigTag Oct 3, 2024
935ad99
chore: fix comment
ZigTag Oct 3, 2024
4da123d
feat: downloading works
ZigTag Oct 4, 2024
d27e685
feat: implemented sorting and filtering to ListAvailablePackages
ZigTag Oct 4, 2024
d810ecc
refactor: moved some errors over to traits.rs
ZigTag Oct 4, 2024
7ca93c0
wip: v2 compiles
ZigTag Oct 4, 2024
7684210
update rfcs
professoralex13 Oct 7, 2024
ac90fb8
feat: implemented airports in v2
ZigTag Oct 8, 2024
bf7d275
Merge branch 'dfdv2' of https://github.com/Navigraph/msfs-navigation-…
ZigTag Oct 8, 2024
fa95989
wip: start implementing new functions for v2
ZigTag Oct 9, 2024
df48499
wip: still implementing airways/proceedures
ZigTag Oct 10, 2024
628d2b0
fix: remove unnecessary dep
ZigTag Oct 10, 2024
c7cd81f
feat: implement airway fetching
ZigTag Oct 11, 2024
30a751f
chore: added comments
ZigTag Oct 11, 2024
7e33d4f
refactor: made the searching faster
ZigTag Oct 11, 2024
5189c6a
feat: uses active to display active db rather than keeping it set int…
ZigTag Oct 15, 2024
12d2b0e
feat: implemented package cleaning and deleting
ZigTag Oct 16, 2024
a936ffb
refactor: rewrote so its compatible without the ID system
ZigTag Oct 16, 2024
8d9d9e3
feat: implemented communication and runway for v2
ZigTag Oct 16, 2024
00e0709
feat: departures work
ZigTag Oct 17, 2024
28c0b4a
feat: implemented rest of procedure types
ZigTag Oct 17, 2024
f785af1
feat: completed all funcitons
ZigTag Oct 17, 2024
95e6398
fix: database info updated
ZigTag Oct 18, 2024
6c0c62c
feat: implement database format switching and trait enums
ZigTag Oct 21, 2024
f640436
chore: update rust version (from pr 4)
ZigTag Oct 21, 2024
a1421b5
chore: cargo fmt + clippy lints
ZigTag Oct 22, 2024
8117433
wip: setting active on finish download
ZigTag Oct 22, 2024
a28fdcb
feat: implement switch on download
ZigTag Oct 22, 2024
f88c55b
wip: rework status logic
ZigTag Oct 22, 2024
5307ba0
refactor: change get_navigation_data_install_status to just return st…
ZigTag Oct 23, 2024
ec098b6
feat: now defaults to enabling a database by default
ZigTag Oct 23, 2024
4048ea9
chore: cargo fmt + clippy lints
ZigTag Oct 23, 2024
598bb71
wip: trying to get jest working
ZigTag Oct 23, 2024
08e67d8
wip: what is happening?
ZigTag Oct 24, 2024
c6d3eca
fix: 4 line fix
ZigTag Oct 25, 2024
bc10933
wip: updating tests to work with v1 and v2
ZigTag Oct 25, 2024
a5e2c6a
wip: updating test cases
ZigTag Oct 25, 2024
7da6a91
feat: added a lot of v2 test cases
ZigTag Oct 29, 2024
f0987cf
fix: all non time-out tests
ZigTag Oct 29, 2024
a3d40de
refactor: replace db_type with a method on DatabaseTrait
ZigTag Oct 29, 2024
27a2362
chore: remove timeouts
ZigTag Oct 30, 2024
2cb2968
fix: add some new fields
ZigTag Oct 30, 2024
0e1888f
chore: fmt + clippy
ZigTag Oct 31, 2024
2e4cd82
refactor: got rid of some clones, as well as added databasePath to cy…
ZigTag Oct 31, 2024
5ba31a9
fix: serde serializes cycle.json properly now
ZigTag Oct 31, 2024
3ab0fe7
BREAKING: remove get installation status
professoralex13 Nov 4, 2024
152cb97
fix: jest
ZigTag Nov 5, 2024
c6cfe76
chore: cargo fmt + clippy lint
ZigTag Nov 5, 2024
59488de
fix: is_bundled now displays correctly
ZigTag Nov 5, 2024
f14eb72
fix: todos
ZigTag Nov 5, 2024
1eb76c8
feat: version now shows short git hash as well
ZigTag Nov 5, 2024
26a7e46
feat: add tailwind to example gauge
ZigTag Nov 5, 2024
1169e8e
feat: new tabbing and pages
ZigTag Nov 6, 2024
9c63c25
fix: removed tailwind-merge
ZigTag Nov 6, 2024
3db3dcd
feat: made theming nicer, trying to work out why the database won't show
ZigTag Nov 6, 2024
7b8c631
feat: added active database
ZigTag Nov 6, 2024
f11f75a
feat: implemented database selecting
ZigTag Nov 7, 2024
601085f
feat: implemented auth/download page
ZigTag Nov 7, 2024
a3669d8
feat: started to implement function selector
ZigTag Nov 8, 2024
daedbe7
feat: test page works
ZigTag Nov 12, 2024
5705f4d
fix: resizing issue (hardcoded witdh for now)
ZigTag Nov 12, 2024
51c8f54
fix: scrollbars and added hover
ZigTag Nov 12, 2024
dc1842d
feat: add all function types
ZigTag Nov 12, 2024
68b9e67
fix: api output type
ZigTag Nov 13, 2024
c68d8ba
fix: tests
professoralex13 Nov 13, 2024
00355b2
feat: implement package deletion button
ZigTag Nov 14, 2024
b0b1b4f
chore: cargo fmt
ZigTag Nov 14, 2024
4319e79
chore: cargo clippy
ZigTag Nov 14, 2024
3673bb1
chore: remove custom cargo fmt
ZigTag Nov 14, 2024
f0099fc
fix: workflow script
ZigTag Nov 14, 2024
d595602
Merge branch 'main' into dfdv2
ZigTag Nov 14, 2024
628e975
fix: workflow script 2
ZigTag Nov 14, 2024
3f573b2
feat: package management tests
professoralex13 Nov 14, 2024
b50f9ce
Merge branch 'main' into dfdv2
professoralex13 Nov 14, 2024
42db948
chore: remove `build_dev` script
pepperoni505 Nov 18, 2024
cf21b47
fix: add missing rustflags
pepperoni505 Nov 18, 2024
c91550f
Merge branch 'main' into dfdv2
pepperoni505 Nov 18, 2024
46d7498
feat: implemented more crash failsafes along with old data migration
ZigTag Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ tsconfig.tsbuildinfo
.vs
examples/aircraft/PackageSources/html_ui/Pages/VCockpit/Instruments/Navigraph/NavigationDataInterfaceSample
examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/panel/msfs_navigation_data_interface.wasm
examples/aircraft/PackageSources/bundled-navigation-data
!examples/aircraft/PackageSources/bundled-navigation-data/sample-data-v1
!examples/aircraft/PackageSources/bundled-navigation-data/sample-data-v2

out

# Rust
Expand Down
1 change: 1 addition & 0 deletions docs/RFC 001.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ This interface is also not designed for use outside of Microsoft Flight Simulato
- Do: `Vhf`
- Dont: `NDB`
- Latitudes should be encoded to as `lat` and Longitudes should be encoded to as `long`, and should wherever they are used in conjunction with each other, be part of a `Coordinates` data structure
- For enum types, Unknown shall be an enum variant if neccessary, and for all other types such as numbers or strings, an unknown value will be indicated by being undefined. This applies for fields which are only supported by certain database sources, if there is an output field that some database does not provide, that value shall be set to unknown, whatever that means for the said field.

---

Expand Down
126 changes: 126 additions & 0 deletions docs/RFC 002.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Specification for loading and persistence of Navigation Data packages in Microsoft Flight Simulator

To be Reviewed By: Katlyn Courtade, Jack Lavigne, Markus Hamburger

Authors: Alex Cutforth

Status: In Progress

## Definition of Terms

- `developers` refers to any third party aircraft developer wishing to use Navigraph's in sim navigation data package loader
- `sim`/`the sim` refers to Microsoft Flight Simulator specifically
- `wasm-interface` refers to the WASM bundle that is run in sim by aircraft wishing to download or load Navigraph's navigation data. Aircraft developers can interface with this bundle through CommBus calls

## Problem

Shipping navigation data to aircraft is traditionally done by an external program, while the simulator is not running. This is inconvinent especially when users forget to update their navigation data before starting the simulator. This RFC will outline a system for storing navigation data packages in sim persistently, and outline a system for automatically loading bundled navigation data.

# Solution

## Storage

Navigation Data packages shall be stored within a folder in the simulator `work` folder called `navigation-data`, so `/work/navigation-data`. Each package should be a folder containing all the data and metadata for that package. These folders should be given uuids as names to prevent collisions. The contents of these folders should match the contents of the ZIP folder provided from the Navigraph packages API, that is, the .zip is essentially transformed into a file system folder with a uuid name.

The UUID of each folder should be seeded based on the [uniqeness properties](#package-uniqueness) of the `cycle.json` so that folder names can be used to check if two packages are the same without reading both `cycle.json`s. This also ensures that two packages that are the 'same' are not installed at the same time.

Every package which is downloaded must contain exactly one `cycle.json` file placed at the root. This file shall follow the following structure:

```ts
{
cycle: string, // E.g.: "2311" Represents the AIRAC cycle number of this package
revision: string, // E.g.: "2"
name: string, // E.g.: "avionics_v1" (this is an arbitrary name that generally represents what/who this package is meant for)
format: 'dfd' | 'dfdv2' | 'custom', // Represents the format of the data present. Note that further format types may be added if they are supported with custom wrappers in the `wasm-interface`
validityPeriod: string, // E.g.: "2024-10-03/2024-10-30" Represents the time period through which this package is valid (generally matches the AIRAC cycle period)

// Required for dfd_v1 and dfd_v2
databasePath?: string, // E.g.: "/e_dfd_2311.s3db" Provides the path to the dfd database file from the root of the folder

// May contain any other neccessary metadata such as paths to certain files/folders
}
```

Any folder within the `navigation-data` folder which does not contain a `cycle.json` at the root, or contains more than one `cycle.json` will be regarded as an invalid package, and will not be recognised by the wasm-interface.

### Example file structure:

```
work
| navigation-data
| | bac9657d-36b8-4ffb-8052-7d88b13f6ff8
| | | cycle.json
| | | e_dfd_2311.s3db
| | | ...
| |
| | 27b1642c-7572-468a-b11a-be1b944c5e43
| | | cycle.json
| | | Config
| | | | .DS_Store
| | | |
| | | | NavData
| | | | | airports.dat
| | | | | apNavAPT.txt
| | | | | ...
| | | |
| | | | SidStars
| | | | | NZCH.txt
| | | | | KJFK.txt
| | | | | ...

```

## Package Uniqueness

The `cycle.json` properties: `cycle`, `revision`, `name` and `format` shall be used to differentiate packages from one another. That is to say, the `navigation-data` folder shouldn't have multiple packages with the same set of said properties.

## Bundled data

**It is important to note that the package folder name is unrelated to the `name` field in `cycle.json`**

Aircraft devlopers may bundle navigation data packages with their aircraft by placing them in `/PackageSources/bundled-navigation-data` in the same way packages are stored in `\work\navigation-data`. On initialisation of the wasm-interface, all packages in `bundled-navigation-data` that are not already in `/work/navigation-data` (see [Package Uniqueness](#package-uniqueness) for details on how to check if two packages are the same) shall be copied to `/work/navigation-data`. The packages in `bundled-navigation-data` may have any folder name, so when copying a package to `/work/navigation-data` the folder shall be renamed to the seeded uuid. If this was not the case, an aircraft update may bundle a newer cycle version package which would then have the same folder name as the previous package in `/work/navigation-data`, so to avoid having to check for clashes and delete the previous package, the package folder will be given seeded uuid name. This is to ensure developers to properly check that their desired package and format is present before tring to load it (This can be done using the function outlined in [Package Selection](#package-selection)). Packages which are copied over from `bundled-navigation-data` should not be deleted from `bundled-navigation-data`.

## Download

Navigation data can be downloaded using Navigraph's packages API. The wasm-interface shall provide a function `DownloadNavigationData` which will take in a download URL, and download it to the `\work\navigation-data`. The wasm-interface will unzip the contents of the download into a folder with a seeded uuid name in order to match the [required file structure](#example-file-structure). The wasm-interface should also provide a function `SetDownloadOptions` which allows the developer to specify the maximum file extraction/deletion rate to maintain sim performance.

Note that the packages API may provide packages which are not valid navigation data packages, do not attempt to download these as they will not be recognised by the `wasm-interface` once installed.

The DownloadNavigationData function shall provide an optional parameter to **explicitly** enable automatic selection of the package once it has been downloaded.

## Package deletion

The wasm-interface shall provide a function `DeletePackage` which shall delete a package from `/work/navigation-data` based on its uuid.

## Package Cleanup

The wasm-interface shall provide a function `CleanPackages` which shall delete all package from `/work/navigation-data` which do not have the same format as the currently active database. It shall accept an optional parameter `count` which will limit the number of matching format packages to retain. Any packages which are also present in the `bundled-navigation-data` folder will be retained regardless of `count` or format.

## Package Selection

The wasm-interface shall provide a function `ListAvailablePackages` which returns a list of valid packages present in the `/work/navigation-data` folder.

### `ListAvailablePackages` Result type

```ts
[
{
uuid: string, // E.g.: "bac9657d-36b8-4ffb-8052-7d88b13f6ff8" Provides the seeded uuid of the package (same as the folder name)
path: string, // E.g. "/work/navigation-data/bac9657d-36b8-4ffb-8052-7d88b13f6ff8" Provides the absolute path in the wasm file system to the package folder.
is_bundled: boolean,
cycle: {
// Provides all the data from the cycle.json
...
}
}
...
]
```

### Active package

A package is said to be "selected" or "active" by having its folder renamed to `active`. This enables persistent selection and assurance that only one package is active at any one time. Developers can then find the currently selected package in `/work/navigation-data/active/`.

The wasm-interface shall provide a function `SetActivePackage`. This function shall take in the uuid of the package to be selected, and that package folder shall then be renamed to `active`. If the active package `cycle.json` format field indicates the package is of a format that can be read by the `wasm-interface` database functionality, it will be automatically selected for use. When a package is "de-selected", that is, a different package is selected, it's folder shall be renamed to its seeded uuid.

The wasm-interface shall also provide a function `GetActivePackage`. This function shall return information about the package which is currently active, in the same format as `ListAvailablePackages`. If no package is active, the function shall return null.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@
<AssetDir>PackageSources\Data\</AssetDir>
<OutputDir>Data\</OutputDir>
</AssetGroup>
<AssetGroup Name="NavigationData">
<Type>Copy</Type>
<Flags>
<FSXCompatibility>false</FSXCompatibility>
</Flags>
<AssetDir>PackageSources\NavigationData\</AssetDir>
<OutputDir>NavigationData\</OutputDir>
</AssetGroup>
<AssetGroup Name="SimObject">
<Type>SimObject</Type>
<Flags>
Expand All @@ -43,6 +35,14 @@
<AssetDir>PackageSources\SimObjects\Airplanes\Navigraph_Navigation_Data_Interface_Aircraft\</AssetDir>
<OutputDir>SimObjects\Airplanes\Navigraph_Navigation_Data_Interface_Aircraft\</OutputDir>
</AssetGroup>
<AssetGroup Name="bundled-navigation-data">
<Type>Copy</Type>
<Flags>
<FSXCompatibility>false</FSXCompatibility>
</Flags>
<AssetDir>PackageSources\bundled-navigation-data\</AssetDir>
<OutputDir>bundled-navigation-data\</OutputDir>
</AssetGroup>
<AssetGroup Name="html_ui">
<Type>Copy</Type>
<Flags>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"cycle":"2401","revision":"1","name":"Navigraph Avionics", "format": "dfdv2", "validityPeriod": "2024-01-25/2024-02-21"}
Binary file not shown.
57 changes: 51 additions & 6 deletions examples/gauge/Components/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { ComponentProps, DisplayComponent, FSComponent, Subscribable, UUID, VNode } from "@microsoft/msfs-sdk"
import {
ComponentProps,
DisplayComponent,
FSComponent,
Subscribable,
SubscribableUtils,
UUID,
VNode,
} from "@microsoft/msfs-sdk"
import { InterfaceNavbarItemV2 } from "./Utils"

interface InputProps extends ComponentProps {
value?: string
value: Subscribable<string>
setValue: (value: string) => void
default?: Subscribable<string> | string
class?: string | Subscribable<string>
textarea?: boolean
}
Expand All @@ -10,13 +21,16 @@ export class Input extends DisplayComponent<InputProps> {
private readonly inputId = UUID.GenerateUuid()
private readonly inputRef = FSComponent.createRef<HTMLInputElement>()

get value() {
return this.inputRef.instance.value
}

onAfterRender(node: VNode): void {
super.onAfterRender(node)

this.props.value.map(val => (this.inputRef.instance.value = val))
SubscribableUtils.toSubscribable(this.props.default ?? "", true).map(val => {
this.inputRef.instance.placeholder = val
})

this.inputRef.instance.addEventListener("input", () => this.props.setValue(this.inputRef.instance.value ?? ""))

this.inputRef.instance.onfocus = this.onInputFocus
this.inputRef.instance.onblur = this.onInputBlur
}
Expand Down Expand Up @@ -54,3 +68,34 @@ export class Input extends DisplayComponent<InputProps> {
return <input ref={this.inputRef} {...this.getInputProps()} />
}
}

interface CheckboxProps extends ComponentProps {
value: Subscribable<string>
setValue: (value: string) => void
default?: Subscribable<string> | string
class?: string
}

export class Checkbox extends DisplayComponent<CheckboxProps> {
private readonly isActive = this.props.value.map(val => (val == "true" ? true : false))

private onClick = () => {
this.props.setValue(this.isActive.get() ? "false" : "true")
}

render(): VNode {
return (
<InterfaceNavbarItemV2
content={""}
active={this.isActive}
class={`h-full flex-grow bg-white text-black flex items-center justify-center hover:bg-gray-400 ${
this.props.class ?? ""
}`}
activeClass="hover:!bg-green-700 !bg-green-500 !text-white"
setActive={() => this.onClick()}
>
<span class="text-4xl">{this.isActive.map(val => (val ? "✔" : "X"))}</span>
</InterfaceNavbarItemV2>
)
}
}
12 changes: 12 additions & 0 deletions examples/gauge/Components/InterfaceSample.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,25 @@
padding: 2rem;
}

.horizontal-no-pad {
display: flex;
flex-direction: row;
justify-content: space-evenly;
align-items: flex-start;
}

.vertical {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.scrollable {
overflow: scroll;
height: 400px;
}

.text-field {
width: fit-content;
height: 50px;
Expand Down
Loading
Loading