Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 168:494587193f5d
Use 16bits for TTS sum.
+ Display in divemode as 16bits.
+ Display in decoplanning as 16bits.
author | JeanDo |
---|---|
date | Tue, 25 Jan 2011 01:02:35 +0100 |
parents | cb055a7d75f3 |
children | e26f49674956 |
comparison
equal
deleted
inserted
replaced
167:cb055a7d75f3 | 168:494587193f5d |
---|---|
63 // 05/23/10 v109: 5 gas changes & 1 min timer | 63 // 05/23/10 v109: 5 gas changes & 1 min timer |
64 // 07/13/10 v110: cns vault added | 64 // 07/13/10 v110: cns vault added |
65 // 12/25/10 v110: split in three files (deco.c, main.c, definitions.h) | 65 // 12/25/10 v110: split in three files (deco.c, main.c, definitions.h) |
66 // 2011/01/20: [jDG] Create a common file included in ASM and C code. | 66 // 2011/01/20: [jDG] Create a common file included in ASM and C code. |
67 // 2011/01/23: [jDG] Added read_custom_function(). | 67 // 2011/01/23: [jDG] Added read_custom_function(). |
68 // + Make int_O_ascenttime an int. | |
68 // | 69 // |
69 // TODO: | 70 // TODO: |
70 // + Make char_O_ascenttime an int. | |
71 // + Fusion deco array for both models. | 71 // + Fusion deco array for both models. |
72 // + Allow (CF) revesring stop order (while copying). | 72 // + Allow (CF) revesring stop order (while copying). |
73 // + Allow (CF) delay for gas switch while predicting ascent. | 73 // + Allow (CF) delay for gas switch while predicting ascent. |
74 // + Allow to abort MD2 calculation (have to restart next time). | 74 // + Allow to abort MD2 calculation (have to restart next time). |
75 // | 75 // |
141 static float temp_pres_gtissue; | 141 static float temp_pres_gtissue; |
142 static float temp_pres_gtissue_diff; | 142 static float temp_pres_gtissue_diff; |
143 static float temp_pres_gtissue_limit_GF_low; | 143 static float temp_pres_gtissue_limit_GF_low; |
144 static float temp_pres_gtissue_limit_GF_low_below_surface; | 144 static float temp_pres_gtissue_limit_GF_low_below_surface; |
145 static unsigned int temp_depth_limit; | 145 static unsigned int temp_depth_limit; |
146 static unsigned char temp_decotime; | |
147 static unsigned char temp_gtissue_no; | 146 static unsigned char temp_gtissue_no; |
148 static unsigned int temp_depth_last_deco; // new in v.101 | 147 static unsigned int temp_depth_last_deco; // new in v.101 |
149 | 148 |
150 static unsigned char temp_depth_GF_low_meter; | 149 static unsigned char temp_depth_GF_low_meter; |
151 static unsigned char internal_deco_pointer; | 150 static unsigned char internal_deco_pointer; |
934 } // for 0 to 16 | 933 } // for 0 to 16 |
935 | 934 |
936 clear_decoarray(); | 935 clear_decoarray(); |
937 char_O_deco_status = 0; | 936 char_O_deco_status = 0; |
938 char_O_nullzeit = 0; | 937 char_O_nullzeit = 0; |
939 char_O_ascenttime = 0; | 938 int_O_ascenttime = 0; |
940 char_O_gradient_factor = 0; | 939 char_O_gradient_factor = 0; |
941 char_O_relative_gradient_GF = 0; | 940 char_O_relative_gradient_GF = 0; |
942 } | 941 } |
943 | 942 |
944 ////////////////////////////////////////////////////////////////////////////// | 943 ////////////////////////////////////////////////////////////////////////////// |
962 calc_tissue_2_secs(); // update the pressure in the 32 tissues in accordance with the new ambient pressure | 961 calc_tissue_2_secs(); // update the pressure in the 32 tissues in accordance with the new ambient pressure |
963 | 962 |
964 clear_decoarray(); | 963 clear_decoarray(); |
965 char_O_deco_status = 0; | 964 char_O_deco_status = 0; |
966 char_O_nullzeit = 0; | 965 char_O_nullzeit = 0; |
967 char_O_ascenttime = 0; | 966 int_O_ascenttime = 0; |
968 calc_gradient_factor(); | 967 calc_gradient_factor(); |
969 } | 968 } |
970 | 969 |
971 ////////////////////////////////////////////////////////////////////////////// | 970 ////////////////////////////////////////////////////////////////////////////// |
972 // calc_hauptroutine | 971 // calc_hauptroutine |
1257 temp_atem = 0.0; // new in v.101 | 1256 temp_atem = 0.0; // new in v.101 |
1258 temp2_atem = 0.0; // new in v.101 | 1257 temp2_atem = 0.0; // new in v.101 |
1259 } | 1258 } |
1260 sim_tissue_1min(); | 1259 sim_tissue_1min(); |
1261 update_internal_deco_table_GF(); | 1260 update_internal_deco_table_GF(); |
1262 temp_decotime = 1; | |
1263 update_decoarray(); | 1261 update_decoarray(); |
1264 char_O_deco_status = char_O_deco_status + 1; | 1262 char_O_deco_status = char_O_deco_status + 1; |
1265 if (char_O_deco_status < 16) | 1263 if (char_O_deco_status < 16) |
1266 int_temp_decostatus = 1; | 1264 int_temp_decostatus = 1; |
1267 } | 1265 } |
1268 else // if (temp_depth_limit > 0) | 1266 else // if (temp_depth_limit > 0) |
1269 { | 1267 { |
1270 char_O_deco_status = 0; | 1268 char_O_deco_status = 0; |
1271 } | 1269 } |
1272 } while (int_temp_decostatus == 1); | 1270 } while (int_temp_decostatus == 1); |
1273 | 1271 |
1274 if (char_O_deco_status > 15) | 1272 if (char_O_deco_status > 15) |
1275 { | 1273 { |
1337 calc_He_ratio = deco_He_ratio5; | 1335 calc_He_ratio = deco_He_ratio5; |
1338 } | 1336 } |
1339 } | 1337 } |
1340 else // new in v.101 | 1338 else // new in v.101 |
1341 { | 1339 { |
1342 if (temp_deco > deco_ppO2_change) | 1340 if (temp_deco > deco_ppO2_change) |
1343 deco_diluent = ((temp_deco - const_ppO2)/(N2_ratio + He_ratio)); // new in v.101 // calculate at half of the ascent | 1341 deco_diluent = ((temp_deco - const_ppO2)/(N2_ratio + He_ratio)); // new in v.101 // calculate at half of the ascent |
1344 else | 1342 else |
1345 deco_diluent = ((temp_deco - deco_ppO2)/(N2_ratio + He_ratio)); // new in v.101 // calculate at half of the ascent | 1343 deco_diluent = ((temp_deco - deco_ppO2)/(N2_ratio + He_ratio)); // new in v.101 // calculate at half of the ascent |
1346 if (deco_diluent > (temp_deco)) // new in v.101 | 1344 if (deco_diluent > (temp_deco)) // new in v.101 |
1347 deco_diluent = temp_deco; // new in v.101 // calculate at half of the ascent | 1345 deco_diluent = temp_deco; // new in v.101 // calculate at half of the ascent |
1348 } | 1346 } |
1349 temp_deco -= 0.5; | 1347 temp_deco -= 0.5; |
1350 if (deco_diluent > 0.0627) // new in v.101 | 1348 if (deco_diluent > 0.0627) // new in v.101 |
1351 { | 1349 { |
1352 temp_atem = calc_N2_ratio * (deco_diluent - 0.0627); // changed in v.101 | 1350 temp_atem = calc_N2_ratio * (deco_diluent - 0.0627); // changed in v.101 |
1504 if (pres_respiration > pres_surface) | 1502 if (pres_respiration > pres_surface) |
1505 { | 1503 { |
1506 switch (char_O_deco_status) | 1504 switch (char_O_deco_status) |
1507 { | 1505 { |
1508 case 2: | 1506 case 2: |
1509 char_O_ascenttime = 255; | 1507 int_O_ascenttime = -1; |
1510 break; | 1508 break; |
1511 case 1: | 1509 case 1: |
1512 break; | 1510 break; |
1513 default: | 1511 default: |
1514 { | 1512 { |
1515 overlay unsigned char x; | 1513 // + 0.6 to count 1 minute ascent time from 4 meter to surface |
1516 overlay float ascent = pres_respiration - pres_surface + 0.6; // + 0.6 hence 1 minute ascent time from a depth of 4 meter on | 1514 overlay float ascent = pres_respiration - pres_surface + 0.6; |
1517 | |
1518 if (ascent < 0.0) | 1515 if (ascent < 0.0) |
1519 ascent = 0.0; | 1516 ascent = 0.0; |
1520 if (ascent > 255.0) | 1517 int_O_ascenttime = (unsigned int)ascent; |
1521 ascent = 255.0; | 1518 |
1522 char_O_ascenttime = (char)ascent; | 1519 if( char_I_deco_model == 0 ) //---- ZH-L16 model |
1523 | |
1524 for(x=0; x<7; x++) | |
1525 { | 1520 { |
1526 overlay int int_ascent = (int)char_O_ascenttime + (int)char_O_array_decotime[x]; | 1521 overlay unsigned char x; |
1527 if(int_ascent >= 255) | 1522 for(x=0; x<7; x++) |
1528 char_O_ascenttime = 255; | 1523 int_O_ascenttime += (unsigned int)char_O_array_decotime[x]; |
1529 else | |
1530 char_O_ascenttime = int_ascent; | |
1531 } | 1524 } |
1525 else //---------------------------- ZH-L16-GF model | |
1526 { | |
1527 overlay unsigned char x; | |
1528 for(x=0; x<32; x++) | |
1529 int_O_ascenttime += (unsigned int)internal_deco_table[x]; | |
1530 } | |
1531 | |
1532 break; | 1532 break; |
1533 } | 1533 } |
1534 } | 1534 } |
1535 } | 1535 } |
1536 else | 1536 else |
1537 char_O_ascenttime = 0; | 1537 int_O_ascenttime = 0; |
1538 } | 1538 } |
1539 | 1539 |
1540 ////////////////////////////////////////////////////////////////////////////// | 1540 ////////////////////////////////////////////////////////////////////////////// |
1541 // update_startvalues | 1541 // update_startvalues |
1542 // | 1542 // |
1659 overlay unsigned char x = 0; | 1659 overlay unsigned char x = 0; |
1660 do | 1660 do |
1661 { | 1661 { |
1662 if (char_O_array_decodepth[x] == temp_depth_limit) | 1662 if (char_O_array_decodepth[x] == temp_depth_limit) |
1663 { | 1663 { |
1664 stop_time = char_O_array_decotime[x] + temp_decotime; | 1664 stop_time = char_O_array_decotime[x] + 1; |
1665 if (stop_time < 0) | 1665 if (stop_time < 0) |
1666 stop_time = 0; | 1666 stop_time = 0; |
1667 if (stop_time > 240) | 1667 if (stop_time > 240) |
1668 stop_time = 240; | 1668 stop_time = 240; |
1669 char_O_array_decotime[x] = stop_time; | 1669 char_O_array_decotime[x] = stop_time; |
1675 { | 1675 { |
1676 if (temp_depth_limit > 255) | 1676 if (temp_depth_limit > 255) |
1677 char_O_array_decodepth[x] = 255; | 1677 char_O_array_decodepth[x] = 255; |
1678 else | 1678 else |
1679 char_O_array_decodepth[x] = (char)temp_depth_limit; | 1679 char_O_array_decodepth[x] = (char)temp_depth_limit; |
1680 stop_time = char_O_array_decotime[x] + temp_decotime; | 1680 stop_time = char_O_array_decotime[x] + 1; |
1681 if (stop_time > 240) | 1681 if (stop_time > 240) |
1682 char_O_array_decotime[x] = 240; | 1682 char_O_array_decotime[x] = 240; |
1683 else | 1683 else |
1684 char_O_array_decotime[x] = (char)stop_time; | 1684 char_O_array_decotime[x] = (char)stop_time; |
1685 x = 10; // exit | 1685 x = 10; // exit |
1688 x++; | 1688 x++; |
1689 } // else | 1689 } // else |
1690 } while (x<6); | 1690 } while (x<6); |
1691 if (x == 6) | 1691 if (x == 6) |
1692 { | 1692 { |
1693 stop_time = char_O_array_decotime[6] + temp_decotime; | 1693 stop_time = char_O_array_decotime[6] + 1; |
1694 if (stop_time > 220) | 1694 if (stop_time > 220) |
1695 char_O_array_decotime[6] = 220; | 1695 char_O_array_decotime[6] = 220; |
1696 else | 1696 else |
1697 char_O_array_decotime[6] = (char)stop_time; | 1697 char_O_array_decotime[6] = (char)stop_time; |
1698 } // if x == 6 | 1698 } // if x == 6 |
1881 calc_tissue_1_min(); // update the pressure in the 32 tissues in accordance with the new ambient pressure | 1881 calc_tissue_1_min(); // update the pressure in the 32 tissues in accordance with the new ambient pressure |
1882 | 1882 |
1883 clear_decoarray(); | 1883 clear_decoarray(); |
1884 char_O_deco_status = 0; | 1884 char_O_deco_status = 0; |
1885 char_O_nullzeit = 0; | 1885 char_O_nullzeit = 0; |
1886 char_O_ascenttime = 0; | 1886 int_O_ascenttime = 0; |
1887 calc_gradient_factor(); | 1887 calc_gradient_factor(); |
1888 } | 1888 } |
1889 | 1889 |
1890 ////////////////////////////////////////////////////////////////////////////// | 1890 ////////////////////////////////////////////////////////////////////////////// |
1891 ////////////////////////////////////////////////////////////////////////////// | 1891 ////////////////////////////////////////////////////////////////////////////// |