Skip to content

Commit

Permalink
fix: pushback did not pause when leaving flyPad Pushback page #7645 @…
Browse files Browse the repository at this point in the history
…ac5bef4
  • Loading branch information
Saschl authored and beheh committed Dec 22, 2022
1 parent 37c62f1 commit a5c4627
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 29 deletions.
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
1. [HYD] Simple temperature simulation - @Crocket63 (crocket)
1. [FLIGHTMODEL] Reduced flap induced drag - @donstim (donbikes#4084)
1. [RMP] RMPs navigation backup - Julian Sebline (Julian Sebline#8476 on Discord)
1. [EFB] Fix and improve pushback system and add API documentation - @frankkopp (Frank Kopp)

## 0.9.0

Expand Down
26 changes: 26 additions & 0 deletions docs/a320-simvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [Landing Gear (ATA 32)](#landing-gear-ata-32)
- [ATC (ATA 34)](#atc-ata-34)
- [Radio Altimeter (ATA 34)](#radio-altimeter-ata-34)
- [Electronic Flight Bag ATA 46](#electronic-flight-bag--ata-46-)

## Uncategorized

Expand Down Expand Up @@ -3498,3 +3499,28 @@ In the variables below, {number} should be replaced with one item in the set: {
- {number}
- 0
- 1

## Electronic Flight Bag (ATA 46)

- A32NX_PUSHBACK_SYSTEM_ENABLED
- Boolean
- Read/Write
- Whether the pushback system is enabled
- Further conditions are "Pushback Tug Attached" and "Aircraft On Ground" otherwise the system
has no impact on the aircraft

- A32NX_PUSHBACK_SPD_FACTOR
- Number
- Read/Write
- Determines the speed of the pushback tug from -100% to 100%
- {number}
- -1.0
- 1.0

- A32NX_PUSHBACK_HDG_FACTOR
- Number
- Read/Write
- Determines the heading of the pushback tug from max left (-1.0) to right (1.0)
- {number}
- -1.0
- 1.0
6 changes: 3 additions & 3 deletions src/flypad-backend/src/Pushback/Pushback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ void Pushback::onUpdate(double deltaTime) {

// As we might use the elevator for taxiing we compensate for wind to avoid
// the aircraft lifting any gears.
const FLOAT64 windCounterRotAccel = getWindVelBodyZ() / 1000.0;
const FLOAT64 windCounterRotAccel = getWindVelBodyZ() / 2000.0;
FLOAT64 movementCounterRotAccel = windCounterRotAccel;
if (inertiaSpeed > 0) {
movementCounterRotAccel -= 1.1;
movementCounterRotAccel -= 0.5;
}
else if (inertiaSpeed < 0) {
movementCounterRotAccel += 2.0;
movementCounterRotAccel += 1.0;
}
else {
movementCounterRotAccel = 0.0;
Expand Down
36 changes: 11 additions & 25 deletions src/instruments/src/EFB/Ground/Pages/PushbackPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const PushbackPage = () => {
const [parkingBrakeEngaged, setParkingBrakeEngaged] = useSimVar('L:A32NX_PARK_BRAKE_LEVER_POS', 'Bool', 250);
const [nwStrgDisc] = useSimVar('L:A32NX_HYD_NW_STRG_DISC_ECAM_MEMO', 'Bool', 250);

const [pushbackPaused, setPushbackPaused] = useSimVar('L:A32NX_PUSHBACK_PAUSED', 'bool', 250);
const [tugCmdHdgFactor, setCmdHdgFactor] = useSimVar('L:A32NX_PUSHBACK_HDG_FACTOR', 'number', 100);
const [tugCmdSpdFactor, setCmdSpdFactor] = useSimVar('L:A32NX_PUSHBACK_SPD_FACTOR', 'number', 100);

Expand All @@ -70,8 +69,6 @@ export const PushbackPage = () => {
// Required so these can be used inside the useEffect return callback
const pushBackAttachedRef = useRef(pushbackAttached);
pushBackAttachedRef.current = pushbackAttached;
const pushbackPausedRef = useRef(pushbackPaused);
pushbackPausedRef.current = pushbackPaused;

const pushbackUIAvailable: boolean = simOnGround;
const tugInTransit: boolean = pushbackAttached !== nwStrgDisc;
Expand Down Expand Up @@ -129,19 +126,13 @@ export const PushbackPage = () => {
callTug();
};

const handlePause = () => {
if (!pushbackPaused) {
setCmdHdgFactor(0);
setCmdSpdFactor(0);
}
setPushbackPaused(!pushbackPaused);
const stopMovement = () => {
setCmdHdgFactor(0);
setCmdSpdFactor(0);
};

const handleTugSpeed = (speed: number) => {
setCmdSpdFactor(MathUtils.clamp(speed, -1, 1));
if (speed) {
setPushbackPaused(false);
}
};

const handleTugDirectionLeft = () => {
Expand All @@ -159,18 +150,18 @@ export const PushbackPage = () => {
// called once when loading and unloading the page
useEffect(() => {
// when loading the page
setPushbackPaused(true);
stopMovement();

// when unloading the page
// !obs: as with setInterval no access to current local variable values
return (() => {
if (pushBackAttachedRef.current && !pushbackPausedRef.current) {
if (pushBackAttachedRef.current) {
toast.info(t('Pushback.LeavePageMessage'), {
autoClose: 750,
hideProgressBar: true,
closeButton: false,
});
setPushbackPaused(() => true);
stopMovement();
}
});
}, []);
Expand Down Expand Up @@ -198,7 +189,6 @@ export const PushbackPage = () => {
setCmdSpdFactor(0);
return;
}
setPushbackPaused(false);
setCmdSpdFactor(-elevatorPosition);
}, [elevatorPosition]);

Expand All @@ -221,10 +211,6 @@ export const PushbackPage = () => {
{' '}
{updateDeltaTime.toFixed(4)}
<br />
pushbackPaused:
{' '}
{pushbackPaused ? 1 : 0}
<br />
pushBackWait:
{' '}
{pushbackWait}
Expand Down Expand Up @@ -522,18 +508,18 @@ export const PushbackPage = () => {
{/* Pause/Moving Button */}
<div className="w-full">
<p className="text-center">
{pushbackPaused ? t('Pushback.Halt') : t('Pushback.Moving')}
{tugCmdSpdFactor !== 0 ? t('Pushback.Moving') : t('Pushback.Halt')}
</p>
<TooltipWrapper text={t('Pushback.TT.PausePushback')}>
<button
type="button"
onClick={handlePause}
onClick={stopMovement}
className="flex justify-center items-center w-full h-20 hover:text-theme-highlight bg-theme-highlight hover:bg-theme-body rounded-md border-2 border-theme-highlight transition duration-100"
>
{pushbackPaused ? (
<PlayCircleFill size={40} />
) : (
{tugCmdSpdFactor !== 0 ? (
<PauseCircleFill size={40} />
) : (
<PlayCircleFill size={40} />
)}
</button>
</TooltipWrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/instruments/src/EFB/UtilComponents/BingMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const BingMap: React.FC<BingMapProps> = ({ configFolder, mapId, range = D
const svgMapConfig = new SvgMapConfig();

svgMapConfig.load(configFolder, () => {
console.log(`[ReactBingMap (${mapId})] NetBingMap config loaded`);
// console.log(`[ReactBingMap (${mapId})] NetBingMap config loaded`);
if (!mapRef.current) return;

svgMapConfig.generateBingMap(mapRef.current);
Expand Down

0 comments on commit a5c4627

Please sign in to comment.