comparison Discovery/Src/data_central.c @ 682:8775d3dc6325 Betatest

Bugfix low ppO2 warning in bailout mode: the code has different sources for divesettings (real and simulated). The ppo2 calculation code used the pointer to the real structure. As result in simulation mode an error occured caused by the ppo2 calculation which was not aware that a bailout happened (because the real structure was references instead of the simulator ones). The problem has been fixed by using the "stateUsed" pointer which is refering to the structure currenty in use.
author Ideenmodellierer
date Mon, 25 Apr 2022 21:15:01 +0200
parents 1b995079c045
children 6f5a18bb25be
comparison
equal deleted inserted replaced
681:7fa5ef6ae419 682:8775d3dc6325
410 410
411 411
412 412
413 void updateSetpointStateUsed(void) 413 void updateSetpointStateUsed(void)
414 { 414 {
415 if(!isLoopMode(stateReal.diveSettings.diveMode)) 415 if(!isLoopMode(stateUsed->diveSettings.diveMode))
416 { 416 {
417 stateUsedWrite->lifeData.actualGas.setPoint_cbar = 0; 417 stateUsedWrite->lifeData.actualGas.setPoint_cbar = 0;
418 stateUsedWrite->lifeData.ppO2 = decom_calc_ppO2(stateUsed->lifeData.pressure_ambient_bar, &stateUsed->lifeData.actualGas); 418 stateUsedWrite->lifeData.ppO2 = decom_calc_ppO2(stateUsed->lifeData.pressure_ambient_bar, &stateUsed->lifeData.actualGas);
419 } 419 }
420 else 420 else
496 lifeData->actualGas.GasIdInSettings = gasId; 496 lifeData->actualGas.GasIdInSettings = gasId;
497 lifeData->actualGas.nitrogen_percentage = nitrogen; 497 lifeData->actualGas.nitrogen_percentage = nitrogen;
498 lifeData->actualGas.helium_percentage = pSettings->gas[gasId].helium_percentage; 498 lifeData->actualGas.helium_percentage = pSettings->gas[gasId].helium_percentage;
499 lifeData->actualGas.setPoint_cbar = setpoint_cbar; 499 lifeData->actualGas.setPoint_cbar = setpoint_cbar;
500 lifeData->actualGas.change_during_ascent_depth_meter_otherwise_zero = 0; 500 lifeData->actualGas.change_during_ascent_depth_meter_otherwise_zero = 0;
501 lifeData->actualGas.AppliedDiveMode = pSettings->dive_mode; 501 lifeData->actualGas.AppliedDiveMode = stateUsed->diveSettings.diveMode;
502 lifeData->actualGas.pscr_factor = 1.0 / pSettings->pscr_lung_ratio * pSettings->pscr_o2_drop; 502 lifeData->actualGas.pscr_factor = 1.0 / pSettings->pscr_lung_ratio * pSettings->pscr_o2_drop;
503 if(isLoopMode(pSettings->dive_mode) && (gasId > NUM_OFFSET_DILUENT)) 503 if(isLoopMode(pSettings->dive_mode) && (gasId > NUM_OFFSET_DILUENT))
504 lifeData->lastDiluent_GasIdInSettings = gasId; 504 lifeData->lastDiluent_GasIdInSettings = gasId;
505 } 505 }
506 506