Non GSX Fuel setting
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tfdidesign-md11-load-manager",
|
||||
"version": "0.1.188",
|
||||
"version": "0.2.8",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
|
||||
@@ -2,7 +2,7 @@ import { FC, useEffect, useState } from 'react';
|
||||
import { WASMDataF } from '../../types/WASMData';
|
||||
import { LoadingState, SimBrief } from '../../types/general';
|
||||
import { ImportFlightPlanKH } from '../../utils/TFDISBImport';
|
||||
import { CoherentCallSBEntryF, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import { CoherentCallSBEntryF, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import CGSelect from '../CGSelect/CGSelect';
|
||||
import ActionBar from '../actionbar/ActionBar';
|
||||
import Input from '../input/Input';
|
||||
@@ -16,8 +16,7 @@ interface SBEntryProps {
|
||||
|
||||
const SBEntryF: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLoadingState }) => {
|
||||
const [CGTarget, setCGTarget] = useState(WASMData.targetPayload.CGTarget);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.livePayload.fuel));
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.targetPayload.fuel));
|
||||
const [SBInFlight, setSBInFlight] = useState(false);
|
||||
|
||||
// FROM EFB
|
||||
@@ -52,6 +51,11 @@ const SBEntryF: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLoad
|
||||
}
|
||||
};
|
||||
|
||||
const updateData = (SBPlan?: SimBrief, _fuel?: number) => {
|
||||
CoherentCallSBEntryF(CGTarget, _fuel ?? fuel, SBPlan);
|
||||
};
|
||||
|
||||
useEffect(() => updateData(), [CGTarget, fuel]);
|
||||
useEffect(() => {
|
||||
if (!simBrief || gsxActive) return;
|
||||
|
||||
@@ -70,12 +74,13 @@ const SBEntryF: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLoad
|
||||
return;
|
||||
}
|
||||
|
||||
updateData(undefined, SBResponse.message as SimBrief);
|
||||
const _fuel = parseFloat((SBResponse.message as SimBrief).fuel as unknown as string) ?? 0;
|
||||
|
||||
setFuel(parseFloat((SBResponse.message as SimBrief).fuel as unknown as string) ?? 0);
|
||||
updateData(SBResponse.message as SimBrief, _fuel);
|
||||
|
||||
setFuel(_fuel);
|
||||
setSBInFlight(false);
|
||||
}, [simBrief, gsxActive]);
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
setFuel((prev) => {
|
||||
@@ -84,13 +89,6 @@ const SBEntryF: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLoad
|
||||
}),
|
||||
[WASMData.userData.isER]
|
||||
);
|
||||
useEffect(() => {
|
||||
setFuelEnabled((prev) => (!prev ? inRangeOf(Math.round(WASMData.livePayload.fuel), fuel) : prev));
|
||||
}, [WASMData.livePayload.fuel]);
|
||||
|
||||
const updateData = (_CGTarget?: number, SBPlan?: SimBrief) => {
|
||||
CoherentCallSBEntryF(_CGTarget ?? CGTarget, SBPlan);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -106,22 +104,6 @@ const SBEntryF: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLoad
|
||||
onChange={(value) => handleInput(value, WASMData.limits.maxFuel, setFuel)}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
<button
|
||||
className="middle none center rounded-lg bg-green-600 px-6 py-3 font-sans text-xs font-bold uppercase text-white shadow-md shadow-green-500/20 transition-all hover:shadow-lg hover:shadow-green-500/40 focus:opacity-[0.85] focus:shadow-none active:opacity-[0.85] active:shadow-none disabled:pointer-events-none disabled:opacity-50 disabled:shadow-none"
|
||||
data-ripple-light="true"
|
||||
onClick={() => {
|
||||
SimVar.SetSimVarValue(
|
||||
'L:MD11_EFB_PAYLOAD_FUEL',
|
||||
'lbs',
|
||||
WASMData.userData.isImperial ? fuel : fuel * 2.20462262185
|
||||
);
|
||||
SimVar.SetSimVarValue('L:MD11_EFB_READ_READY', 'bool', true);
|
||||
setFuelEnabled(WASMData.livePayload.fuel === fuel);
|
||||
}}
|
||||
disabled={loadingState !== 'preview' || !fuelEnabled || gsxActive}
|
||||
>
|
||||
Load Fuel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -164,14 +146,12 @@ const SBEntryF: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLoad
|
||||
increase={() =>
|
||||
setCGTarget((prev) => {
|
||||
const _new = prev + 0.1;
|
||||
updateData(_new);
|
||||
return _new;
|
||||
})
|
||||
}
|
||||
decrease={() =>
|
||||
setCGTarget((prev) => {
|
||||
const _new = prev - 0.1;
|
||||
updateData(_new);
|
||||
return _new;
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { FC, useEffect, useState } from 'react';
|
||||
import { WASMDataPax } from '../../types/WASMData';
|
||||
import { LoadingState, SimBrief } from '../../types/general';
|
||||
import { ImportFlightPlanKH } from '../../utils/TFDISBImport';
|
||||
import { CoherentCallSBEntryPax, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import { CoherentCallSBEntryPax, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import CGSelect from '../CGSelect/CGSelect';
|
||||
import ActionBar from '../actionbar/ActionBar';
|
||||
import Input from '../input/Input';
|
||||
@@ -16,7 +16,7 @@ interface SBEntryProps {
|
||||
|
||||
const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLoadingState }) => {
|
||||
const [CGTarget, setCGTarget] = useState(WASMData.targetPayload.CGTarget);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.livePayload.fuel));
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.targetPayload.fuel));
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
const [SBInFlight, setSBInFlight] = useState(false);
|
||||
|
||||
@@ -52,6 +52,10 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
|
||||
}
|
||||
};
|
||||
|
||||
const updateData = (SBPlan?: SimBrief, _fuel?: number) => {
|
||||
CoherentCallSBEntryPax(CGTarget, _fuel ?? fuel, SBPlan);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!simBrief || gsxActive) return;
|
||||
|
||||
@@ -70,12 +74,17 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
|
||||
return;
|
||||
}
|
||||
|
||||
updateData(undefined, SBResponse.message as SimBrief);
|
||||
const _fuel = parseFloat((SBResponse.message as SimBrief).fuel as unknown as string) ?? 0;
|
||||
|
||||
updateData(SBResponse.message as SimBrief, _fuel);
|
||||
|
||||
setFuel(_fuel);
|
||||
|
||||
setFuel(parseFloat((SBResponse.message as SimBrief).fuel as unknown as string) ?? 0);
|
||||
setSBInFlight(false);
|
||||
}, [simBrief, gsxActive]);
|
||||
|
||||
useEffect(() => updateData(), [CGTarget, fuel]);
|
||||
useEffect(
|
||||
() =>
|
||||
setFuel((prev) => {
|
||||
@@ -84,13 +93,6 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
|
||||
}),
|
||||
[WASMData.userData.isER]
|
||||
);
|
||||
useEffect(() => {
|
||||
setFuelEnabled((prev) => (!prev ? inRangeOf(Math.round(WASMData.livePayload.fuel), fuel) : prev));
|
||||
}, [WASMData.livePayload.fuel]);
|
||||
|
||||
const updateData = (_CGTarget?: number, SBPlan?: SimBrief) => {
|
||||
CoherentCallSBEntryPax(_CGTarget ?? CGTarget, SBPlan);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -106,22 +108,6 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
|
||||
onChange={(value) => handleInput(value, WASMData.limits.maxFuel, setFuel)}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
<button
|
||||
className="middle none center rounded-lg bg-green-600 px-6 py-3 font-sans text-xs font-bold uppercase text-white shadow-md shadow-green-500/20 transition-all hover:shadow-lg hover:shadow-green-500/40 focus:opacity-[0.85] focus:shadow-none active:opacity-[0.85] active:shadow-none disabled:pointer-events-none disabled:opacity-50 disabled:shadow-none"
|
||||
data-ripple-light="true"
|
||||
onClick={() => {
|
||||
SimVar.SetSimVarValue(
|
||||
'L:MD11_EFB_PAYLOAD_FUEL',
|
||||
'lbs',
|
||||
WASMData.userData.isImperial ? fuel : fuel * 2.20462262185
|
||||
);
|
||||
SimVar.SetSimVarValue('L:MD11_EFB_READ_READY', 'bool', true);
|
||||
setFuelEnabled(WASMData.livePayload.fuel === fuel);
|
||||
}}
|
||||
disabled={loadingState !== 'preview' || !fuelEnabled || gsxActive}
|
||||
>
|
||||
Load Fuel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -164,14 +150,12 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
|
||||
increase={() =>
|
||||
setCGTarget((prev) => {
|
||||
const _new = prev + 0.1;
|
||||
updateData(_new);
|
||||
return _new;
|
||||
})
|
||||
}
|
||||
decrease={() =>
|
||||
setCGTarget((prev) => {
|
||||
const _new = prev - 0.1;
|
||||
updateData(_new);
|
||||
return _new;
|
||||
})
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ const OptionsF: FC<OptionsFProps> = ({ WASMData, loadingState, gsxActive }) => {
|
||||
<td className="p-1 px-2">0 {WASMData.userData.isImperial ? 'lbs' : 'kg'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="p-1 px-2">Empty Weight</td>
|
||||
<td className="p-1 px-2">Empty Weight (inc. crew)</td>
|
||||
<td className="p-1 px-2">{WASMData.userData.isImperial ? '249537 lbs' : '113188 kg'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -84,7 +84,7 @@ const OptionsF: FC<OptionsFProps> = ({ WASMData, loadingState, gsxActive }) => {
|
||||
<td className="p-1 px-2">0 {WASMData.userData.isImperial ? 'lbs' : 'kg'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="p-1 px-2">Empty Weight</td>
|
||||
<td className="p-1 px-2">Empty Weight (inc. crew)</td>
|
||||
<td className="p-1 px-2">{WASMData.userData.isImperial ? '249137 lbs' : '113006 kg'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -2,8 +2,8 @@ import { FC, useEffect, useState } from 'react';
|
||||
import { LoadingState } from '../../types/general';
|
||||
import { WASMDataPax } from '../../types/WASMData';
|
||||
import { CoherentCallGSXReset, CoherentCallOptionsSet } from '../../utils/utils';
|
||||
import ToggleComponentKH from '../toggleComponent/ToggleComponent';
|
||||
import Input from '../input/Input';
|
||||
import ToggleComponentKH from '../toggleComponent/ToggleComponent';
|
||||
|
||||
interface OptionsPaxProps {
|
||||
WASMData: WASMDataPax;
|
||||
@@ -105,8 +105,8 @@ const OptionsPax: FC<OptionsPaxProps> = ({ WASMData, loadingState, gsxActive })
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="p-1 px-2">Empty Weight</td>
|
||||
<td className="p-1 px-2">{WASMData.userData.isImperial ? '284375 lbs' : '128991 kg'}</td>
|
||||
<td className="p-1 px-2">Empty Weight (inc. crew)</td>
|
||||
<td className="p-1 px-2">{WASMData.userData.isImperial ? '286465 lbs' : '129937 kg'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="p-1 px-2">Max Zero Fuel Weight</td>
|
||||
@@ -145,8 +145,8 @@ const OptionsPax: FC<OptionsPaxProps> = ({ WASMData, loadingState, gsxActive })
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="p-1 px-2">Empty Weight</td>
|
||||
<td className="p-1 px-2">{WASMData.userData.isImperial ? '283975 lbs' : '128809 kg'}</td>
|
||||
<td className="p-1 px-2">Empty Weight (inc. crew)</td>
|
||||
<td className="p-1 px-2">{WASMData.userData.isImperial ? '286065 lbs' : '129755 kg'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="p-1 px-2">Max Zero Fuel Weight</td>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { LoadingState } from '../../types/general';
|
||||
import { WASMDataF } from '../../types/WASMData';
|
||||
import { CoherentCallStationEntryF, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import { CoherentCallStationEntryF, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import ActionBar from '../actionbar/ActionBar';
|
||||
import Input from '../input/Input';
|
||||
|
||||
@@ -19,8 +19,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, gsxActiv
|
||||
const [upper4, setUpper4] = useState(WASMData.targetPayload.upper4);
|
||||
const [lowerForward, setLowerForward] = useState(WASMData.targetPayload.lowerForward);
|
||||
const [lowerRear, setLowerRear] = useState(WASMData.targetPayload.lowerRear);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.livePayload.fuel));
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.targetPayload.fuel));
|
||||
|
||||
const ZFW = () => {
|
||||
if (loadingState !== 'loaded' && !gsxActive) return Math.round(WASMData.targetPayload.total);
|
||||
@@ -52,10 +51,10 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, gsxActiv
|
||||
};
|
||||
|
||||
const updateData = () => {
|
||||
CoherentCallStationEntryF(upper1, upper2, upper3, upper4, lowerForward, lowerRear);
|
||||
CoherentCallStationEntryF(upper1, upper2, upper3, upper4, lowerForward, lowerRear, fuel);
|
||||
};
|
||||
|
||||
useEffect(() => updateData(), [upper1, upper2, upper3, upper4, lowerForward, lowerRear]);
|
||||
useEffect(() => updateData(), [upper1, upper2, upper3, upper4, lowerForward, lowerRear, fuel]);
|
||||
useEffect(
|
||||
() =>
|
||||
setFuel((prev) => {
|
||||
@@ -64,9 +63,6 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, gsxActiv
|
||||
}),
|
||||
[WASMData.userData.isER]
|
||||
);
|
||||
useEffect(() => {
|
||||
setFuelEnabled((prev) => (!prev ? inRangeOf(Math.round(WASMData.livePayload.fuel), fuel) : prev));
|
||||
}, [WASMData.livePayload.fuel]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -82,22 +78,6 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, gsxActiv
|
||||
onChange={(value) => handleInput(value, WASMData.limits.maxFuel, setFuel)}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
<button
|
||||
className="middle none center rounded-lg bg-green-600 px-6 py-3 font-sans text-xs font-bold uppercase text-white shadow-md shadow-green-500/20 transition-all hover:shadow-lg hover:shadow-green-500/40 focus:opacity-[0.85] focus:shadow-none active:opacity-[0.85] active:shadow-none disabled:pointer-events-none disabled:opacity-50 disabled:shadow-none"
|
||||
data-ripple-light="true"
|
||||
onClick={() => {
|
||||
SimVar.SetSimVarValue(
|
||||
'L:MD11_EFB_PAYLOAD_FUEL',
|
||||
'lbs',
|
||||
WASMData.userData.isImperial ? fuel : fuel * 2.20462262185
|
||||
);
|
||||
SimVar.SetSimVarValue('L:MD11_EFB_READ_READY', 'bool', true);
|
||||
setFuelEnabled(WASMData.livePayload.fuel === fuel);
|
||||
}}
|
||||
disabled={loadingState !== 'preview' || !fuelEnabled || gsxActive}
|
||||
>
|
||||
Load Fuel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { LoadingState } from '../../types/general';
|
||||
import { WASMDataPax } from '../../types/WASMData';
|
||||
import { CoherentCallStationEntryPax, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import { CoherentCallStationEntryPax, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import ActionBar from '../actionbar/ActionBar';
|
||||
import Input from '../input/Input';
|
||||
|
||||
@@ -20,7 +20,6 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, gsxAct
|
||||
const [forwardCargo, setForwardCargo] = useState(WASMData.targetPayload.forwardCargo);
|
||||
const [rearCargo, setRearCargo] = useState(WASMData.targetPayload.rearCargo);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.livePayload.fuel));
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
|
||||
const ZFW = () => {
|
||||
if (loadingState !== 'loaded' && !gsxActive) return Math.round(WASMData.targetPayload.total);
|
||||
@@ -52,10 +51,10 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, gsxAct
|
||||
};
|
||||
|
||||
const updateData = () => {
|
||||
CoherentCallStationEntryPax(business1, business2, economy1, economy2, forwardCargo, rearCargo);
|
||||
CoherentCallStationEntryPax(business1, business2, economy1, economy2, forwardCargo, rearCargo, fuel);
|
||||
};
|
||||
|
||||
useEffect(() => updateData(), [business1, business2, economy1, economy2, forwardCargo, rearCargo]);
|
||||
useEffect(() => updateData(), [business1, business2, economy1, economy2, forwardCargo, rearCargo, fuel]);
|
||||
useEffect(
|
||||
() =>
|
||||
setFuel((prev) => {
|
||||
@@ -64,9 +63,6 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, gsxAct
|
||||
}),
|
||||
[WASMData.userData.isER]
|
||||
);
|
||||
useEffect(() => {
|
||||
setFuelEnabled((prev) => (!prev ? inRangeOf(Math.round(WASMData.livePayload.fuel), fuel) : prev));
|
||||
}, [WASMData.livePayload.fuel]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -82,22 +78,6 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, gsxAct
|
||||
onChange={(value) => handleInput(value, WASMData.limits.maxFuel, setFuel)}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
<button
|
||||
className="middle none center rounded-lg bg-green-600 px-6 py-3 font-sans text-xs font-bold uppercase text-white shadow-md shadow-green-500/20 transition-all hover:shadow-lg hover:shadow-green-500/40 focus:opacity-[0.85] focus:shadow-none active:opacity-[0.85] active:shadow-none disabled:pointer-events-none disabled:opacity-50 disabled:shadow-none"
|
||||
data-ripple-light="true"
|
||||
onClick={() => {
|
||||
SimVar.SetSimVarValue(
|
||||
'L:MD11_EFB_PAYLOAD_FUEL',
|
||||
'lbs',
|
||||
WASMData.userData.isImperial ? fuel : fuel * 2.20462262185
|
||||
);
|
||||
SimVar.SetSimVarValue('L:MD11_EFB_READ_READY', 'bool', true);
|
||||
setFuelEnabled(WASMData.livePayload.fuel === fuel);
|
||||
}}
|
||||
disabled={loadingState !== 'preview' || !fuelEnabled || gsxActive}
|
||||
>
|
||||
Load Fuel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { WASMDataF } from '../../types/WASMData';
|
||||
import { LoadingState } from '../../types/general';
|
||||
import { CoherentCallZFWEntry, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import { CoherentCallZFWEntry, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import CGSelect from '../CGSelect/CGSelect';
|
||||
import ActionBar from '../actionbar/ActionBar';
|
||||
import Input from '../input/Input';
|
||||
@@ -15,9 +15,8 @@ interface ZFWEntryProps {
|
||||
|
||||
const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, setLoadingState }) => {
|
||||
const [CGTarget, setCGTarget] = useState(WASMData.targetPayload.CGTarget);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.livePayload.fuel));
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.targetPayload.fuel));
|
||||
const [ZFWTarget, setZFWTarget] = useState(Math.round(WASMData.targetPayload.total));
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
|
||||
const ZFW = () => {
|
||||
if (loadingState !== 'loaded' && !gsxActive) return ZFWTarget;
|
||||
@@ -55,12 +54,13 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
|
||||
|
||||
const converted = parseInt(input);
|
||||
if (converted) {
|
||||
if (converted < 0) setZFWTarget(Math.round(WASMData.targetPayload.empty + WASMData.targetPayload.crew));
|
||||
if (converted <= 0) setZFWTarget(Math.round(WASMData.targetPayload.empty + WASMData.targetPayload.crew));
|
||||
else if (converted > WASMData.limits.maxZFW) setZFWTarget(WASMData.limits.maxZFW);
|
||||
else setZFWTarget(converted);
|
||||
}
|
||||
};
|
||||
const handleBlur = (input: string) => {
|
||||
|
||||
const handleBlurZFW = (input: string) => {
|
||||
const minZFW = Math.round(WASMData.targetPayload.empty + WASMData.targetPayload.crew);
|
||||
|
||||
if (!input) {
|
||||
@@ -74,10 +74,13 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
|
||||
else if (converted > WASMData.limits.maxZFW) setZFWTarget(WASMData.limits.maxZFW);
|
||||
else setZFWTarget(converted);
|
||||
}
|
||||
|
||||
updateData(converted);
|
||||
};
|
||||
|
||||
const updateData = () => {
|
||||
CoherentCallZFWEntry(ZFWTarget, CGTarget, fuel);
|
||||
};
|
||||
|
||||
useEffect(() => updateData(), [ZFWTarget, CGTarget, fuel]);
|
||||
useEffect(
|
||||
() =>
|
||||
setFuel((prev) => {
|
||||
@@ -86,13 +89,6 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
|
||||
}),
|
||||
[WASMData.userData.isER]
|
||||
);
|
||||
useEffect(() => {
|
||||
setFuelEnabled((prev) => (!prev ? inRangeOf(Math.round(WASMData.livePayload.fuel), fuel) : prev));
|
||||
}, [WASMData.livePayload.fuel]);
|
||||
|
||||
const updateData = (_ZFWTarget?: number, _CGTarget?: number) => {
|
||||
CoherentCallZFWEntry(_ZFWTarget ?? ZFWTarget, _CGTarget ?? CGTarget);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -108,22 +104,6 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
|
||||
onChange={(value) => handleInput(value, WASMData.limits.maxFuel, setFuel)}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
<button
|
||||
className="middle none center rounded-lg bg-green-600 px-6 py-3 font-sans text-xs font-bold uppercase text-white shadow-md shadow-green-500/20 transition-all hover:shadow-lg hover:shadow-green-500/40 focus:opacity-[0.85] focus:shadow-none active:opacity-[0.85] active:shadow-none disabled:pointer-events-none disabled:opacity-50 disabled:shadow-none"
|
||||
data-ripple-light="true"
|
||||
onClick={() => {
|
||||
SimVar.SetSimVarValue(
|
||||
'L:MD11_EFB_PAYLOAD_FUEL',
|
||||
'lbs',
|
||||
WASMData.userData.isImperial ? fuel : fuel * 2.20462262185
|
||||
);
|
||||
SimVar.SetSimVarValue('L:MD11_EFB_READ_READY', 'bool', true);
|
||||
setFuelEnabled(WASMData.livePayload.fuel === fuel);
|
||||
}}
|
||||
disabled={loadingState !== 'preview' || !fuelEnabled || gsxActive}
|
||||
>
|
||||
Load Fuel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -138,7 +118,7 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={ZFWTarget}
|
||||
onChange={(value) => handleInputZFW(value)}
|
||||
onBlur={(value) => handleBlur(value)}
|
||||
onBlur={(value) => handleBlurZFW(value)}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
@@ -156,14 +136,12 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
|
||||
increase={() =>
|
||||
setCGTarget((prev) => {
|
||||
const _new = prev + 0.1;
|
||||
updateData(undefined, _new);
|
||||
return _new;
|
||||
})
|
||||
}
|
||||
decrease={() =>
|
||||
setCGTarget((prev) => {
|
||||
const _new = prev - 0.1;
|
||||
updateData(undefined, _new);
|
||||
return _new;
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { WASMDataPax } from '../../types/WASMData';
|
||||
import { LoadingState } from '../../types/general';
|
||||
import { CoherentCallZFWEntry, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import { CoherentCallZFWEntry, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import CGSelect from '../CGSelect/CGSelect';
|
||||
import ActionBar from '../actionbar/ActionBar';
|
||||
import Input from '../input/Input';
|
||||
@@ -15,9 +15,8 @@ interface ZFWEntryProps {
|
||||
|
||||
const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, setLoadingState }) => {
|
||||
const [CGTarget, setCGTarget] = useState(WASMData.targetPayload.CGTarget);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.livePayload.fuel));
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.targetPayload.fuel));
|
||||
const [ZFWTarget, setZFWTarget] = useState(Math.round(WASMData.targetPayload.total));
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
|
||||
const ZFW = () => {
|
||||
if (loadingState !== 'loaded' && !gsxActive) return ZFWTarget;
|
||||
@@ -60,7 +59,8 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, set
|
||||
else setZFWTarget(converted);
|
||||
}
|
||||
};
|
||||
const handleBlur = (input: string) => {
|
||||
|
||||
const handleBlurZFW = (input: string) => {
|
||||
const minZFW = Math.round(WASMData.targetPayload.empty + WASMData.targetPayload.crew);
|
||||
|
||||
if (!input) {
|
||||
@@ -74,10 +74,13 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, set
|
||||
else if (converted > WASMData.limits.maxZFW) setZFWTarget(WASMData.limits.maxZFW);
|
||||
else setZFWTarget(converted);
|
||||
}
|
||||
|
||||
updateData(converted);
|
||||
};
|
||||
|
||||
const updateData = () => {
|
||||
CoherentCallZFWEntry(ZFWTarget, CGTarget, fuel);
|
||||
};
|
||||
|
||||
useEffect(() => updateData(), [ZFWTarget, CGTarget, fuel]);
|
||||
useEffect(
|
||||
() =>
|
||||
setFuel((prev) => {
|
||||
@@ -86,13 +89,6 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, set
|
||||
}),
|
||||
[WASMData.userData.isER]
|
||||
);
|
||||
useEffect(() => {
|
||||
setFuelEnabled((prev) => (!prev ? inRangeOf(Math.round(WASMData.livePayload.fuel), fuel) : prev));
|
||||
}, [WASMData.livePayload.fuel]);
|
||||
|
||||
const updateData = (_ZFWTarget?: number, _CGTarget?: number) => {
|
||||
CoherentCallZFWEntry(_ZFWTarget ?? ZFWTarget, _CGTarget ?? CGTarget);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -108,22 +104,6 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, set
|
||||
onChange={(value) => handleInput(value, WASMData.limits.maxFuel, setFuel)}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
<button
|
||||
className="middle none center rounded-lg bg-green-600 px-6 py-3 font-sans text-xs font-bold uppercase text-white shadow-md shadow-green-500/20 transition-all hover:shadow-lg hover:shadow-green-500/40 focus:opacity-[0.85] focus:shadow-none active:opacity-[0.85] active:shadow-none disabled:pointer-events-none disabled:opacity-50 disabled:shadow-none"
|
||||
data-ripple-light="true"
|
||||
onClick={() => {
|
||||
SimVar.SetSimVarValue(
|
||||
'L:MD11_EFB_PAYLOAD_FUEL',
|
||||
'lbs',
|
||||
WASMData.userData.isImperial ? fuel : fuel * 2.20462262185
|
||||
);
|
||||
SimVar.SetSimVarValue('L:MD11_EFB_READ_READY', 'bool', true);
|
||||
setFuelEnabled(WASMData.livePayload.fuel === fuel);
|
||||
}}
|
||||
disabled={loadingState !== 'preview' || !fuelEnabled || gsxActive}
|
||||
>
|
||||
Load Fuel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -138,7 +118,7 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, set
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={ZFWTarget}
|
||||
onChange={(value) => handleInputZFW(value)}
|
||||
onBlur={(value) => handleBlur(value)}
|
||||
onBlur={(value) => handleBlurZFW(value)}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
@@ -156,14 +136,12 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, set
|
||||
increase={() =>
|
||||
setCGTarget((prev) => {
|
||||
const _new = prev + 0.1;
|
||||
updateData(undefined, _new);
|
||||
return _new;
|
||||
})
|
||||
}
|
||||
decrease={() =>
|
||||
setCGTarget((prev) => {
|
||||
const _new = prev - 0.1;
|
||||
updateData(undefined, _new);
|
||||
return _new;
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ interface WASMData {
|
||||
sbPlanned: {
|
||||
ZFW: number;
|
||||
GW: number;
|
||||
fuel: number;
|
||||
};
|
||||
loaded: boolean;
|
||||
}
|
||||
@@ -26,6 +27,7 @@ interface TargetPayload {
|
||||
ZFWCG: number;
|
||||
TOCG: number;
|
||||
total: number;
|
||||
fuel: number;
|
||||
}
|
||||
|
||||
interface TargetPayloadPax extends TargetPayload {
|
||||
@@ -39,9 +41,7 @@ interface TargetPayloadPax extends TargetPayload {
|
||||
rearCargo: number;
|
||||
}
|
||||
|
||||
interface LivePayloadPax extends TargetPayloadPax {
|
||||
fuel: number;
|
||||
}
|
||||
type LivePayloadPax = TargetPayloadPax;
|
||||
|
||||
interface TargetPayloadF extends TargetPayload {
|
||||
empty: number;
|
||||
@@ -54,9 +54,7 @@ interface TargetPayloadF extends TargetPayload {
|
||||
lowerRear: number;
|
||||
}
|
||||
|
||||
interface LivePayloadF extends TargetPayloadF {
|
||||
fuel: number;
|
||||
}
|
||||
type LivePayloadF = TargetPayloadF;
|
||||
|
||||
interface GSX {
|
||||
couatlStarted: boolean;
|
||||
|
||||
@@ -25,7 +25,7 @@ export const inRangeOf = (value: number, target: number, tolerance: number = 10)
|
||||
return Math.abs(value - target) < tolerance;
|
||||
};
|
||||
|
||||
export const CoherentCallZFWEntry = (ZFWTarget: number, CGTarget: number) => {
|
||||
export const CoherentCallZFWEntry = (ZFWTarget: number, CGTarget: number, fuelTarget: number) => {
|
||||
Coherent.call(
|
||||
COHERENT_COMM_BUS_WASM_CALL,
|
||||
CommBusEvent.UPDATE_TARGET,
|
||||
@@ -33,6 +33,7 @@ export const CoherentCallZFWEntry = (ZFWTarget: number, CGTarget: number) => {
|
||||
mode: CallMode.ZFW_SET,
|
||||
ZFWTarget: ZFWTarget,
|
||||
CGTarget: CGTarget,
|
||||
fuelTarget: fuelTarget,
|
||||
})
|
||||
);
|
||||
};
|
||||
@@ -43,7 +44,8 @@ export const CoherentCallStationEntryPax = (
|
||||
economy1: number,
|
||||
economy2: number,
|
||||
forwardCargo: number,
|
||||
rearCargo: number
|
||||
rearCargo: number,
|
||||
fuelTarget: number
|
||||
) => {
|
||||
Coherent.call(
|
||||
COHERENT_COMM_BUS_WASM_CALL,
|
||||
@@ -56,6 +58,7 @@ export const CoherentCallStationEntryPax = (
|
||||
economy2,
|
||||
forwardCargo,
|
||||
rearCargo,
|
||||
fuelTarget,
|
||||
})
|
||||
);
|
||||
};
|
||||
@@ -66,7 +69,8 @@ export const CoherentCallStationEntryF = (
|
||||
upper3: number,
|
||||
upper4: number,
|
||||
lowerForward: number,
|
||||
lowerRear: number
|
||||
lowerRear: number,
|
||||
fuelTarget: number
|
||||
) => {
|
||||
Coherent.call(
|
||||
COHERENT_COMM_BUS_WASM_CALL,
|
||||
@@ -79,11 +83,12 @@ export const CoherentCallStationEntryF = (
|
||||
upper4,
|
||||
lowerForward,
|
||||
lowerRear,
|
||||
fuelTarget,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
export const CoherentCallSBEntryPax = (CGTarget: number, SBPlan?: SimBrief) => {
|
||||
export const CoherentCallSBEntryPax = (CGTarget: number, fuel: number, SBPlan?: SimBrief) => {
|
||||
Coherent.call(
|
||||
COHERENT_COMM_BUS_WASM_CALL,
|
||||
CommBusEvent.UPDATE_TARGET,
|
||||
@@ -94,11 +99,12 @@ export const CoherentCallSBEntryPax = (CGTarget: number, SBPlan?: SimBrief) => {
|
||||
CGTarget: CGTarget,
|
||||
plannedZFW: SBPlan?.plannedZFW,
|
||||
plannedGW: SBPlan?.plannedGW,
|
||||
fuel: fuel,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
export const CoherentCallSBEntryF = (CGTarget: number, SBPlan?: SimBrief) => {
|
||||
export const CoherentCallSBEntryF = (CGTarget: number, fuel: number, SBPlan?: SimBrief) => {
|
||||
Coherent.call(
|
||||
COHERENT_COMM_BUS_WASM_CALL,
|
||||
CommBusEvent.UPDATE_TARGET,
|
||||
@@ -108,6 +114,7 @@ export const CoherentCallSBEntryF = (CGTarget: number, SBPlan?: SimBrief) => {
|
||||
CGTarget: CGTarget,
|
||||
plannedZFW: SBPlan?.plannedZFW,
|
||||
plannedGW: SBPlan?.plannedGW,
|
||||
fuel: SBPlan?.fuel,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user