mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Merge branch 'master' of https://github.com/dje29/subsurface
This commit is contained in:
commit
08284275e7
31 changed files with 210 additions and 201 deletions
|
|
@ -117,8 +117,8 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
|||
if (i >= MAX_CYLINDERS)
|
||||
continue;
|
||||
|
||||
o2 = rint(gasmix.oxygen * 1000);
|
||||
he = rint(gasmix.helium * 1000);
|
||||
o2 = lrint(gasmix.oxygen * 1000);
|
||||
he = lrint(gasmix.helium * 1000);
|
||||
|
||||
/* Ignore bogus data - libdivecomputer does some crazy stuff */
|
||||
if (o2 + he <= O2_IN_AIR || o2 > 1000) {
|
||||
|
|
@ -149,8 +149,8 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
|||
if (rc == DC_STATUS_SUCCESS) {
|
||||
cylinder_t *cyl = dive->cylinder + i;
|
||||
|
||||
cyl->type.size.mliter = rint(tank.volume * 1000);
|
||||
cyl->type.workingpressure.mbar = rint(tank.workpressure * 1000);
|
||||
cyl->type.size.mliter = lrint(tank.volume * 1000);
|
||||
cyl->type.workingpressure.mbar = lrint(tank.workpressure * 1000);
|
||||
|
||||
cyl->cylinder_use = OC_GAS;
|
||||
if (tank.type & DC_TANKINFO_CC_O2)
|
||||
|
|
@ -166,10 +166,11 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
|||
* First, the pressures are off by a constant factor. WTF?
|
||||
* Then we can round the wet sizes so we get to multiples of 10
|
||||
* for cuft sizes (as that's all that you can enter) */
|
||||
dive->cylinder[i].type.workingpressure.mbar *= 206.843 / 206.7;
|
||||
dive->cylinder[i].type.workingpressure.mbar = lrint(
|
||||
dive->cylinder[i].type.workingpressure.mbar * 206.843 / 206.7 );
|
||||
char name_buffer[9];
|
||||
int rounded_size = ml_to_cuft(gas_volume(&dive->cylinder[i],
|
||||
dive->cylinder[i].type.workingpressure));
|
||||
int rounded_size = lrint(ml_to_cuft(gas_volume(&dive->cylinder[i],
|
||||
dive->cylinder[i].type.workingpressure)));
|
||||
rounded_size = (int)((rounded_size + 5) / 10) * 10;
|
||||
switch (dive->cylinder[i].type.workingpressure.mbar) {
|
||||
case 206843:
|
||||
|
|
@ -189,8 +190,8 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
|||
break;
|
||||
}
|
||||
dive->cylinder[i].type.description = copy_string(name_buffer);
|
||||
dive->cylinder[i].type.size.mliter = cuft_to_l(rounded_size) * 1000 /
|
||||
mbar_to_atm(dive->cylinder[i].type.workingpressure.mbar);
|
||||
dive->cylinder[i].type.size.mliter = lrint(cuft_to_l(rounded_size) * 1000 /
|
||||
mbar_to_atm(dive->cylinder[i].type.workingpressure.mbar));
|
||||
}
|
||||
}
|
||||
if (tank.gasmix != i) { // we don't handle this, yet
|
||||
|
|
@ -203,8 +204,8 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
|||
|
||||
// this new API also gives us the beginning and end pressure for the tank
|
||||
if (!IS_FP_SAME(tank.beginpressure, 0.0) && !IS_FP_SAME(tank.endpressure, 0.0)) {
|
||||
dive->cylinder[i].start.mbar = tank.beginpressure * 1000;
|
||||
dive->cylinder[i].end.mbar = tank.endpressure * 1000;
|
||||
dive->cylinder[i].start.mbar = lrint(tank.beginpressure * 1000);
|
||||
dive->cylinder[i].end.mbar = lrint(tank.endpressure * 1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -330,7 +331,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
|||
finish_sample(dc);
|
||||
break;
|
||||
case DC_SAMPLE_DEPTH:
|
||||
sample->depth.mm = rint(value.depth * 1000);
|
||||
sample->depth.mm = lrint(value.depth * 1000);
|
||||
break;
|
||||
case DC_SAMPLE_PRESSURE:
|
||||
/* Do we already have a pressure reading? */
|
||||
|
|
@ -341,7 +342,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
|||
break;
|
||||
}
|
||||
sample->sensor = value.pressure.tank;
|
||||
sample->cylinderpressure.mbar = rint(value.pressure.value * 1000);
|
||||
sample->cylinderpressure.mbar = lrint(value.pressure.value * 1000);
|
||||
break;
|
||||
case DC_SAMPLE_GASMIX:
|
||||
handle_gasmix(dc, sample, value.gasmix);
|
||||
|
|
@ -373,11 +374,11 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
|||
#if DC_VERSION_CHECK(0, 3, 0)
|
||||
case DC_SAMPLE_SETPOINT:
|
||||
/* for us a setpoint means constant pO2 from here */
|
||||
sample->setpoint.mbar = po2 = rint(value.setpoint * 1000);
|
||||
sample->setpoint.mbar = po2 = lrint(value.setpoint * 1000);
|
||||
break;
|
||||
case DC_SAMPLE_PPO2:
|
||||
if (nsensor < 3)
|
||||
sample->o2sensor[nsensor].mbar = rint(value.ppo2 * 1000);
|
||||
sample->o2sensor[nsensor].mbar = lrint(value.ppo2 * 1000);
|
||||
else
|
||||
report_error("%d is more o2 sensors than we can handle", nsensor);
|
||||
nsensor++;
|
||||
|
|
@ -386,22 +387,22 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
|||
dc->no_o2sensors = nsensor;
|
||||
break;
|
||||
case DC_SAMPLE_CNS:
|
||||
sample->cns = cns = rint(value.cns * 100);
|
||||
sample->cns = cns = lrint(value.cns * 100);
|
||||
break;
|
||||
case DC_SAMPLE_DECO:
|
||||
if (value.deco.type == DC_DECO_NDL) {
|
||||
sample->ndl.seconds = ndl = value.deco.time;
|
||||
sample->stopdepth.mm = stopdepth = rint(value.deco.depth * 1000.0);
|
||||
sample->stopdepth.mm = stopdepth = lrint(value.deco.depth * 1000.0);
|
||||
sample->in_deco = in_deco = false;
|
||||
} else if (value.deco.type == DC_DECO_DECOSTOP ||
|
||||
value.deco.type == DC_DECO_DEEPSTOP) {
|
||||
sample->in_deco = in_deco = true;
|
||||
sample->stopdepth.mm = stopdepth = rint(value.deco.depth * 1000.0);
|
||||
sample->stopdepth.mm = stopdepth = lrint(value.deco.depth * 1000.0);
|
||||
sample->stoptime.seconds = stoptime = value.deco.time;
|
||||
ndl = 0;
|
||||
} else if (value.deco.type == DC_DECO_SAFETYSTOP) {
|
||||
sample->in_deco = in_deco = false;
|
||||
sample->stopdepth.mm = stopdepth = rint(value.deco.depth * 1000.0);
|
||||
sample->stopdepth.mm = stopdepth = lrint(value.deco.depth * 1000.0);
|
||||
sample->stoptime.seconds = stoptime = value.deco.time;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -627,7 +628,7 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, struct device_data_t
|
|||
return rc;
|
||||
}
|
||||
if (rc == DC_STATUS_SUCCESS)
|
||||
dive->dc.maxdepth.mm = rint(maxdepth * 1000);
|
||||
dive->dc.maxdepth.mm = lrint(maxdepth * 1000);
|
||||
|
||||
#if DC_VERSION_CHECK(0, 5, 0) && defined(DC_GASMIX_UNKNOWN)
|
||||
// if this is defined then we have a fairly late version of libdivecomputer
|
||||
|
|
@ -678,7 +679,7 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, struct device_data_t
|
|||
return rc;
|
||||
}
|
||||
if (rc == DC_STATUS_SUCCESS)
|
||||
dive->dc.salinity = rint(salinity.density * 10.0);
|
||||
dive->dc.salinity = lrint(salinity.density * 10.0);
|
||||
|
||||
double surface_pressure = 0;
|
||||
rc = dc_parser_get_field(parser, DC_FIELD_ATMOSPHERIC, 0, &surface_pressure);
|
||||
|
|
@ -687,7 +688,7 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, struct device_data_t
|
|||
return rc;
|
||||
}
|
||||
if (rc == DC_STATUS_SUCCESS)
|
||||
dive->dc.surface_pressure.mbar = rint(surface_pressure * 1000.0);
|
||||
dive->dc.surface_pressure.mbar = lrint(surface_pressure * 1000.0);
|
||||
#endif
|
||||
|
||||
#ifdef DC_FIELD_STRING
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue