aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-16 22:11:34 +0000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-16 22:13:12 +0000
commit202c5cbfeb6888b05ae4b14b4f563666bc6ca763 (patch)
treee99552b1afb08bf86e50a930ba7c8f1c4eb9fc4e
parent84dc8b8962ae8a4a75ca1ec81acd09989f757c98 (diff)
downloadsubsurface-202c5cbfeb6888b05ae4b14b4f563666bc6ca763.tar.gz
Save CCR cylinder use in XML and git
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--dive.c3
-rw-r--r--dive.h4
-rw-r--r--load-git.c8
-rw-r--r--parse-xml.c12
-rw-r--r--save-git.c3
-rw-r--r--save-xml.c2
6 files changed, 31 insertions, 1 deletions
diff --git a/dive.c b/dive.c
index f9914d479..a361ce003 100644
--- a/dive.c
+++ b/dive.c
@@ -26,6 +26,9 @@ static const char *default_tags[] = {
QT_TRANSLATE_NOOP("gettextFromC", "deco")
};
+const char *cylinderuse_text[] = { "OC-gas", "diluent", "oxygen" };
+
+
int event_is_gaschange(struct event *ev)
{
return ev->type == SAMPLE_EVENT_GASCHANGE ||
diff --git a/dive.h b/dive.h
index e6b72f9bc..0848905e7 100644
--- a/dive.h
+++ b/dive.h
@@ -48,7 +48,9 @@ extern "C" {
#endif
enum dive_comp_type {OC, CCR, PSCR}; // Flags (Open-circuit and Closed-circuit-rebreather) for setting dive computer type
-enum cylinderuse {OC_GAS, DILUENT, OXYGEN}; // The different uses for cylinders
+enum cylinderuse {OC_GAS, DILUENT, OXYGEN, NUM_GAS_USE}; // The different uses for cylinders
+
+extern const char *cylinderuse_text[];
struct gasmix {
fraction_t o2;
diff --git a/load-git.c b/load-git.c
index 53172f61e..9cf6baf6c 100644
--- a/load-git.c
+++ b/load-git.c
@@ -254,6 +254,14 @@ static void parse_cylinder_keyvalue(void *_cylinder, const char *key, const char
cylinder->end = get_pressure(value);
return;
}
+ if (!strcmp(key, "use")) {
+ for (enum cylinderuse i = 0; i < NUM_GAS_USE; i++) {
+ if (same_string(value, cylinderuse_text[i])) {
+ cylinder->cylinder_use = i;
+ return;
+ }
+ }
+ }
report_error("Unknown cylinder key/value pair (%s/%s)", key, value);
}
diff --git a/parse-xml.c b/parse-xml.c
index 0b17db79e..70ac63ee2 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -317,6 +317,16 @@ static void pressure(char *buffer, pressure_t *pressure)
}
}
+static void cylinder_use(char *buffer, enum cylinderuse *cyl_use)
+{
+ for (enum cylinderuse i = 0; i < NUM_GAS_USE; i++) {
+ if (same_string(buffer, cylinderuse_text[i])) {
+ *cyl_use = i;
+ return;
+ }
+ }
+}
+
static void salinity(char *buffer, int *salinity)
{
union int_or_float val;
@@ -1226,6 +1236,8 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf)
return;
if (MATCH("end.cylinder", pressure, &dive->cylinder[cur_cylinder_index].end))
return;
+ if (MATCH("use.cylinder", cylinder_use, &dive->cylinder[cur_cylinder_index].cylinder_use))
+ return;
if (MATCH("description.weightsystem", utf8_string, &dive->weightsystem[cur_ws_index].description))
return;
if (MATCH("weight.weightsystem", weight, &dive->weightsystem[cur_ws_index].weight))
diff --git a/save-git.c b/save-git.c
index 93348306e..68fc52637 100644
--- a/save-git.c
+++ b/save-git.c
@@ -159,6 +159,9 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive)
put_gasmix(b, &cylinder->gasmix);
put_pressure(b, cylinder->start, " start=", "bar");
put_pressure(b, cylinder->end, " end=", "bar");
+ if (cylinder->cylinder_use != OC_GAS)
+ put_format(b, " use=%s", cylinderuse_text[cylinder->cylinder_use]);
+
put_string(b, "\n");
}
}
diff --git a/save-xml.c b/save-xml.c
index ac9ef874e..31ad436bc 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -179,6 +179,8 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive)
put_gasmix(b, &cylinder->gasmix);
put_pressure(b, cylinder->start, " start='", " bar'");
put_pressure(b, cylinder->end, " end='", " bar'");
+ if (cylinder->cylinder_use != OC_GAS)
+ show_utf8(b, cylinderuse_text[cylinder->cylinder_use], " use='", "'", 1);
put_format(b, " />\n");
}
}