summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/dive.c15
-rw-r--r--core/dive.h7
-rw-r--r--core/plannernotes.c21
3 files changed, 22 insertions, 21 deletions
diff --git a/core/dive.c b/core/dive.c
index 84acecb38..54d2a00f4 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -1172,6 +1172,21 @@ static void sanitize_cylinder_info(struct dive *dive)
}
}
+/* Perform isobaric counterdiffusion calculations for gas changes in trimix dives.
+ * Here we use the rule-of-fifths where, during a change involving trimix gas, the increase in nitrogen
+ * should not exceed one fifth of the decrease in helium.
+ * Parameters: 1) pointers to two gas mixes, the gas being switched from and the gas being switched to.
+ * 2) a pointer to an icd_data structure.
+ * Output: i) The icd_data stucture is filled with the delta_N2 and delta_He numbers (as permille).
+ * ii) Function returns a boolean indicating an exceeding of the rule-of-fifths. False = no icd problem.
+ */
+bool isobaric_counterdiffusion(struct gasmix *oldgasmix, struct gasmix *newgasmix, struct icd_data *results)
+{
+ results->dN2 = get_he(oldgasmix) + get_o2(oldgasmix) - get_he(newgasmix) - get_o2(newgasmix);
+ results->dHe = get_he(newgasmix) - get_he(oldgasmix);
+ return get_he(oldgasmix) && results->dN2 > 0 && 5 * results->dN2 > -results->dHe;
+}
+
/* some events should never be thrown away */
static bool is_potentially_redundant(struct event *event)
{
diff --git a/core/dive.h b/core/dive.h
index 3532b4a59..c155abbfd 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -114,6 +114,13 @@ typedef struct
const char *description; /* "integrated", "belt", "ankle" */
} weightsystem_t;
+struct icd_data { // This structure provides communication between function isobaric_counterdiffusion() and the calling software.
+ int dN2; // The change in fraction (permille) of nitrogen during the change
+ int dHe; // The change in fraction (permille) of helium during the change
+};
+
+extern bool isobaric_counterdiffusion(struct gasmix *oldgasmix, struct gasmix *newgasmix, struct icd_data *results);
+
/*
* Events are currently based straight on what libdivecomputer gives us.
* We need to wrap these into our own events at some point to remove some of the limitations.
diff --git a/core/plannernotes.c b/core/plannernotes.c
index 4021806ea..1c03d2048 100644
--- a/core/plannernotes.c
+++ b/core/plannernotes.c
@@ -30,27 +30,6 @@ int diveplan_duration(struct diveplan *diveplan)
return (duration + 30) / 60;
}
-struct icd_data { // This structure provides communication between function isobaric_counterdiffusion() and the calling software.
- int dN2; // The change in fraction (permille) of nitrogen during the change
- int dHe; // The change in fraction (permille) of helium during the change
-};
-
-/* Perform isobaric counterdiffusion calculations for gas changes in trimix dives.
- * Here we use the rule-of-fifths where, during a change involving trimix gas, the increase in nitrogen
- * should not exceed one fifth of the decrease in helium.
- * Parameters: 1) Pointer to the dive structure.
- * 2) pointers to two gas mixes, the gas being switched from and the gas being switched to.
- * 3) a pointer to an icd_data structure.
- * Output: i) The icd_data stucture is filled with the delta_N2 and delta_He numbers (as permille).
- * ii) Function returns a boolean indicating an exceeding of the rule-of-fifths. False = no icd problem.
- */
-bool isobaric_counterdiffusion(struct gasmix *oldgasmix, struct gasmix *newgasmix, struct icd_data *results)
-{
- results->dN2 = get_he(oldgasmix) + get_o2(oldgasmix) - get_he(newgasmix) - get_o2(newgasmix);
- results->dHe = get_he(newgasmix) - get_he(oldgasmix);
- return get_he(oldgasmix) && results->dN2 > 0 && 5 * results->dN2 > -results->dHe;
-}
-
/* Add the icd results of one trimix gas change to the dive plan html buffer. Two rows are added to the table, one
* indicating fractions of gas, the other indication partial pressures of gas. This function makes use of the
* icd_data structure that was filled with information by the function isobaric_counterdiffusion().