Migration
Diese Seite wurde aus der AirSimTech MediaWiki migriert.
Navigation Database Access
Overview
NavDbActor is the single-threaded gatekeeper for all navigation database access in the FMGC. It owns the OleDb connection context to ASTNAV.mdb and ensures that all queries are serialized through a single actor mailbox, preventing the OleDb multi-thread crashes that occur when connections are shared across threads. All navigation data queries — airports, navaids, waypoints, SIDs, STARs, approaches, airways, and ILS corrections — are routed through this actor. Callers use the Ask+PipeTo pattern to submit queries without blocking their own mailboxes.
At startup, NavDbActor preloads all airports and navaids into memory during PreStart(), enabling O(1) in-memory lookup for those record types. Procedure and airway queries are executed on demand and cached per airport after the first load.
Ask+PipeTo Pattern
Callers never block waiting for a database response. Instead, they use Akka.NET's Ask+PipeTo pattern: the query is sent to NavDbActor as an Ask request, and the result is piped back to the caller's own mailbox as a typed message. The caller continues processing other messages while NavDbActor handles the query on its own thread.
The pattern is identical for all query types — only the message class and return type change. This design is critical because trajectory computation and MCDU page rendering share the same time budget; a blocking database call inside either actor would break the <100ms response target.
Query Handlers
NavDbActor delegates all queries to three specialist handler classes. Each handler owns its own OleDb access logic and returns typed result objects.
| Message | Handler Class | Return Type | Description |
|---|---|---|---|
LookupAirport |
AirportQueryHandler.Lookup |
AirportResult |
Look up airport by ICAO code (case-insensitive). Includes runways and ILS records. Preloaded at startup. |
LookupNavaid |
NavaidQueryHandler.Lookup |
NavaidResult |
Look up all navaids by identifier. Multiple navaids may share an identifier (e.g., co-located VOR and NDB). Preloaded at startup. |
LookupWaypoint |
NavaidQueryHandler.LookupWaypoint |
WaypointResult |
Look up all waypoints by identifier. Multiple waypoints may share an identifier. Preloaded at startup. |
SearchNavaidsNear |
NavaidQueryHandler |
NavaidResult |
Search navaids within a given range (NM) of a lat/lon position. Used for radio nav autotune proximity lookups. |
ReadIlsCorrections |
NavaidQueryHandler.ReadIlsCorrections |
IlsCorrectionResult |
Read user-overridden ILS corrections from Userdata.mdb for a given airport ICAO. On-demand query against the user database. |
LoadSid |
ProcedureQueryHandler.LoadSid |
ProcedureResult |
Load all SID procedures (ProcedureType=2) for an airport and runway designator. Common transitions (RunwayId=-1) always included. Cached per airport after first load. |
LoadStar |
ProcedureQueryHandler.LoadStar |
ProcedureResult |
Load all STAR procedures (ProcedureType=1) for an airport and runway designator. Cached per airport after first load. |
LoadApproach |
ProcedureQueryHandler.LoadApproach |
ProcedureResult |
Load approach procedures (ProcedureType=3) for an airport, runway, and optional approach name. Cached per airport after first load. |
LoadAirway |
ProcedureQueryHandler.LoadAirway |
AirwayResult |
Expand an airway between two named fixes. Queries the ATS table and resolves waypoint IDs via a delegate to NavaidQueryHandler. On-demand, not cached. |
LookupByIdent |
NavDbActor (in-memory) |
IdentLookupResult |
Combined navaid + waypoint search by identifier (VB6 parity: Get_Navaids searches navaids first, then waypoints). Returns IdentLookupMatch list with ident, lat/lon, frequency, source type ("VOR"/"NDB"/"ILS"/"WPT"), and database ID. Uses preloaded in-memory maps — no DB round-trip. Used by McduActor for FPLN page scratchpad waypoint insertion (Phase 23). |
LoadCompanyRoutes |
NavDbActor (stub) |
ProcedureResult |
Placeholder — logs a warning and returns an empty result. Company route loading is handled by UserdataActor. |
ProcedureResult carries two collections: a Procedures list of TerminalRecord objects (procedure headers) and a Legs dictionary keyed by TerminalId mapping to the ordered list of ProcedureLeg waypoints.
Database Paths
All databases are configured via the INI file, read during FmgcSupervisor initialization:
| INI Section | INI Key | Database File | Contents |
|---|---|---|---|
[Database] |
AstnavPath |
ASTNAV.mdb |
Airports, runways, ILS, navaids, waypoints, SID/STAR/approach procedures, airways (ATS table) |
[Database] |
UserdataPath |
Userdata.mdb |
ILS corrections, saved flight situations, company routes |
[Database] |
OpcamiPath |
OPCAMI.mdb |
Aircraft/engine configuration, performance thresholds, weight limits, fuel parameters, speed limits (single OPCAMI table, ID-keyed rows) |
Example INI read:
Dim astnavPath As String = config.GetValue("Database", "AstnavPath")
Dim userDataPath As String = config.GetValue("Database", "UserdataPath")
IniConfiguration.GetValue performs case-insensitive section and key lookup, replicating VB6 GetPrivateProfileString behaviour.
OleDb Connection
All OleDb connections use the Microsoft.ACE.OLEDB.12.0 provider with shared read access:
AirportQueryHandler and NavaidQueryHandler open and close a connection during PreloadAll(). ProcedureQueryHandler opens and closes connections per query using the Using block pattern. There is no persistent open connection — the OleDb provider's connection pool manages the underlying file handles. All access is serialised through the NavDbActor mailbox, eliminating concurrent access to the Access MDB file.
NavDbHelpers
NavDbHelpers is a Friend Class exposed to the test project via InternalsVisibleTo("A320_FMGC.Tests"). It provides two coordinate parsing utilities shared across all query handlers:
ParseLatLong(raw As String) As Double
: Converts a VB6-format DMS coordinate string to decimal degrees. Handles both the 8-character (without hundredths) and 10-character (with hundredths) formats stored in ASTNAV.mdb. Direction prefixes: N/E are positive, S/W are negative. Longitude uses 3-digit degrees; latitude uses 2-digit degrees.
: Examples: "N51282100" → +51.4725, "W0002741" → −0.4614
ParseSignedDecimalCoord(raw As String) As Double
: Parses a signed decimal-degree coordinate string from the Airport, Navaid, and Waypoint tables. Format: "+50,033310" or "-008,570456" (comma as decimal separator, sign prefix). Replaces the comma with a dot and parses with InvariantCulture. Returns 0.0 for null, empty, or unparseable strings. Navaid and Waypoint lat/lon fields use this same signed decimal format (not DMS), matching the Airport table storage.
ParseRunwayCoord(raw As String) As Double
: Handles the two storage formats used in the Runway table: decimal degrees (used as-is) and a raw integer needing division by 10000. Replicates VB6 ConvertLatLongString.
FormatIlsFrequency(raw As String) As String
: Formats an ILS frequency value from the database for display on MCDU pages.
AIRAC Cycle Information
During startup preload, NavDbActor reads the AIRAC table from ASTNAV.mdb to determine the active navigation database cycle. This matches VB6 frmMain.CheckNavdataUpdate (lines 6131-6299).
AIRAC Table Query
The single-row result contains three fields:
| Column | Type | Example | Purpose |
|---|---|---|---|
AIRAC |
String | "2601" |
4-digit AIRAC cycle identifier (YYnn) |
StartDate |
String | "28JAN" |
Cycle effective start date |
EndDate |
String | "25FEB" |
Cycle effective end date |
Field Derivation
Two display values are computed from the raw AIRAC fields, matching the VB6 Mid() formulas:
| Display Field | Formula | Example |
|---|---|---|
ActiveDb |
StartDate & "-" & EndDate |
"28JAN-25FEB" |
ActiveDbName |
"AST" & AIRAC |
"AST2601" |
Second Nav Database Detection
NavDbActor checks for a second navigation database at DatabaseUpdate\ASTNAV.mdb (relative to the application path). If found, it reads the same AIRAC table from the update database and compares cycle numbers. A database update is flagged as available when the update AIRAC year+cycle is numerically greater than the active one.
The result is carried on PreloadComplete via the AiracInfo class:
| Property | Type | Description |
|---|---|---|
ActiveDb |
String | Active date range (e.g. "28JAN-25FEB") |
ActiveDbName |
String | Active database name (e.g. "AST2601") |
SecondDb |
String | Update date range (empty if no update) |
SecondDbName |
String | Update database name (empty if no update) |
DatabaseUpdateAvailable |
Boolean | True when update cycle is newer |
Data Flow
NavDbActor.ReadAiracInfo() is called at the end of preload, after airports/navaids/waypoints are loaded. The AiracInfo is attached to the PreloadComplete message sent back to FmgcSupervisor. The supervisor merges AIRAC data with OPCAMI data into a complete StatusSnapshot and sends it to both McduActors via SetStatusData. The STATUS page then displays the active and (optionally) second nav database fields.
OPCAMI Configuration Database
OPCAMI.mdb is a separate Access database containing aircraft-specific configuration parameters. Unlike the navigation databases which are queried through NavDbActor, OPCAMI is read once during startup by FmgcSupervisor.PreStart() and the data is distributed to actors via messages.
OPCAMI Table Structure
The database contains a single OPCAMI table with ID-keyed rows. Each row has an integer ID and a string Value. The OpcamiData.ReadFromDatabase() method reads all rows and maps them using a Select Case on the ID, matching VB6 DatabaseHandle.cls ReadOPCAMI() exactly.
| ID | Field | Type | DB Transform | Purpose |
|---|---|---|---|---|
| 1 | WeightUnit | String | Direct | "K"=kg, "L"=lbs |
| 2 | LengthUnit | String | Direct | Length unit preference |
| 3 | MDAMDH | String | Direct | MDA/MDH selector |
| 4 | MaxGW | Double | /10 | Maximum gross weight (tons) |
| 5 | MaxRTERSV | Double | /10 | Maximum route reserve |
| 6 | MaxZFW | Double | /10 | Maximum zero fuel weight |
| 7 | MaxBLOCK | Double | /10 | Maximum block fuel |
| 8 | ForceSPDLIM | String | Direct | "Y"=force speed limit |
| 10 | ACType | String | Direct | Aircraft type (e.g. "A320-214") |
| 11 | EngType | String | Direct | Engine type (e.g. "CFM56-5B4") |
| 12 | ThrRedHeight | Integer | Direct | Thrust reduction height (ft AGL) |
| 13 | AccHeight | Integer | Direct | Acceleration height (ft AGL) |
| 14 | EOAccHeight | Integer | Direct | Engine-out acceleration height (ft AGL) |
| 15 | PerfFactor | Double | /10 | Performance correction factor |
| 16 | IdleFactor | Double | /10 | Idle thrust correction factor |
| 17 | TaxiFuel | Integer | Direct | Taxi fuel (kg) |
| 18 | PercentageOfTripFuelForRTERSV | Integer | Direct | Trip fuel % for route reserve |
| 22 | TimeFinalHoldingPattern | Integer | Direct | Final holding pattern time (min) |
| 23 | StandardTransAlt | Integer | Direct | Standard transition altitude (ft) |
| 24 | SPDLIM_SPD | Integer | Direct | Speed limit speed (kts) |
| 25 | SPDLIM_ALT | Integer | Direct | Speed limit altitude (ft) |
| 26 | DIRTO_Direct | Boolean | "N"=True | Direct-to routing flag |
| 27 | Waypoint_Abbreviation | String | "LLXX"="L" | Waypoint abbreviation type |
IDs 9, 19, 20, 21 are not used and are skipped during parsing.
Data Flow
FmgcSupervisor.PreStart() reads the OPCAMI database path from INI, calls OpcamiData.ReadFromDatabase(), then sends SetStatusData to both McduActors with real AcType, EngType, IdleFactor, and PerfFactor values (replacing hardcoded defaults). The full OpcamiData object is available for other consumers that need performance thresholds, speed limits, and fuel parameters.
Source Files
| File | Purpose |
|---|---|
A320_FMGC/NavDb/NavDbActor.vb |
ReceiveActor with all message handlers; delegates to query handler classes |
A320_FMGC/NavDb/AirportQueryHandler.vb |
Preloads and serves airports, runways, and ILS records |
A320_FMGC/NavDb/NavaidQueryHandler.vb |
Preloads and serves navaids and waypoints; ILS corrections from Userdata.mdb |
A320_FMGC/NavDb/ProcedureQueryHandler.vb |
On-demand SID/STAR/approach loading and airway expansion |
A320_FMGC/NavDb/NavDbMessages.vb |
All query and result message classes |
A320_FMGC/NavDb/NavDbModels.vb |
AirportRecord, RunwayRecord, IlsRecord, NavaidRecord, WaypointRecord, TerminalRecord, ProcedureLeg, AirwayRecord |
A320_FMGC/NavDb/NavDbHelpers.vb |
Coordinate and frequency parsing utilities |
A320_FMGC/Common/IniConfiguration.vb |
INI file parser; provides GetValue("Database", "AstnavPath") |
A320_FMGC/Common/OpcamiData.vb |
OPCAMI configuration class; ReadFromDatabase() and ParseFromIdValuePairs() |