Skip to content

Commit

Permalink
improved APIs, refactoring, added tail number widget, added multi-vie…
Browse files Browse the repository at this point in the history
…w functions
  • Loading branch information
pmasci committed Nov 18, 2022
1 parent bb4405f commit c8d5936
Showing 53 changed files with 4,781 additions and 2,036 deletions.
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
"description": "DAA-Displays is a toolkit for model-based design and analysis of cockpit displays. It includes a library of interactive graphical display elements (widgets) for cockpit systems, and simulations tools supporting comparative analysis of cockpit displays.",
"author": "Paolo Masci",
"license": "NASA-1.3",
"version": "1.0.12",
"version": "1.0.14",
"repository": {
"type": "git",
"url": "https://github.com/nasa/daa-displays"
@@ -24,15 +24,15 @@
"handlebars": "^4.7.7",
"jquery": "^3.5.1",
"node": "^14.14.41",
"leaflet": "^1.7.1"
"leaflet": "^1.9.2"
},
"devDependencies": {
"@types/backbone": "1.3.42",
"@types/express": "^4.16.1",
"@types/jquery": "^3.3.38",
"@types/node": "^14.14.41",
"@types/ws": "^6.0.1",
"@types/leaflet": "^1.7.9",
"@types/leaflet": "^1.9.0",
"typescript": "^4.8.4"
}
}
24 changes: 9 additions & 15 deletions src/3d-view.ts
Original file line number Diff line number Diff line change
@@ -27,17 +27,11 @@
* UNILATERAL TERMINATION OF THIS AGREEMENT.
*/
import { AirspeedTape } from './daa-displays/daa-airspeed-tape';
import { AltitudeTape } from './daa-displays/daa-altitude-tape';
import { VerticalSpeedTape } from './daa-displays/daa-vertical-speed-tape';
import { Compass } from './daa-displays/daa-compass';
import { HScale } from './daa-displays/daa-hscale';

import { DaaSymbol, InteractiveMap } from './daa-displays/daa-interactive-map';
import { InteractiveMap } from './daa-displays/daa-interactive-map';
import { DaaConfig, DAAPlayer, parseDaaConfigInBrowser } from './daa-displays/daa-player';
import { LLAData, ScenarioDataPoint } from './daa-displays/utils/daa-server';

import * as utils from './daa-displays/daa-utils';
import { ViewOptions } from './daa-displays/daa-view-options';
import { DaaSymbol, LLAData, ScenarioDataPoint } from './daa-displays/utils/daa-types';

function render (data: { map: InteractiveMap }) {
const daaSymbols: DaaSymbol[] = [ "daa-target", "daa-traffic-monitor", "daa-traffic-avoid", "daa-alert" ]; // 0..3
@@ -131,10 +125,10 @@ player.define("step", async () => {
player.define("init", async () => {
// compute java output
await player.exec({
alertingLogic: player.getSelectedWellClearVersion(), //"DAAtoPVS-1.0.1.jar",
alertingConfig: player.getSelectedConfiguration(),
alertingLogic: player.readSelectedDaaVersion(), //"DAAtoPVS-1.0.1.jar",
alertingConfig: player.readSelectedDaaConfiguration(),
scenario: player.getSelectedScenario(),
wind: player.getSelectedWindSettings()
wind: player.getSelectedWind()
});
// viewOptions.applyCurrentViewOptions();
});
@@ -201,9 +195,9 @@ async function createPlayer(args: DaaConfig): Promise<void> {
player.appendSidePanelView();
await player.appendScenarioSelector();
await player.appendWindSettings({ selector: "daidalus-wind", dropDown: false, fromToSelectorVisible: true });
await player.appendWellClearVersionSelector({ selector: "daidalus-version" });
await player.appendWellClearConfigurationSelector({ selector: "daidalus-configuration" });
await player.selectConfiguration("DO_365A_no_SUM");
await player.appendDaaVersionSelector({ selector: "daidalus-version" });
await player.appendDaaConfigurationSelector({ selector: "daidalus-configuration" });
await player.selectDaaConfiguration("DO_365A_no_SUM");
player.appendSimulationControls({
parent: "simulation-controls",
displays: [ "daa-disp" ]
@@ -220,7 +214,7 @@ async function createPlayer(args: DaaConfig): Promise<void> {
// auto-load scenario+config if they are specified in the browser
if (args) {
if (args.scenario) { player.selectScenario(args.scenario); }
if (args.config) { await player.selectConfiguration(args.config); }
if (args.config) { await player.selectDaaConfiguration(args.config); }
await player.loadSelectedScenario();
}
}
27 changes: 16 additions & 11 deletions src/daa-displays/daa-airspeed-tape.ts
Original file line number Diff line number Diff line change
@@ -47,8 +47,9 @@
* TERMINATION OF THIS AGREEMENT.
**/
import * as utils from './daa-utils';
import * as conversions from './utils/daa-math';
import * as templates from './templates/daa-airspeed-templates';
import * as server from '../daa-server/utils/daa-server';
import { ResolutionElement, Vector3D } from './utils/daa-types';

// internal class, renders a resolution bug over the tape
class SpeedBug {
@@ -101,14 +102,14 @@ class SpeedBug {
/**
* @function <a name="ResolutionBug_setMaxWedgeAperture">setMaxWedgeAperture</a>
* @desc Sets the maximum aperture of the resolution wedge.
* @param deg (real) Aperture of the wedge (in degrees)
* @param knot (real) Aperture of the wedge (in knots)
* @memberof module:ResolutionBug
* @instance
* @inner
*/
setMaxWedgeAperture (deg: number | string): void {
if (isFinite(+deg) && +deg >= 0) {
this.maxWedgeAperture = +deg;
setMaxWedgeAperture (knot: number | string): void {
if (isFinite(+knot) && +knot >= 0) {
this.maxWedgeAperture = +knot;
}
}
/**
@@ -287,8 +288,8 @@ export class AirspeedTape {

static convert (val: number, unitsFrom: string, unitsTo: string): number {
if (unitsFrom !== unitsTo) {
if ((unitsFrom === "knot" || unitsFrom === "kn" || unitsFrom === "knots") && (unitsTo === "msec" || unitsTo === "ms" || unitsTo === "m/s")) { return parseFloat(utils.knots2msec(val).toFixed(2)); }
if ((unitsFrom === "msec" || unitsFrom === "ms" || unitsFrom === "m/s") && (unitsTo === "knot" || unitsTo === "kn" || unitsTo === "knots")) { return parseFloat(utils.msec2knots(val).toFixed(2)) / 100; }
if ((unitsFrom === "knot" || unitsFrom === "kn" || unitsFrom === "knots") && (unitsTo === "msec" || unitsTo === "ms" || unitsTo === "m/s")) { return parseFloat(conversions.knots2msec(val).toFixed(2)); }
if ((unitsFrom === "msec" || unitsFrom === "ms" || unitsFrom === "m/s") && (unitsTo === "knot" || unitsTo === "kn" || unitsTo === "knots")) { return parseFloat(conversions.msec2knots(val).toFixed(2)) / 100; }
}
// return parseFloat(val.toFixed(2)); // [profiler] 12.7ms
return Math.floor(val * 100) / 100; // [profiler] 0.1ms
@@ -614,7 +615,7 @@ export class AirspeedTape {
* @memberof module:AirspeedTape
* @instance
*/
setBug(info: number | server.ResolutionElement, opt?: {
setBug(info: number | ResolutionElement, opt?: {
wedgeConstraints?: utils.FromTo[],
resolutionBugColor?: string,
wedgeAperture?: number
@@ -645,6 +646,10 @@ export class AirspeedTape {
this.resolutionBug.hide();
this.resetIndicatorColor();
}
/**
* Utility function, sets max wedge aperture
* @param aperture (knots)
*/
setMaxWedgeAperture (aperture: number | string): void {
this.resolutionBug.setMaxWedgeAperture(aperture);
this.resolutionBug.refresh();
@@ -723,7 +728,7 @@ export class AirspeedTape {
*/
setWindDirection(deg: number, opt?: { units?: string }): AirspeedTape {
opt = opt || {};
this.windDirection = (opt.units === "rad") ? utils.rad2deg(deg) : deg;
this.windDirection = (opt.units === "rad") ? conversions.rad2deg(deg) : deg;
this.updateWind();
// do we need to update airspeed??
// return this.setAirSpeed(this.ground_speed - ???);
@@ -741,7 +746,7 @@ export class AirspeedTape {
*/
setWindSpeed(val: number, opt?: { units?: string }): AirspeedTape {
opt = opt || {};
this.windSpeed = (opt.units === "msec") ? utils.msec2knots(val) : val;
this.windSpeed = (opt.units === "msec") ? conversions.msec2knots(val) : val;
this.updateWind();
// ground speed and true airspeed need to be updated every time wind speed changes
this.updateGroundSpeed();
@@ -811,7 +816,7 @@ export class AirspeedTape {
* @return {real} Airspeed value, in knots.
* @memberof module:AirspeedTape
*/
static v2gs(v: utils.Vector3D | server.Vector3D): number {
static v2gs(v: Vector3D<number | string>): number {
if (v) {
return Math.sqrt((+v.x * +v.x) + (+v.y * +v.y));
}
66 changes: 17 additions & 49 deletions src/daa-displays/daa-altitude-tape.ts
Original file line number Diff line number Diff line change
@@ -13,46 +13,7 @@
* (<a href="http://www.pvsioweb.org" target=_blank>www.pvsioweb.org</a>).</p>
* <p>Google Chrome is recommended for correct rendering of the widget.</p></div>
* <img src="images/daa-altitude-tape.png" style="margin-left:8%; max-height:250px;" alt="DAA Altitude Tape Widget"></div>
* @example
// file index.js (to be stored in pvsio-web/examples/demos/daa-displays/)
require.config({
paths: {
widgets: "../../client/app/widgets",
text: "../../client/app/widgets/daa-displays/lib/text/text"
}
});
require(["widgets/daa-displays/daa-altitude-tape"], function (AltitudeTape) {
"use strict";
const altitudeTape = new AltitudeTape("altitude", {
top: 100, left: 600
});
altitudeTape.setAltitude(4000);
altitudeTape.setBands({
RECOVERY: [ { from: 3800, to: 4000 } ],
NEAR: [ { from: 4000, to: 4200 } ]
});
});
// file index.html (to be stored in pvsio-web/examples/demos/daa-displays/)
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible">
<title></title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../client/app/widgets/daa-displays/lib/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="../../client/app/widgets/daa-displays/lib/font-awesome/5.6.1/css/all.min.css">
<link rel="stylesheet" href="../../client/app/widgets/daa-displays/css/daa-displays.css">
</head>
<script src="../../client/app/widgets/daa-displays/lib/underscore/underscore.js"></script>
<script src="../../client/app/widgets/daa-displays/lib/jquery/jquery-3.3.1.slim.min.js"></script>
<script src="../../client/app/widgets/daa-displays/lib/popper/popper-1.14.3.min.js"></script>
<script src="../../client/app/widgets/daa-displays/lib/bootstrap/4.1.3/bootstrap.min.js"></script>
<script src="../../client/app/widgets/daa-displays/lib/handlebars/handlebars-v4.0.12.js"></script>
<script src="../../client/app/widgets/daa-displays/lib/requireJS/require.js" data-main="index.js"></script>
</html>
*
* @author Paolo Masci
* @date October 2018
* @copyright
@@ -91,8 +52,9 @@ require(["widgets/daa-displays/daa-altitude-tape"], function (AltitudeTape) {
* TERMINATION OF THIS AGREEMENT.
**/
import * as utils from './daa-utils';
import * as conversions from './utils/daa-math';
import * as templates from './templates/daa-altitude-templates';
import { ResolutionElement } from '../daa-server/utils/daa-server';
import { ResolutionElement } from './utils/daa-types';

// internal class, renders a resolution bug over the tape
class SpeedBug {
@@ -162,14 +124,14 @@ class SpeedBug {
/**
* @function <a name="ResolutionBug_setMaxWedgeAperture">setMaxWedgeAperture</a>
* @desc Sets the maximum aperture of the resolution wedge.
* @param val (real) Aperture of the wedge (in ft)
* @param ft (real) Aperture of the wedge (in ft)
* @memberof module:ResolutionBug
* @instance
* @inner
*/
setMaxWedgeAperture (val: number | string): void {
if (isFinite(+val) && +val >= 0) {
this.maxWedgeAperture = +val;
setMaxWedgeAperture (ft: number | string): void {
if (isFinite(+ft) && +ft >= 0) {
this.maxWedgeAperture = +ft;
}
}
/**
@@ -349,7 +311,9 @@ export class AltitudeTape {
// otherwise bands are displayed as usual
const saturateRed: boolean = this.resolutionBug.getWedgeAperture() > 0
&& this.bands && this.bands.RECOVERY && this.bands.RECOVERY.length > 0;
Object.keys(this.bands).forEach(alert => {
const alerts: string[] = Object.keys(this.bands);
for (let i = 0; i < alerts?.length; i++) {
const alert: string = alerts[i];
const segments: utils.FromTo[] = this.bands[alert];
// console.log(segments);
let segs = [];
@@ -375,7 +339,7 @@ export class AltitudeTape {
dash: (saturateRed) ? false : utils.bandColors[alert].style === "dash"
});
// console.log(theHTML);
});
}
$(`#${this.id}-bands`).html(theHTML);
}
// utility function for creating altitude tick marks
@@ -545,8 +509,8 @@ export class AltitudeTape {
// utility function, converts values between units
static convert (val: number, unitsFrom: string, unitsTo: string): number {
if (unitsFrom !== unitsTo) {
if ((unitsFrom === "meters" || unitsFrom === "m") && (unitsTo === "feet" || unitsTo === "ft")) { return parseFloat(utils.meters2feet(val).toFixed(2)); }
if ((unitsFrom === "feet" || unitsFrom === "ft") && (unitsTo === "meters" || unitsTo === "m")) { return parseFloat(utils.feet2meters(val).toFixed(2)) / 100; }
if ((unitsFrom === "meters" || unitsFrom === "m") && (unitsTo === "feet" || unitsTo === "ft")) { return parseFloat(conversions.meters2feet(val).toFixed(2)); }
if ((unitsFrom === "feet" || unitsFrom === "ft") && (unitsTo === "meters" || unitsTo === "m")) { return parseFloat(conversions.feet2meters(val).toFixed(2)) / 100; }
}
// return parseFloat(val.toFixed(2)); // [profiler] 12.7ms
return Math.floor(val * 100) / 100; // [profiler] 0.1ms
@@ -670,6 +634,10 @@ export class AltitudeTape {
this.resolutionBug.hide();
this.resetIndicatorColor();
}
/**
* Utility function, sets max wedge aperture
* @param aperture (ft)
*/
setMaxWedgeAperture (aperture: number | string): void {
this.resolutionBug.setMaxWedgeAperture(aperture);
this.resolutionBug.refresh();
Loading

0 comments on commit c8d5936

Please sign in to comment.