Initial commit

This commit is contained in:
mwerezak
2014-06-09 23:05:17 -04:00
parent 0d2b9b8c33
commit 80590ea58b
2 changed files with 121 additions and 29 deletions
@@ -96,12 +96,10 @@
var/shutdown_pump = 0
switch(command)
if("cycle_ext")
state = STATE_WAIT
target_state = TARGET_OUTOPEN
begin_cycle_out()
if("cycle_int")
state = STATE_WAIT
target_state = TARGET_INOPEN
begin_cycle_in()
if("cycle_ext_door")
cycleDoors(TARGET_OUTOPEN)
@@ -145,36 +143,44 @@
/datum/computer/file/embedded_program/proc/process()
if(!state && target_state)
switch(target_state)
if(TARGET_INOPEN)
memory["target_pressure"] = memory["internal_sensor_pressure"]
if(TARGET_OUTOPEN)
memory["target_pressure"] = memory["external_sensor_pressure"]
if(!state)
if(target_state)
switch(target_state)
if(TARGET_INOPEN)
memory["target_pressure"] = memory["internal_sensor_pressure"]
if(TARGET_OUTOPEN)
memory["target_pressure"] = memory["external_sensor_pressure"]
//lock down the airlock before activating pumps
toggleDoor(memory["exterior_status"], tag_exterior_door, 1, "close")
toggleDoor(memory["interior_status"], tag_interior_door, 1, "close")
//lock down the airlock before activating pumps
toggleDoor(memory["exterior_status"], tag_exterior_door, 1, "close")
toggleDoor(memory["interior_status"], tag_interior_door, 1, "close")
var/chamber_pressure = memory["chamber_sensor_pressure"]
var/target_pressure = memory["target_pressure"]
var/chamber_pressure = memory["chamber_sensor_pressure"]
var/target_pressure = memory["target_pressure"]
if(memory["purge"])
target_pressure = 0
if(memory["purge"])
target_pressure = 0
if(chamber_pressure <= target_pressure)
state = STATE_PRESSURIZE
signalPump(tag_airpump, 1, 1, target_pressure) //send a signal to start pressurizing
else if(chamber_pressure > target_pressure)
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
if(chamber_pressure <= target_pressure)
state = STATE_PRESSURIZE
signalPump(tag_airpump, 1, 1, target_pressure) //send a signal to start pressurizing
else if(chamber_pressure > target_pressure)
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
else
//make sure to return to a sane idle state
if(memory["pump_status"] != "off") //send a signal to stop pumping
signalPump(tag_airpump, 0)
//the airlock will not allow itself to continue to cycle when any of the doors are forced open.
if (state && !check_doors_closed())
stop_cycling()
switch(state)
if(STATE_PRESSURIZE)
if(memory["chamber_sensor_pressure"] >= memory["target_pressure"] * 0.95)
@@ -209,6 +215,22 @@
return 1
//these are here so that subtypes don't have to make so many assuptions about our implementation
/datum/computer/file/embedded_program/proc/begin_cycle_in()
state = STATE_WAIT
target_state = TARGET_INOPEN
/datum/computer/file/embedded_program/proc/begin_cycle_out()
state = STATE_WAIT
target_state = TARGET_OUTOPEN
/datum/computer/file/embedded_program/proc/stop_cycling()
state = STATE_WAIT
target_state = TARGET_NONE
/datum/computer/file/embedded_program/proc/done_cycling()
return (state == STATE_WAIT && target_state == TARGET_NONE)
/datum/computer/file/embedded_program/proc/post_signal(datum/signal/signal, comm_line)
if(master)
@@ -216,6 +238,8 @@
else
del(signal)
/datum/computer/file/embedded_program/proc/check_doors_closed()
return (memory["interior_status"]["state"] == "closed" && memory["exterior_status"["state"] == "closed")
/datum/computer/file/embedded_program/proc/signalDoor(var/tag, var/command)
var/datum/signal/signal = new
@@ -235,7 +259,7 @@
)
post_signal(signal)
//this is called to set the appropriate door state at the end of a cycling process, or for the exterior buttons
/datum/computer/file/embedded_program/proc/cycleDoors(var/target)
switch(target)
if(TARGET_OUTOPEN)
@@ -0,0 +1,68 @@
#define STATE_UNDOCKED 0
#define STATE_DOCKING 1
#define STATE_UNDOCKING 2
#define STATE_DOCKED 3
/datum/computer/file/embedded_program/docking_port
var/tag_target //the tag of the docking controller that we are trying to dock with
var/airlock_override = 0 //allows use of the docking port as a normal airlock (normally this is only allowed in STATE_UNDOCKED)
var/dock_state = STATE_UNDOCKED
/datum/computer/file/embedded_program/docking_port/receive_signal(datum/signal/signal, receive_method, receive_param)
var/receive_tag = signal.data["tag"]
var/command = signal.data["command"]
if(!receive_tag) return
if(receive_tag==tag_target && command="request_undock")
begin_undock()
else if (command=="request_dock")
if (tag_target) //something is already docked here
//send an error message
else
tag_target = receive_tag
begin_dock()
..()
/datum/computer/file/embedded_program/docking_port/receive_user_command(command)
/datum/computer/file/embedded_program/docking_port/process()
..() //process regular airlock stuff first
switch(dock_state)
if(STATE_DOCKING)
if(done_cycling())
state = STATE_DOCKED
//send confirmation
//open doors
toggleDoor(memory["interior_status"], tag_interior_door, memory["secure"], "open")
toggleDoor(memory["exterior_status"], tag_exterior_door, memory["secure"], "open")
if(STATE_UNDOCKING)
if() //check doors are closed or override
state = STATE_UNDOCKED
//send confirmation
tag_target = null
/datum/computer/file/embedded_program/docking_port/cycleDoors(var/target)
if (state == STATE_UNDOCKED || airlock_override)
..()
//get the docking port into a good state for docking.
/datum/computer/file/embedded_program/proc/begin_dock()
dock_state = STATE_DOCKING
begin_cycle_in()
//get the docking port into a good state for undocking.
/datum/computer/file/embedded_program/proc/begin_undock()
dock_state = STATE_UNDOCKING
stop_cycling()
//close the doors
toggleDoor(memory["interior_status"], tag_interior_door, memory["secure"], "close")
toggleDoor(memory["exterior_status"], tag_exterior_door, memory["secure"], "close")