Cleanup old configs

This commit is contained in:
Kilian Hofmann 2025-06-11 00:44:15 +02:00
parent ee46d0bff1
commit 890622453e
6 changed files with 11 additions and 773 deletions

View File

@ -9,11 +9,9 @@ interface IAppProps {
const App: FC<IAppProps> = ({ commBus }) => {
const [SBUsername, setSBUsername] = useState<string>();
//FIXME: TS Type
const [WASMData, setWASMData] = useState<WASMDataPax>();
const [isReady, setIsReady] = useState(false);
// Main Loop for Live Payload
// CommBus
const usernameCallback = useCallback((username: string) => {
setSBUsername(username);

View File

@ -1,14 +1,15 @@
import { FC } from 'react';
import { SharedConfig } from '../../configs/shared';
interface CGSelectProps {
minCG: number;
maxCG: number;
value: number;
disabled: boolean;
increase: () => void;
decrease: () => void;
}
const CGSelect: FC<CGSelectProps> = ({ value, disabled, increase, decrease }) => {
const CGSelect: FC<CGSelectProps> = ({ minCG, maxCG, value, disabled, increase, decrease }) => {
return (
<div className="relative">
<input
@ -17,7 +18,7 @@ const CGSelect: FC<CGSelectProps> = ({ value, disabled, increase, decrease }) =>
value={value.toFixed(1)}
/>
<button
disabled={disabled || value <= SharedConfig.CGLimits.min}
disabled={disabled || value <= minCG}
className="absolute right-2 top-0 -mt-[.5px] border-t bg-zinc-700 text-white disabled:text-zinc-400"
onClick={increase}
>
@ -45,7 +46,7 @@ const CGSelect: FC<CGSelectProps> = ({ value, disabled, increase, decrease }) =>
</svg>
</button>
<button
disabled={disabled || value >= SharedConfig.CGLimits.max}
disabled={disabled || value >= maxCG}
className="absolute bottom-0 right-2 -mt-[.5px] border-b bg-zinc-700 text-white disabled:text-zinc-400"
onClick={decrease}
>

View File

@ -1,5 +1,5 @@
import { FC, useEffect, useState } from 'react';
import { emptyAircraft, SharedConfig } from '../../configs/shared';
import { emptyAircraft } from '../../configs/shared';
import { COHERENT_COMBUS_WASM_CALL, COMM_BUS_UPDATE_TARGET_EVENT } from '../../constants';
import { WASMDataPax } from '../../types/WASMData';
import CGSelect from '../CGSelect/CGSelect';
@ -112,9 +112,11 @@ const ZFWEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoading
</div>
<div className="relative flex w-full items-center justify-between rounded-b-md bg-zinc-700 p-2 px-4">
<label>
Target ZFWCG ({SharedConfig.CGLimits.min} - {SharedConfig.CGLimits.max})
Target ZFWCG ({WASMData.limits.minCG} - {WASMData.limits.maxCG})
</label>
<CGSelect
minCG={WASMData.limits.minCG}
maxCG={WASMData.limits.maxCG}
value={targetZFWCG}
disabled={loadingState !== 'preview'}
increase={() =>

View File

@ -1,598 +0,0 @@
import { ArmsFuel, Fuel, SharedConfig, toPercentMAC } from './shared';
export interface PayloadPax {
empty: number;
pilot: number;
firstOfficer: number;
engineer: number;
cabinCrewFront: number;
business1Left: number;
business1Center: number;
business1Right: number;
business2Left: number;
business2Center: number;
business2Right: number;
economy1Left: number;
economy1Center: number;
economy1Right: number;
economy2Left: number;
economy2Center: number;
economy2Right: number;
cabinCrewRear: number;
forwardCargo: number;
rearCargo: number;
leftAuxPax: number;
rightAuxPax: number;
paxCount: {
business1: number;
business2: number;
economy1: number;
economy2: number;
total: number;
};
}
export const PaxConfig = {
// TODO: Extract from CFG at runtime.
arms: {
empty: -159.6,
pilot: 984,
firstOfficer: 984,
engineer: 960,
cabinCrewFront: 792,
business1Left: 540,
business1Center: 540,
business1Right: 540,
business2Left: 300,
business2Center: 300,
business2Right: 300,
economy1Left: -240,
economy1Center: -240,
economy1Right: -240,
economy2Left: -600,
economy2Center: -600,
economy2Right: -600,
cabinCrewRear: -660,
forwardCargo: 360,
rearCargo: -360,
leftAuxPax: 60,
rightAuxPax: 60,
},
// TODO: Make user adjustable
weights: {
pax: {
lbs: 190,
kg: 86,
},
baggage: {
lbs: 50,
kg: 23,
},
base: {
lbs: {
pilot: 190,
firstOfficer: 190,
engineer: 190,
cabinCrewFront: 380,
cabinCrewRear: 950,
total: 190 + 190 + 190 + 380 + 950,
},
kg: {
pilot: 86,
firstOfficer: 86,
engineer: 86,
cabinCrewFront: 172,
cabinCrewRear: 430,
total: 86 + 86 + 86 + 172 + 430,
},
},
},
stationMax: {
business1: 30,
business2: 45,
economy1: 86,
economy2: 137,
total: 30 + 45 + 86 + 137,
},
maxZWF: {
lbs: 400000,
kg: 181437,
},
weightToPax: (weight: number, unit: 'kg' | 'lbs') => {
return Math.round(weight / PaxConfig.weights.pax[unit]);
},
calculateCGs: (payload: PayloadPax, fuel: Fuel): [number, number] => {
let totalMoment =
payload.empty * PaxConfig.arms.empty +
payload.pilot * PaxConfig.arms.pilot +
payload.firstOfficer * PaxConfig.arms.firstOfficer +
payload.engineer * PaxConfig.arms.engineer +
payload.cabinCrewFront * PaxConfig.arms.cabinCrewFront +
payload.business1Left * PaxConfig.arms.business1Left +
payload.business1Center * PaxConfig.arms.business1Center +
payload.business1Right * PaxConfig.arms.business1Right +
payload.business2Left * PaxConfig.arms.business2Left +
payload.business2Center * PaxConfig.arms.business2Center +
payload.business2Right * PaxConfig.arms.business2Right +
payload.economy1Left * PaxConfig.arms.economy1Left +
payload.economy1Center * PaxConfig.arms.economy1Center +
payload.economy1Right * PaxConfig.arms.economy1Right +
payload.economy2Left * PaxConfig.arms.economy2Left +
payload.economy2Center * PaxConfig.arms.economy2Center +
payload.economy2Right * PaxConfig.arms.economy2Right +
payload.cabinCrewRear * PaxConfig.arms.cabinCrewRear +
payload.forwardCargo * PaxConfig.arms.forwardCargo +
payload.rearCargo * PaxConfig.arms.rearCargo +
payload.leftAuxPax * PaxConfig.arms.leftAuxPax +
payload.rightAuxPax * PaxConfig.arms.rightAuxPax;
let totalWeight =
payload.empty +
payload.pilot +
payload.firstOfficer +
payload.engineer +
payload.cabinCrewFront +
payload.business1Left +
payload.business1Center +
payload.business1Right +
payload.business2Left +
payload.business2Center +
payload.business2Right +
payload.economy1Left +
payload.economy1Center +
payload.economy1Right +
payload.economy2Left +
payload.economy2Center +
payload.economy2Right +
payload.cabinCrewRear +
payload.forwardCargo +
payload.rearCargo +
payload.leftAuxPax +
payload.rightAuxPax;
const ZFWCG = toPercentMAC(totalMoment / totalWeight);
totalMoment +=
fuel.main1 * ArmsFuel.main1 +
fuel.main3 * ArmsFuel.main3 +
fuel.main2 * ArmsFuel.main2 +
fuel.upperAux * ArmsFuel.upperAux +
fuel.lowerAux * ArmsFuel.lowerAux +
fuel.main1Tip * ArmsFuel.main1Tip +
fuel.main3Tip * ArmsFuel.main3Tip +
fuel.tail * ArmsFuel.tail +
fuel.forwardAux1 * ArmsFuel.forwardAux1 +
fuel.forwardAux2 * ArmsFuel.forwardAux2;
totalWeight +=
fuel.main1 +
fuel.main3 +
fuel.main2 +
fuel.upperAux +
fuel.lowerAux +
fuel.main1Tip +
fuel.main3Tip +
fuel.tail +
fuel.forwardAux1 +
fuel.forwardAux2;
const toCG = toPercentMAC(totalMoment / totalWeight);
return [ZFWCG, toCG];
},
generateDistribution: (
OEW: number,
business1: number,
business2: number,
economy1: number,
economy2: number,
forwardCargo: number,
rearCargo: number,
unit: 'kg' | 'lbs',
isER: boolean
): PayloadPax => {
const distribution: PayloadPax = {
empty: OEW,
...PaxConfig.weights.base[unit],
business1Left: (business1 / 3) * PaxConfig.weights.pax[unit],
business1Center: (business1 / 3) * PaxConfig.weights.pax[unit],
business1Right: (business1 / 3) * PaxConfig.weights.pax[unit],
business2Left: (business2 / 3) * PaxConfig.weights.pax[unit],
business2Center: (business2 / 3) * PaxConfig.weights.pax[unit],
business2Right: (business2 / 3) * PaxConfig.weights.pax[unit],
economy1Left: (economy1 / 3) * PaxConfig.weights.pax[unit],
economy1Center: (economy1 / 3) * PaxConfig.weights.pax[unit],
economy1Right: (economy1 / 3) * PaxConfig.weights.pax[unit],
economy2Left: (economy2 / 3) * PaxConfig.weights.pax[unit],
economy2Center: (economy2 / 3) * PaxConfig.weights.pax[unit],
economy2Right: (economy2 / 3) * PaxConfig.weights.pax[unit],
forwardCargo: forwardCargo,
rearCargo: rearCargo,
leftAuxPax: isER ? SharedConfig.erExtraWeight[unit] : 0,
rightAuxPax: isER ? SharedConfig.erExtraWeight[unit] : 0,
paxCount: {
business1,
business2,
economy1,
economy2,
total: business1 + business2 + economy1 + economy2,
},
};
return distribution;
},
distribute: (
ZFWTarget: number,
CGTarget: number,
OEW: number,
fuelLive: Fuel,
unit: 'kg' | 'lbs',
isER: boolean,
numPax?: number
) => {
const payload =
ZFWTarget -
OEW -
PaxConfig.weights.base[unit].pilot -
PaxConfig.weights.base[unit].firstOfficer -
PaxConfig.weights.base[unit].engineer -
PaxConfig.weights.base[unit].cabinCrewFront -
PaxConfig.weights.base[unit].cabinCrewRear -
(isER ? SharedConfig.erExtraWeight[unit] * 2 : 0);
let _numPax =
numPax ??
Math.max(
0,
Math.min(
PaxConfig.stationMax.total,
Math.floor(payload / (PaxConfig.weights.pax[unit] + PaxConfig.weights.baggage[unit]))
)
);
let cargo = Math.round(payload - _numPax * PaxConfig.weights.pax[unit] - _numPax * PaxConfig.weights.baggage[unit]);
let business1 = 0;
let business2 = 0;
let economy1 = 0;
let economy2 = 0;
let forwardCargo = 0;
let rearCargo = 0;
let __numPax = 0;
let count = PaxConfig.stationMax.economy2;
// initial distribution
while (_numPax > 0 && count > 0) {
if (_numPax >= 4) {
if (business1 < PaxConfig.stationMax.business1) {
business1++;
__numPax++;
}
if (business2 < PaxConfig.stationMax.business2) {
business2++;
__numPax++;
}
if (economy1 < PaxConfig.stationMax.economy1) {
economy1++;
__numPax++;
}
if (economy2 < PaxConfig.stationMax.economy2) {
economy2++;
__numPax++;
}
} else if (_numPax === 3) {
if (business2 < PaxConfig.stationMax.business2) {
business2++;
__numPax++;
}
if (economy1 < PaxConfig.stationMax.economy1) {
economy1++;
__numPax++;
}
if (economy2 < PaxConfig.stationMax.economy2) {
economy2++;
__numPax++;
}
} else if (_numPax === 2) {
if (economy1 < PaxConfig.stationMax.economy1) {
economy1++;
__numPax++;
}
if (economy2 < PaxConfig.stationMax.economy2) {
economy2++;
__numPax++;
}
} else if (_numPax === 1) {
if (economy2 < PaxConfig.stationMax.economy2) {
economy2++;
__numPax++;
}
}
_numPax -= __numPax;
if (__numPax % 2 === 0) {
forwardCargo += (__numPax / 2) * PaxConfig.weights.baggage[unit];
rearCargo += (__numPax / 2) * PaxConfig.weights.baggage[unit];
} else {
__numPax--;
forwardCargo += (__numPax / 2 + 1) * PaxConfig.weights.baggage[unit];
rearCargo += (__numPax / 2) * PaxConfig.weights.baggage[unit];
}
__numPax = 0;
count--;
}
count = SharedConfig.stationMax.forward[unit];
while (cargo > 0 && count > 0) {
if (forwardCargo < SharedConfig.stationMax.forward[unit]) {
forwardCargo++;
cargo--;
}
if (rearCargo < SharedConfig.stationMax.rear[unit]) {
rearCargo++;
cargo--;
}
count--;
}
// Refinement pax
count = PaxConfig.stationMax.total;
while (count > 0) {
const distribution = PaxConfig.generateDistribution(
OEW,
business1,
business2,
economy1,
economy2,
forwardCargo,
rearCargo,
unit,
isER
);
const _CGs = PaxConfig.calculateCGs(distribution, fuelLive);
// in front of target
if (_CGs[0] < CGTarget - SharedConfig.CGLimits.tolerance) {
if (business1 > 0) {
business1--;
} else if (business2 > 0) {
business2--;
} else if (economy1 > 0) {
economy1--;
} else {
break;
}
if (economy2 < PaxConfig.stationMax.economy2) {
economy2++;
} else if (economy1 < PaxConfig.stationMax.economy1) {
economy1++;
} else if (business2 < PaxConfig.stationMax.business2) {
business2++;
} else {
business1++;
}
}
// behind target
else if (_CGs[0] > CGTarget + SharedConfig.CGLimits.tolerance) {
if (economy2 > 0) {
economy2--;
} else if (economy1 > 0) {
economy1--;
} else if (business2 > 0) {
business2--;
} else {
break;
}
if (business1 < PaxConfig.stationMax.business1) {
business1++;
} else if (business2 < PaxConfig.stationMax.business2) {
business2++;
} else if (economy1 < PaxConfig.stationMax.economy1) {
economy1++;
} else {
economy2++;
}
} else {
break;
}
count--;
}
// Refinement cargo
count = SharedConfig.stationMax.forward[unit] + SharedConfig.stationMax.rear[unit];
while (count > 0) {
const distribution = PaxConfig.generateDistribution(
OEW,
business1,
business2,
economy1,
economy2,
forwardCargo,
rearCargo,
unit,
isER
);
const _CGs = PaxConfig.calculateCGs(distribution, fuelLive);
// in front of target
if (_CGs[0] < CGTarget - SharedConfig.CGLimits.tolerance) {
if (forwardCargo > 0 && rearCargo < SharedConfig.stationMax.rear[unit]) {
if (
forwardCargo > PaxConfig.weights.baggage[unit] &&
rearCargo < SharedConfig.stationMax.forward[unit] - PaxConfig.weights.baggage[unit]
) {
forwardCargo -= PaxConfig.weights.baggage[unit];
rearCargo += PaxConfig.weights.baggage[unit];
} else {
forwardCargo--;
rearCargo++;
}
} else {
break;
}
}
// behind target
else if (_CGs[0] > CGTarget + SharedConfig.CGLimits.tolerance) {
if (rearCargo > 0 && forwardCargo < SharedConfig.stationMax.forward[unit]) {
if (
rearCargo > PaxConfig.weights.baggage[unit] &&
forwardCargo < SharedConfig.stationMax.rear[unit] - PaxConfig.weights.baggage[unit]
) {
rearCargo -= PaxConfig.weights.baggage[unit];
forwardCargo += PaxConfig.weights.baggage[unit];
} else {
rearCargo--;
forwardCargo++;
}
} else {
break;
}
} else {
break;
}
count--;
}
const distribution = PaxConfig.generateDistribution(
OEW,
business1,
business2,
economy1,
economy2,
forwardCargo,
rearCargo,
unit,
isER
);
return distribution;
},
// SIM access
getWeights: (unit: 'kg' | 'lbs') => {
const payload: PayloadPax = {
empty: SimVar.GetSimVarValue('EMPTY WEIGHT', unit),
pilot: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:1', unit),
firstOfficer: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:2', unit),
engineer: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:3', unit),
cabinCrewFront: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:4', unit),
business1Left: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:5', unit),
business1Center: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:6', unit),
business1Right: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:7', unit),
business2Left: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:8', unit),
business2Center: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:9', unit),
business2Right: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:10', unit),
economy1Left: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:11', unit),
economy1Center: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:12', unit),
economy1Right: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:13', unit),
economy2Left: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:14', unit),
economy2Center: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:15', unit),
economy2Right: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:16', unit),
cabinCrewRear: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:17', unit),
forwardCargo: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:18', unit),
rearCargo: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:19', unit),
leftAuxPax: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:20', unit),
rightAuxPax: SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:21', unit),
paxCount: {
business1: 0,
business2: 0,
economy1: 0,
economy2: 0,
total: 0,
},
};
return payload;
},
setBaseWeight: (unit: 'kg' | 'lbs', isER: boolean) => {
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:1', unit, PaxConfig.weights.base[unit].pilot); // Pilot
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:2', unit, PaxConfig.weights.base[unit].firstOfficer); // First officer
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:3', unit, PaxConfig.weights.base[unit].engineer); // Engineer
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:4', unit, PaxConfig.weights.base[unit].cabinCrewFront); // Cabin Crew front
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:17', unit, PaxConfig.weights.base[unit].cabinCrewRear); // Cabin Crew rear
if (isER) {
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:20', unit, SharedConfig.erExtraWeight[unit]); // Forward Aux 1
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:21', unit, SharedConfig.erExtraWeight[unit]); // Forward Aux 2
}
},
setWeights: (payload: PayloadPax, unit: 'kg' | 'lbs') => {
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:4', unit, payload.cabinCrewFront); // Cabin Crew front
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:5', unit, payload.business1Left); // Business 1L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:6', unit, payload.business1Center); // Business 1C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:7', unit, payload.business1Right); // Business 1R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:8', unit, payload.business2Left); // Business 2L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:9', unit, payload.business2Center); // Business 2C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:10', unit, payload.business2Right); // Business 2R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:11', unit, payload.economy1Left); // Economy 1L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:12', unit, payload.economy1Center); // Economy 1C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:13', unit, payload.economy1Right); // Economy 1R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:14', unit, payload.economy2Left); // Economy 2L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:15', unit, payload.economy2Center); // Economy 2C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:16', unit, payload.economy2Right); // Economy 2R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:17', unit, payload.cabinCrewRear); //Cabin Crew rear
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:18', unit, payload.forwardCargo); // Forward Cargo
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:19', unit, payload.rearCargo); // Rear Cargo
},
setWeightsProgressive: (payload: PayloadPax, paxNum: number, cargoPercent: number, unit: 'kg' | 'lbs') => {
const business1Scalar = Math.min(1, paxNum / payload.paxCount.business1);
paxNum -= payload.paxCount.business1 * business1Scalar;
const business2Scalar = Math.min(1, paxNum / payload.paxCount.business2);
paxNum -= payload.paxCount.business2 * business2Scalar;
const economy1Scalar = Math.min(1, paxNum / payload.paxCount.economy1);
paxNum -= payload.paxCount.economy1 * economy1Scalar;
const economy2Scalar = Math.min(1, paxNum / payload.paxCount.economy2);
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:4', unit, payload.cabinCrewFront); // Cabin Crew front
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:5', unit, payload.business1Left * business1Scalar); // Business 1L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:6', unit, payload.business1Center * business1Scalar); // Business 1C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:7', unit, payload.business1Right * business1Scalar); // Business 1R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:8', unit, payload.business2Left * business2Scalar); // Business 2L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:9', unit, payload.business2Center * business2Scalar); // Business 2C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:10', unit, payload.business2Right * business2Scalar); // Business 2R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:11', unit, payload.economy1Left * economy1Scalar); // Economy 1L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:12', unit, payload.economy1Center * economy1Scalar); // Economy 1C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:13', unit, payload.economy1Right * economy1Scalar); // Economy 1R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:14', unit, payload.economy2Left * economy2Scalar); // Economy 2L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:15', unit, payload.economy2Center * economy2Scalar); // Economy 2C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:16', unit, payload.economy2Right * economy2Scalar); // Economy 2R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:17', unit, payload.cabinCrewRear); //Cabin Crew rear
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:18', unit, payload.forwardCargo * (cargoPercent / 100)); // Forward Cargo
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:19', unit, payload.rearCargo * (cargoPercent / 100)); // Rear Cargo
},
unload: (unit: 'kg' | 'lbs', isER: boolean) => {
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:1', unit, 0); // Pilot
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:2', unit, 0); // First officer
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:3', unit, 0); // Engineer
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:4', unit, 0); // Cabin Crew front
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:17', unit, 0); // Cabin Crew rear
if (!isER) {
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:20', unit, 0); // Forward Aux 1
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:21', unit, 0); // Forward Aux 2
}
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:4', unit, 0); // Cabin Crew front
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:5', unit, 0); // Business 1L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:6', unit, 0); // Business 1C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:7', unit, 0); // Business 1R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:8', unit, 0); // Business 2L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:9', unit, 0); // Business 2C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:10', unit, 0); // Business 2R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:11', unit, 0); // Economy 1L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:12', unit, 0); // Economy 1C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:13', unit, 0); // Economy 1R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:14', unit, 0); // Economy 2L
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:15', unit, 0); // Economy 2C
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:16', unit, 0); // Economy 2R
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:17', unit, 0); //Cabin Crew rear
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:18', unit, 0); // Forward Cargo
SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:19', unit, 0); // Rear Cargo
},
};

View File

@ -1,172 +1,5 @@
import { COHERENT_COMBUS_WASM_CALL, COMM_BUS_LIVE_DATA_EVENT } from '../constants';
export interface Fuel {
main1: number;
main3: number;
main2: number;
upperAux: number;
lowerAux: number;
main1Tip: number;
main3Tip: number;
tail: number;
forwardAux1: number;
forwardAux2: number;
}
// TODO: Extract from CFG at runtime.
export const ArmsFuel = {
main1: -240,
main3: -240,
main2: 120,
upperAux: 0,
lowerAux: 0,
main1Tip: -468,
main3Tip: -468,
tail: -840,
forwardAux1: 60,
forwardAux2: 60,
};
// TODO: Extract following four from CFG at runtime
const rootChord = 34.68;
const wingSpan = 170.5;
const wingArea = 3648;
const quarterMAC = -165; //aero_center
const tipChord = (2 * wingArea) / wingSpan - rootChord;
const taperRatio = tipChord / rootChord;
const MAC = (2 / 3) * rootChord * ((1 + taperRatio + taperRatio ** 2) / (1 + taperRatio)) * 12;
const LEMAC = quarterMAC + (1 / 4) * MAC;
export const toPercentMAC = (positionInInches: number) => {
return ((positionInInches - LEMAC) / MAC) * -100;
};
export const SharedConfig = {
stationMax: {
//PMC pallet due to 104in door
forward: {
lbs: 6 * 15000,
kg: 6 * 6804,
},
//LD3s due to 70in door
rear: {
lbs: 14 * 3500,
kg: 14 * 1588,
},
},
maxTOW: {
er: {
lbs: 630500,
kg: 285990,
},
norm: {
lbs: 625500,
kg: 283722,
},
},
maxFuel: {
er: {
lbs: 282619,
kg: 128193,
},
norm: {
lbs: 256207,
kg: 116213,
},
},
erExtraWeight: {
lbs: 200,
kg: 91,
},
CGLimits: {
min: 12,
default: 20.5,
max: 34,
tolerance: 0.05,
},
};
export const initialPayload = {
empty: 0,
pilot: 0,
firstOfficer: 0,
engineer: 0,
cabinCrewFront: 0,
business1Left: 0,
business1Center: 0,
business1Right: 0,
business2Left: 0,
business2Center: 0,
business2Right: 0,
economy1Left: 0,
economy1Center: 0,
economy1Right: 0,
economy2Left: 0,
economy2Center: 0,
economy2Right: 0,
cabinCrewRear: 0,
forwardCargo: 0,
rearCargo: 0,
leftAuxPax: 0,
rightAuxPax: 0,
upper1Left: 0,
upper1Right: 0,
upper2Left: 0,
upper2Right: 0,
upper3Left: 0,
upper3Right: 0,
upper4Left: 0,
upper4Right: 0,
lowerForward: 0,
lowerRear: 0,
leftAuxF: 0,
rightAuxF: 0,
paxCount: {
business1: 0,
business2: 0,
economy1: 0,
economy2: 0,
total: 0,
},
};
export const initialFuel = {
main1: 0,
main3: 0,
main2: 0,
upperAux: 0,
lowerAux: 0,
main1Tip: 0,
main3Tip: 0,
tail: 0,
forwardAux1: 0,
forwardAux2: 0,
};
// SIM access
export const getFuel = (unit: 'kg' | 'lbs') => {
const conversion = SimVar.GetSimVarValue('FUEL WEIGHT PER GALLON', unit);
const fuel = {
main1: SimVar.GetSimVarValue('FUEL TANK LEFT MAIN QUANTITY', 'gal') * conversion,
main3: SimVar.GetSimVarValue('FUEL TANK RIGHT MAIN QUANTITY', 'gal') * conversion,
main2: SimVar.GetSimVarValue('FUEL TANK CENTER QUANTITY', 'gal') * conversion,
upperAux: SimVar.GetSimVarValue('FUEL TANK CENTER2 QUANTITY', 'gal') * conversion,
lowerAux: SimVar.GetSimVarValue('FUEL TANK CENTER3 QUANTITY', 'gal') * conversion,
main1Tip: SimVar.GetSimVarValue('FUEL TANK LEFT TIP QUANTITY', 'gal') * conversion,
main3Tip: SimVar.GetSimVarValue('FUEL TANK RIGHT TIP QUANTITY', 'gal') * conversion,
tail: SimVar.GetSimVarValue('FUEL TANK EXTERNAL1 QUANTITY', 'gal') * conversion,
forwardAux1: SimVar.GetSimVarValue('FUEL TANK LEFT AUX QUANTITY', 'gal') * conversion,
forwardAux2: SimVar.GetSimVarValue('FUEL TANK RIGHT AUX QUANTITY', 'gal') * conversion,
};
return fuel;
};
export const emptyAircraft = () => {
Coherent.call(
COHERENT_COMBUS_WASM_CALL,

View File

@ -2,3 +2,5 @@ export const COHERENT_COMBUS_WASM_CALL = 'COMM_BUS_WASM_CALLBACK';
export const TFDI_SIMBRIEF_USERNAME_EVENT = 'requestSimBriefUsername';
export const COMM_BUS_LIVE_DATA_EVENT = 'khofmann_tfdi_md-11_load_manager_live_data';
export const COMM_BUS_UPDATE_TARGET_EVENT = 'khofmann_tfdi_md-11_load_manager_update_target';
export const CG_ADJUST = 0.05;