mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: introduce a few user-defined literals for unit types
Thise makes initialization of unit types more palatable. For example: surface.time = sample.time - duration_t { .seconds = 20 }; => surface.time = sample.time - 20_sec; delta_depth.mm = feet_to_mm(1.0); // 1ft => delta_depth = 1_ft; get_cylinderid_at_time(..., { .seconds = 20 * 60 + 1 })); => get_cylinderid_at_time(..., 20_min + 1_sec)); Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f09601bc93
commit
ae81b42fe2
36 changed files with 320 additions and 264 deletions
|
@ -239,19 +239,19 @@ static char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive, struct
|
|||
read_bytes(1);
|
||||
switch (tmp_1byte) {
|
||||
case 1:
|
||||
dt_dive->dcs[0].surface_pressure.mbar = 1013;
|
||||
dt_dive->dcs[0].surface_pressure = 1_atm;
|
||||
break;
|
||||
case 2:
|
||||
dt_dive->dcs[0].surface_pressure.mbar = 932;
|
||||
dt_dive->dcs[0].surface_pressure = 932_mbar;
|
||||
break;
|
||||
case 3:
|
||||
dt_dive->dcs[0].surface_pressure.mbar = 828;
|
||||
dt_dive->dcs[0].surface_pressure = 828_mbar;
|
||||
break;
|
||||
case 4:
|
||||
dt_dive->dcs[0].surface_pressure.mbar = 735;
|
||||
dt_dive->dcs[0].surface_pressure = 735_mbar;
|
||||
break;
|
||||
default:
|
||||
dt_dive->dcs[0].surface_pressure.mbar = 1013;
|
||||
dt_dive->dcs[0].surface_pressure = 1_atm;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -336,9 +336,9 @@ static char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive, struct
|
|||
cylinder_t cyl;
|
||||
cyl.type.size.mliter = tmp_2bytes * 10;
|
||||
cyl.type.description = cyl_type_by_size(tmp_2bytes * 10);
|
||||
cyl.start.mbar = 200000;
|
||||
cyl.gasmix.he.permille = 0;
|
||||
cyl.gasmix.o2.permille = 210;
|
||||
cyl.start = 200_bar;
|
||||
cyl.gasmix.he = 0_percent;
|
||||
cyl.gasmix.o2 = 21_percent;
|
||||
cyl.manually_added = true;
|
||||
dt_dive->cylinders.push_back(std::move(cyl));
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ static char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive, struct
|
|||
if (tmp_2bytes != 0x7fff)
|
||||
dt_dive->watertemp.mkelvin = dt_dive->dcs[0].watertemp.mkelvin = C_to_mkelvin((double)(tmp_2bytes / 100));
|
||||
else
|
||||
dt_dive->watertemp.mkelvin = 0;
|
||||
dt_dive->watertemp = 0_K;
|
||||
|
||||
/*
|
||||
* Air used in bar*100.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue