Airbag: bug fix

This commit is contained in:
Sidi Liang 2020-04-04 15:07:39 +08:00
parent b3afca0662
commit c7d0f834d0
No known key found for this signature in database
GPG Key ID: 79F0A6B20B72F42F
2 changed files with 16 additions and 5 deletions

View File

@ -486,20 +486,21 @@ var Safety = {
if(math.abs(me.accXProp.getValue() * FT2M) > me.airbagAccelerationLimit){
#active Front
me.frontAirbagProp.setValue(1);
me.safetySystemTimer.stop();
}
#side airbag
if(math.abs(me.accYProp.getValue() * FT2M) > me.airbagAccelerationLimit){
#active side
me.sideAirbagProp.setValue(1);
me.safetySystemTimer.stop();
}
},
reset: func(){
#resetting stops the system
me.safetySystemTimer.stop();
me.frontAirbagProp.setValue(0);
me.frontAirbagProp.setValue(0);
me.sideAirbagProp.setValue(0);
},
init: func(){
#initialize or reinitialize
me.frontAirbagProp.setValue(0);
me.sideAirbagProp.setValue(0);
if(me.safetySystemTimer == nil) me.safetySystemTimer = maketimer(me.updateInterval, func me.update());

View File

@ -135,12 +135,22 @@
</button>
<button>
<halign>left</halign>
<legend>Toggle Airbag</legend>
<legend>Enable/Repair Airbag</legend>
<pref-width>120</pref-width>
<pref-height>28</pref-height>
<binding>
<command>nasal</command>
<script>followme.safety.toggle()</script>
<script>followme.safety.init()</script>
</binding>
</button>
<button>
<halign>left</halign>
<legend>Disable Airbag</legend>
<pref-width>120</pref-width>
<pref-height>28</pref-height>
<binding>
<command>nasal</command>
<script>followme.safety.stop()</script>
</binding>
</button>
</group>