flight-indicators 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -2
- package/dist/index.cjs +678 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +187 -1
- package/dist/index.d.ts +187 -1
- package/dist/index.js +662 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -2
package/dist/index.cjs
CHANGED
|
@@ -23,11 +23,26 @@ var index_exports = {};
|
|
|
23
23
|
__export(index_exports, {
|
|
24
24
|
Airspeed: () => Airspeed,
|
|
25
25
|
Altimeter: () => Altimeter,
|
|
26
|
+
AoaIndicator: () => AoaIndicator,
|
|
26
27
|
AttitudeIndicator: () => AttitudeIndicator,
|
|
28
|
+
DEFAULT_BAR_GAUGES: () => DEFAULT_BAR_GAUGES,
|
|
29
|
+
DEFAULT_MANIFOLD: () => DEFAULT_MANIFOLD,
|
|
30
|
+
DEFAULT_RPM: () => DEFAULT_RPM,
|
|
31
|
+
DataPanel: () => DataPanel,
|
|
32
|
+
EngineIndicator: () => EngineIndicator,
|
|
33
|
+
FlapIndicator: () => FlapIndicator,
|
|
34
|
+
FuelIndicator: () => FuelIndicator,
|
|
27
35
|
HeadingIndicator: () => HeadingIndicator,
|
|
36
|
+
MAX_BAR_GAUGES: () => MAX_BAR_GAUGES,
|
|
37
|
+
MAX_CYLINDERS: () => MAX_CYLINDERS,
|
|
38
|
+
MAX_FIELDS: () => MAX_FIELDS,
|
|
39
|
+
MAX_TANKS: () => MAX_TANKS,
|
|
28
40
|
TurnCoordinator: () => TurnCoordinator,
|
|
29
41
|
VerticalSpeed: () => VerticalSpeed,
|
|
30
|
-
|
|
42
|
+
VorIndicator: () => VorIndicator,
|
|
43
|
+
WindIndicator: () => WindIndicator,
|
|
44
|
+
formatValue: () => formatValue,
|
|
45
|
+
vorDeviation: () => vorDeviation
|
|
31
46
|
});
|
|
32
47
|
module.exports = __toCommonJS(index_exports);
|
|
33
48
|
|
|
@@ -591,14 +606,675 @@ function WindIndicator({
|
|
|
591
606
|
) })
|
|
592
607
|
] });
|
|
593
608
|
}
|
|
609
|
+
|
|
610
|
+
// src/components/VorIndicator.tsx
|
|
611
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
612
|
+
var CARDINALS3 = { 0: "N", 90: "E", 180: "S", 270: "W" };
|
|
613
|
+
var AMBER2 = "#ffb000";
|
|
614
|
+
var FULL_SCALE_DEG = 10;
|
|
615
|
+
var DOT_SPACING = 22;
|
|
616
|
+
var FULL_SCALE_PX = DOT_SPACING * 5;
|
|
617
|
+
var norm2 = (deg) => (deg % 360 + 360) % 360;
|
|
618
|
+
var signedDiff = (a, b) => ((a - b) % 360 + 540) % 360 - 180;
|
|
619
|
+
function vorDeviation(course, radial) {
|
|
620
|
+
const d = signedDiff(radial, course);
|
|
621
|
+
return Math.abs(d) <= 90 ? { deviation: -d, toFrom: "FROM" } : { deviation: signedDiff(d, 180), toFrom: "TO" };
|
|
622
|
+
}
|
|
623
|
+
function Flag({ y, up, visible, testId }) {
|
|
624
|
+
const dir = up ? -1 : 1;
|
|
625
|
+
const tip = y + dir * 17;
|
|
626
|
+
const headBase = y + dir * 1;
|
|
627
|
+
const tail = y - dir * 15;
|
|
628
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { "data-testid": testId, opacity: visible ? 1 : 0, style: { transition: "opacity 200ms ease-out" }, children: [
|
|
629
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
630
|
+
"path",
|
|
631
|
+
{
|
|
632
|
+
d: `M ${CENTER} ${tip} L ${CENTER - 13} ${headBase} H ${CENTER - 4} V ${tail} H ${CENTER + 4} V ${headBase} H ${CENTER + 13} Z`,
|
|
633
|
+
fill: "#fff",
|
|
634
|
+
stroke: "#000",
|
|
635
|
+
strokeWidth: "1.5",
|
|
636
|
+
strokeLinejoin: "round"
|
|
637
|
+
}
|
|
638
|
+
),
|
|
639
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("text", { x: CENTER + 22, y, fill: "#fff", fontSize: "15", fontWeight: "bold", dominantBaseline: "central", children: up ? "TO" : "FROM" })
|
|
640
|
+
] });
|
|
641
|
+
}
|
|
642
|
+
function VorIndicator({ course = 0, radial, deviation, toFrom, signal = true, ...props }) {
|
|
643
|
+
const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
|
|
644
|
+
const crs = finite(course);
|
|
645
|
+
const computed = typeof radial === "number" && Number.isFinite(radial) ? vorDeviation(crs, radial) : void 0;
|
|
646
|
+
const rawDeviation = finite(deviation, computed?.deviation ?? 0);
|
|
647
|
+
const dev = signal ? clamp(rawDeviation, -FULL_SCALE_DEG, FULL_SCALE_DEG) : 0;
|
|
648
|
+
const flag = !signal ? "OFF" : toFrom ?? computed?.toFrom ?? "OFF";
|
|
649
|
+
const displayCourse = useContinuousAngle(crs);
|
|
650
|
+
const courseText = String(Math.round(norm2(crs)) || 360).padStart(3, "0");
|
|
651
|
+
const needleX = dev / FULL_SCALE_DEG * FULL_SCALE_PX;
|
|
652
|
+
const devText = Math.abs(dev) < 0.05 ? "centred" : `${Math.abs(dev).toFixed(1)}\xB0 ${dev > 0 ? "right" : "left"}`;
|
|
653
|
+
const label = signal ? `VOR indicator: course ${courseText}\xB0, needle ${devText}, ${flag === "OFF" ? "no TO/FROM indication" : flag}` : `VOR indicator: course ${courseText}\xB0, no signal`;
|
|
654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(InstrumentFrame, { ...props, label, children: [
|
|
655
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { "data-testid": "vor-card", style: motionStyle(`rotate(${-displayCourse}deg)`, duration), children: [
|
|
656
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { stroke: "#fff", strokeLinecap: "round", children: range(0, 355, 5).map((a) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: tickPath(176, a % 10 === 0 ? 152 : 164, a), strokeWidth: a % 10 === 0 ? 3 : 2 }, a)) }),
|
|
657
|
+
range(0, 330, 30).map((a) => {
|
|
658
|
+
const [x, y] = polar(132, a);
|
|
659
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
660
|
+
"text",
|
|
661
|
+
{
|
|
662
|
+
x,
|
|
663
|
+
y,
|
|
664
|
+
transform: `rotate(${a} ${x} ${y})`,
|
|
665
|
+
fill: a % 90 === 0 ? AMBER2 : "#fff",
|
|
666
|
+
fontSize: a % 90 === 0 ? 28 : 24,
|
|
667
|
+
fontWeight: "bold",
|
|
668
|
+
textAnchor: "middle",
|
|
669
|
+
dominantBaseline: "central",
|
|
670
|
+
children: CARDINALS3[a] ?? String(a / 10)
|
|
671
|
+
},
|
|
672
|
+
a
|
|
673
|
+
);
|
|
674
|
+
})
|
|
675
|
+
] }),
|
|
676
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: `M ${CENTER} ${CENTER - 150} l -10 -28 h 20 z`, fill: AMBER2, stroke: "#000", strokeWidth: "1.5" }),
|
|
677
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: `M ${CENTER} ${CENTER + 150} l -8 24 h 16 z`, fill: "#fff", stroke: "#000", strokeWidth: "1.5" }),
|
|
678
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { stroke: AMBER2, strokeWidth: "4", strokeLinecap: "round", children: [45, 90, 135, 225, 270, 315].map((a) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: tickPath(192, 178, a) }, a)) }),
|
|
679
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { fill: "#fff", stroke: "#000", strokeWidth: "1", children: range(1, 5, 1).flatMap((i) => [-i, i]).map((i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("circle", { cx: CENTER + i * DOT_SPACING, cy: CENTER, r: "5" }, i)) }),
|
|
680
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("circle", { cx: CENTER, cy: CENTER, r: "9", fill: "none", stroke: "#fff", strokeWidth: "2.5" }),
|
|
681
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Flag, { y: CENTER - 54, up: true, visible: flag === "TO", testId: "vor-to" }),
|
|
682
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Flag, { y: CENTER + 54, up: false, visible: flag === "FROM", testId: "vor-from" }),
|
|
683
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { "data-testid": "vor-needle", style: motionStyle(`translate(${needleX}px, 0px)`, duration), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("rect", { x: CENTER - 3, y: CENTER - 68, width: "6", height: "136", rx: "3", fill: "#fff", stroke: "#000", strokeWidth: "1.5" }) }),
|
|
684
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("rect", { x: CENTER - 44, y: CENTER + 72, width: "88", height: "26", rx: "4", fill: "#000", stroke: "#555", strokeWidth: "2" }),
|
|
685
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
686
|
+
"text",
|
|
687
|
+
{
|
|
688
|
+
"data-testid": "vor-course",
|
|
689
|
+
x: CENTER,
|
|
690
|
+
y: CENTER + 86,
|
|
691
|
+
fill: "#fff",
|
|
692
|
+
fontSize: "17",
|
|
693
|
+
fontFamily: "monospace",
|
|
694
|
+
fontWeight: "bold",
|
|
695
|
+
textAnchor: "middle",
|
|
696
|
+
dominantBaseline: "central",
|
|
697
|
+
children: [
|
|
698
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("tspan", { fill: "#ccc", children: "CRS " }),
|
|
699
|
+
courseText
|
|
700
|
+
]
|
|
701
|
+
}
|
|
702
|
+
),
|
|
703
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { "data-testid": "vor-nav-flag", opacity: signal ? 0 : 1, style: { transition: "opacity 200ms ease-out" }, children: [
|
|
704
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("rect", { x: CENTER - 28, y: CENTER - 98, width: "56", height: "24", rx: "3", fill: "#d42626", stroke: "#000", strokeWidth: "1.5" }),
|
|
705
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("text", { x: CENTER, y: CENTER - 85, fill: "#fff", fontSize: "15", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: "NAV" })
|
|
706
|
+
] })
|
|
707
|
+
] });
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// src/components/DataPanel.tsx
|
|
711
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
712
|
+
var MAX_FIELDS = 6;
|
|
713
|
+
var SIDE = 252;
|
|
714
|
+
var PAD = 8;
|
|
715
|
+
var GAP = 8;
|
|
716
|
+
var ORIGIN = CENTER - SIDE / 2;
|
|
717
|
+
var VALUE_SIZE = { 1: 52, 2: 36, 3: 27 };
|
|
718
|
+
function formatValue(field) {
|
|
719
|
+
if (typeof field.value === "string") return field.value;
|
|
720
|
+
const n = finite(field.value, NaN);
|
|
721
|
+
return Number.isNaN(n) ? "---" : n.toFixed(Math.max(0, Math.floor(finite(field.decimals, 0))));
|
|
722
|
+
}
|
|
723
|
+
function DataPanel({ fields = [], heading, ...props }) {
|
|
724
|
+
const shown = fields.slice(0, MAX_FIELDS);
|
|
725
|
+
const cols = shown.length <= 2 ? 1 : 2;
|
|
726
|
+
const rows = Math.max(1, Math.ceil(shown.length / cols));
|
|
727
|
+
const cellW = (SIDE - PAD * 2 - GAP * (cols - 1)) / cols;
|
|
728
|
+
const cellH = (SIDE - PAD * 2 - GAP * (rows - 1)) / rows;
|
|
729
|
+
const valueSize = VALUE_SIZE[rows] ?? 27;
|
|
730
|
+
const label = `${heading ?? "Data panel"}: ` + (shown.length ? shown.map((f) => `${f.name} ${formatValue(f)}${f.unit ? ` ${f.unit}` : ""}`).join(", ") : "no data");
|
|
731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(InstrumentFrame, { ...props, label, children: [
|
|
732
|
+
heading && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("text", { x: CENTER, y: ORIGIN - 14, fill: "#ccc", fontSize: "13", fontWeight: "bold", letterSpacing: "2", textAnchor: "middle", dominantBaseline: "central", children: heading.toUpperCase() }),
|
|
733
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: ORIGIN, y: ORIGIN, width: SIDE, height: SIDE, rx: "10", fill: "#1c1f24", stroke: "#3a3f47", strokeWidth: "2" }),
|
|
734
|
+
shown.map((f, i) => {
|
|
735
|
+
const col = i % cols;
|
|
736
|
+
const row = Math.floor(i / cols);
|
|
737
|
+
const x = ORIGIN + PAD + col * (cellW + GAP);
|
|
738
|
+
const y = ORIGIN + PAD + row * (cellH + GAP);
|
|
739
|
+
const value = formatValue(f);
|
|
740
|
+
const fit = Math.min(valueSize, (cellW - 16) / (0.62 * Math.max(1, value.length)));
|
|
741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("g", { "data-testid": `data-field-${i}`, children: [
|
|
742
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x, y, width: cellW, height: cellH, rx: "6", fill: "#000", stroke: "#262a30", strokeWidth: "1" }),
|
|
743
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("text", { x: x + 8, y: y + 12, fill: "#9aa4b1", fontSize: "12", fontWeight: "bold", letterSpacing: "1", dominantBaseline: "central", children: f.name.toUpperCase() }),
|
|
744
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
745
|
+
"text",
|
|
746
|
+
{
|
|
747
|
+
"data-testid": `data-value-${i}`,
|
|
748
|
+
x: x + cellW / 2,
|
|
749
|
+
y: y + cellH / 2 + 7,
|
|
750
|
+
fill: f.color ?? "#fff",
|
|
751
|
+
fontSize: fit,
|
|
752
|
+
fontFamily: "monospace",
|
|
753
|
+
fontWeight: "bold",
|
|
754
|
+
textAnchor: "middle",
|
|
755
|
+
dominantBaseline: "central",
|
|
756
|
+
children: value
|
|
757
|
+
}
|
|
758
|
+
),
|
|
759
|
+
f.unit && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("text", { x: x + cellW - 8, y: y + cellH - 12, fill: "#9aa4b1", fontSize: "12", textAnchor: "end", dominantBaseline: "central", children: f.unit })
|
|
760
|
+
] }, i);
|
|
761
|
+
})
|
|
762
|
+
] });
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// src/components/FuelIndicator.tsx
|
|
766
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
767
|
+
var MAX_TANKS = 4;
|
|
768
|
+
var GREEN2 = "#2ee05a";
|
|
769
|
+
var RED = "#ff3b3b";
|
|
770
|
+
var GREY = "#9aa4b1";
|
|
771
|
+
var SIDE2 = 252;
|
|
772
|
+
var PAD2 = 6;
|
|
773
|
+
var ORIGIN2 = CENTER - SIDE2 / 2;
|
|
774
|
+
var INNER_LEFT = ORIGIN2 + PAD2;
|
|
775
|
+
var INNER_W = SIDE2 - PAD2 * 2;
|
|
776
|
+
var FOOTER_Y = ORIGIN2 + SIDE2 - 36;
|
|
777
|
+
var BAR_TOP = ORIGIN2 + 38;
|
|
778
|
+
var BAR_H = 114;
|
|
779
|
+
var BAR_BOTTOM = BAR_TOP + BAR_H;
|
|
780
|
+
var DEFAULT_TANKS = [
|
|
781
|
+
{ name: "LEFT", quantity: 0 },
|
|
782
|
+
{ name: "RIGHT", quantity: 0 }
|
|
783
|
+
];
|
|
784
|
+
function FuelIndicator({
|
|
785
|
+
tanks = DEFAULT_TANKS,
|
|
786
|
+
capacity = 50,
|
|
787
|
+
unit = "gal",
|
|
788
|
+
low,
|
|
789
|
+
decimals = 1,
|
|
790
|
+
label = "FUEL",
|
|
791
|
+
...props
|
|
792
|
+
}) {
|
|
793
|
+
const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
|
|
794
|
+
const places = Math.max(0, Math.floor(finite(decimals, 1)));
|
|
795
|
+
const shown = tanks.slice(0, MAX_TANKS);
|
|
796
|
+
const cols = Math.max(1, shown.length);
|
|
797
|
+
const colW = INNER_W / cols;
|
|
798
|
+
const barW = clamp(colW / 8, 8, 16);
|
|
799
|
+
const valueSize = Math.min(26, colW / 4.4);
|
|
800
|
+
const readings = shown.map((t) => {
|
|
801
|
+
const cap = Math.max(1e-9, finite(t.capacity, finite(capacity, 50)));
|
|
802
|
+
const qty = clamp(finite(t.quantity), 0, cap);
|
|
803
|
+
const fraction = qty / cap;
|
|
804
|
+
const full = fraction >= 0.995;
|
|
805
|
+
const isLow = qty <= finite(low, cap * 0.1);
|
|
806
|
+
return { name: t.name, qty, cap, fraction, full, isLow, text: full ? "FULL" : qty.toFixed(places) };
|
|
807
|
+
});
|
|
808
|
+
const title = `${label}: ` + (readings.length ? readings.map((r) => `${r.name} ${r.full ? "full" : `${r.text} of ${r.cap.toFixed(places)} ${unit}`}${r.isLow ? " (low)" : ""}`).join(", ") : "no tanks");
|
|
809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(InstrumentFrame, { ...props, label: title, children: [
|
|
810
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("rect", { x: ORIGIN2, y: ORIGIN2, width: SIDE2, height: SIDE2, rx: "10", fill: "#000", stroke: "#3a3f47", strokeWidth: "2" }),
|
|
811
|
+
readings.map((r, i) => {
|
|
812
|
+
const cx = INNER_LEFT + colW * (i + 0.5);
|
|
813
|
+
const color = r.isLow ? RED : GREEN2;
|
|
814
|
+
const tickX = cx - barW / 2 - 14;
|
|
815
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("g", { "data-testid": `fuel-tank-${i}`, children: [
|
|
816
|
+
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: `M ${INNER_LEFT + colW * i} ${ORIGIN2 + 10} V ${FOOTER_Y}`, stroke: "#555", strokeWidth: "1.5" }),
|
|
817
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("text", { x: cx, y: ORIGIN2 + 22, fill: "#fff", fontSize: Math.min(17, colW / 5), fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: r.name.toUpperCase() }),
|
|
818
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("g", { strokeWidth: "2.5", strokeLinecap: "round", children: [0, 0.25, 0.5, 0.75, 1].map((f) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
819
|
+
"path",
|
|
820
|
+
{
|
|
821
|
+
d: `M ${tickX - 7} ${BAR_BOTTOM - f * BAR_H} h 7`,
|
|
822
|
+
stroke: f === 1 ? GREEN2 : f === 0 ? RED : GREY
|
|
823
|
+
},
|
|
824
|
+
f
|
|
825
|
+
)) }),
|
|
826
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("rect", { x: cx - barW / 2, y: BAR_TOP, width: barW, height: BAR_H, fill: "#15181c" }),
|
|
827
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("g", { "data-testid": `fuel-bar-${i}`, style: motionStyle(`scaleY(${r.fraction})`, duration, cx, BAR_BOTTOM), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("rect", { x: cx - barW / 2, y: BAR_TOP, width: barW, height: BAR_H, fill: color }) }),
|
|
828
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
829
|
+
"text",
|
|
830
|
+
{
|
|
831
|
+
"data-testid": `fuel-value-${i}`,
|
|
832
|
+
x: cx,
|
|
833
|
+
y: BAR_BOTTOM + 22,
|
|
834
|
+
fill: r.isLow ? RED : "#fff",
|
|
835
|
+
fontSize: valueSize,
|
|
836
|
+
fontFamily: "monospace",
|
|
837
|
+
fontWeight: "bold",
|
|
838
|
+
textAnchor: "middle",
|
|
839
|
+
dominantBaseline: "central",
|
|
840
|
+
children: r.text
|
|
841
|
+
}
|
|
842
|
+
),
|
|
843
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("text", { x: cx, y: BAR_BOTTOM + 44, fill: "#fff", fontSize: "13", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: unit })
|
|
844
|
+
] }, i);
|
|
845
|
+
}),
|
|
846
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: `M ${ORIGIN2 + 8} ${FOOTER_Y} H ${ORIGIN2 + SIDE2 - 8}`, stroke: "#555", strokeWidth: "1.5" }),
|
|
847
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("text", { x: CENTER, y: FOOTER_Y + 19, fill: "#fff", fontSize: "24", fontWeight: "bold", letterSpacing: "2", textAnchor: "middle", dominantBaseline: "central", children: label.toUpperCase() })
|
|
848
|
+
] });
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// src/components/EngineIndicator.tsx
|
|
852
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
853
|
+
var MAX_CYLINDERS = 6;
|
|
854
|
+
var MAX_BAR_GAUGES = 4;
|
|
855
|
+
var GREEN3 = "#5fe04a";
|
|
856
|
+
var YELLOW = "#ffd400";
|
|
857
|
+
var RED2 = "#ff3030";
|
|
858
|
+
var BLUE = "#4fb7e8";
|
|
859
|
+
var LABEL = "#b9c8e6";
|
|
860
|
+
var LINE = "#8a8f99";
|
|
861
|
+
var round2 = (n) => Math.round(n * 100) / 100;
|
|
862
|
+
var DIAL_R = 182;
|
|
863
|
+
function chord(y, inset = 8) {
|
|
864
|
+
const half = Math.sqrt(Math.max(0, DIAL_R * DIAL_R - (y - CENTER) ** 2)) - inset;
|
|
865
|
+
return `M ${round2(CENTER - half)} ${y} H ${round2(CENTER + half)}`;
|
|
866
|
+
}
|
|
867
|
+
var DEFAULT_MANIFOLD = { min: 10, max: 35, green: [15, 29], yellow: [29, 31], high: 31, unit: "IN", decimals: 1 };
|
|
868
|
+
var DEFAULT_RPM = { min: 0, max: 3e3, green: [800, 2500], yellow: [2500, 2700], high: 2700, decimals: 0 };
|
|
869
|
+
var DEFAULT_BAR_GAUGES = [
|
|
870
|
+
{ label: "Oil P", min: 0, max: 100, green: [30, 60], low: 10, high: 95, unit: "PSI" },
|
|
871
|
+
{ label: "Oil T", min: 0, max: 250, green: [75, 240], high: 240, unit: "\xB0F" },
|
|
872
|
+
{ label: "Fuel P", min: 0, max: 30, low: 1, high: 28, unit: "PSI", decimals: 1 },
|
|
873
|
+
{ label: "Fuel F", min: 0, max: 30, green: [8, 20], unit: "GPH", decimals: 1 }
|
|
874
|
+
];
|
|
875
|
+
function resolve(g, defaults = {}) {
|
|
876
|
+
const min = finite(g.min, finite(defaults.min, 0));
|
|
877
|
+
const max = Math.max(min + 1e-9, finite(g.max, finite(defaults.max, 100)));
|
|
878
|
+
const value = clamp(finite(g.value), min, max);
|
|
879
|
+
const fraction = (value - min) / (max - min);
|
|
880
|
+
const decimals = Math.max(0, Math.floor(finite(g.decimals, finite(defaults.decimals, 0))));
|
|
881
|
+
const low = g.low ?? defaults.low;
|
|
882
|
+
const high = g.high ?? defaults.high;
|
|
883
|
+
const yellow = g.yellow ?? defaults.yellow;
|
|
884
|
+
const inRed = low !== void 0 && value <= low || high !== void 0 && value >= high;
|
|
885
|
+
const inYellow = yellow !== void 0 && value >= yellow[0] && value <= yellow[1];
|
|
886
|
+
return {
|
|
887
|
+
value,
|
|
888
|
+
min,
|
|
889
|
+
max,
|
|
890
|
+
fraction,
|
|
891
|
+
color: inRed ? RED2 : inYellow ? YELLOW : "#fff",
|
|
892
|
+
text: value.toFixed(decimals),
|
|
893
|
+
unit: g.unit ?? defaults.unit,
|
|
894
|
+
green: g.green ?? defaults.green,
|
|
895
|
+
yellow,
|
|
896
|
+
low,
|
|
897
|
+
high
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
var ARC_R = 46;
|
|
901
|
+
var ARC_SWEEP = 100;
|
|
902
|
+
var ARC_Y = 112;
|
|
903
|
+
function arcAt(cx, cy, r, a0, a1) {
|
|
904
|
+
const [x0, y0] = polar(r, a0, cx, cy);
|
|
905
|
+
const [x1, y1] = polar(r, a1, cx, cy);
|
|
906
|
+
return `M ${x0} ${y0} A ${r} ${r} 0 ${a1 - a0 > 180 ? 1 : 0} 1 ${x1} ${y1}`;
|
|
907
|
+
}
|
|
908
|
+
function ArcGauge({ cx, label, g, duration, testId }) {
|
|
909
|
+
const span = g.max - g.min;
|
|
910
|
+
const angle = (v) => round2(-ARC_SWEEP + 2 * ARC_SWEEP * clamp((v - g.min) / span, 0, 1));
|
|
911
|
+
const band = (from, to, color) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: arcAt(cx, ARC_Y, ARC_R, angle(from), angle(to)), stroke: color, strokeWidth: "6", fill: "none" });
|
|
912
|
+
const [tipX, tipY] = polar(ARC_R - 4, 0, cx, ARC_Y);
|
|
913
|
+
const [lx, ly] = polar(ARC_R - 16, -7, cx, ARC_Y);
|
|
914
|
+
const [rx, ry] = polar(ARC_R - 16, 7, cx, ARC_Y);
|
|
915
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { children: [
|
|
916
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: arcAt(cx, ARC_Y, ARC_R, -ARC_SWEEP, ARC_SWEEP), stroke: "#fff", strokeWidth: "1.5", fill: "none" }),
|
|
917
|
+
g.green && band(g.green[0], g.green[1], GREEN3),
|
|
918
|
+
g.yellow && band(g.yellow[0], g.yellow[1], YELLOW),
|
|
919
|
+
g.low !== void 0 && band(g.min, g.low, RED2),
|
|
920
|
+
g.high !== void 0 && band(g.high, g.max, RED2),
|
|
921
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("g", { "data-testid": testId, style: motionStyle(`rotate(${angle(g.value)}deg)`, duration, cx, ARC_Y), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: `M ${tipX} ${tipY} L ${lx} ${ly} L ${rx} ${ry} Z`, fill: "#fff", stroke: "#000", strokeWidth: "1" }) }),
|
|
922
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { x: cx, y: ARC_Y - 20, fill: LABEL, fontSize: "14", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: label }),
|
|
923
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("text", { x: cx, y: ARC_Y + 4, fill: g.color, fontSize: "28", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: [
|
|
924
|
+
g.text,
|
|
925
|
+
g.unit && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tspan", { fontSize: "11", dx: "2", children: g.unit })
|
|
926
|
+
] })
|
|
927
|
+
] });
|
|
928
|
+
}
|
|
929
|
+
var BAR_X0 = 210;
|
|
930
|
+
var BAR_X1 = 296;
|
|
931
|
+
var BAR_ROW_H = 39;
|
|
932
|
+
var BAR_TOP2 = 137;
|
|
933
|
+
function BarGauge({ top, g, label, duration, testId }) {
|
|
934
|
+
const y = top + 14;
|
|
935
|
+
const at = (v) => round2(BAR_X0 + (BAR_X1 - BAR_X0) * clamp((v - g.min) / (g.max - g.min), 0, 1));
|
|
936
|
+
const seg = (from, to, color, w = 7) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: `M ${at(from)} ${y} H ${at(to)}`, stroke: color, strokeWidth: w });
|
|
937
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { children: [
|
|
938
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: `M ${BAR_X0} ${y} H ${BAR_X1}`, stroke: "#fff", strokeWidth: "2" }),
|
|
939
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: `M ${BAR_X0} ${y - 4} v 8 M ${BAR_X1} ${y - 4} v 8`, stroke: "#fff", strokeWidth: "2" }),
|
|
940
|
+
g.green && seg(g.green[0], g.green[1], GREEN3),
|
|
941
|
+
g.yellow && seg(g.yellow[0], g.yellow[1], YELLOW),
|
|
942
|
+
g.low !== void 0 && seg(g.min, g.low, RED2),
|
|
943
|
+
g.high !== void 0 && seg(g.high, g.max, RED2),
|
|
944
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("g", { "data-testid": testId, style: motionStyle(`translate(${round2(at(g.value) - BAR_X0)}px, 0px)`, duration), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: `M ${BAR_X0} ${y - 3} l -5 -9 h 10 z`, fill: "#fff", stroke: "#000", strokeWidth: "1" }) }),
|
|
945
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { x: BAR_X0, y: top + 31, fill: LABEL, fontSize: "13", fontWeight: "bold", dominantBaseline: "central", children: label }),
|
|
946
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { x: 350, y: top + 15, fill: g.color, fontSize: "20", fontWeight: "bold", textAnchor: "end", dominantBaseline: "central", children: g.text }),
|
|
947
|
+
g.unit && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { x: 350, y: top + 31, fill: LABEL, fontSize: "10", fontWeight: "bold", textAnchor: "end", dominantBaseline: "central", children: g.unit })
|
|
948
|
+
] });
|
|
949
|
+
}
|
|
950
|
+
function Tank({ x, fraction, duration, testId }) {
|
|
951
|
+
const top = 304;
|
|
952
|
+
const h = 40;
|
|
953
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { children: [
|
|
954
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { x: x - 7, y: top, width: "14", height: h, rx: "3", fill: "#000", stroke: "#fff", strokeWidth: "1.5" }),
|
|
955
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("g", { "data-testid": testId, style: motionStyle(`scaleY(${fraction})`, duration, x, top + h - 2), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { x: x - 5.5, y: top + 2, width: "11", height: h - 4, fill: BLUE }) }),
|
|
956
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { x: x - 5.5, y: top + h - 5, width: "11", height: "3", fill: RED2 })
|
|
957
|
+
] });
|
|
958
|
+
}
|
|
959
|
+
var hottest = (values) => {
|
|
960
|
+
const finite_ = values.map((v) => finite(v, NaN)).filter((v) => !Number.isNaN(v));
|
|
961
|
+
return finite_.length ? Math.max(...finite_) : void 0;
|
|
962
|
+
};
|
|
963
|
+
function EngineIndicator({
|
|
964
|
+
power,
|
|
965
|
+
manifold = {},
|
|
966
|
+
rpm = {},
|
|
967
|
+
cht = [],
|
|
968
|
+
egt = [],
|
|
969
|
+
tit,
|
|
970
|
+
chtLimit = 400,
|
|
971
|
+
chtScale = 500,
|
|
972
|
+
egtScale = 1700,
|
|
973
|
+
temperatureUnit = "\xB0F",
|
|
974
|
+
gauges = DEFAULT_BAR_GAUGES,
|
|
975
|
+
amps,
|
|
976
|
+
volts,
|
|
977
|
+
fuelLeft,
|
|
978
|
+
fuelRight,
|
|
979
|
+
fuelCapacity = 30,
|
|
980
|
+
fuelUnit = "GAL",
|
|
981
|
+
...props
|
|
982
|
+
}) {
|
|
983
|
+
const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
|
|
984
|
+
const man = resolve(manifold, DEFAULT_MANIFOLD);
|
|
985
|
+
const speed = resolve(rpm, DEFAULT_RPM);
|
|
986
|
+
const bars = gauges.slice(0, MAX_BAR_GAUGES).map((g) => ({ label: g.label, g: resolve(g) }));
|
|
987
|
+
const chtValues = cht.slice(0, MAX_CYLINDERS);
|
|
988
|
+
const egtValues = egt.slice(0, MAX_CYLINDERS);
|
|
989
|
+
const cylinders = Math.max(chtValues.length, egtValues.length);
|
|
990
|
+
const hasTit = typeof tit === "number" && Number.isFinite(tit);
|
|
991
|
+
const columns = cylinders + (hasTit ? 1 : 0);
|
|
992
|
+
const chtMax = hottest(chtValues);
|
|
993
|
+
const egtMax = hottest(egtValues);
|
|
994
|
+
const chartX0 = 50;
|
|
995
|
+
const chartX1 = 192;
|
|
996
|
+
const chartBase = 284;
|
|
997
|
+
const chartH = 88;
|
|
998
|
+
const colW = columns > 0 ? (chartX1 - chartX0) / columns : 0;
|
|
999
|
+
const barW = clamp(colW * 0.35, 4, 9);
|
|
1000
|
+
const chtFrac = (v) => clamp(finite(v) / Math.max(1e-9, finite(chtScale, 500)), 0, 1);
|
|
1001
|
+
const egtFrac = (v) => clamp(finite(v) / Math.max(1e-9, finite(egtScale, 1700)), 0, 1);
|
|
1002
|
+
const limitY = chartBase - chartH * chtFrac(chtLimit);
|
|
1003
|
+
const cap = Math.max(1e-9, finite(fuelCapacity, 30));
|
|
1004
|
+
const left = clamp(finite(fuelLeft), 0, cap);
|
|
1005
|
+
const right = clamp(finite(fuelRight), 0, cap);
|
|
1006
|
+
const fmt = (v, d = 0) => typeof v === "number" && Number.isFinite(v) ? v.toFixed(d) : "---";
|
|
1007
|
+
const readouts = [
|
|
1008
|
+
{ name: "CHT", value: chtMax, color: GREEN3, x: 62 },
|
|
1009
|
+
{ name: "EGT", value: egtMax, color: BLUE, x: 118 },
|
|
1010
|
+
{ name: "TIT", value: hasTit ? tit : void 0, color: "#fff", x: 170 }
|
|
1011
|
+
].filter((r) => r.value !== void 0);
|
|
1012
|
+
const label = "Engine: " + [
|
|
1013
|
+
power !== void 0 ? `power ${fmt(power)}%` : null,
|
|
1014
|
+
`MAN ${man.text}${man.unit ? ` ${man.unit}` : ""}`,
|
|
1015
|
+
`RPM ${speed.text}`,
|
|
1016
|
+
chtMax !== void 0 ? `CHT ${fmt(chtMax)}${temperatureUnit}` : null,
|
|
1017
|
+
egtMax !== void 0 ? `EGT ${fmt(egtMax)}${temperatureUnit}` : null,
|
|
1018
|
+
hasTit ? `TIT ${fmt(tit)}${temperatureUnit}` : null,
|
|
1019
|
+
...bars.map((b) => `${b.label} ${b.g.text}${b.g.unit ? ` ${b.g.unit}` : ""}`),
|
|
1020
|
+
amps !== void 0 ? `${fmt(amps)} A` : null,
|
|
1021
|
+
fuelLeft !== void 0 || fuelRight !== void 0 ? `fuel ${fmt(fuelLeft)}/${fmt(fuelRight)} ${fuelUnit}` : null,
|
|
1022
|
+
volts !== void 0 ? `${fmt(volts, 1)} V` : null
|
|
1023
|
+
].filter(Boolean).join(", ");
|
|
1024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(InstrumentFrame, { ...props, label, children: [
|
|
1025
|
+
power !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("text", { x: CENTER, y: 44, fill: "#fff", fontSize: "18", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: [
|
|
1026
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("tspan", { fill: LABEL, fontSize: "11", children: [
|
|
1027
|
+
"POWER",
|
|
1028
|
+
" "
|
|
1029
|
+
] }),
|
|
1030
|
+
fmt(power),
|
|
1031
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tspan", { fontSize: "11", children: "%" })
|
|
1032
|
+
] }),
|
|
1033
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ArcGauge, { cx: 118, label: "MAN", g: man, duration, testId: "engine-man" }),
|
|
1034
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ArcGauge, { cx: 282, label: "RPM", g: speed, duration, testId: "engine-rpm" }),
|
|
1035
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { stroke: LINE, strokeWidth: "1.5", children: [
|
|
1036
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: chord(133) }),
|
|
1037
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M 200 133 V 298" }),
|
|
1038
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: chord(298) }),
|
|
1039
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M 136 298 V 348 M 264 298 V 348" })
|
|
1040
|
+
] }),
|
|
1041
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("g", { fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: readouts.map((r) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { children: [
|
|
1042
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("text", { x: r.x, y: 144, fill: LABEL, fontSize: "13", children: [
|
|
1043
|
+
r.name,
|
|
1044
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tspan", { fontSize: "9", children: temperatureUnit })
|
|
1045
|
+
] }),
|
|
1046
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { "data-testid": `engine-${r.name.toLowerCase()}`, x: r.x, y: 165, fill: r.color, fontSize: "22", children: fmt(r.value) })
|
|
1047
|
+
] }, r.name)) }),
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M 40 178 H 190", stroke: LINE, strokeWidth: "1" }),
|
|
1049
|
+
columns > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { children: [
|
|
1050
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: `M ${chartX0} ${limitY} H ${chartX1}`, stroke: RED2, strokeWidth: "1.5", strokeDasharray: "5 4" }),
|
|
1051
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { x: chartX0 - 4, y: limitY, fill: "#fff", fontSize: "10", fontWeight: "bold", textAnchor: "end", dominantBaseline: "central", children: "CHT" }),
|
|
1052
|
+
Array.from({ length: cylinders }, (_, i) => {
|
|
1053
|
+
const x0 = chartX0 + colW * i;
|
|
1054
|
+
const mid = x0 + colW / 2;
|
|
1055
|
+
const c = chtValues[i];
|
|
1056
|
+
const e = egtValues[i];
|
|
1057
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { children: [
|
|
1058
|
+
c !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("g", { "data-testid": `engine-cht-${i}`, style: motionStyle(`scaleY(${chtFrac(c)})`, duration, mid, chartBase), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { x: mid - barW - 1, y: chartBase - chartH, width: barW, height: chartH, fill: GREEN3 }) }),
|
|
1059
|
+
e !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("g", { "data-testid": `engine-egt-${i}`, style: motionStyle(`scaleY(${egtFrac(e)})`, duration, mid, chartBase), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { x: mid + 1, y: chartBase - chartH, width: barW, height: chartH, fill: BLUE }) }),
|
|
1060
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { x: mid, y: 294, fill: "#fff", fontSize: "12", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: i + 1 })
|
|
1061
|
+
] }, i);
|
|
1062
|
+
}),
|
|
1063
|
+
hasTit && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { children: [
|
|
1064
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("g", { "data-testid": "engine-tit-bar", style: motionStyle(`scaleY(${egtFrac(tit)})`, duration, chartX1 - colW / 2, chartBase), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { x: chartX1 - colW / 2 - barW / 2, y: chartBase - chartH, width: barW, height: chartH, fill: "#fff" }) }),
|
|
1065
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { x: chartX1 - colW / 2, y: 294, fill: "#fff", fontSize: "12", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: "T" })
|
|
1066
|
+
] })
|
|
1067
|
+
] }),
|
|
1068
|
+
bars.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { children: [
|
|
1069
|
+
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: `M 206 ${BAR_TOP2 + BAR_ROW_H * i - 2} H 352`, stroke: LINE, strokeWidth: "1" }),
|
|
1070
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(BarGauge, { top: BAR_TOP2 + BAR_ROW_H * i, g: b.g, label: b.label, duration, testId: `engine-bar-${i}` })
|
|
1071
|
+
] }, b.label)),
|
|
1072
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: [
|
|
1073
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("text", { "data-testid": "engine-amps", x: 104, y: 318, fill: "#fff", fontSize: "20", children: [
|
|
1074
|
+
fmt(amps),
|
|
1075
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tspan", { fontSize: "11", dx: "2", children: "A" })
|
|
1076
|
+
] }),
|
|
1077
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { x: 104, y: 338, fill: LABEL, fontSize: "13", children: "ALT" }),
|
|
1078
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Tank, { x: 152, fraction: left / cap, duration, testId: "engine-fuel-left" }),
|
|
1079
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Tank, { x: 248, fraction: right / cap, duration, testId: "engine-fuel-right" }),
|
|
1080
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("text", { "data-testid": "engine-fuel", x: 200, y: 316, fill: "#fff", fontSize: "20", children: [
|
|
1081
|
+
fmt(left),
|
|
1082
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tspan", { dx: "14", children: fmt(right) })
|
|
1083
|
+
] }),
|
|
1084
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { x: 200, y: 335, fill: LABEL, fontSize: "13", children: "Fuel" }),
|
|
1085
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { x: 200, y: 348, fill: LABEL, fontSize: "9", children: fuelUnit }),
|
|
1086
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("text", { "data-testid": "engine-volts", x: 296, y: 318, fill: "#fff", fontSize: "20", children: [
|
|
1087
|
+
fmt(volts, 1),
|
|
1088
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tspan", { fontSize: "11", dx: "2", children: "V" })
|
|
1089
|
+
] }),
|
|
1090
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("text", { x: 296, y: 338, fill: LABEL, fontSize: "13", children: "BATT" })
|
|
1091
|
+
] })
|
|
1092
|
+
] });
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// src/components/FlapIndicator.tsx
|
|
1096
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1097
|
+
var GREEN4 = "#3ddc3d";
|
|
1098
|
+
var YELLOW2 = "#ffd400";
|
|
1099
|
+
var ORANGE = "#ff8a00";
|
|
1100
|
+
var RED3 = "#ff2a2a";
|
|
1101
|
+
var BAR_X = 226;
|
|
1102
|
+
var BAR_W = 30;
|
|
1103
|
+
var BAR_TOP3 = 78;
|
|
1104
|
+
var BAR_BOTTOM2 = 302;
|
|
1105
|
+
var BAR_H2 = BAR_BOTTOM2 - BAR_TOP3;
|
|
1106
|
+
function segmentColor(fraction) {
|
|
1107
|
+
if (fraction < 0.25) return GREEN4;
|
|
1108
|
+
if (fraction < 0.5) return YELLOW2;
|
|
1109
|
+
if (fraction < 0.75) return ORANGE;
|
|
1110
|
+
return RED3;
|
|
1111
|
+
}
|
|
1112
|
+
function FlapIndicator({
|
|
1113
|
+
flaps = 0,
|
|
1114
|
+
max = 40,
|
|
1115
|
+
detents,
|
|
1116
|
+
segments = 20,
|
|
1117
|
+
speedLimits,
|
|
1118
|
+
airspeed,
|
|
1119
|
+
label = "WING FLAP",
|
|
1120
|
+
...props
|
|
1121
|
+
}) {
|
|
1122
|
+
const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
|
|
1123
|
+
const full = Math.max(1e-9, finite(max, 40));
|
|
1124
|
+
const position = clamp(finite(flaps), 0, full);
|
|
1125
|
+
const fraction = position / full;
|
|
1126
|
+
const count = Math.max(1, Math.floor(finite(segments, 20)));
|
|
1127
|
+
const lit = Math.round(fraction * count);
|
|
1128
|
+
const scale = (detents ?? Array.from({ length: Math.floor(full / 10) + 1 }, (_, i) => i * 10)).filter((d) => d >= 0 && d <= full);
|
|
1129
|
+
const yAt = (deg) => Math.round((BAR_TOP3 + deg / full * BAR_H2) * 100) / 100;
|
|
1130
|
+
const limit = (speedLimits ?? []).filter((l) => Number.isFinite(l.flaps) && Number.isFinite(l.speed) && l.flaps <= position).sort((a, b) => b.flaps - a.flaps)[0];
|
|
1131
|
+
const ias = finite(airspeed, NaN);
|
|
1132
|
+
const overspeed = limit !== void 0 && !Number.isNaN(ias) && ias > limit.speed;
|
|
1133
|
+
const segH = BAR_H2 / count;
|
|
1134
|
+
const title = `${label}: ${Math.round(position)}\xB0 of ${Math.round(full)}\xB0` + (limit ? `, max ${Math.round(limit.speed)} knots${overspeed ? " (overspeed)" : ""}` : "");
|
|
1135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(InstrumentFrame, { ...props, label: title, children: [
|
|
1136
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("rect", { x: BAR_X - BAR_W / 2 - 4, y: BAR_TOP3 - 4, width: BAR_W + 8, height: BAR_H2 + 8, rx: "4", fill: "#000", stroke: "#333", strokeWidth: "1.5" }),
|
|
1137
|
+
Array.from({ length: count }, (_, i) => {
|
|
1138
|
+
const y = BAR_TOP3 + i * segH;
|
|
1139
|
+
const on = i < lit;
|
|
1140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1141
|
+
"rect",
|
|
1142
|
+
{
|
|
1143
|
+
"data-testid": `flap-segment-${i}`,
|
|
1144
|
+
"data-lit": on ? "true" : "false",
|
|
1145
|
+
x: BAR_X - BAR_W / 2,
|
|
1146
|
+
y: y + 1,
|
|
1147
|
+
width: BAR_W,
|
|
1148
|
+
height: Math.max(1, segH - 2),
|
|
1149
|
+
rx: "1.5",
|
|
1150
|
+
fill: segmentColor((i + 0.5) / count),
|
|
1151
|
+
opacity: on ? 1 : 0.18,
|
|
1152
|
+
style: { transition: "opacity 150ms ease-out" }
|
|
1153
|
+
},
|
|
1154
|
+
i
|
|
1155
|
+
);
|
|
1156
|
+
}),
|
|
1157
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("g", { fill: "#fff", fontSize: "18", fontWeight: "bold", dominantBaseline: "central", children: scale.map((d) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("g", { children: [
|
|
1158
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: `M ${BAR_X + BAR_W / 2 + 8} ${yAt(d)} h 8`, stroke: "#fff", strokeWidth: "2" }),
|
|
1159
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("text", { x: BAR_X + BAR_W / 2 + 22, y: yAt(d), children: d })
|
|
1160
|
+
] }, d)) }),
|
|
1161
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("g", { "data-testid": "flap-pointer", style: motionStyle(`translate(0px, ${yAt(position) - BAR_TOP3}px)`, duration), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: `M ${BAR_X - BAR_W / 2 - 8} ${BAR_TOP3} l -14 -8 v 16 z`, fill: "#fff", stroke: "#000", strokeWidth: "1" }) }),
|
|
1162
|
+
limit && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("g", { textAnchor: "middle", dominantBaseline: "central", fill: overspeed ? RED3 : "#fff", children: [
|
|
1163
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("text", { "data-testid": "flap-speed", x: 118, y: 176, fontSize: "36", fontWeight: "bold", children: [
|
|
1164
|
+
Math.round(limit.speed),
|
|
1165
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tspan", { fontSize: "13", dx: "3", children: "KTS" })
|
|
1166
|
+
] }),
|
|
1167
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("text", { x: 118, y: 212, fontSize: "13", fontWeight: "bold", fill: "#bbb", letterSpacing: "2", children: "MAX" })
|
|
1168
|
+
] }),
|
|
1169
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("text", { x: CENTER, y: 345, fill: "#ccc", fontSize: "16", textAnchor: "middle", children: label.toUpperCase() })
|
|
1170
|
+
] });
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// src/components/AoaIndicator.tsx
|
|
1174
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1175
|
+
var GREEN5 = "#3ddc3d";
|
|
1176
|
+
var AMBER3 = "#ffb000";
|
|
1177
|
+
var RED4 = "#ff2a2a";
|
|
1178
|
+
var UNLIT_OPACITY = 0.15;
|
|
1179
|
+
var ROWS = [
|
|
1180
|
+
{ shape: "bar", color: GREEN5, y: 300 },
|
|
1181
|
+
{ shape: "bar", color: GREEN5, y: 278 },
|
|
1182
|
+
{ shape: "bar", color: GREEN5, y: 256 },
|
|
1183
|
+
{ shape: "bar", color: GREEN5, y: 234 },
|
|
1184
|
+
{ shape: "donut", color: GREEN5, y: 208 },
|
|
1185
|
+
{ shape: "bar", color: AMBER3, y: 182 },
|
|
1186
|
+
{ shape: "split", color: AMBER3, y: 160 },
|
|
1187
|
+
{ shape: "chevron", color: AMBER3, y: 125 },
|
|
1188
|
+
{ shape: "chevron", color: AMBER3, y: 103 },
|
|
1189
|
+
{ shape: "chevron", color: RED4, y: 74 },
|
|
1190
|
+
{ shape: "chevron", color: RED4, y: 52 }
|
|
1191
|
+
];
|
|
1192
|
+
var DONUT = ROWS.findIndex((r) => r.shape === "donut");
|
|
1193
|
+
var ABOVE = ROWS.length - 1 - DONUT;
|
|
1194
|
+
var HALF = 70;
|
|
1195
|
+
var BAR_H3 = 12;
|
|
1196
|
+
var CHEVRON_DEPTH = 26;
|
|
1197
|
+
function RowShape({ shape, y }) {
|
|
1198
|
+
const l = CENTER - HALF;
|
|
1199
|
+
const r = CENTER + HALF;
|
|
1200
|
+
switch (shape) {
|
|
1201
|
+
case "bar":
|
|
1202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: l, y: y - BAR_H3 / 2, width: HALF * 2, height: BAR_H3, rx: "2" });
|
|
1203
|
+
case "split":
|
|
1204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
1205
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: l, y: y - BAR_H3 / 2, width: 50, height: BAR_H3, rx: "2" }),
|
|
1206
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: r - 50, y: y - BAR_H3 / 2, width: 50, height: BAR_H3, rx: "2" })
|
|
1207
|
+
] });
|
|
1208
|
+
case "donut":
|
|
1209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
1210
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: l, y: y - BAR_H3 / 2, width: HALF - 24, height: BAR_H3, rx: "2" }),
|
|
1211
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: CENTER + 24, y: y - BAR_H3 / 2, width: HALF - 24, height: BAR_H3, rx: "2" }),
|
|
1212
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: CENTER, cy: y, r: 13, fill: "none", strokeWidth: "7" })
|
|
1213
|
+
] });
|
|
1214
|
+
case "chevron":
|
|
1215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: `M ${l} ${y} L ${CENTER} ${y + CHEVRON_DEPTH} L ${r} ${y}`, fill: "none", strokeWidth: "11", strokeLinejoin: "miter" });
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
function AoaIndicator({ aoa = 0, min = 0, optimum, max = 20, showValue = false, label = "AOA", ...props }) {
|
|
1219
|
+
const lo = finite(min, 0);
|
|
1220
|
+
const hi = Math.max(lo + 1e-6, finite(max, 20));
|
|
1221
|
+
const opt = clamp(finite(optimum, (lo + hi) / 2), lo, hi);
|
|
1222
|
+
const value = finite(aoa, NaN);
|
|
1223
|
+
const thresholds = ROWS.map((_, i) => i <= DONUT ? lo + i / DONUT * (opt - lo) : opt + (i - DONUT) / ABOVE * (hi - opt));
|
|
1224
|
+
const lit = Number.isNaN(value) ? 0 : thresholds.filter((t) => value >= t - 1e-9).length;
|
|
1225
|
+
const stall = lit === ROWS.length;
|
|
1226
|
+
const reading = Number.isNaN(value) ? "---" : `${value.toFixed(1)}\xB0`;
|
|
1227
|
+
const state = stall ? " (stall warning)" : lit > DONUT + 1 ? " (high)" : lit === DONUT + 1 ? " (optimum)" : "";
|
|
1228
|
+
const title = `${label}: ${reading}${Number.isNaN(value) ? "" : state}`;
|
|
1229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(InstrumentFrame, { ...props, label: title, children: [
|
|
1230
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: CENTER - HALF - 10, y: 40, width: (HALF + 10) * 2, height: 278, rx: "10", fill: "#000", stroke: "#333", strokeWidth: "1.5" }),
|
|
1231
|
+
ROWS.map((row, i) => {
|
|
1232
|
+
const on = i < lit;
|
|
1233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1234
|
+
"g",
|
|
1235
|
+
{
|
|
1236
|
+
"data-testid": `aoa-row-${i}`,
|
|
1237
|
+
"data-lit": on ? "true" : "false",
|
|
1238
|
+
fill: row.color,
|
|
1239
|
+
stroke: row.color,
|
|
1240
|
+
strokeWidth: "0",
|
|
1241
|
+
opacity: on ? 1 : UNLIT_OPACITY,
|
|
1242
|
+
style: { transition: "opacity 150ms ease-out" },
|
|
1243
|
+
children: [
|
|
1244
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(RowShape, { shape: row.shape, y: row.y }),
|
|
1245
|
+
on && stall && row.shape === "chevron" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("animate", { attributeName: "opacity", values: "1;0.25;1", dur: "0.6s", repeatCount: "indefinite" })
|
|
1246
|
+
]
|
|
1247
|
+
},
|
|
1248
|
+
i
|
|
1249
|
+
);
|
|
1250
|
+
}),
|
|
1251
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("text", { "data-testid": "aoa-value", x: CENTER, y: 340, fill: "#fff", fontSize: "18", fontWeight: "bold", textAnchor: "middle", children: reading }),
|
|
1252
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("text", { x: CENTER, y: showValue ? 362 : 345, fill: "#ccc", fontSize: "16", textAnchor: "middle", children: label.toUpperCase() })
|
|
1253
|
+
] });
|
|
1254
|
+
}
|
|
594
1255
|
// Annotate the CommonJS export names for ESM import in node:
|
|
595
1256
|
0 && (module.exports = {
|
|
596
1257
|
Airspeed,
|
|
597
1258
|
Altimeter,
|
|
1259
|
+
AoaIndicator,
|
|
598
1260
|
AttitudeIndicator,
|
|
1261
|
+
DEFAULT_BAR_GAUGES,
|
|
1262
|
+
DEFAULT_MANIFOLD,
|
|
1263
|
+
DEFAULT_RPM,
|
|
1264
|
+
DataPanel,
|
|
1265
|
+
EngineIndicator,
|
|
1266
|
+
FlapIndicator,
|
|
1267
|
+
FuelIndicator,
|
|
599
1268
|
HeadingIndicator,
|
|
1269
|
+
MAX_BAR_GAUGES,
|
|
1270
|
+
MAX_CYLINDERS,
|
|
1271
|
+
MAX_FIELDS,
|
|
1272
|
+
MAX_TANKS,
|
|
600
1273
|
TurnCoordinator,
|
|
601
1274
|
VerticalSpeed,
|
|
602
|
-
|
|
1275
|
+
VorIndicator,
|
|
1276
|
+
WindIndicator,
|
|
1277
|
+
formatValue,
|
|
1278
|
+
vorDeviation
|
|
603
1279
|
});
|
|
604
1280
|
//# sourceMappingURL=index.cjs.map
|