Unify sample pressure and o2pressure as pressure[2] array

We currently carry two pressures around for all the samples and plot
info, but the second pressure is reserved for CCR dives as the O2
cylinder pressure.

That's kind of annoying when we *could* use it for regular sidemount
dives as the secondary pressure.

So start prepping for that instead: don't make it "pressure" and
"o2pressure", make it just be an array of two pressure values.

NOTE! This is purely mindless prepwork.  It literally just does a
search-and-replace, keeping the exact same semantics, so "pressure[1]"
is still just O2 pressure.

But at some future date, we can now start using it for a second sensor
value for sidemount instead.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2017-07-20 14:39:02 -07:00 committed by Dirk Hohndel
parent 94d8abd1a2
commit 11a0c0cc70
17 changed files with 68 additions and 68 deletions

View file

@ -585,7 +585,7 @@ static void cochran_parse_samples(struct dive *dive, const unsigned char *log,
sample->stopdepth.mm = lrint(deco_ceiling * FEET * 1000); sample->stopdepth.mm = lrint(deco_ceiling * FEET * 1000);
sample->temperature.mkelvin = C_to_mkelvin((temp - 32) / 1.8); sample->temperature.mkelvin = C_to_mkelvin((temp - 32) / 1.8);
sample->sensor = 0; sample->sensor = 0;
sample->cylinderpressure.mbar = lrint(psi * PSI / 100); sample->pressure[0].mbar = lrint(psi * PSI / 100);
finish_sample(dc); finish_sample(dc);

View file

@ -1359,17 +1359,17 @@ static void simplify_dc_pressures(struct divecomputer *dc)
for (i = 0; i < dc->samples; i++) { for (i = 0; i < dc->samples; i++) {
struct sample *sample = dc->sample + i; struct sample *sample = dc->sample + i;
int pressure = sample->cylinderpressure.mbar; int pressure = sample->pressure[0].mbar;
int o2_pressure = sample->o2cylinderpressure.mbar; int o2_pressure = sample->pressure[1].mbar;
int index; int index;
index = sample->sensor; index = sample->sensor;
if (index == lastindex) { if (index == lastindex) {
/* Remove duplicate redundant pressure information */ /* Remove duplicate redundant pressure information */
if (pressure == lastpressure) if (pressure == lastpressure)
sample->cylinderpressure.mbar = 0; sample->pressure[0].mbar = 0;
if (o2_pressure == lasto2pressure) if (o2_pressure == lasto2pressure)
sample->o2cylinderpressure.mbar = 0; sample->pressure[1].mbar = 0;
} }
lastindex = index; lastindex = index;
lastpressure = pressure; lastpressure = pressure;
@ -1423,8 +1423,8 @@ static void fixup_dive_pressures(struct dive *dive, struct divecomputer *dc)
if (sample->depth.mm < SURFACE_THRESHOLD) if (sample->depth.mm < SURFACE_THRESHOLD)
continue; continue;
fixup_start_pressure(dive, sample->sensor, sample->cylinderpressure); fixup_start_pressure(dive, sample->sensor, sample->pressure[0]);
fixup_start_pressure(dive, o2index, sample->o2cylinderpressure); fixup_start_pressure(dive, o2index, sample->pressure[1]);
} }
/* ..and from the end for ending pressures */ /* ..and from the end for ending pressures */
@ -1434,8 +1434,8 @@ static void fixup_dive_pressures(struct dive *dive, struct divecomputer *dc)
if (sample->depth.mm < SURFACE_THRESHOLD) if (sample->depth.mm < SURFACE_THRESHOLD)
continue; continue;
fixup_end_pressure(dive, sample->sensor, sample->cylinderpressure); fixup_end_pressure(dive, sample->sensor, sample->pressure[0]);
fixup_end_pressure(dive, o2index, sample->o2cylinderpressure); fixup_end_pressure(dive, o2index, sample->pressure[1]);
} }
simplify_dc_pressures(dc); simplify_dc_pressures(dc);
@ -1713,8 +1713,8 @@ static void merge_samples(struct divecomputer *res, struct divecomputer *a, stru
sample.depth = as->depth; sample.depth = as->depth;
if (as->temperature.mkelvin) if (as->temperature.mkelvin)
sample.temperature = as->temperature; sample.temperature = as->temperature;
if (as->cylinderpressure.mbar) if (as->pressure[0].mbar)
sample.cylinderpressure = as->cylinderpressure; sample.pressure[0] = as->pressure[0];
if (as->sensor) if (as->sensor)
sample.sensor = as->sensor; sample.sensor = as->sensor;
if (as->cns) if (as->cns)
@ -2625,7 +2625,7 @@ static int same_sample(struct sample *a, struct sample *b)
return 0; return 0;
if (a->temperature.mkelvin != b->temperature.mkelvin) if (a->temperature.mkelvin != b->temperature.mkelvin)
return 0; return 0;
if (a->cylinderpressure.mbar != b->cylinderpressure.mbar) if (a->pressure[0].mbar != b->pressure[0].mbar)
return 0; return 0;
return a->sensor == b->sensor; return a->sensor == b->sensor;
} }

View file

@ -194,8 +194,7 @@ struct sample // BASE TYPE BYTES UNITS RANGE DE
depth_t depth; // int32_t 4 mm (0-2000 km) dive depth of this sample depth_t depth; // int32_t 4 mm (0-2000 km) dive depth of this sample
depth_t stopdepth; // int32_t 4 mm (0-2000 km) depth of next deco stop depth_t stopdepth; // int32_t 4 mm (0-2000 km) depth of next deco stop
temperature_t temperature; // int32_t 4 mdegrK (0-2 MdegK) ambient temperature temperature_t temperature; // int32_t 4 mdegrK (0-2 MdegK) ambient temperature
pressure_t cylinderpressure; // int32_t 4 mbar (0-2 Mbar) main cylinder pressure pressure_t pressure[2]; // int32_t 4 mbar (0-2 Mbar) cylinder pressures (main and CCR o2)
pressure_t o2cylinderpressure; // int32_t 4 mbar (0-2 Mbar) CCR o2 cylinder pressure (rebreather)
o2pressure_t setpoint; // uint16_t 2 mbar (0-65 bar) O2 partial pressure (will be setpoint) o2pressure_t setpoint; // uint16_t 2 mbar (0-65 bar) O2 partial pressure (will be setpoint)
o2pressure_t o2sensor[3]; // uint16_t 6 mbar (0-65 bar) Up to 3 PO2 sensor values (rebreather) o2pressure_t o2sensor[3]; // uint16_t 6 mbar (0-65 bar) Up to 3 PO2 sensor values (rebreather)
bearing_t bearing; // int16_t 2 degrees (-32k to 32k deg) compass bearing bearing_t bearing; // int16_t 2 degrees (-32k to 32k deg) compass bearing

View file

@ -291,7 +291,7 @@ static void add_sample_data(struct sample *sample, enum csv_format type, double
sample->temperature.mkelvin = F_to_mkelvin(val); sample->temperature.mkelvin = F_to_mkelvin(val);
break; break;
case CSV_PRESSURE: case CSV_PRESSURE:
sample->cylinderpressure.mbar = psi_to_mbar(val * 4); sample->pressure[0].mbar = psi_to_mbar(val * 4);
break; break;
case POSEIDON_DEPTH: case POSEIDON_DEPTH:
sample->depth.mm = lrint(val * 0.5 * 1000); sample->depth.mm = lrint(val * 0.5 * 1000);
@ -309,10 +309,10 @@ static void add_sample_data(struct sample *sample, enum csv_format type, double
sample->o2sensor[1].mbar = lrint(val * 10); sample->o2sensor[1].mbar = lrint(val * 10);
break; break;
case POSEIDON_PRESSURE: case POSEIDON_PRESSURE:
sample->cylinderpressure.mbar = lrint(val * 1000); sample->pressure[0].mbar = lrint(val * 1000);
break; break;
case POSEIDON_O2CYLINDER: case POSEIDON_O2CYLINDER:
sample->o2cylinderpressure.mbar = lrint(val * 1000); sample->pressure[1].mbar = lrint(val * 1000);
break; break;
case POSEIDON_NDL: case POSEIDON_NDL:
sample->ndl.seconds = lrint(val * 60); sample->ndl.seconds = lrint(val * 60);

View file

@ -249,12 +249,12 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
if (cyl < 0) if (cyl < 0)
return; // Can we do this?!? return; // Can we do this?!?
pressure = O2CYLINDER_PRESSURE(entry); pressure = O2CYLINDER_PRESSURE(entry);
save_pressure = &(entry->o2cylinderpressure[SENSOR_PR]); save_pressure = &(entry->pressure[1][SENSOR_PR]);
save_interpolated = &(entry->o2cylinderpressure[INTERPOLATED_PR]); save_interpolated = &(entry->pressure[1][INTERPOLATED_PR]);
} else { } else {
pressure = SENSOR_PRESSURE(entry); pressure = SENSOR_PRESSURE(entry);
save_pressure = &(entry->pressure[SENSOR_PR]); save_pressure = &(entry->pressure[0][SENSOR_PR]);
save_interpolated = &(entry->pressure[INTERPOLATED_PR]); save_interpolated = &(entry->pressure[0][INTERPOLATED_PR]);
cyl = entry->cylinderindex; cyl = entry->cylinderindex;
} }

View file

@ -354,14 +354,14 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
break; break;
case DC_SAMPLE_PRESSURE: case DC_SAMPLE_PRESSURE:
/* Do we already have a pressure reading? */ /* Do we already have a pressure reading? */
if (sample->cylinderpressure.mbar) { if (sample->pressure[0].mbar) {
/* Do we prefer the one we already have? */ /* Do we prefer the one we already have? */
/* If so, just ignore the new one */ /* If so, just ignore the new one */
if (sample->sensor == current_gas_index) if (sample->sensor == current_gas_index)
break; break;
} }
sample->sensor = value.pressure.tank; sample->sensor = value.pressure.tank;
sample->cylinderpressure.mbar = lrint(value.pressure.value * 1000); sample->pressure[0].mbar = lrint(value.pressure.value * 1000);
break; break;
case DC_SAMPLE_GASMIX: case DC_SAMPLE_GASMIX:
handle_gasmix(dc, sample, value.gasmix); handle_gasmix(dc, sample, value.gasmix);

View file

@ -335,7 +335,7 @@ static void parse_dives (int log_version, const unsigned char *buf, unsigned int
sample->depth.mm = array_uint16_le(ds + (d - 1) * 2) * 10; // cm->mm sample->depth.mm = array_uint16_le(ds + (d - 1) * 2) * 10; // cm->mm
sample->temperature.mkelvin = C_to_mkelvin((float) array_uint16_le(ts + (d - 1) * 2) / 10); // dC->mK sample->temperature.mkelvin = C_to_mkelvin((float) array_uint16_le(ts + (d - 1) * 2) / 10); // dC->mK
sample->sensor = event.pressure.sensor; sample->sensor = event.pressure.sensor;
sample->cylinderpressure.mbar = event.pressure.mbar; sample->pressure[0].mbar = event.pressure.mbar;
finish_sample(dc); finish_sample(dc);
break; break;
@ -353,7 +353,7 @@ static void parse_dives (int log_version, const unsigned char *buf, unsigned int
sample->depth.mm = depth_mm; sample->depth.mm = depth_mm;
sample->temperature.mkelvin = temp_mk; sample->temperature.mkelvin = temp_mk;
sample->sensor = event.pressure.sensor; sample->sensor = event.pressure.sensor;
sample->cylinderpressure.mbar = event.pressure.mbar; sample->pressure[0].mbar = event.pressure.mbar;
finish_sample(dc); finish_sample(dc);
d++; d++;
@ -361,7 +361,7 @@ static void parse_dives (int log_version, const unsigned char *buf, unsigned int
} else { // Event is prior to sample } else { // Event is prior to sample
sample->time.seconds = event.time; sample->time.seconds = event.time;
sample->sensor = event.pressure.sensor; sample->sensor = event.pressure.sensor;
sample->cylinderpressure.mbar = event.pressure.mbar; sample->pressure[0].mbar = event.pressure.mbar;
if (last_time == sample_time) { if (last_time == sample_time) {
sample->depth.mm = depth_mm; sample->depth.mm = depth_mm;
sample->temperature.mkelvin = temp_mk; sample->temperature.mkelvin = temp_mk;

View file

@ -540,7 +540,7 @@ static void parse_sample_keyvalue(void *_sample, const char *key, const char *va
} }
if (!strcmp(key, "o2pressure")) { if (!strcmp(key, "o2pressure")) {
pressure_t p = get_pressure(value); pressure_t p = get_pressure(value);
sample->o2cylinderpressure.mbar = p.mbar; sample->pressure[1].mbar = p.mbar;
return; return;
} }
if (!strcmp(key, "heartbeat")) { if (!strcmp(key, "heartbeat")) {
@ -574,7 +574,7 @@ static char *parse_sample_unit(struct sample *sample, double val, char *unit)
sample->depth.mm = lrint(1000*val); sample->depth.mm = lrint(1000*val);
break; break;
case 'b': case 'b':
sample->cylinderpressure.mbar = lrint(1000*val); sample->pressure[0].mbar = lrint(1000*val);
break; break;
default: default:
sample->temperature.mkelvin = C_to_mkelvin(val); sample->temperature.mkelvin = C_to_mkelvin(val);
@ -600,7 +600,7 @@ static struct sample *new_sample(struct divecomputer *dc)
struct sample *sample = prepare_sample(dc); struct sample *sample = prepare_sample(dc);
if (sample != dc->sample) { if (sample != dc->sample) {
memcpy(sample, sample-1, sizeof(struct sample)); memcpy(sample, sample-1, sizeof(struct sample));
sample->cylinderpressure.mbar = 0; sample->pressure[0].mbar = 0;
} }
return sample; return sample;
} }

View file

@ -712,7 +712,7 @@ static int divinglog_fill_sample(struct sample *sample, const char *name, char *
return MATCH("time.p", sampletime, &sample->time) || return MATCH("time.p", sampletime, &sample->time) ||
MATCH("depth.p", depth, &sample->depth) || MATCH("depth.p", depth, &sample->depth) ||
MATCH("temp.p", fahrenheit, &sample->temperature) || MATCH("temp.p", fahrenheit, &sample->temperature) ||
MATCH("press1.p", psi_or_bar, &sample->cylinderpressure) || MATCH("press1.p", psi_or_bar, &sample->pressure[0]) ||
0; 0;
} }
@ -731,7 +731,7 @@ static int uddf_fill_sample(struct sample *sample, const char *name, char *buf)
return MATCH("divetime", sampletime, &sample->time) || return MATCH("divetime", sampletime, &sample->time) ||
MATCH("depth", depth, &sample->depth) || MATCH("depth", depth, &sample->depth) ||
MATCH("temperature", temperature, &sample->temperature) || MATCH("temperature", temperature, &sample->temperature) ||
MATCH("tankpressure", pressure, &sample->cylinderpressure) || MATCH("tankpressure", pressure, &sample->pressure[0]) ||
MATCH("ref.switchmix", uddf_gasswitch, sample) || MATCH("ref.switchmix", uddf_gasswitch, sample) ||
0; 0;
} }
@ -927,13 +927,13 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu
int in_deco; int in_deco;
start_match("sample", name, buf); start_match("sample", name, buf);
if (MATCH("pressure.sample", pressure, &sample->cylinderpressure)) if (MATCH("pressure.sample", pressure, &sample->pressure[0]))
return; return;
if (MATCH("cylpress.sample", pressure, &sample->cylinderpressure)) if (MATCH("cylpress.sample", pressure, &sample->pressure[0]))
return; return;
if (MATCH("pdiluent.sample", pressure, &sample->cylinderpressure)) if (MATCH("pdiluent.sample", pressure, &sample->pressure[0]))
return; return;
if (MATCH("o2pressure.sample", pressure, &sample->o2cylinderpressure)) if (MATCH("o2pressure.sample", pressure, &sample->pressure[1]))
return; return;
if (MATCH("cylinderindex.sample", get_cylinderindex, &sample->sensor)) if (MATCH("cylinderindex.sample", get_cylinderindex, &sample->sensor))
return; return;
@ -2364,7 +2364,7 @@ extern int dm4_dive(void *param, int columns, char **data, char **column)
if (data[18] && data[18][0]) if (data[18] && data[18][0])
cur_sample->temperature.mkelvin = C_to_mkelvin(tempBlob[i]); cur_sample->temperature.mkelvin = C_to_mkelvin(tempBlob[i]);
if (data[19] && data[19][0]) if (data[19] && data[19][0])
cur_sample->cylinderpressure.mbar = pressureBlob[i]; cur_sample->pressure[0].mbar = pressureBlob[i];
sample_end(); sample_end();
} }
@ -2498,7 +2498,7 @@ extern int dm5_dive(void *param, int columns, char **data, char **column)
if (temp >= -10 && temp < 50) if (temp >= -10 && temp < 50)
cur_sample->temperature.mkelvin = C_to_mkelvin(temp); cur_sample->temperature.mkelvin = C_to_mkelvin(temp);
if (pressure >= 0 && pressure < 350000) if (pressure >= 0 && pressure < 350000)
cur_sample->cylinderpressure.mbar = pressure; cur_sample->pressure[0].mbar = pressure;
sample_end(); sample_end();
} }
@ -2526,7 +2526,7 @@ extern int dm5_dive(void *param, int columns, char **data, char **column)
if (data[18] && data[18][0]) if (data[18] && data[18][0])
cur_sample->temperature.mkelvin = C_to_mkelvin(tempBlob[i]); cur_sample->temperature.mkelvin = C_to_mkelvin(tempBlob[i]);
if (data[19] && data[19][0]) if (data[19] && data[19][0])
cur_sample->cylinderpressure.mbar = pressureBlob[i]; cur_sample->pressure[0].mbar = pressureBlob[i];
sample_end(); sample_end();
} }
} }
@ -2687,7 +2687,7 @@ extern int shearwater_profile_sample(void *handle, int columns, char **data, cha
/* We don't actually have data[3], but it should appear in the /* We don't actually have data[3], but it should appear in the
* SQL query at some point. * SQL query at some point.
if (data[3]) if (data[3])
cur_sample->cylinderpressure.mbar = metric ? atoi(data[3]) * 1000 : psi_to_mbar(atoi(data[3])); cur_sample->pressure[0].mbar = metric ? atoi(data[3]) * 1000 : psi_to_mbar(atoi(data[3]));
*/ */
sample_end(); sample_end();
@ -3137,7 +3137,7 @@ extern int divinglog_profile(void *handle, int columns, char **data, char **colu
if (data[2]) { if (data[2]) {
memcpy(pres, &data[2][i * 11 + 3], 4); memcpy(pres, &data[2][i * 11 + 3], 4);
cur_sample->cylinderpressure.mbar = atoi(pres) * 100; cur_sample->pressure[0].mbar = atoi(pres) * 100;
} }
if (data[3] && strlen(data[3])) { if (data[3] && strlen(data[3])) {

View file

@ -296,7 +296,7 @@ static void create_dive_from_plan(struct diveplan *diveplan, bool track_gas)
sample->sac.mliter = prefs.bottomsac; sample->sac.mliter = prefs.bottomsac;
oldpo2 = dp->setpoint; oldpo2 = dp->setpoint;
if (track_gas && cyl->type.workingpressure.mbar) if (track_gas && cyl->type.workingpressure.mbar)
sample->cylinderpressure.mbar = cyl->end.mbar; sample->pressure[0].mbar = cyl->end.mbar;
sample->manually_entered = true; sample->manually_entered = true;
finish_sample(dc); finish_sample(dc);
while (dp) { while (dp) {
@ -334,7 +334,7 @@ static void create_dive_from_plan(struct diveplan *diveplan, bool track_gas)
sample->manually_entered = dp->entered; sample->manually_entered = dp->entered;
sample->sac.mliter = dp->entered ? prefs.bottomsac : prefs.decosac; sample->sac.mliter = dp->entered ? prefs.bottomsac : prefs.decosac;
if (track_gas && cyl->type.workingpressure.mbar) if (track_gas && cyl->type.workingpressure.mbar)
sample->cylinderpressure.mbar = cyl->sample_end.mbar; sample->pressure[0].mbar = cyl->sample_end.mbar;
finish_sample(dc); finish_sample(dc);
lastcylid = dp->cylinderid; lastcylid = dp->cylinderid;
} }
@ -352,7 +352,7 @@ static void create_dive_from_plan(struct diveplan *diveplan, bool track_gas)
update_cylinder_pressure(&displayed_dive, sample[-1].depth.mm, depth.mm, time - sample[-1].time.seconds, update_cylinder_pressure(&displayed_dive, sample[-1].depth.mm, depth.mm, time - sample[-1].time.seconds,
dp->entered ? diveplan->bottomsac : diveplan->decosac, cyl, !dp->entered); dp->entered ? diveplan->bottomsac : diveplan->decosac, cyl, !dp->entered);
if (cyl->type.workingpressure.mbar) if (cyl->type.workingpressure.mbar)
sample->cylinderpressure.mbar = cyl->end.mbar; sample->pressure[0].mbar = cyl->end.mbar;
} }
finish_sample(dc); finish_sample(dc);
dp = dp->next; dp = dp->next;

View file

@ -370,7 +370,7 @@ static int set_cylinder_index(struct plot_info *pi, int i, int cylinderindex, in
break; break;
if (entry->cylinderindex != cylinderindex) { if (entry->cylinderindex != cylinderindex) {
entry->cylinderindex = cylinderindex; entry->cylinderindex = cylinderindex;
entry->pressure[0] = 0; entry->pressure[0][0] = 0;
} }
i++; i++;
} }
@ -478,7 +478,7 @@ struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer
while (--i >= 0) { while (--i >= 0) {
int depth = s->depth.mm; int depth = s->depth.mm;
int pressure = s->cylinderpressure.mbar; int pressure = s->pressure[0].mbar;
int temperature = s->temperature.mkelvin; int temperature = s->temperature.mkelvin;
int heartbeat = s->heartbeat; int heartbeat = s->heartbeat;
@ -641,8 +641,8 @@ struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer *
} }
/* FIXME! sensor index -> cylinder index translation! */ /* FIXME! sensor index -> cylinder index translation! */
// entry->cylinderindex = sample->sensor; // entry->cylinderindex = sample->sensor;
SENSOR_PRESSURE(entry) = sample->cylinderpressure.mbar; SENSOR_PRESSURE(entry) = sample->pressure[0].mbar;
O2CYLINDER_PRESSURE(entry) = sample->o2cylinderpressure.mbar; O2CYLINDER_PRESSURE(entry) = sample->pressure[1].mbar;
if (sample->temperature.mkelvin) if (sample->temperature.mkelvin)
entry->temperature = lasttemp = sample->temperature.mkelvin; entry->temperature = lasttemp = sample->temperature.mkelvin;
else else

View file

@ -23,12 +23,13 @@ struct plot_data {
unsigned int in_deco : 1; unsigned int in_deco : 1;
int cylinderindex; int cylinderindex;
int sec; int sec;
/* pressure[0] is sensor cylinder pressure [when CCR, the pressure of the diluent cylinder] /* pressure[0] is main sensor pressure (diluent for CCR)
* pressure[1] is interpolated cylinder pressure */ * pressure[1] is secondary sensor pressure (O2 for CCR)
int pressure[2]; *
/* o2pressure[0] is o2 cylinder pressure [CCR] * pressure[x][0] is sensor pressure
* o2pressure[1] is interpolated o2 cylinder pressure [CCR] */ * pressure[x][1] is interpolated pressure
int o2cylinderpressure[2]; */
int pressure[2][2];
int temperature; int temperature;
/* Depth info */ /* Depth info */
int depth; int depth;
@ -97,11 +98,11 @@ int get_maxdepth(struct plot_info *pi);
#define SENSOR_PR 0 #define SENSOR_PR 0
#define INTERPOLATED_PR 1 #define INTERPOLATED_PR 1
#define SENSOR_PRESSURE(_entry) (_entry)->pressure[SENSOR_PR] #define SENSOR_PRESSURE(_entry) (_entry)->pressure[0][SENSOR_PR]
#define O2CYLINDER_PRESSURE(_entry) (_entry)->o2cylinderpressure[SENSOR_PR] #define O2CYLINDER_PRESSURE(_entry) (_entry)->pressure[1][SENSOR_PR]
#define CYLINDER_PRESSURE(_o2, _entry) (_o2 ? O2CYLINDER_PRESSURE(_entry) : SENSOR_PRESSURE(_entry)) #define CYLINDER_PRESSURE(_o2, _entry) (_o2 ? O2CYLINDER_PRESSURE(_entry) : SENSOR_PRESSURE(_entry))
#define INTERPOLATED_PRESSURE(_entry) (_entry)->pressure[INTERPOLATED_PR] #define INTERPOLATED_PRESSURE(_entry) (_entry)->pressure[0][INTERPOLATED_PR]
#define INTERPOLATED_O2CYLINDER_PRESSURE(_entry) (_entry)->o2cylinderpressure[INTERPOLATED_PR] #define INTERPOLATED_O2CYLINDER_PRESSURE(_entry) (_entry)->pressure[1][INTERPOLATED_PR]
#define GET_PRESSURE(_entry) (SENSOR_PRESSURE(_entry) ? SENSOR_PRESSURE(_entry) : INTERPOLATED_PRESSURE(_entry)) #define GET_PRESSURE(_entry) (SENSOR_PRESSURE(_entry) ? SENSOR_PRESSURE(_entry) : INTERPOLATED_PRESSURE(_entry))
#define GET_O2CYLINDER_PRESSURE(_entry) (O2CYLINDER_PRESSURE(_entry) ? O2CYLINDER_PRESSURE(_entry) : INTERPOLATED_O2CYLINDER_PRESSURE(_entry)) #define GET_O2CYLINDER_PRESSURE(_entry) (O2CYLINDER_PRESSURE(_entry) ? O2CYLINDER_PRESSURE(_entry) : INTERPOLATED_O2CYLINDER_PRESSURE(_entry))
#define SAC_WINDOW 45 /* sliding window in seconds for current SAC calculation */ #define SAC_WINDOW 45 /* sliding window in seconds for current SAC calculation */

View file

@ -246,14 +246,14 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
put_format(b, "%3u:%02u", FRACTION(sample->time.seconds, 60)); put_format(b, "%3u:%02u", FRACTION(sample->time.seconds, 60));
put_milli(b, " ", sample->depth.mm, "m"); put_milli(b, " ", sample->depth.mm, "m");
put_temperature(b, sample->temperature, " ", "°C"); put_temperature(b, sample->temperature, " ", "°C");
put_pressure(b, sample->cylinderpressure, " ", "bar"); put_pressure(b, sample->pressure[0], " ", "bar");
put_pressure(b, sample->o2cylinderpressure," o2pressure=","bar"); put_pressure(b, sample->pressure[1]," o2pressure=","bar");
/* /*
* We only show sensor information for samples with pressure, and only if it * We only show sensor information for samples with pressure, and only if it
* changed from the previous sensor we showed. * changed from the previous sensor we showed.
*/ */
if (sample->cylinderpressure.mbar && sample->sensor != old->sensor) { if (sample->pressure[0].mbar && sample->sensor != old->sensor) {
put_format(b, " sensor=%d", sample->sensor); put_format(b, " sensor=%d", sample->sensor);
old->sensor = sample->sensor; old->sensor = sample->sensor;
} }

View file

@ -175,7 +175,7 @@ void put_HTML_samples(struct membuffer *b, struct dive *dive)
char *separator = "\"samples\":["; char *separator = "\"samples\":[";
for (i = 0; i < dive->dc.samples; i++) { for (i = 0; i < dive->dc.samples; i++) {
put_format(b, "%s[%d,%d,%d,%d]", separator, s->time.seconds, s->depth.mm, s->cylinderpressure.mbar, s->temperature.mkelvin); put_format(b, "%s[%d,%d,%d,%d]", separator, s->time.seconds, s->depth.mm, s->pressure[0].mbar, s->temperature.mkelvin);
separator = ", "; separator = ", ";
s++; s++;
} }

View file

@ -200,14 +200,14 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
put_temperature(b, sample->temperature, " temp='", " C'"); put_temperature(b, sample->temperature, " temp='", " C'");
old->temperature = sample->temperature; old->temperature = sample->temperature;
} }
put_pressure(b, sample->cylinderpressure, " pressure='", " bar'"); put_pressure(b, sample->pressure[0], " pressure='", " bar'");
put_pressure(b, sample->o2cylinderpressure, " o2pressure='", " bar'"); put_pressure(b, sample->pressure[1], " o2pressure='", " bar'");
/* /*
* We only show sensor information for samples with pressure, and only if it * We only show sensor information for samples with pressure, and only if it
* changed from the previous sensor we showed. * changed from the previous sensor we showed.
*/ */
if (sample->cylinderpressure.mbar && sample->sensor != old->sensor) { if (sample->pressure[0].mbar && sample->sensor != old->sensor) {
put_format(b, " sensor='%d'", sample->sensor); put_format(b, " sensor='%d'", sample->sensor);
old->sensor = sample->sensor; old->sensor = sample->sensor;
} }

View file

@ -360,7 +360,7 @@ void uemis_parse_divelog_binary(char *base64, void *datap)
sample->depth.mm = rel_mbar_to_depth(u_sample->water_pressure, dive); sample->depth.mm = rel_mbar_to_depth(u_sample->water_pressure, dive);
sample->temperature.mkelvin = C_to_mkelvin(u_sample->dive_temperature / 10.0); sample->temperature.mkelvin = C_to_mkelvin(u_sample->dive_temperature / 10.0);
sample->sensor = active; sample->sensor = active;
sample->cylinderpressure.mbar = sample->pressure[0].mbar =
(u_sample->tank_pressure_high * 256 + u_sample->tank_pressure_low) * 10; (u_sample->tank_pressure_high * 256 + u_sample->tank_pressure_low) * 10;
sample->cns = u_sample->cns; sample->cns = u_sample->cns;
uemis_event(dive, dc, sample, u_sample); uemis_event(dive, dc, sample, u_sample);

View file

@ -32,7 +32,7 @@ QVariant DivePlotDataModel::data(const QModelIndex &index, int role) const
case TIME: case TIME:
return item.sec; return item.sec;
case PRESSURE: case PRESSURE:
return item.pressure[0]; return item.pressure[0][0];
case TEMPERATURE: case TEMPERATURE:
return item.temperature; return item.temperature;
case COLOR: case COLOR:
@ -42,9 +42,9 @@ QVariant DivePlotDataModel::data(const QModelIndex &index, int role) const
case CYLINDERINDEX: case CYLINDERINDEX:
return item.cylinderindex; return item.cylinderindex;
case SENSOR_PRESSURE: case SENSOR_PRESSURE:
return item.pressure[0]; return item.pressure[0][0];
case INTERPOLATED_PRESSURE: case INTERPOLATED_PRESSURE:
return item.pressure[1]; return item.pressure[0][1];
case CEILING: case CEILING:
return item.ceiling; return item.ceiling;
case SAC: case SAC: