Airlock controller fixes

Fixes airlocks opening their doors before the pumps have turned off.
Fixes airlocks getting confused if you mash buttons in quick succession.
This commit is contained in:
mwerezak
2015-07-04 23:17:20 -04:00
parent 93c3d03801
commit c46f32e8d7

View File

@@ -109,10 +109,14 @@
var/shutdown_pump = 0
switch(command)
if("cycle_ext")
begin_cycle_out()
//only respond to these commands if the airlock isn't already doing something
//prevents the controller from getting confused and doing strange things
if(state == target_state)
begin_cycle_out()
if("cycle_int")
begin_cycle_in()
if(state == target_state)
begin_cycle_in()
if("cycle_ext_door")
cycleDoors(TARGET_OUTOPEN)
@@ -122,14 +126,6 @@
if("abort")
stop_cycling()
/*
//dont do this. If the airlock can't get enough air to pressurize the person inside is stuck
state = STATE_PRESSURIZE
target_state = TARGET_NONE
memory["target_pressure"] = ONE_ATMOSPHERE
signalPump(tag_airpump, 1, 1, memory["target_pressure"])
process()
*/
if("force_ext")
toggleDoor(memory["exterior_status"], tag_exterior_door, memory["secure"], "toggle")
@@ -140,11 +136,9 @@
if("purge")
memory["purge"] = !memory["purge"]
if(memory["purge"])
toggleDoor(memory["exterior_status"], tag_exterior_door, 1, "close")
toggleDoor(memory["interior_status"], tag_interior_door, 1, "close")
state = STATE_DEPRESSURIZE
close_doors()
state = STATE_PREPARE
target_state = TARGET_NONE
signalPump(tag_airpump, 1, 0, 0)
if("secure")
memory["secure"] = !memory["secure"]
@@ -188,12 +182,12 @@
var/target_pressure = memory["target_pressure"]
if(memory["purge"])
//purge apparently means clearing the airlock chamber to vacuum (then refilling, handled later)
target_pressure = 0
state = STATE_DEPRESSURIZE
signalPump(tag_airpump, 1, 0, 0) //send a signal to start depressurizing
if(memory["purge"])
target_pressure = 0
if(chamber_pressure <= target_pressure)
else if(chamber_pressure <= target_pressure)
state = STATE_PRESSURIZE
signalPump(tag_airpump, 1, 1, target_pressure) //send a signal to start pressurizing
@@ -201,40 +195,37 @@
state = STATE_DEPRESSURIZE
signalPump(tag_airpump, 1, 0, target_pressure) //send a signal to start depressurizing
//Check for vacuum - this is set after the pumps so the pumps are aiming for 0
if(!memory["target_pressure"])
memory["target_pressure"] = ONE_ATMOSPHERE * 0.05
//Make sure the airlock isn't aiming for pure vacuum - an impossibility
memory["target_pressure"] = max(target_pressure, ONE_ATMOSPHERE * 0.05)
if(STATE_PRESSURIZE)
if(memory["chamber_sensor_pressure"] >= memory["target_pressure"] * 0.95)
cycleDoors(target_state)
state = STATE_IDLE
target_state = TARGET_NONE
//not done until the pump has reported that it's off
if(memory["pump_status"] != "off")
signalPump(tag_airpump, 0) //send a signal to stop pumping
else
cycleDoors(target_state)
state = STATE_IDLE
target_state = TARGET_NONE
if(STATE_DEPRESSURIZE)
if(memory["purge"])
if(memory["chamber_sensor_pressure"] <= ONE_ATMOSPHERE * 0.05)
state = STATE_PRESSURIZE
signalPump(tag_airpump, 1, 1, memory["target_pressure"])
else if(memory["chamber_sensor_pressure"] <= memory["target_pressure"] * 1.05)
cycleDoors(target_state)
state = STATE_IDLE
target_state = TARGET_NONE
//send a signal to stop pumping
if(memory["pump_status"] != "off")
if(memory["chamber_sensor_pressure"] <= memory["target_pressure"] * 1.05)
if(memory["purge"])
memory["purge"] = 0
memory["target_pressure"] = memory["internal_sensor_pressure"]
state = STATE_PREPARE
target_state = TARGET_NONE
else if(memory["pump_status"] != "off")
signalPump(tag_airpump, 0)
else
cycleDoors(target_state)
state = STATE_IDLE
target_state = TARGET_NONE
memory["processing"] = state != target_state
memory["processing"] = (state != target_state)
return 1