mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Start cleaning up sensor indexing for multiple sensors
This is a very timid start at making us actually use multiple sensors without the magical special case for just CCR oxygen tracking. It mainly does: - turn the "sample->sensor" index into an array of two indexes, to match the pressures themselves. - get rid of dive->{oxygen_cylinder_index,diluent_cylinder_index}, since a CCR dive should now simply set the sample->sensor[] indices correctly instead. - in a couple of places, start actually looping over the sensors rather than special-case the O2 case (although often the small "loops" are just unrolled, since it's just two cases. but in many cases we still end up only covering the zero sensor case, because the CCR O2 sensor code coverage was fairly limited. It's entirely possible (even likely) that this migth break some existing case: it tries to be a fairly direct ("stupid") translation of the old code, but unlike the preparatory patch this does actually does change some semantics. For example, right now the git loader code assumes that if the git save data contains a o2pressure entry, it just hardcodes the O2 sensor index to 1. In fact, one issue is going to simply be that our file formats do not have that multiple sensor format, but instead had very clearly encoded things as being the CCR O2 pressure sensor. But this is hopefully close to usable, and I will need feedback (and maybe test cases) from people who have existing CCR dives with pressure data. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
11a0c0cc70
commit
1e38d9239a
19 changed files with 174 additions and 188 deletions
|
@ -151,7 +151,7 @@ static bool in_userid = false;
|
|||
static struct tm cur_tm;
|
||||
static int cur_cylinder_index, cur_ws_index;
|
||||
static int lastndl, laststoptime, laststopdepth, lastcns, lastpo2, lastindeco;
|
||||
static int lastcylinderindex, lastsensor, next_o2_sensor;
|
||||
static int lastcylinderindex, lastsensor, lasto2sensor = 1, next_o2_sensor;
|
||||
static struct extra_data cur_extra_data;
|
||||
|
||||
/*
|
||||
|
@ -352,8 +352,12 @@ static void pressure(char *buffer, pressure_t *pressure)
|
|||
|
||||
static void cylinder_use(char *buffer, enum cylinderuse *cyl_use)
|
||||
{
|
||||
if (trimspace(buffer))
|
||||
*cyl_use = cylinderuse_from_text(buffer);
|
||||
if (trimspace(buffer)) {
|
||||
int use = cylinderuse_from_text(buffer);
|
||||
*cyl_use = use;
|
||||
if (use == OXYGEN)
|
||||
lasto2sensor = cur_cylinder_index;
|
||||
}
|
||||
}
|
||||
|
||||
static void salinity(char *buffer, int *salinity)
|
||||
|
@ -935,9 +939,9 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu
|
|||
return;
|
||||
if (MATCH("o2pressure.sample", pressure, &sample->pressure[1]))
|
||||
return;
|
||||
if (MATCH("cylinderindex.sample", get_cylinderindex, &sample->sensor))
|
||||
if (MATCH("cylinderindex.sample", get_cylinderindex, &sample->sensor[0]))
|
||||
return;
|
||||
if (MATCH("sensor.sample", get_sensor, &sample->sensor))
|
||||
if (MATCH("sensor.sample", get_sensor, &sample->sensor[0]))
|
||||
return;
|
||||
if (MATCH("depth.sample", depth, &sample->depth))
|
||||
return;
|
||||
|
@ -1524,6 +1528,7 @@ static void reset_dc_info(struct divecomputer *dc)
|
|||
(void) dc;
|
||||
lastcns = lastpo2 = lastndl = laststoptime = laststopdepth = lastindeco = 0;
|
||||
lastsensor = lastcylinderindex = 0;
|
||||
lasto2sensor = 1;
|
||||
}
|
||||
|
||||
static void reset_dc_settings(void)
|
||||
|
@ -1718,7 +1723,8 @@ static void sample_start(void)
|
|||
cur_sample->stopdepth.mm = laststopdepth;
|
||||
cur_sample->cns = lastcns;
|
||||
cur_sample->setpoint.mbar = lastpo2;
|
||||
cur_sample->sensor = lastsensor;
|
||||
cur_sample->sensor[0] = lastsensor;
|
||||
cur_sample->sensor[1] = lasto2sensor;
|
||||
next_o2_sensor = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue