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,9 +109,13 @@
var/shutdown_pump = 0 var/shutdown_pump = 0
switch(command) switch(command)
if("cycle_ext") if("cycle_ext")
//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() begin_cycle_out()
if("cycle_int") if("cycle_int")
if(state == target_state)
begin_cycle_in() begin_cycle_in()
if("cycle_ext_door") if("cycle_ext_door")
@@ -122,14 +126,6 @@
if("abort") if("abort")
stop_cycling() 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") if("force_ext")
toggleDoor(memory["exterior_status"], tag_exterior_door, memory["secure"], "toggle") toggleDoor(memory["exterior_status"], tag_exterior_door, memory["secure"], "toggle")
@@ -140,11 +136,9 @@
if("purge") if("purge")
memory["purge"] = !memory["purge"] memory["purge"] = !memory["purge"]
if(memory["purge"]) if(memory["purge"])
toggleDoor(memory["exterior_status"], tag_exterior_door, 1, "close") close_doors()
toggleDoor(memory["interior_status"], tag_interior_door, 1, "close") state = STATE_PREPARE
state = STATE_DEPRESSURIZE
target_state = TARGET_NONE target_state = TARGET_NONE
signalPump(tag_airpump, 1, 0, 0)
if("secure") if("secure")
memory["secure"] = !memory["secure"] memory["secure"] = !memory["secure"]
@@ -188,12 +182,12 @@
var/target_pressure = memory["target_pressure"] var/target_pressure = memory["target_pressure"]
if(memory["purge"]) if(memory["purge"])
//purge apparently means clearing the airlock chamber to vacuum (then refilling, handled later)
target_pressure = 0 target_pressure = 0
state = STATE_DEPRESSURIZE
signalPump(tag_airpump, 1, 0, 0) //send a signal to start depressurizing
if(memory["purge"]) else if(chamber_pressure <= target_pressure)
target_pressure = 0
if(chamber_pressure <= target_pressure)
state = STATE_PRESSURIZE state = STATE_PRESSURIZE
signalPump(tag_airpump, 1, 1, target_pressure) //send a signal to start pressurizing signalPump(tag_airpump, 1, 1, target_pressure) //send a signal to start pressurizing
@@ -201,40 +195,37 @@
state = STATE_DEPRESSURIZE state = STATE_DEPRESSURIZE
signalPump(tag_airpump, 1, 0, target_pressure) //send a signal to start depressurizing 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 //Make sure the airlock isn't aiming for pure vacuum - an impossibility
if(!memory["target_pressure"]) memory["target_pressure"] = max(target_pressure, ONE_ATMOSPHERE * 0.05)
memory["target_pressure"] = ONE_ATMOSPHERE * 0.05
if(STATE_PRESSURIZE) if(STATE_PRESSURIZE)
if(memory["chamber_sensor_pressure"] >= memory["target_pressure"] * 0.95) if(memory["chamber_sensor_pressure"] >= memory["target_pressure"] * 0.95)
cycleDoors(target_state) //not done until the pump has reported that it's off
state = STATE_IDLE
target_state = TARGET_NONE
if(memory["pump_status"] != "off") if(memory["pump_status"] != "off")
signalPump(tag_airpump, 0) //send a signal to stop pumping 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(STATE_DEPRESSURIZE)
if(memory["chamber_sensor_pressure"] <= memory["target_pressure"] * 1.05)
if(memory["purge"]) if(memory["purge"])
if(memory["chamber_sensor_pressure"] <= ONE_ATMOSPHERE * 0.05) memory["purge"] = 0
state = STATE_PRESSURIZE memory["target_pressure"] = memory["internal_sensor_pressure"]
signalPump(tag_airpump, 1, 1, memory["target_pressure"]) state = STATE_PREPARE
target_state = TARGET_NONE
else if(memory["pump_status"] != "off")
else if(memory["chamber_sensor_pressure"] <= memory["target_pressure"] * 1.05) signalPump(tag_airpump, 0)
else
cycleDoors(target_state) cycleDoors(target_state)
state = STATE_IDLE state = STATE_IDLE
target_state = TARGET_NONE target_state = TARGET_NONE
//send a signal to stop pumping
if(memory["pump_status"] != "off")
signalPump(tag_airpump, 0)
memory["processing"] = (state != target_state)
memory["processing"] = state != target_state
return 1 return 1