Extend temperature with surface, min and max values.

This commit is contained in:
Jef Driesen 2014-10-20 22:12:58 +02:00
parent a4e5d4234c
commit 693a452250
3 changed files with 21 additions and 12 deletions

View File

@ -363,17 +363,24 @@ doparse (FILE *fp, dc_device_t *device, const unsigned char data[], unsigned int
// Parse the temperature.
message ("Parsing the temperature.\n");
double temperature = 0.0;
rc = dc_parser_get_field (parser, DC_FIELD_TEMPERATURE, 0, &temperature);
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
WARNING ("Error parsing the temperature.");
dc_parser_destroy (parser);
return rc;
}
for (unsigned int i = 0; i < 3; ++i) {
dc_field_type_t fields[] = {DC_FIELD_TEMPERATURE_SURFACE,
DC_FIELD_TEMPERATURE_MINIMUM,
DC_FIELD_TEMPERATURE_MAXIMUM};
const char *names[] = {"surface", "minimum", "maximum"};
if (rc != DC_STATUS_UNSUPPORTED) {
fprintf (fp, "<temperature>%.1f</temperature>\n",
temperature);
double temperature = 0.0;
rc = dc_parser_get_field (parser, fields[i], 0, &temperature);
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
WARNING ("Error parsing the temperature.");
dc_parser_destroy (parser);
return rc;
}
if (rc != DC_STATUS_UNSUPPORTED) {
fprintf (fp, "<temperature type=\"%s\">%.1f</temperature>\n",
names[i], temperature);
}
}
// Parse the maxdepth.

View File

@ -54,7 +54,9 @@ typedef enum dc_field_type_t {
DC_FIELD_GASMIX,
DC_FIELD_SALINITY,
DC_FIELD_ATMOSPHERIC,
DC_FIELD_TEMPERATURE
DC_FIELD_TEMPERATURE_SURFACE,
DC_FIELD_TEMPERATURE_MINIMUM,
DC_FIELD_TEMPERATURE_MAXIMUM
} dc_field_type_t;
typedef enum parser_sample_event_t {

View File

@ -139,7 +139,7 @@ cressi_leonardo_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, u
gasmix->oxygen = data[0x19] / 100.0;
gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium;
break;
case DC_FIELD_TEMPERATURE:
case DC_FIELD_TEMPERATURE_MINIMUM:
*((double *) value) = data[0x22];
break;
default: