mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Use state structure for sample rate info
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
This commit is contained in:
parent
5ae54f481c
commit
fd5aad7192
3 changed files with 8 additions and 8 deletions
|
@ -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";
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue