diff --git a/README.md b/README.md index add52f4..ad534ac 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ c182rg-improvement-project/ * pilot, copilot and baggage doors * pilot and copilot windows * static elements (e.g. rain cover) + * payload weights (pilots, passengers and baggage) # Planned features Planned features can be found by looking at the diff --git a/c182rg-improvement-project/html_ui/Pages/VCockpit/Instruments/AlexChesters/StateSaving/AC182RG.ts b/c182rg-improvement-project/html_ui/Pages/VCockpit/Instruments/AlexChesters/StateSaving/AC182RG.ts index 785efa7..ba41e0a 100644 --- a/c182rg-improvement-project/html_ui/Pages/VCockpit/Instruments/AlexChesters/StateSaving/AC182RG.ts +++ b/c182rg-improvement-project/html_ui/Pages/VCockpit/Instruments/AlexChesters/StateSaving/AC182RG.ts @@ -11,6 +11,13 @@ type AC182RGPersistentStorageIds = { leftTankVolume: string, rightTankVolume: string }, + payload: { + pilot: string, + copilot: string, + backPaxLeft: string, + backPaxRight: string, + baggage: string + }, switchPanel: { masterBattery: string, alternator: string, @@ -70,6 +77,13 @@ class AC182RG extends BaseInstrument { leftTankVolume: `AC182RG_LEFT_FUEL_TANK_${this.aircraftIdentifier}`, rightTankVolume: `AC182RG_RIGHT_FUEL_TANK_${this.aircraftIdentifier}` }, + payload: { + pilot: `AC182RG_PAYLOAD_PILOT_${this.aircraftIdentifier}`, + copilot: `AC182RG_PAYLOAD_COPILOT_${this.aircraftIdentifier}`, + backPaxLeft: `AC182RG_PAYLOAD_BACKPAXLEFT_${this.aircraftIdentifier}`, + backPaxRight: `AC182RG_PAYLOAD_BACKPAXRIGHT_${this.aircraftIdentifier}`, + baggage: `AC182RG_PAYLOAD_BAGGAGE_${this.aircraftIdentifier}` + }, switchPanel: { masterBattery: `AC182RG_MASTER_BATTERY_${this.aircraftIdentifier}`, alternator: `AC182RG_ALTERNATOR_${this.aircraftIdentifier}`, @@ -131,6 +145,26 @@ class AC182RG extends BaseInstrument { SetStoredData(this.storageIds.fuel.leftTankVolume, leftTankVolume.toString()) SetStoredData(this.storageIds.fuel.rightTankVolume, rightTankVolume.toString()) } + + persistPayloadState() { + var pilotWeight = SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:1', 'kilograms') + var copilotWeight = SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:2', 'kilograms') + var backPaxLeftWeight = SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:3', 'kilograms') + var backPaxRightWeight = SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:4', 'kilograms') + var baggageWeight = SimVar.GetSimVarValue('PAYLOAD STATION WEIGHT:5', 'kilograms') + + logger.debug('persisting pilot weight (kgs)', pilotWeight) + logger.debug('persisting copilot weight (kgs)', copilotWeight) + logger.debug('persisting back pax left weight (kgs)', backPaxLeftWeight) + logger.debug('persisting back pax right weight (kgs)', backPaxRightWeight) + logger.debug('persisting baggage weight (kgs)', baggageWeight) + + SetStoredData(this.storageIds.payload.pilot, pilotWeight.toString()) + SetStoredData(this.storageIds.payload.copilot, copilotWeight.toString()) + SetStoredData(this.storageIds.payload.backPaxLeft, backPaxLeftWeight.toString()) + SetStoredData(this.storageIds.payload.backPaxRight, backPaxRightWeight.toString()) + SetStoredData(this.storageIds.payload.baggage, baggageWeight.toString()) + } persistSwitchPanelState() { var masterBattery = SimVar.GetSimVarValue('ELECTRICAL MASTER BATTERY:1', 'bool') @@ -246,6 +280,7 @@ class AC182RG extends BaseInstrument { persistState() { try { this.persistFuelState() + this.persistPayloadState() this.persistSwitchPanelState() this.persistInstrumentsState() this.persistControlSurfaces() @@ -268,6 +303,26 @@ class AC182RG extends BaseInstrument { SimVar.SetSimVarValue('FUEL TANK RIGHT MAIN QUANTITY', 'gallons', Number(rightTankStoredVolume || 10)) } + applyPayloadState() { + var pilotWeight = GetStoredData(this.storageIds.payload.pilot) + var copilotWeight = GetStoredData(this.storageIds.payload.copilot) + var backPaxLeftWeight = GetStoredData(this.storageIds.payload.backPaxLeft) + var backPaxRightWeight = GetStoredData(this.storageIds.payload.backPaxRight) + var baggageWeight = GetStoredData(this.storageIds.payload.baggage) + + logger.log('applying pilot weight (kgs) state', pilotWeight) + logger.log('applying copilot weight (kgs) state', copilotWeight) + logger.log('applying back pax left weight (kgs) state', backPaxLeftWeight) + logger.log('applying back pax right weight (kgs) state', backPaxRightWeight) + logger.log('applying baggage weight (kgs) state', baggageWeight) + + SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:1', 'kilograms', Number(pilotWeight || 77)) + SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:2', 'kilograms', Number(copilotWeight || 77)) + SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:3', 'kilograms', Number(backPaxLeftWeight || 0)) + SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:4', 'kilograms', Number(backPaxRightWeight || 0)) + SimVar.SetSimVarValue('PAYLOAD STATION WEIGHT:5', 'kilograms', Number(baggageWeight || 8)) + } + applySwitchPanelState() { var masterBattery = GetStoredData(this.storageIds.switchPanel.masterBattery) var alternator = GetStoredData(this.storageIds.switchPanel.alternator) @@ -419,6 +474,7 @@ class AC182RG extends BaseInstrument { applyState() { try { this.applyFuelState() + this.applyPayloadState() this.applySwitchPanelState() this.applyInstrumentState() this.applyControlSurfacesState()