5 * Some silly typedefs to make our units very explicit.
7 * Also, the units are chosen so that values can be expressible as
8 * integers, so that we never have FP rounding issues. And they
9 * are small enough that converting to/from imperial units doesn't
12 * We also strive to make '0' a meaningless number saying "not
13 * initialized", since many values are things that may not have
14 * been reported (eg tank pressure or temperature from dive
15 * computers that don't support them). But sometimes -1 is an even
16 * more explicit way of saying "not there".
18 * Thus "millibar" for pressure, for example, or "millikelvin" for
19 * temperatures. Doing temperatures in celsius or fahrenheit would
20 * make for loss of precision when converting from one to the other,
21 * and using millikelvin is SI-like but also means that a temperature
22 * of '0' is clearly just a missing temperature or tank pressure.
24 * Also strive to use units that can not possibly be mistaken for a
25 * valid value in a "normal" system without conversion. If the max
26 * depth of a dive is '20000', you probably didn't convert from mm on
27 * output, or if the max depth gets reported as "0.2ft" it was either
28 * a really boring dive, or there was some missing input conversion,
29 * and a 60-ft dive got recorded as 60mm.
31 * Doing these as "structs containing value" means that we always
32 * have to explicitly write out those units in order to get at the
33 * actual value. So there is hopefully little fear of using a value
34 * in millikelvin as Fahrenheit by mistake.
36 * We don't actually use these all yet, so maybe they'll change, but
37 * I made a number of types as guidelines.
78 static inline int to_feet(depth_t depth)
80 return depth.mm * 0.00328084 + 0.5;
83 static inline int to_C(temperature_t temp)
87 return (temp.mkelvin - 273150) / 1000;
90 static inline int to_PSI(pressure_t pressure)
92 return pressure.mbar * 0.0145037738 + 0.5;
98 temperature_t temperature;
99 pressure_t tankpressure;
105 depth_t maxdepth, meandepth;
106 duration_t duration, surfacetime;
108 temperature_t airtemp, watertemp;
109 pressure_t beginning_pressure, end_pressure;
111 struct sample sample[];
121 extern struct dive_table dive_table;
123 void parse_xml_init(void);
124 void parse_xml_file(const char *filename);