From 5925a7cdb11f029353ef464948bc227458548da7 Mon Sep 17 00:00:00 2001 From: Sidi Liang <1467329765@qq.com> Date: Wed, 31 Jul 2019 14:22:33 +0800 Subject: [PATCH] System: bug fix --- Nasal/systems.nas | 32 ++++++++++++++++++------------ gui/dialogs/battery-management.xml | 4 ++++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Nasal/systems.nas b/Nasal/systems.nas index fb8f882..caa5275 100644 --- a/Nasal/systems.nas +++ b/Nasal/systems.nas @@ -272,24 +272,30 @@ var chargeBatterySec = func(){ } var chargeTimer = maketimer(1, chargeBatterySec); var chargeBatteryStart = func(){ - if(props.getNode("/",1).getValue("services/service-truck/connect") == 1 and props.getNode("/",1).getValue("/controls/engines/engine/started") == 0){ - var deltaBattery = 288000-props.getNode("/systems/electrical/e-tron/battery-kWs").getValue(); - var remainingTime = sprintf("%.0f", (deltaBattery / 240) / 60); #Based on 20 mins from 0 to full - #screen.log.write("Recharging. About "~remainingTime~" mins remaining.", 0, 0.584, 1); - setprop("/sim/sound/voices/pilot", "Recharging. About "~remainingTime~" mins remaining."); - chargeTimer.start(); - props.getNode("/controls/is-recharging", 1).setValue(1); - }else if(!props.getNode("/",1).getValue("services/service-truck/connect")){ - #screen.log.write("Cannot recharge. Call service truck and connect the cable first.", 0, 0.584, 1); - setprop("/sim/sound/voices/pilot", "Cannot recharge. Call service truck and connect the cable first."); - }else if(props.getNode("/",1).getValue("/controls/engines/engine/started")){ - #screen.log.write("Cannot recharge. Shut down the engine first.", 0, 0.584, 1); - setprop("/sim/sound/voices/pilot", "Cannot recharge. Shut down the engine first."); + if(!chargeTimer.isRunning()){ + if(props.getNode("/",1).getValue("services/service-truck/connect") == 1 and props.getNode("/",1).getValue("/controls/engines/engine/started") == 0){ + var deltaBattery = 288000-props.getNode("/systems/electrical/e-tron/battery-kWs").getValue(); + var remainingTime = sprintf("%.0f", (deltaBattery / 240) / 60); #Based on 20 mins from 0 to full + #screen.log.write("Recharging. About "~remainingTime~" mins remaining.", 0, 0.584, 1); + setprop("/sim/sound/voices/pilot", "Recharging. About "~remainingTime~" mins remaining."); + chargeTimer.start(); + props.getNode("/controls/is-recharging", 1).setValue(1); + }else if(!props.getNode("/",1).getValue("services/service-truck/connect")){ + screen.log.write("Cannot recharge. Call service truck and connect the cable first.", 0, 0.584, 1); + setprop("/sim/sound/voices/pilot", "Cannot recharge. Call service truck and connect the cable first."); + }else if(props.getNode("/",1).getValue("/controls/engines/engine/started")){ + screen.log.write("Cannot recharge. Shut down the engine first.", 0, 0.584, 1); + setprop("/sim/sound/voices/pilot", "Cannot recharge. Shut down the engine first."); + } + }else if(chargeTimer.isRunning()){ + chargeBatteryStop(); } } var chargeBatteryStop = func(){ chargeTimer.stop(); + screen.log.write("Recharge Stopped", 0, 0.584, 1); + setprop("/sim/sound/voices/pilot", "Recharge Stopped. Have a nice ride!"); props.getNode("/controls/is-recharging", 1).setValue(0); } diff --git a/gui/dialogs/battery-management.xml b/gui/dialogs/battery-management.xml index 45649b9..e43fa60 100755 --- a/gui/dialogs/battery-management.xml +++ b/gui/dialogs/battery-management.xml @@ -74,6 +74,10 @@ property-toggle services/service-truck/enable + + nasal + + dialog-update