* technically the SI unit for pressure is Pascal, but
* we default to bar (10^5 pascal), which people
* actually use. Similarly, C instead of Kelvin.
+ * And kg instead of g.
*/
const struct units SI_units = {
.length = METERS,
const char *name;
} event;
static struct tm tm;
-static int cylinder_index;
+static int cylinder_index, ws_index;
static enum import_source {
UNKNOWN,
free(buffer);
}
+static void weight(char *buffer, void *_weight)
+{
+ weight_t *weight = _weight;
+ union int_or_float val;
+
+ switch (integer_or_float(buffer, &val)) {
+ case FLOAT:
+ switch (input_units.weight) {
+ case KG:
+ weight->grams = val.fp * 1000 + 0.5;
+ break;
+ case LBS:
+ weight->grams = val.fp * 453.6 + 0.5;
+ break;
+ }
+ break;
+ default:
+ printf("Strange depth reading %s\n", buffer);
+ }
+}
+
static void temperature(char *buffer, void *_temperature)
{
temperature_t *temperature = _temperature;
return;
if (MATCH(".cylinder.end", pressure, &dive->cylinder[cylinder_index].end))
return;
-
+ if (MATCH(".weightsystem.description", utf8_string, &dive->weightsystem[ws_index].description))
+ return;
+ if (MATCH(".weightsystem.weight", weight, &dive->weightsystem[ws_index].weight))
+ return;
+ if (MATCH("weight", weight, &dive->weightsystem[ws_index].weight))
+ return;
if (MATCH(".o2", gasmix, &dive->cylinder[cylinder_index].gasmix.o2))
return;
if (MATCH(".n2", gasmix_nitrogen, &dive->cylinder[cylinder_index].gasmix))
record_dive(dive);
dive = NULL;
cylinder_index = 0;
+ ws_index = 0;
}
static void event_start(void)
cylinder_index++;
}
+static void ws_start(void)
+{
+}
+
+static void ws_end(void)
+{
+ ws_index++;
+}
+
static void sample_start(void)
{
sample = prepare_sample(&dive);
{ "event", event_start, event_end },
{ "gasmix", cylinder_start, cylinder_end },
{ "cylinder", cylinder_start, cylinder_end },
+ { "weightsystem", ws_start, ws_end },
{ "P", sample_start, sample_end },
/* Import type recognition */