Remove the clock parameters from the constructor
Only a few dive computer backends (reefnet, aladin and memomouse) require the clock parameters for parsing the date/time. Therefore, those parameters are removed from the constructor function and applications should set the clock parameters with the dc_parser_set_clock() function instead.
This commit is contained in:
parent
0a4f37770f
commit
679db0bae6
@ -39,8 +39,6 @@
|
|||||||
.Fa "dc_parser_t **parser"
|
.Fa "dc_parser_t **parser"
|
||||||
.Fa "dc_context_t *context"
|
.Fa "dc_context_t *context"
|
||||||
.Fa "dc_descriptor_t *descriptor"
|
.Fa "dc_descriptor_t *descriptor"
|
||||||
.Fa "unsigned int devtime"
|
|
||||||
.Fa "dc_ticks_t systime"
|
|
||||||
.Fc
|
.Fc
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
Creates a parser for a single dive extracted from the dive computer with
|
Creates a parser for a single dive extracted from the dive computer with
|
||||||
|
|||||||
@ -54,12 +54,20 @@ parse (dc_buffer_t *buffer, dc_context_t *context, dc_descriptor_t *descriptor,
|
|||||||
|
|
||||||
// Create the parser.
|
// Create the parser.
|
||||||
message ("Creating the parser.\n");
|
message ("Creating the parser.\n");
|
||||||
rc = dc_parser_new2 (&parser, context, descriptor, devtime, systime);
|
rc = dc_parser_new2 (&parser, context, descriptor);
|
||||||
if (rc != DC_STATUS_SUCCESS) {
|
if (rc != DC_STATUS_SUCCESS) {
|
||||||
ERROR ("Error creating the parser.");
|
ERROR ("Error creating the parser.");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the clock.
|
||||||
|
message ("Setting the clock.\n");
|
||||||
|
rc = dc_parser_set_clock (parser, devtime, systime);
|
||||||
|
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||||
|
ERROR ("Error setting the clock.");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
// Register the data.
|
// Register the data.
|
||||||
message ("Registering the data.\n");
|
message ("Registering the data.\n");
|
||||||
rc = dc_parser_set_data (parser, data, size);
|
rc = dc_parser_set_data (parser, data, size);
|
||||||
|
|||||||
@ -279,7 +279,7 @@ dc_status_t
|
|||||||
dc_parser_new (dc_parser_t **parser, dc_device_t *device);
|
dc_parser_new (dc_parser_t **parser, dc_device_t *device);
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
dc_parser_new2 (dc_parser_t **parser, dc_context_t *context, dc_descriptor_t *descriptor, unsigned int devtime, dc_ticks_t systime);
|
dc_parser_new2 (dc_parser_t **parser, dc_context_t *context, dc_descriptor_t *descriptor);
|
||||||
|
|
||||||
dc_family_t
|
dc_family_t
|
||||||
dc_parser_get_type (dc_parser_t *parser);
|
dc_parser_get_type (dc_parser_t *parser);
|
||||||
|
|||||||
38
src/parser.c
38
src/parser.c
@ -72,7 +72,7 @@
|
|||||||
#define REACTPROWHITE 0x4354
|
#define REACTPROWHITE 0x4354
|
||||||
|
|
||||||
static dc_status_t
|
static dc_status_t
|
||||||
dc_parser_new_internal (dc_parser_t **out, dc_context_t *context, dc_family_t family, unsigned int model, unsigned int devtime, dc_ticks_t systime)
|
dc_parser_new_internal (dc_parser_t **out, dc_context_t *context, dc_family_t family, unsigned int model)
|
||||||
{
|
{
|
||||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||||
dc_parser_t *parser = NULL;
|
dc_parser_t *parser = NULL;
|
||||||
@ -102,19 +102,19 @@ dc_parser_new_internal (dc_parser_t **out, dc_context_t *context, dc_family_t fa
|
|||||||
break;
|
break;
|
||||||
case DC_FAMILY_UWATEC_ALADIN:
|
case DC_FAMILY_UWATEC_ALADIN:
|
||||||
case DC_FAMILY_UWATEC_MEMOMOUSE:
|
case DC_FAMILY_UWATEC_MEMOMOUSE:
|
||||||
rc = uwatec_memomouse_parser_create (&parser, context, devtime, systime);
|
rc = uwatec_memomouse_parser_create (&parser, context);
|
||||||
break;
|
break;
|
||||||
case DC_FAMILY_UWATEC_SMART:
|
case DC_FAMILY_UWATEC_SMART:
|
||||||
rc = uwatec_smart_parser_create (&parser, context, model);
|
rc = uwatec_smart_parser_create (&parser, context, model);
|
||||||
break;
|
break;
|
||||||
case DC_FAMILY_REEFNET_SENSUS:
|
case DC_FAMILY_REEFNET_SENSUS:
|
||||||
rc = reefnet_sensus_parser_create (&parser, context, devtime, systime);
|
rc = reefnet_sensus_parser_create (&parser, context);
|
||||||
break;
|
break;
|
||||||
case DC_FAMILY_REEFNET_SENSUSPRO:
|
case DC_FAMILY_REEFNET_SENSUSPRO:
|
||||||
rc = reefnet_sensuspro_parser_create (&parser, context, devtime, systime);
|
rc = reefnet_sensuspro_parser_create (&parser, context);
|
||||||
break;
|
break;
|
||||||
case DC_FAMILY_REEFNET_SENSUSULTRA:
|
case DC_FAMILY_REEFNET_SENSUSULTRA:
|
||||||
rc = reefnet_sensusultra_parser_create (&parser, context, devtime, systime);
|
rc = reefnet_sensusultra_parser_create (&parser, context);
|
||||||
break;
|
break;
|
||||||
case DC_FAMILY_OCEANIC_VTPRO:
|
case DC_FAMILY_OCEANIC_VTPRO:
|
||||||
rc = oceanic_vtpro_parser_create (&parser, context, model);
|
rc = oceanic_vtpro_parser_create (&parser, context, model);
|
||||||
@ -215,20 +215,36 @@ dc_parser_new_internal (dc_parser_t **out, dc_context_t *context, dc_family_t fa
|
|||||||
dc_status_t
|
dc_status_t
|
||||||
dc_parser_new (dc_parser_t **out, dc_device_t *device)
|
dc_parser_new (dc_parser_t **out, dc_device_t *device)
|
||||||
{
|
{
|
||||||
|
dc_status_t status = DC_STATUS_SUCCESS;
|
||||||
|
dc_parser_t *parser = NULL;
|
||||||
|
|
||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
return DC_STATUS_INVALIDARGS;
|
return DC_STATUS_INVALIDARGS;
|
||||||
|
|
||||||
return dc_parser_new_internal (out, device->context,
|
status = dc_parser_new_internal (&parser, device->context,
|
||||||
dc_device_get_type (device), device->devinfo.model,
|
dc_device_get_type (device), device->devinfo.model);
|
||||||
device->clock.devtime, device->clock.systime);
|
if (status != DC_STATUS_SUCCESS)
|
||||||
|
goto error_exit;
|
||||||
|
|
||||||
|
status = dc_parser_set_clock (parser, device->clock.devtime, device->clock.systime);
|
||||||
|
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED)
|
||||||
|
goto error_free;
|
||||||
|
|
||||||
|
*out = parser;
|
||||||
|
|
||||||
|
return DC_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
error_free:
|
||||||
|
dc_parser_deallocate (parser);
|
||||||
|
error_exit:
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
dc_parser_new2 (dc_parser_t **out, dc_context_t *context, dc_descriptor_t *descriptor, unsigned int devtime, dc_ticks_t systime)
|
dc_parser_new2 (dc_parser_t **out, dc_context_t *context, dc_descriptor_t *descriptor)
|
||||||
{
|
{
|
||||||
return dc_parser_new_internal (out, context,
|
return dc_parser_new_internal (out, context,
|
||||||
dc_descriptor_get_type (descriptor), dc_descriptor_get_model (descriptor),
|
dc_descriptor_get_type (descriptor), dc_descriptor_get_model (descriptor));
|
||||||
devtime, systime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_parser_t *
|
dc_parser_t *
|
||||||
|
|||||||
@ -36,7 +36,7 @@ dc_status_t
|
|||||||
reefnet_sensus_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream);
|
reefnet_sensus_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream);
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
reefnet_sensus_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int devtime, dc_ticks_t systime);
|
reefnet_sensus_parser_create (dc_parser_t **parser, dc_context_t *context);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,7 +71,7 @@ static const dc_parser_vtable_t reefnet_sensus_parser_vtable = {
|
|||||||
|
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
reefnet_sensus_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int devtime, dc_ticks_t systime)
|
reefnet_sensus_parser_create (dc_parser_t **out, dc_context_t *context)
|
||||||
{
|
{
|
||||||
reefnet_sensus_parser_t *parser = NULL;
|
reefnet_sensus_parser_t *parser = NULL;
|
||||||
|
|
||||||
@ -88,8 +88,8 @@ reefnet_sensus_parser_create (dc_parser_t **out, dc_context_t *context, unsigned
|
|||||||
// Set the default values.
|
// Set the default values.
|
||||||
parser->atmospheric = DEF_ATMOSPHERIC;
|
parser->atmospheric = DEF_ATMOSPHERIC;
|
||||||
parser->hydrostatic = DEF_DENSITY_SALT * GRAVITY;
|
parser->hydrostatic = DEF_DENSITY_SALT * GRAVITY;
|
||||||
parser->devtime = devtime;
|
parser->devtime = 0;
|
||||||
parser->systime = systime;
|
parser->systime = 0;
|
||||||
parser->cached = 0;
|
parser->cached = 0;
|
||||||
parser->divetime = 0;
|
parser->divetime = 0;
|
||||||
parser->maxdepth = 0;
|
parser->maxdepth = 0;
|
||||||
|
|||||||
@ -36,7 +36,7 @@ dc_status_t
|
|||||||
reefnet_sensuspro_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream);
|
reefnet_sensuspro_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream);
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
reefnet_sensuspro_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int devtime, dc_ticks_t systime);
|
reefnet_sensuspro_parser_create (dc_parser_t **parser, dc_context_t *context);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ static const dc_parser_vtable_t reefnet_sensuspro_parser_vtable = {
|
|||||||
|
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
reefnet_sensuspro_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int devtime, dc_ticks_t systime)
|
reefnet_sensuspro_parser_create (dc_parser_t **out, dc_context_t *context)
|
||||||
{
|
{
|
||||||
reefnet_sensuspro_parser_t *parser = NULL;
|
reefnet_sensuspro_parser_t *parser = NULL;
|
||||||
|
|
||||||
@ -87,8 +87,8 @@ reefnet_sensuspro_parser_create (dc_parser_t **out, dc_context_t *context, unsig
|
|||||||
// Set the default values.
|
// Set the default values.
|
||||||
parser->atmospheric = DEF_ATMOSPHERIC;
|
parser->atmospheric = DEF_ATMOSPHERIC;
|
||||||
parser->hydrostatic = DEF_DENSITY_SALT * GRAVITY;
|
parser->hydrostatic = DEF_DENSITY_SALT * GRAVITY;
|
||||||
parser->devtime = devtime;
|
parser->devtime = 0;
|
||||||
parser->systime = systime;
|
parser->systime = 0;
|
||||||
parser->cached = 0;
|
parser->cached = 0;
|
||||||
parser->divetime = 0;
|
parser->divetime = 0;
|
||||||
parser->maxdepth = 0;
|
parser->maxdepth = 0;
|
||||||
|
|||||||
@ -36,7 +36,7 @@ dc_status_t
|
|||||||
reefnet_sensusultra_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream);
|
reefnet_sensusultra_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream);
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
reefnet_sensusultra_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int devtime, dc_ticks_t systime);
|
reefnet_sensusultra_parser_create (dc_parser_t **parser, dc_context_t *context);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ static const dc_parser_vtable_t reefnet_sensusultra_parser_vtable = {
|
|||||||
|
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
reefnet_sensusultra_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int devtime, dc_ticks_t systime)
|
reefnet_sensusultra_parser_create (dc_parser_t **out, dc_context_t *context)
|
||||||
{
|
{
|
||||||
reefnet_sensusultra_parser_t *parser = NULL;
|
reefnet_sensusultra_parser_t *parser = NULL;
|
||||||
|
|
||||||
@ -87,8 +87,8 @@ reefnet_sensusultra_parser_create (dc_parser_t **out, dc_context_t *context, uns
|
|||||||
// Set the default values.
|
// Set the default values.
|
||||||
parser->atmospheric = DEF_ATMOSPHERIC;
|
parser->atmospheric = DEF_ATMOSPHERIC;
|
||||||
parser->hydrostatic = DEF_DENSITY_SALT * GRAVITY;
|
parser->hydrostatic = DEF_DENSITY_SALT * GRAVITY;
|
||||||
parser->devtime = devtime;
|
parser->devtime = 0;
|
||||||
parser->systime = systime;
|
parser->systime = 0;
|
||||||
parser->cached = 0;
|
parser->cached = 0;
|
||||||
parser->divetime = 0;
|
parser->divetime = 0;
|
||||||
parser->maxdepth = 0;
|
parser->maxdepth = 0;
|
||||||
|
|||||||
@ -35,7 +35,7 @@ dc_status_t
|
|||||||
uwatec_memomouse_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream);
|
uwatec_memomouse_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream);
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
uwatec_memomouse_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int devtime, dc_ticks_t systime);
|
uwatec_memomouse_parser_create (dc_parser_t **parser, dc_context_t *context);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,7 +59,7 @@ static const dc_parser_vtable_t uwatec_memomouse_parser_vtable = {
|
|||||||
|
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
uwatec_memomouse_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int devtime, dc_ticks_t systime)
|
uwatec_memomouse_parser_create (dc_parser_t **out, dc_context_t *context)
|
||||||
{
|
{
|
||||||
uwatec_memomouse_parser_t *parser = NULL;
|
uwatec_memomouse_parser_t *parser = NULL;
|
||||||
|
|
||||||
@ -74,8 +74,8 @@ uwatec_memomouse_parser_create (dc_parser_t **out, dc_context_t *context, unsign
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the default values.
|
// Set the default values.
|
||||||
parser->devtime = devtime;
|
parser->devtime = 0;
|
||||||
parser->systime = systime;
|
parser->systime = 0;
|
||||||
|
|
||||||
*out = (dc_parser_t*) parser;
|
*out = (dc_parser_t*) parser;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user