Mercurial > public > hwos_code
comparison src/p2_deco.c @ 646:5b7fe7777425
3.16 release
author | heinrichs weikamp |
---|---|
date | Thu, 14 Oct 2021 12:03:24 +0200 |
parents | 8c1f1f334275 |
children | 1e695355dfc4 |
comparison
equal
deleted
inserted
replaced
642:a9a0188091e4 | 646:5b7fe7777425 |
---|---|
126 #define ppWater 0.06270 // water vapor partial pressure in the lungs | 126 #define ppWater 0.06270 // water vapor partial pressure in the lungs |
127 #define METER_TO_BAR 0.09807 // conversion factor (1 m water column = 0.09807 bar) | 127 #define METER_TO_BAR 0.09807 // conversion factor (1 m water column = 0.09807 bar) |
128 #define BAR_TO_METER 10.19716 // conversion factor (1 bar = 10.19716 m ) | 128 #define BAR_TO_METER 10.19716 // conversion factor (1 bar = 10.19716 m ) |
129 #define SURFACE_DESAT_FACTOR 0.70420 // surface desaturation safety factor | 129 #define SURFACE_DESAT_FACTOR 0.70420 // surface desaturation safety factor |
130 #define HYST 1.0E-06 // threshold for tissue graphics on-gassing / off-gassing visualization | 130 #define HYST 1.0E-06 // threshold for tissue graphics on-gassing / off-gassing visualization |
131 #define GAS_DENSITY_He_FACTOR 17.64 // in multiples of 0.01 grams per liter | |
132 #define GAS_DENSITY_N2_FACTOR 123.46 // in multiples of 0.01 grams per liter | |
133 #define GAS_DENSITY_O2_FACTOR 141.02 // in multiples of 0.01 grams per liter | |
131 | 134 |
132 // thresholds | 135 // thresholds |
133 #define CNS_LIMIT_WARNING 100 // threshold for CNS warning | 136 #define CNS_LIMIT_WARNING 100 // threshold for CNS warning |
134 #define CNS_LIMIT_ATTENTION 70 // threshold for CNS attention | 137 #define CNS_LIMIT_ATTENTION 70 // threshold for CNS attention |
135 #define PRESSURE_LIMIT_WARNING 200 // threshold for pressure reading warning : 20.0 bar | 138 #define PRESSURE_LIMIT_WARNING 200 // threshold for pressure reading warning : 20.0 bar |
136 #define PRESSURE_LIMIT_ATTENTION 500 // threshold for pressure reading attention: 50.0 bar | 139 #define PRESSURE_LIMIT_ATTENTION 500 // threshold for pressure reading attention: 50.0 bar |
137 #define GAS_NEEDS_ATTENTION 0.7 // threshold for gas needs attention [1 = 100%] | 140 #define GAS_NEEDS_ATTENTION 0.7 // threshold for gas needs attention [1 = 100%] |
138 #define O2_CONSUMPTION_LIMIT_ATTENTION 20 // threshold for O2 "SAC" attention: 2.0 l/min | 141 #define O2_CONSUMPTION_LIMIT_ATTENTION 20 // threshold for O2 "SAC" attention: 2.0 l/min |
139 #define ppO2_GAP_TO_SETPOINT 10 // gap between setpoint and max. ppO2 of the pure diluent [cbar] | 142 #define ppO2_GAP_TO_SETPOINT 20 // gap between setpoint and max. ppO2 of the pure diluent [cbar] |
140 #define ppO2_MARGIN_ON_MAX 3 // [cbar] margin on ppO2 max to compensate for surface pressures > 1.000 mbar | 143 #define ppO2_MARGIN_ON_MAX 3 // [cbar] margin on ppO2 max to compensate for surface pressures > 1.000 mbar |
141 #define STOP_CHAINING_LIMIT 3 // max. number of chained stop table entries before deco calculation is aborted | 144 #define STOP_CHAINING_LIMIT 3 // max. number of chained stop table entries before deco calculation is aborted |
145 | |
142 | 146 |
143 | 147 |
144 // deco engine states and modes - (char_O_)main_status: controls current tissue and deco status calculation (as-is situation) | 148 // deco engine states and modes - (char_O_)main_status: controls current tissue and deco status calculation (as-is situation) |
145 #define CALC_VOLUME 0x01 // =1: calculate gas needs | 149 #define CALC_VOLUME 0x01 // =1: calculate gas needs |
146 #define CALCULATE_BOTTOM 0x02 // =1: calculate gas needs in deco calculator mode, =0: in dive mode | 150 #define CALCULATE_BOTTOM 0x02 // =1: calculate gas needs in deco calculator mode, =0: in dive mode |
1573 // | 1577 // |
1574 // Return value is TRUE if a better gas is available | 1578 // Return value is TRUE if a better gas is available |
1575 // | 1579 // |
1576 static unsigned char gas_find_best(void) | 1580 static unsigned char gas_find_best(void) |
1577 { | 1581 { |
1578 overlay unsigned char switch_depth = 255; | 1582 overlay unsigned char switch_depth = sim_gas_current_depth; |
1579 overlay unsigned char switch_gas = 0; | 1583 overlay unsigned char switch_gas = 0; |
1580 | 1584 |
1581 | 1585 |
1582 // loop over all gases to find the shallowest one below or at current depth | 1586 // loop over all gases to find the shallowest one below or at current depth |
1583 for( j = 0; j < NUM_GAS; ++j ) | 1587 for( j = 0; j < NUM_GAS; ++j ) |
1941 if( tissue_increment & TISSUE_SELECTOR ) | 1945 if( tissue_increment & TISSUE_SELECTOR ) |
1942 { | 1946 { |
1943 overlay unsigned char temp; | 1947 overlay unsigned char temp; |
1944 | 1948 |
1945 // compute gas density of current mix in multiples of 0.01 grams per liter | 1949 // compute gas density of current mix in multiples of 0.01 grams per liter |
1946 int_O_gas_density = (unsigned int)( 17.9 * ppHe + 125.1 * ppN2 + 142.8 * ppO2 ); | 1950 int_O_gas_density = (unsigned int)( GAS_DENSITY_He_FACTOR * ppHe + GAS_DENSITY_N2_FACTOR * ppN2 + GAS_DENSITY_O2_FACTOR * ppO2 ); |
1947 | 1951 |
1948 // convert gas density into an 8 bit integer, scaling 0.1 grams per liter | 1952 // convert gas density into an 8 bit integer, scaling 0.1 grams per liter |
1949 temp = (unsigned char)( (int_O_gas_density + 9) / 10 ); | 1953 temp = (unsigned char)( (int_O_gas_density + 9) / 10 ); |
1950 | 1954 |
1951 // limit to display max and set warning or attention flag | 1955 // limit to display max and set warning or attention flag |