|
1 |
| -import { ClockEvents, FSComponent, Subject, VNode } from '@microsoft/msfs-sdk'; |
2 |
| - |
3 |
| -import './MfdFmsPositionNavaids.scss'; |
4 |
| -import { NavaidSubsectionCode } from '@flybywiresim/fbw-sdk'; |
5 | 1 | import { AbstractMfdPageProps } from 'instruments/src/MFD/MFD';
|
6 |
| -import { Footer } from 'instruments/src/MFD/pages/common/Footer'; |
7 |
| - |
8 | 2 | import { Button } from 'instruments/src/MFD/pages/common/Button';
|
9 |
| -import { FmsPage } from 'instruments/src/MFD/pages/common/FmsPage'; |
10 |
| -import { MfdSimvars } from 'instruments/src/MFD/shared/MFDSimvarPublisher'; |
11 |
| -import { InputField } from 'instruments/src/MFD/pages/common/InputField'; |
12 | 3 | import {
|
13 | 4 | FrequencyILSFormat,
|
14 | 5 | FrequencyVORDMEFormat,
|
15 | 6 | InboundCourseFormat,
|
16 | 7 | LsCourseFormat,
|
17 | 8 | NavaidIdentFormat,
|
18 | 9 | } from 'instruments/src/MFD/pages/common/DataEntryFormats';
|
| 10 | +import { FmsPage } from 'instruments/src/MFD/pages/common/FmsPage'; |
| 11 | +import { Footer } from 'instruments/src/MFD/pages/common/Footer'; |
| 12 | +import { InputField } from 'instruments/src/MFD/pages/common/InputField'; |
19 | 13 | import { TopTabNavigator, TopTabNavigatorPage } from 'instruments/src/MFD/pages/common/TopTabNavigator';
|
20 |
| -import { NavigationDatabaseService } from '@fmgc/index'; |
| 14 | +import { MfdSimvars } from 'instruments/src/MFD/shared/MFDSimvarPublisher'; |
21 | 15 | import { NXSystemMessages } from 'instruments/src/MFD/shared/NXSystemMessages';
|
| 16 | + |
| 17 | +import { coordinateToString, NavaidSubsectionCode } from '@flybywiresim/fbw-sdk'; |
| 18 | +import { NavigationDatabaseService, SelectedNavaidType } from '@fmgc/index'; |
22 | 19 | import { NavRadioTuningStatus } from '@fmgc/navigation/NavaidTuner';
|
| 20 | +import { ClockEvents, FSComponent, SimVarValueType, Subject, VNode } from '@microsoft/msfs-sdk'; |
| 21 | + |
| 22 | +import './MfdFmsPositionNavaids.scss'; |
23 | 23 |
|
24 | 24 | interface MfdFmsPositionNavaidsProps extends AbstractMfdPageProps {}
|
25 | 25 |
|
| 26 | +interface SelectedNavaid { |
| 27 | + ident: Subject<string>; |
| 28 | + frequencyOrChannel: Subject<string>; |
| 29 | + class: Subject<string>; |
| 30 | +} |
| 31 | + |
| 32 | +const NAVAID_TYPE_STRINGS: Record<SelectedNavaidType, string> = { |
| 33 | + [SelectedNavaidType.None]: '', |
| 34 | + [SelectedNavaidType.Dme]: 'DME', |
| 35 | + [SelectedNavaidType.Vor]: 'VOR', |
| 36 | + [SelectedNavaidType.VorDme]: 'VOR/DME', |
| 37 | + [SelectedNavaidType.VorTac]: 'VOR/TAC', |
| 38 | + [SelectedNavaidType.Tacan]: 'TACAN', |
| 39 | + [SelectedNavaidType.Ils]: 'ILS/DME', |
| 40 | + [SelectedNavaidType.Gls]: 'GLS', |
| 41 | + [SelectedNavaidType.Mls]: 'MLS', |
| 42 | +}; |
| 43 | + |
26 | 44 | export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
|
27 | 45 | private navaidsSelectedPageIndex = Subject.create<number>(0);
|
28 | 46 |
|
@@ -66,25 +84,15 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
|
66 | 84 |
|
67 | 85 | private lsCourseEnteredByPilot = Subject.create<boolean>(false);
|
68 | 86 |
|
69 |
| - private firstRowIdent = Subject.create<string | null>(null); |
70 |
| - |
71 |
| - private firstRowFrequency = Subject.create<string | null>(null); |
72 |
| - |
73 |
| - private firstRowClass = Subject.create<string | null>(null); |
74 |
| - |
75 |
| - private secondRowIdent = Subject.create<string | null>(null); |
76 |
| - |
77 |
| - private secondRowFrequency = Subject.create<string | null>(null); |
78 |
| - |
79 |
| - private secondRowClass = Subject.create<string | null>(null); |
80 |
| - |
81 |
| - private thirdRowIdentRef = FSComponent.createRef<HTMLDivElement>(); |
82 |
| - |
83 |
| - private thirdRowIdent = Subject.create<string | null>(null); |
| 87 | + private readonly selectedNavaids: SelectedNavaid[] = Array.from({ length: 3 }, () => ({ |
| 88 | + ident: Subject.create(''), |
| 89 | + frequencyOrChannel: Subject.create(''), |
| 90 | + class: Subject.create(''), |
| 91 | + })); |
84 | 92 |
|
85 |
| - private thirdRowFrequency = Subject.create<string | null>(null); |
| 93 | + private readonly radioNavMode = Subject.create(''); |
86 | 94 |
|
87 |
| - private thirdRowClass = Subject.create<string | null>(null); |
| 95 | + private readonly radioNavPosition = Subject.create(''); |
88 | 96 |
|
89 | 97 | private deselectedNavaids = [
|
90 | 98 | Subject.create<string | null>(null),
|
@@ -146,11 +154,51 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
|
146 | 154 | }
|
147 | 155 | });
|
148 | 156 |
|
149 |
| - // Third line for selected navaids table: Display LS if set |
150 |
| - this.thirdRowFrequency.set(mmr.frequency ? mmr.frequency.toFixed(2) : ''); |
151 |
| - this.thirdRowClass.set(mmr.ident ? 'ILS/DME' : ''); |
152 |
| - this.thirdRowIdent.set(mmr.ident ?? null); |
153 |
| - this.thirdRowIdentRef.instance.style.visibility = mmr.ident ? 'visible' : 'hidden'; |
| 157 | + const selectedNavaids = this.props.fmcService.master?.navigation.getSelectedNavaids(); |
| 158 | + |
| 159 | + if (selectedNavaids) { |
| 160 | + for (const [i, navaid] of selectedNavaids.entries()) { |
| 161 | + if (i === 0) { |
| 162 | + // display vor is not shown on this page on A380 |
| 163 | + continue; |
| 164 | + } |
| 165 | + this.selectedNavaids[i - 1].ident.set(navaid.ident ?? ''); |
| 166 | + this.selectedNavaids[i - 1].frequencyOrChannel.set( |
| 167 | + navaid.facility === null || navaid.frequency === null ? '' : navaid.frequency.toFixed(2), |
| 168 | + ); |
| 169 | + this.selectedNavaids[i - 1].class.set(navaid.facility !== null ? NAVAID_TYPE_STRINGS[navaid.type] : ''); |
| 170 | + } |
| 171 | + // fake it until we make it |
| 172 | + if (selectedNavaids[1].facility !== null && selectedNavaids[2].facility !== null) { |
| 173 | + this.radioNavMode.set('DME/DME'); |
| 174 | + this.radioNavPosition.set( |
| 175 | + coordinateToString( |
| 176 | + SimVar.GetSimVarValue('PLANE LATITUDE', SimVarValueType.Degree), |
| 177 | + SimVar.GetSimVarValue('PLANE LONGITUDE', SimVarValueType.Degree), |
| 178 | + false, |
| 179 | + ), |
| 180 | + ); |
| 181 | + } else if (selectedNavaids[1].facility !== null) { |
| 182 | + this.radioNavMode.set('VOR/DME'); |
| 183 | + this.radioNavPosition.set( |
| 184 | + coordinateToString( |
| 185 | + SimVar.GetSimVarValue('PLANE LATITUDE', SimVarValueType.Degree), |
| 186 | + SimVar.GetSimVarValue('PLANE LONGITUDE', SimVarValueType.Degree), |
| 187 | + false, |
| 188 | + ), |
| 189 | + ); |
| 190 | + } else { |
| 191 | + this.radioNavMode.set(''); |
| 192 | + } |
| 193 | + } else { |
| 194 | + for (const sel of this.selectedNavaids) { |
| 195 | + sel.ident.set(''); |
| 196 | + sel.frequencyOrChannel.set(''); |
| 197 | + sel.class.set(''); |
| 198 | + } |
| 199 | + this.radioNavMode.set(''); |
| 200 | + this.radioNavPosition.set(''); |
| 201 | + } |
154 | 202 | }
|
155 | 203 |
|
156 | 204 | private async parseNavaid(navaid: string, onlyVor = false) {
|
@@ -414,34 +462,71 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
|
414 | 462 | <div class="mfd-label br bb">IDENT</div>
|
415 | 463 | <div class="mfd-label br bb">FREQ/CHAN</div>
|
416 | 464 | <div class="mfd-label bb">CLASS</div>
|
417 |
| - <div class="mfd-label br">{this.firstRowIdent}</div> |
418 |
| - <div class="mfd-value br">{this.firstRowFrequency}</div> |
419 |
| - <div class="mfd-value">{this.firstRowClass}</div> |
420 |
| - <div class="mfd-label br">{this.secondRowIdent}</div> |
421 |
| - <div class="mfd-value br">{this.secondRowFrequency}</div> |
422 |
| - <div class="mfd-value">{this.secondRowClass}</div> |
423 | 465 | <div class="mfd-label br">
|
424 |
| - <div ref={this.thirdRowIdentRef}> |
| 466 | + <div class={{ invisible: this.selectedNavaids[0].ident.map((v) => v.length === 0) }}> |
425 | 467 | <Button
|
426 |
| - label={this.thirdRowIdent.map((it) => ( |
| 468 | + label={this.selectedNavaids[0].ident.map((it) => ( |
427 | 469 | <>{it}</>
|
428 | 470 | ))}
|
429 | 471 | onClick={() => {}}
|
430 | 472 | showArrow
|
431 | 473 | menuItems={Subject.create([{ label: 'DATA NAVAID', action: () => {} }])}
|
432 | 474 | idPrefix={`${this.props.mfd.uiService.captOrFo}_MFD_dataNavaid`}
|
433 | 475 | disabled={Subject.create(true)}
|
| 476 | + buttonStyle="min-width: 107px;" |
434 | 477 | />
|
435 | 478 | </div>
|
436 | 479 | </div>
|
437 |
| - <div class="mfd-value br">{this.thirdRowFrequency}</div> |
438 |
| - <div class="mfd-value">{this.thirdRowClass}</div> |
439 |
| - </div> |
440 |
| - <div class="mfd-label" style="padding-left: 30px; margin-bottom: 20px;"> |
441 |
| - RADIO NAV MODE |
| 480 | + <div class="mfd-value br">{this.selectedNavaids[0].frequencyOrChannel}</div> |
| 481 | + <div class="mfd-value">{this.selectedNavaids[0].class}</div> |
| 482 | + <div class="mfd-label br"> |
| 483 | + <div class={{ invisible: this.selectedNavaids[1].ident.map((v) => v.length === 0) }}> |
| 484 | + <Button |
| 485 | + label={this.selectedNavaids[1].ident.map((it) => ( |
| 486 | + <>{it}</> |
| 487 | + ))} |
| 488 | + onClick={() => {}} |
| 489 | + showArrow |
| 490 | + menuItems={Subject.create([{ label: 'DATA NAVAID', action: () => {} }])} |
| 491 | + idPrefix={`${this.props.mfd.uiService.captOrFo}_MFD_dataNavaid`} |
| 492 | + disabled={Subject.create(true)} |
| 493 | + buttonStyle="min-width: 107px;" |
| 494 | + /> |
| 495 | + </div> |
| 496 | + </div> |
| 497 | + <div class="mfd-value br">{this.selectedNavaids[1].frequencyOrChannel}</div> |
| 498 | + <div class="mfd-value">{this.selectedNavaids[1].class}</div> |
| 499 | + <div class="mfd-label br"> |
| 500 | + <div class={{ invisible: this.selectedNavaids[2].ident.map((v) => v.length === 0) }}> |
| 501 | + <Button |
| 502 | + label={this.selectedNavaids[2].ident.map((it) => ( |
| 503 | + <>{it}</> |
| 504 | + ))} |
| 505 | + onClick={() => {}} |
| 506 | + showArrow |
| 507 | + menuItems={Subject.create([{ label: 'DATA NAVAID', action: () => {} }])} |
| 508 | + idPrefix={`${this.props.mfd.uiService.captOrFo}_MFD_dataNavaid`} |
| 509 | + disabled={Subject.create(true)} |
| 510 | + buttonStyle="min-width: 107px;" |
| 511 | + /> |
| 512 | + </div> |
| 513 | + </div> |
| 514 | + <div class="mfd-value br">{this.selectedNavaids[2].frequencyOrChannel}</div> |
| 515 | + <div class="mfd-value">{this.selectedNavaids[2].class}</div> |
442 | 516 | </div>
|
443 |
| - <div class="mfd-label" style="padding-left: 30px; margin-bottom: 10px;"> |
444 |
| - RADIO POSITION |
| 517 | + <div style="display: grid; grid-template-columns: 190px 320px; margin-left: 80px;"> |
| 518 | + <div class="mfd-label" style="justify-content: right; margin-bottom: 20px;"> |
| 519 | + RADIO NAV MODE |
| 520 | + </div> |
| 521 | + <div class="mfd-value" style="justify-content: left; margin-left: 20px; margin-bottom: 20px;"> |
| 522 | + {this.radioNavMode} |
| 523 | + </div> |
| 524 | + <div class="mfd-label" style="justify-content: right; margin-bottom: 20px;"> |
| 525 | + RADIO POSITION |
| 526 | + </div> |
| 527 | + <div class="mfd-value" style="justify-content: left; margin-left: 20px; margin-bottom: 20px;"> |
| 528 | + {this.radioNavPosition} |
| 529 | + </div> |
445 | 530 | </div>
|
446 | 531 | <div style="border-bottom: 1px solid lightgrey; width: 100%; height: 3px; margin-bottom: 15px;" />
|
447 | 532 | <div class="mfd-label" style="padding-left: 15px; margin-bottom: 10px;">
|
|
0 commit comments