81
81
#define M_OC_REC 6
82
82
#define M_FREEDIVE 7
83
83
84
+ #define SM_3_GAS_NX 0
85
+ #define SM_AIR 1
86
+ #define SM_NX 2
87
+ #define SM_OC_REC 3
88
+
84
89
#define AI_OFF 0
85
90
#define AI_HPCCR 4
86
91
#define AI_ON 5
@@ -428,12 +433,12 @@ static void print_calibration(shearwater_predator_parser_t *parser)
428
433
{
429
434
for (size_t i = 0 ; i < 3 ; ++ i ) {
430
435
if (parser -> calibrated & (1 << i )) {
431
- static const char * name [] = {
436
+ static const char * names [] = {
432
437
"Sensor 1 calibration [bar / V]" ,
433
438
"Sensor 2 calibration [bar / V]" ,
434
439
"Sensor 3 calibration [bar / V]" ,
435
440
};
436
- dc_field_add_string_fmt (& parser -> cache , name [i ], "%.2f" , parser -> calibration [i ] * 1000 );
441
+ dc_field_add_string_fmt (& parser -> cache , names [i ], "%.2f" , parser -> calibration [i ] * 1000 );
437
442
}
438
443
}
439
444
}
@@ -522,6 +527,7 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
522
527
523
528
unsigned int offset = headersize ;
524
529
unsigned int length = size - footersize ;
530
+ unsigned int sub_mode = SM_OC_REC ;
525
531
unsigned int stack_time_total_s = 0 ;
526
532
unsigned int stack_time_remaining_s ;
527
533
while (offset + parser -> samplesize <= length ) {
@@ -718,6 +724,11 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
718
724
dc_field_add_string_fmt (& parser -> cache , "Remaining stack time at start [hh:mm:ss]" , "%d:%02d:%02d" , stack_time_remaining_s / 3600 , (stack_time_remaining_s / 60 ) % 60 , stack_time_remaining_s % 60 );
719
725
}
720
726
}
727
+ if (logversion >= 12 ) {
728
+ if (divemode == M_OC_REC ) {
729
+ sub_mode = data [offset + 5 ];
730
+ }
731
+ }
721
732
if (logversion >= 13 ) {
722
733
tank [0 ].enabled = data [offset + 19 ];
723
734
memcpy (tank [0 ].name , data + offset + 20 , sizeof (tank [0 ].name ));
@@ -904,14 +915,13 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
904
915
break ;
905
916
}
906
917
907
- dc_status_t rc = DC_STATUS_SUCCESS ;
908
918
if (parser -> needs_divecan_calibration_estimate ) {
909
919
struct dc_parser_sensor_calibration_t data = { 0 };
910
920
911
- rc = shearwater_predator_parser_samples_foreach (abstract , NULL , (void * )& data );
921
+ dc_status_t rc = shearwater_predator_parser_samples_foreach (abstract , NULL , (void * )& data );
912
922
913
923
bool calibrated = false;
914
- if (data .sum_ppo2 != 0 ) {
924
+ if (rc == DC_STATUS_SUCCESS && data .sum_ppo2 != 0 ) {
915
925
double calibration = data .sum_calculated_ppo2 / data .sum_ppo2 ;
916
926
if (calibration < 0.98 || calibration > 1.02 ) {
917
927
// The calibration scaling is significant, use it.
@@ -933,6 +943,29 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
933
943
parser -> needs_divecan_calibration_estimate = false;
934
944
}
935
945
946
+ static const char * name = "Divemode" ;
947
+ if (divemode == M_OC_REC ) {
948
+ static const char * oc_rec_modes [] = {
949
+ "3 Gas Nitrox" ,
950
+ "Air" ,
951
+ "Nitrox" ,
952
+ "OC Recreational" ,
953
+ };
954
+ dc_field_add_string_fmt (& parser -> cache , name , "%s" , sub_mode <= SM_OC_REC ? oc_rec_modes [sub_mode ] : "Unknown divemode" );
955
+ } else {
956
+ static const char * modes [] = {
957
+ "CC / BO" ,
958
+ "OC Technical" ,
959
+ "Gauge" ,
960
+ "PPO2 Display" ,
961
+ "SC / BO" ,
962
+ "CC / BO 2" ,
963
+ "OC Recreational" ,
964
+ "Freedive" ,
965
+ };
966
+ dc_field_add_string_fmt (& parser -> cache , name , "%s" , divemode <= M_FREEDIVE ? modes [divemode ] : "Unknown divemode" );
967
+ }
968
+
936
969
return DC_STATUS_SUCCESS ;
937
970
}
938
971
0 commit comments