Skip to content

Commit

Permalink
Added proper extra time for gas switching
Browse files Browse the repository at this point in the history
Added proper extra time for gas switching
Fixed chart time with tissues
  • Loading branch information
VlasovAlexey committed Dec 14, 2023
1 parent e3272f3 commit f81e387
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 93 deletions.
14 changes: 14 additions & 0 deletions HTML_SRC/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Open index.html",
"file": "h:\\DiveProMe+\\SRC\\index.html"
}
]
}
3 changes: 3 additions & 0 deletions HTML_SRC/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"search.followSymlinks": true
}
73 changes: 0 additions & 73 deletions HTML_SRC/build_dive.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ function build_dive(){
tmp_lvl_arr = [];
tmp_lvl_mix_arr = [];

//var rate_asc = document.getElementById("opt_rate_asc");
//var rate_asc_idx = rate_asc.options[rate_asc.selectedIndex].value;
//var rate_dsc = document.getElementById("opt_rate_dsc");
//var rate_dsc_idx = rate_dsc.options[rate_dsc.selectedIndex].value;

//calculate ascending numbers for potentially deco stops
for (i = 0; i < lvl_arr.length/3; i++) {

Expand Down Expand Up @@ -762,11 +757,6 @@ function upd_lvl_opt_arr(){
//upd_lvl_list();
upd_all();
}





//Dec time equal to real time format xx:xx
function time_dec_to_time(tmp_time){
tmp_time_hi = Math.floor(tmp_time);
Expand Down Expand Up @@ -828,46 +818,11 @@ function src_to_5_arr(tmp_arr, flag_full){
var pln_style_val = $("#tn_plan_style option:selected").val();

runtime = 0;
var blns = 0;
for (var i = 0; i < tmp_arr.length; i++) {
dp_end1 = tmp_arr[i].endDepth*1.0;
dp_start1 = tmp_arr[i].startDepth*1.0;
dp_c_time = tmp_arr[i].time*1.0;

//make plan time rounded if classic style selected
/*if (pln_style_val == 2){
if(dp_start1 == dp_end1){
//levels or stops
if(blns >= 1){
dp_c_time = Math.ceil(dp_c_time + blns);
blns = 0;
}
//dp_c_time = Math.ceil(dp_c_time);
}
else{
//transition balances between levels or stops
if(blns >= 1){
//dp_c_time = Math.ceil(dp_c_time + blns);
//blns = 0;
//console.log("ADD!")
}
else{
blns = blns + dp_c_time;
dp_c_time = 0;
}
//console.log(blns);
}
//fix start and exit to surface. Every time this make round to ceil. This add two more minutes to detailed plan anyway
if(i == 0 || i == tmp_arr.length-1){
dp_c_time = Math.ceil(tmp_arr[i].time*1.0);
}
//final update
runtime = runtime + (dp_c_time);
}
else{
runtime = runtime + (dp_c_time);
}*/

runtime = runtime + (dp_c_time);
dp_c_mix = tmp_arr[i].gasName;

Expand Down Expand Up @@ -1095,34 +1050,6 @@ function GasBreakInsert(main_arr) {
return main_arr;
}

//ADD extra stops for gas changing
function ExtraStops(output) {
var tn_cng_time = document.getElementById("opt_cng_time");
var tn_cng_time_idx = parseInt(tn_cng_time.options[tn_cng_time.selectedIndex].value);

//if changing mix time === 0 we need add some time for property dive plan computation.
if(tn_cng_time_idx === 0)
{
//!!!need deep test! changed from 0.0 to 0.00001 after v9.11
//it is important. if 0.0 then crash app. need more testing and resolve this strange work
tn_cng_time_idx = 0.00001;
}

for(c = 1 ; c < output.length ; c++){
if(output[c].gasName != output[c-1].gasName){
output.splice(c,0,
{
endDepth: output[c].startDepth,
startDepth: output[c].startDepth,
time: tn_cng_time_idx,
gasName: output[c].gasName
}
);
}
}
return output;
}

//return max depth in meters from lvl list array
function PlanMaxDepth(plan_array){
var a = 0;
Expand Down
12 changes: 6 additions & 6 deletions HTML_SRC/cookie_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ deleteCookie("mdls_usr1");
*/
var deco_mix_arr = [50,0,100,0,20,30,18,45,15,50,12,60,8,70,40,0,80,0,21,35];
var deco_mix_depth_arr = [0,0,0,0,0,0,0,0,0,0];
var travel_mix_depth_arr = [0,0,0,0,0,0,0,0,0,0];
var travel_mix_depth_arr = [402,402,402,402,402,402,402,402,402,402];
var travel_mix_arr = [21,0,20,30,18,45,15,50,12,60,8,70,40,0,80,0,21,35,100,0];

var lvl_arr = [1,40,20];
Expand Down Expand Up @@ -89,7 +89,7 @@ var opt_calc_cur_ex_rate_yuan_usr = 6;
var opt_calc_cur_ex_rate_fyn_usr = 45;

//new3_0
var plan_style_usr = 1;
var plan_style_usr = 2;
var plan_ccr_usr = 1;

//new4_0
Expand Down Expand Up @@ -118,7 +118,7 @@ var opt_saul_percent_usr = 0.3;
function default_set(){
deco_mix_arr = [50,0,100,0,20,30,18,45,15,55,12,60,10,70,21,35,30,30,60,0];
deco_mix_depth_arr = [0,0,0,0,0,0,0,0,0,0];
travel_mix_depth_arr = [0,0,0,0,0,0,0,0,0,0];
travel_mix_depth_arr = [402,402,402,402,402,402,402,402,402,402];
travel_mix_arr = [21,0,20,30,18,45,15,50,12,60,8,70,40,0,80,0,21,35,100,0];
lvl_arr = [1,39,20];
lvl_mix_arr = [21,0];
Expand Down Expand Up @@ -197,7 +197,7 @@ function default_set(){
opt_calc_cur_ex_rate_fyn_usr = 45;

//new3_0
plan_style_usr = 1;
plan_style_usr = 2;
plan_ccr_usr = 1;

//new4_0
Expand Down Expand Up @@ -1406,7 +1406,7 @@ function create_html(){
create_option("tn_rmv_bt", "opt_rmv_bt", 3, 60, opt_rmv_bt_usr , 1 , 0 , "vol");

del_html_elem("tn_cng_time");
create_option("tn_cng_time", "opt_cng_time", 0, 3, opt_cng_time_usr , 1 , 0 , "none");
create_option("tn_cng_time", "opt_cng_time", 0, 2, opt_cng_time_usr , 1 , 0 , "none");
del_html_elem("tn_lst_stop");
create_option("tn_lst_stop", "opt_lst_stop", 3, 6, opt_lst_stop_usr , 3 , 0 , "depth");
del_html_elem("tn_slevel");
Expand Down Expand Up @@ -1789,7 +1789,7 @@ create_option("tn_rate_asc_surf", "opt_rate_asc_surf", 1, 10, opt_rate_asc_surf_
create_option("tn_rate_asc_deco", "opt_rate_asc_deco", 1, 20, opt_rate_asc_deco_usr , 1 , 0, "depth");
create_option("tn_rmv_deco", "opt_rmv_deco", 3, 60, opt_rmv_deco_usr , 1 , 0, "vol");
create_option("tn_rmv_bt", "opt_rmv_bt", 3, 60, opt_rmv_bt_usr , 1 , 0 , "vol");
create_option("tn_cng_time","opt_cng_time", 0, 3, opt_cng_time_usr , 1 , 0 , "none");
create_option("tn_cng_time","opt_cng_time", 0, 2, opt_cng_time_usr , 1 , 0 , "none");
create_option("tn_lst_stop", "opt_lst_stop", 3, 6, opt_lst_stop_usr , 3 , 0 , "depth");
create_option("tn_slevel", "opt_slevel", 0, 4000, opt_slevel_usr , 100 , 0 , "depth");
create_option("tn_celsus", "opt_celsus", 0, 50, opt_celsus_usr , 2 , 0 , "temper");
Expand Down
31 changes: 29 additions & 2 deletions HTML_SRC/dive_comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,16 +889,44 @@ return s})({"/dive_comp.js":[function(require,module,exports){

//console.log("Start Ceiling:" + ceiling + " with GF:" + gfLow)
//you can get first deco stop here!

//DiveProMe interface
var tn_cng_time = document.getElementById("opt_cng_time");
var tn_cng_time_idx = parseInt(tn_cng_time.options[tn_cng_time.selectedIndex].value);

while (ceiling > 0) {
var currentDepth = ceiling;
var nextDecoDepth = (ceiling - 3);
var time = 0;

//DiveProMe interface
newGasName = this.addDecoDepthChange(nextDecoDepth, ceiling, maxppO2, maxEND, currentGasName);

var gf = gfLow + (gfChangePerMeter * (distanceToSurface - ceiling));
//console.log("GradientFactor:"+gf + " Next decoDepth:" + nextDecoDepth);
while (ceiling > nextDecoDepth && time <= 10000) {
this.addFlat(currentDepth, currentGasName, 1);
time++;
ceiling = this.getCeiling(gf);
ceiling = this.getCeiling(gf);
}

//DiveProMe interface
//Add extra time for gas changing
if ($("#tn_plan_ccr").val() == 1) {
//OC
if(newGasName != currentGasName && tn_cng_time_idx*1.0 > 0){
this.addFlat(currentDepth, currentGasName, tn_cng_time_idx*1.0);
//console.log(currentGasName,tn_cng_time_idx);
}
} else {
//CCR
if(opt_blt_dln == 2){
//nothing
}
//CCR Bailout
else{
console.log("bail");
}
}

//console.log("Held diver at " + currentDepth + " for " + time + " minutes on gas " + currentGasName + ".");
Expand All @@ -908,7 +936,6 @@ return s})({"/dive_comp.js":[function(require,module,exports){
if (!maintainTissues) {
this.resetTissues(origTissues);
}

return dive.collapseSegments(this.segments);
};

Expand Down
15 changes: 12 additions & 3 deletions HTML_SRC/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
background: repeating-linear-gradient(0deg, #ff9966, #ff5e62);
background: repeating-linear-gradient(45deg, #3d203e, #b90037);
background: repeating-linear-gradient(45deg, #04101f, #4684ee);

background: repeating-linear-gradient(45deg, #04101f, #3db0e6);
animation: gradient 4s ease infinite;
-webkit-transition: opacity 200ms ease-in-out;
-moz-transition: opacity 200ms ease-in-out;
Expand Down Expand Up @@ -1426,8 +1426,8 @@
</svg>
</div>
-->
<div style="color: #eeeeee">Copyright © 2023 Alexey Vlasov<br/>
Version 13.4
<div style="color: #eeeeee">Copyright © 2024 Alexey Vlasov<br/>
Version 14.0
</div>

</div>
Expand Down Expand Up @@ -1541,6 +1541,15 @@
</script>
>-->
</head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-00K0HZM6DZ"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-00K0HZM6DZ');
</script>

<body id="body_main" onload="">
<!-- custom node js Platforms(Win,OsX, Linux) start interface position control
<div id="node_os_custom_height"><br/></div> -->
Expand Down
13 changes: 4 additions & 9 deletions HTML_SRC/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function oc_ccr_hide_show_elem() {
element_id_show("ibcd_block");

element_id_show("t_cons_btn");
element_id_show_inline("tn_param_adv");
} else {
//ccr plan!
element_id_hide("btn_add_lvl");
Expand All @@ -178,9 +179,6 @@ function oc_ccr_hide_show_elem() {

element_id_hide("tr_gasbreak_block");

//warning about interface demo mode
//openNav();

//Bailout plan
if (opt_blt_dln == 1) {
element_id_hide("btn_bailout");
Expand Down Expand Up @@ -315,7 +313,7 @@ function upd_all() {
upd_airbr_mix();

//upd_airbr();
main_plan_res = ExtraStops(ShortStop(build_dive()));
main_plan_res = ShortStop(build_dive());
main_plan_src = ccr_compact_plan(main_plan_res);

main_plan_table = src_to_5_arr((main_plan_src) , 0);
Expand Down Expand Up @@ -511,12 +509,9 @@ function upd_lvl_list() {
min_max_arr = ret_mix_range_ccr(lvl_arr[att], get_rl_fraction(get_working_mix_idx_ccr(main_lvl, travel_mix_arr)));
}




if (j > 0) {

//fix deco computation problem with big steeps between levels under ascent and make maximum ascent level half of previos level
//fix deco computation problem with big steeps between levels under ascent and make maximum ascent level half of previous level
if (j < (lvl_arr.length / 3)) {
//alert(lvl_arr[att-2]);
if(parseInt(lvl_arr[att - 2] / 2) < 1) {
Expand All @@ -537,7 +532,7 @@ function upd_lvl_list() {

//console.log(min_max_arr[0],min_max_arr[1], lvl_arr[att+1]);
create_option_lvl("tn_levels", "opt_levels_depth_" + j, min_max_arr[0] * 1.0, (min_max_arr[1] * 1.0) - 1, lvl_arr[att + 1] * 1.0, 1, 0);
// ^^fix rounding problem betwin lvl connections
// ^^fix rounding problem between lvl connections
lvl_dp_watcher[att] = document.getElementById("opt_levels_depth_" + j);
lvl_dp_watcher[att].addEventListener('change', upd_lvl_opt_arr);

Expand Down

0 comments on commit f81e387

Please sign in to comment.