diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2019-01-03 06:56:48 +0200 |
---|---|---|
committer | Miika Turkia <miika.turkia@gmail.com> | 2019-01-03 06:56:48 +0200 |
commit | fd5aad719208f35252bacc9a7a46c829fc631923 (patch) | |
tree | b9134cfc1c10de77344532fbdb3c79b3db4050d8 | |
parent | 5ae54f481c6c1f3ed73c9661ef9d27050ec9b350 (diff) | |
download | subsurface-fd5aad719208f35252bacc9a7a46c829fc631923.tar.gz |
Use state structure for sample rate info
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
-rw-r--r-- | core/import-shearwater.c | 14 | ||||
-rw-r--r-- | core/parse.c | 1 | ||||
-rw-r--r-- | core/parse.h | 1 |
3 files changed, 8 insertions, 8 deletions
diff --git a/core/import-shearwater.c b/core/import-shearwater.c index 1a96c3e64..451b04fe5 100644 --- a/core/import-shearwater.c +++ b/core/import-shearwater.c @@ -13,8 +13,6 @@ #include "membuffer.h" #include "gettext.h" -static int sample_rate = 0; - static int shearwater_cylinders(void *param, int columns, char **data, char **column) { UNUSED(columns); @@ -75,7 +73,7 @@ static int shearwater_changes(void *param, int columns, char **data, char **colu i = state->cur_cylinder_index; } - add_gas_switch_event(state->cur_dive, get_dc(state), sample_rate ? atoi(data[0]) / sample_rate * 10 : atoi(data[0]), i); + add_gas_switch_event(state->cur_dive, get_dc(state), state->sample_rate ? atoi(data[0]) / state->sample_rate * 10 : atoi(data[0]), i); return 0; } @@ -88,7 +86,7 @@ static int shearwater_profile_sample(void *param, int columns, char **data, char sample_start(state); if (data[0]) - state->cur_sample->time.seconds = sample_rate ? atoi(data[0]) / sample_rate * 10 : atoi(data[0]); + state->cur_sample->time.seconds = state->sample_rate ? atoi(data[0]) / state->sample_rate * 10 : atoi(data[0]); if (data[1]) state->cur_sample->depth.mm = state->metric ? lrint(strtod_flags(data[1], NULL, 0) * 1000) : feet_to_mm(strtod_flags(data[1], NULL, 0)); if (data[2]) @@ -139,7 +137,7 @@ static int shearwater_ai_profile_sample(void *param, int columns, char **data, c sample_start(state); if (data[0]) - state->cur_sample->time.seconds = sample_rate ? atoi(data[0]) / sample_rate * 10 : atoi(data[0]); + state->cur_sample->time.seconds = state->sample_rate ? atoi(data[0]) / state->sample_rate * 10 : atoi(data[0]); if (data[1]) state->cur_sample->depth.mm = state->metric ? lrint(strtod_flags(data[1], NULL, 0) * 1000) : feet_to_mm(strtod_flags(data[1], NULL, 0)); if (data[2]) @@ -338,9 +336,9 @@ static int shearwater_cloud_dive(void *param, int columns, char **data, char **c long int dive_id = atol(data[11]); if (data[12]) - sample_rate = atoi(data[12]); + state->sample_rate = atoi(data[12]); else - sample_rate = 0; + state->sample_rate = 0; if (data[2]) add_dive_site(data[2], state->cur_dive, state); @@ -454,7 +452,7 @@ int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer state.sql_handle = handle; // So far have not seen any sample rate in Shearwater Desktop - sample_rate = 0; + state.sample_rate = 0; char get_dives[] = "select l.number,timestamp,location||' / '||site,buddy,notes,imperialUnits,maxDepth,maxTime,startSurfacePressure,computerSerial,computerModel,i.diveId FROM dive_info AS i JOIN dive_logs AS l ON i.diveId=l.diveId"; diff --git a/core/parse.c b/core/parse.c index 8683daed4..2a408b57c 100644 --- a/core/parse.c +++ b/core/parse.c @@ -21,6 +21,7 @@ void init_parser_state(struct parser_state *state) memset(state, 0, sizeof(*state)); state->metric = true; state->cur_event.deleted = 1; + state->sample_rate = 0; } void free_parser_state(struct parser_state *state) diff --git a/core/parse.h b/core/parse.h index d56609e79..31f549e20 100644 --- a/core/parse.h +++ b/core/parse.h @@ -55,6 +55,7 @@ struct parser_state { int cur_cylinder_index, cur_ws_index; int lastcylinderindex, next_o2_sensor; int o2pressure_sensor; + int sample_rate; struct extra_data cur_extra_data; struct units xml_parsing_units; struct dive_table *target_table; /* non-owning */ |