comparison Discovery/Src/data_exchange_main.c @ 288:ba229a012ac7 div-fixes-6

cleanup: no useless checks for simulator state and some more in the style of commit 74a8296a2318. And in addition more cleanup like removing commented and unused code, and making things static. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Mon, 29 Apr 2019 19:43:05 +0200
parents cc30d1aa03a7
children 2f43419102c8
comparison
equal deleted inserted replaced
287:ba9d99a2e310 288:ba229a012ac7
420 } 420 }
421 421
422 422
423 void DataEX_copy_to_deco(void) 423 void DataEX_copy_to_deco(void)
424 { 424 {
425 SDiveState * pStateUsed;
426 if(decoLock == DECO_CALC_running) 425 if(decoLock == DECO_CALC_running)
427 return; 426 return;
428 if(stateUsed == stateRealGetPointer())
429 pStateUsed = stateRealGetPointerWrite();
430 else{
431 pStateUsed = stateSimGetPointerWrite();
432 }
433 427
434 if(decoLock == DECO_CALC_init_as_is_start_of_dive) 428 if(decoLock == DECO_CALC_init_as_is_start_of_dive)
435 { 429 {
436 vpm_init(&pStateUsed->vpm, pStateUsed->diveSettings.vpm_conservatism, 0, 0); 430 vpm_init(&stateUsedWrite->vpm, stateUsedWrite->diveSettings.vpm_conservatism, 0, 0);
437 buehlmann_init(); 431 buehlmann_init();
438 timer_init(); 432 timer_init();
439 resetEvents(pStateUsed); 433 resetEvents(stateUsedWrite);
440 pStateUsed->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0; 434 stateUsedWrite->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0;
441 /*
442 * ToDo by Peter
443 * copy VPM stuff etc. pp.
444 * was void initDiveState(SDiveSettings * pDiveSettings, SVpm * pVpm);
445 */
446 } 435 }
447 436
448 if(decoLock == DECO_CALC_FINSHED_Buehlmann) 437 if(decoLock == DECO_CALC_FINSHED_Buehlmann)
449 { 438 {
450 439
452 switch(decoLock) 441 switch(decoLock)
453 { 442 {
454 443
455 //Deco_calculation finished 444 //Deco_calculation finished
456 case DECO_CALC_FINSHED_vpm: 445 case DECO_CALC_FINSHED_vpm:
457 memcpy(&pStateUsed->decolistVPM,&stateDeco.decolistVPM,sizeof(SDecoinfo)); 446 memcpy(&stateUsedWrite->decolistVPM,&stateDeco.decolistVPM,sizeof(SDecoinfo));
458 pStateUsed->decolistVPM.tickstamp = HAL_GetTick(); 447 stateUsedWrite->decolistVPM.tickstamp = HAL_GetTick();
459 pStateUsed->vpm.deco_zone_reached = stateDeco.vpm.deco_zone_reached; 448 stateUsedWrite->vpm.deco_zone_reached = stateDeco.vpm.deco_zone_reached;
460 for(int i = 0; i< 16; i++) 449 for(int i = 0; i< 16; i++)
461 { 450 {
462 pStateUsed->vpm.adjusted_critical_radius_he[i] = stateDeco.vpm.adjusted_critical_radius_he[i]; 451 stateUsedWrite->vpm.adjusted_critical_radius_he[i] = stateDeco.vpm.adjusted_critical_radius_he[i];
463 pStateUsed->vpm.adjusted_critical_radius_n2[i] = stateDeco.vpm.adjusted_critical_radius_n2[i]; 452 stateUsedWrite->vpm.adjusted_critical_radius_n2[i] = stateDeco.vpm.adjusted_critical_radius_n2[i];
464 pStateUsed->vpm.adjusted_crushing_pressure_he[i] = stateDeco.vpm.adjusted_crushing_pressure_he[i]; 453 stateUsedWrite->vpm.adjusted_crushing_pressure_he[i] = stateDeco.vpm.adjusted_crushing_pressure_he[i];
465 pStateUsed->vpm.adjusted_crushing_pressure_n2[i] = stateDeco.vpm.adjusted_crushing_pressure_n2[i]; 454 stateUsedWrite->vpm.adjusted_crushing_pressure_n2[i] = stateDeco.vpm.adjusted_crushing_pressure_n2[i];
466 pStateUsed->vpm.initial_allowable_gradient_he[i] = stateDeco.vpm.initial_allowable_gradient_he[i]; 455 stateUsedWrite->vpm.initial_allowable_gradient_he[i] = stateDeco.vpm.initial_allowable_gradient_he[i];
467 pStateUsed->vpm.initial_allowable_gradient_n2[i] = stateDeco.vpm.initial_allowable_gradient_n2[i]; 456 stateUsedWrite->vpm.initial_allowable_gradient_n2[i] = stateDeco.vpm.initial_allowable_gradient_n2[i];
468 pStateUsed->vpm.max_actual_gradient[i] = stateDeco.vpm.max_actual_gradient[i]; 457 stateUsedWrite->vpm.max_actual_gradient[i] = stateDeco.vpm.max_actual_gradient[i];
469 } 458 }
470 break; 459 break;
471 case DECO_CALC_FINSHED_Buehlmann: 460 case DECO_CALC_FINSHED_Buehlmann:
472 memcpy(&pStateUsed->decolistBuehlmann,&stateDeco.decolistBuehlmann,sizeof(SDecoinfo)); 461 memcpy(&stateUsedWrite->decolistBuehlmann,&stateDeco.decolistBuehlmann,sizeof(SDecoinfo));
473 pStateUsed->decolistBuehlmann.tickstamp = HAL_GetTick(); 462 stateUsedWrite->decolistBuehlmann.tickstamp = HAL_GetTick();
474 //Copy Data to be stored if regular Buehlmann, not FutureBuehlmann 463 //Copy Data to be stored if regular Buehlmann, not FutureBuehlmann
475 pStateUsed->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = stateDeco.diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero; 464 stateUsedWrite->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = stateDeco.diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero;
476 break; 465 break;
477 case DECO_CALC_FINSHED_FutureBuehlmann: 466 case DECO_CALC_FINSHED_FutureBuehlmann:
478 memcpy(&pStateUsed->decolistFutureBuehlmann,&stateDeco.decolistFutureBuehlmann,sizeof(SDecoinfo)); 467 memcpy(&stateUsedWrite->decolistFutureBuehlmann,&stateDeco.decolistFutureBuehlmann,sizeof(SDecoinfo));
479 pStateUsed->decolistFutureBuehlmann.tickstamp = HAL_GetTick(); 468 stateUsedWrite->decolistFutureBuehlmann.tickstamp = HAL_GetTick();
480 break; 469 break;
481 case DECO_CALC_FINSHED_Futurevpm: 470 case DECO_CALC_FINSHED_Futurevpm:
482 memcpy(&pStateUsed->decolistFutureVPM,&stateDeco.decolistFutureVPM,sizeof(SDecoinfo)); 471 memcpy(&stateUsedWrite->decolistFutureVPM,&stateDeco.decolistFutureVPM,sizeof(SDecoinfo));
483 pStateUsed->decolistFutureVPM.tickstamp = HAL_GetTick(); 472 stateUsedWrite->decolistFutureVPM.tickstamp = HAL_GetTick();
484 break; 473 break;
485 } 474 }
486 475
487 //Copy Inputdata from stateReal to stateDeco 476 //Copy Inputdata from stateReal to stateDeco
488 memcpy(&stateDeco.lifeData,&pStateUsed->lifeData,sizeof(SLifeData)); 477 memcpy(&stateDeco.lifeData,&stateUsedWrite->lifeData,sizeof(SLifeData));
489 memcpy(&stateDeco.diveSettings,&pStateUsed->diveSettings,sizeof(SDiveSettings)); 478 memcpy(&stateDeco.diveSettings,&stateUsedWrite->diveSettings,sizeof(SDiveSettings));
490 479
491 stateDeco.vpm.deco_zone_reached = pStateUsed->vpm.deco_zone_reached; 480 stateDeco.vpm.deco_zone_reached = stateUsedWrite->vpm.deco_zone_reached;
492 // memcpy(&stateDeco.vpm,&pStateUsed->vpm,sizeof(SVpm)); 481 // memcpy(&stateDeco.vpm,&pStateUsed->vpm,sizeof(SVpm));
493 for(int i = 0; i< 16; i++) 482 for(int i = 0; i< 16; i++)
494 { 483 {
495 stateDeco.vpm.max_crushing_pressure_he[i] = pStateUsed->vpm.max_crushing_pressure_he[i]; 484 stateDeco.vpm.max_crushing_pressure_he[i] = stateUsedWrite->vpm.max_crushing_pressure_he[i];
496 stateDeco.vpm.max_crushing_pressure_n2[i] = pStateUsed->vpm.max_crushing_pressure_n2[i]; 485 stateDeco.vpm.max_crushing_pressure_n2[i] = stateUsedWrite->vpm.max_crushing_pressure_n2[i];
497 stateDeco.vpm.adjusted_critical_radius_he[i] = pStateUsed->vpm.adjusted_critical_radius_he[i]; 486 stateDeco.vpm.adjusted_critical_radius_he[i] = stateUsedWrite->vpm.adjusted_critical_radius_he[i];
498 stateDeco.vpm.adjusted_critical_radius_n2[i] = pStateUsed->vpm.adjusted_critical_radius_n2[i]; 487 stateDeco.vpm.adjusted_critical_radius_n2[i] = stateUsedWrite->vpm.adjusted_critical_radius_n2[i];
499 } 488 }
500 decoLock = DECO_CALC_ready; 489 decoLock = DECO_CALC_ready;
501 } 490 }
502 491
503 492