From f207888316767a454c573b914d60de8b34c512ba Mon Sep 17 00:00:00 2001 From: mwerezak Date: Tue, 15 Jul 2014 13:31:32 -0400 Subject: [PATCH] Replaces the volume gas pump --- .../components/binary_devices/pump.dm | 23 +-- .../components/binary_devices/volume_pump.dm | 189 +----------------- code/game/machinery/pipe/construction.dm | 6 +- nano/templates/gas_pump.tmpl | 4 +- 4 files changed, 23 insertions(+), 199 deletions(-) diff --git a/code/ATMOSPHERICS/components/binary_devices/pump.dm b/code/ATMOSPHERICS/components/binary_devices/pump.dm index bfde280ba7..6d4da0c8e0 100644 --- a/code/ATMOSPHERICS/components/binary_devices/pump.dm +++ b/code/ATMOSPHERICS/components/binary_devices/pump.dm @@ -17,7 +17,7 @@ Thus, the two variables affect pump operation are set in New(): icon_state = "map" level = 1 - name = "Gas pump" + name = "gas pump" desc = "A pump" var/on = 0 @@ -31,22 +31,17 @@ Thus, the two variables affect pump operation are set in New(): var/last_power_draw = 0 //for UI var/last_flow_rate = 0 //for UI - var/max_pressure_setting = 9000 //kPa + var/max_pressure_setting = 15000 //kPa var/frequency = 0 var/id = null var/datum/radio_frequency/radio_connection -/obj/machinery/atmospherics/binary/pump/highcap - name = "High capacity gas pump" - desc = "A high capacity pump" - - target_pressure = 15000000 //15 GPa? Really? - active_power_usage = 112500 //150 Horsepower - /obj/machinery/atmospherics/binary/pump/on on = 1 + + /obj/machinery/atmospherics/binary/pump/update_icon() if(!powered()) icon_state = "off" @@ -103,8 +98,12 @@ Thus, the two variables affect pump operation are set in New(): transfer_moles = min(transfer_moles, active_power_usage / specific_power) //Actually transfer the gas + var/input_pressure = air1.return_pressure() + var/datum/gas_mixture/removed = air1.remove(transfer_moles) - last_flow_rate = output_starting_pressure? transfer_moles*R_IDEAL_GAS_EQUATION*removed.temperature/air1.return_pressure() : 0 //need to calculate this here because gas_mixture/remove() is dumb + if (input_pressure > 0) + last_flow_rate = removed.total_moles()*R_IDEAL_GAS_EQUATION*removed.temperature/input_pressure + air2.merge(removed) //if specific_entropy >= 0 then gas is flowing naturally and we don't need to use extra power @@ -178,9 +177,9 @@ Thus, the two variables affect pump operation are set in New(): data = list( "on" = on, - "pressure_set" = round(target_pressure, 0.05), + "pressure_set" = round(target_pressure*100), //Nano UI can't handle rounded non-integers, apparently. "max_pressure" = max_pressure_setting, - "last_flow_rate" = round(last_flow_rate), + "last_flow_rate" = round(last_flow_rate*10), "last_power_draw" = round(last_power_draw), "max_power_draw" = active_power_usage, ) diff --git a/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm b/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm index 2f9d775bd5..065ecc3605 100644 --- a/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm +++ b/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm @@ -1,193 +1,18 @@ -/* -Every cycle, the pump uses the air in air_in to try and make air_out the perfect pressure. - -node1, air1, network1 correspond to input -node2, air2, network2 correspond to output - -Thus, the two variables affect pump operation are set in New(): - air1.volume - This is the volume of gas available to the pump that may be transfered to the output - air2.volume - Higher quantities of this cause more air to be perfected later - but overall network volume is also increased as this increases... -*/ - -/obj/machinery/atmospherics/binary/volume_pump +/obj/machinery/atmospherics/binary/pump/high_power icon = 'icons/atmos/volume_pump.dmi' icon_state = "map" level = 1 - name = "Volumetric gas pump" - desc = "A volumetric pump" + name = "high power gas pump" + desc = "A pump. Has double the power rating of the standard gas pump." - var/on = 0 - var/transfer_rate = 200 + active_power_usage = 15000 //This also doubles as a measure of how powerful the pump is, in Watts. 15000 W ~ 20 HP - var/frequency = 0 - var/id = null - var/datum/radio_frequency/radio_connection - -/obj/machinery/atmospherics/binary/volume_pump/on +/obj/machinery/atmospherics/binary/pump/high_power/on on = 1 -/obj/machinery/atmospherics/binary/volume_pump/update_icon() +/obj/machinery/atmospherics/binary/pump/high_power/update_icon() if(!powered()) icon_state = "off" else - icon_state = "[on ? "on" : "off"]" - -/obj/machinery/atmospherics/binary/volume_pump/update_underlays() - if(..()) - underlays.Cut() - var/turf/T = get_turf(src) - if(!istype(T)) - return - add_underlay(T, node1, turn(dir, -180)) - add_underlay(T, node2, dir) - -/obj/machinery/atmospherics/binary/volume_pump/hide(var/i) - update_underlays() - -/obj/machinery/atmospherics/binary/volume_pump/process() -// ..() - if(stat & (NOPOWER|BROKEN)) - return - if(!on) - return 0 - -// Pump mechanism just won't do anything if the pressure is too high/too low - - var/input_starting_pressure = air1.return_pressure() - var/output_starting_pressure = air2.return_pressure() - - if((input_starting_pressure < 0.01) || (output_starting_pressure > 9000)) - return 1 - - var/transfer_ratio = max(1, transfer_rate/air1.volume) - - var/datum/gas_mixture/removed = air1.remove_ratio(transfer_ratio) - - air2.merge(removed) - - if(network1) - network1.update = 1 - - if(network2) - network2.update = 1 - - return 1 - -/obj/machinery/atmospherics/binary/volume_pump/proc/set_frequency(new_frequency) - radio_controller.remove_object(src, frequency) - frequency = new_frequency - if(frequency) - radio_connection = radio_controller.add_object(src, frequency) - -/obj/machinery/atmospherics/binary/volume_pump/proc/broadcast_status() - if(!radio_connection) - return 0 - - var/datum/signal/signal = new - signal.transmission_method = 1 //radio signal - signal.source = src - - signal.data = list( - "tag" = id, - "device" = "APV", - "power" = on, - "transfer_rate" = transfer_rate, - "sigtype" = "status" - ) - radio_connection.post_signal(src, signal) - - return 1 - -/obj/machinery/atmospherics/binary/volume_pump/interact(mob/user as mob) - var/dat = {"Power: [on?"On":"Off"]
- Desirable output flow: - [round(transfer_rate,1)]l/s | Change - "} - - user << browse("[src.name] control[dat]", "window=atmo_pump") - onclose(user, "atmo_pump") - -/obj/machinery/atmospherics/binary/volume_pump/initialize() - ..() - set_frequency(frequency) - -/obj/machinery/atmospherics/binary/volume_pump/receive_signal(datum/signal/signal) - if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command")) - return 0 - - if(signal.data["power"]) - on = text2num(signal.data["power"]) - - if(signal.data["power_toggle"]) - on = !on - - if(signal.data["set_transfer_rate"]) - transfer_rate = between( - 0, - text2num(signal.data["set_transfer_rate"]), - air1.volume - ) - - if(signal.data["status"]) - spawn(2) - broadcast_status() - return //do not update_icon - - spawn(2) - broadcast_status() - update_icon() - -/obj/machinery/atmospherics/binary/volume_pump/attack_hand(user as mob) - if(..()) - return - src.add_fingerprint(usr) - if(!src.allowed(user)) - user << "\red Access denied." - return - usr.set_machine(src) - interact(user) - return - -/obj/machinery/atmospherics/binary/volume_pump/Topic(href,href_list) - if(..()) return - if(href_list["power"]) - on = !on - if(href_list["set_transfer_rate"]) - var/new_transfer_rate = input(usr,"Enter new output volume (0-200l/s)","Flow control",src.transfer_rate) as num - src.transfer_rate = max(0, min(200, new_transfer_rate)) - usr.set_machine(src) - src.update_icon() - src.updateUsrDialog() - return - -/obj/machinery/atmospherics/binary/volume_pump/power_change() - var/old_stat = stat - ..() - if(old_stat != stat) - update_icon() - -/obj/machinery/atmospherics/binary/volume_pump/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) - if (!istype(W, /obj/item/weapon/wrench)) - return ..() - if (!(stat & NOPOWER) && on) - user << "\red You cannot unwrench this [src], turn it off first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - new /obj/item/pipe(loc, make_from=src) - del(src) \ No newline at end of file + icon_state = "[on ? "on" : "off"]" \ No newline at end of file diff --git a/code/game/machinery/pipe/construction.dm b/code/game/machinery/pipe/construction.dm index e8ec749a31..c9de5a6296 100644 --- a/code/game/machinery/pipe/construction.dm +++ b/code/game/machinery/pipe/construction.dm @@ -74,6 +74,8 @@ Buildable meters src.pipe_type = PIPE_UVENT else if(istype(make_from, /obj/machinery/atmospherics/valve)) src.pipe_type = PIPE_MVALVE + else if(istype(make_from, /obj/machinery/atmospherics/binary/pump/high_power)) + src.pipe_type = PIPE_VOLUME_PUMP else if(istype(make_from, /obj/machinery/atmospherics/binary/pump)) src.pipe_type = PIPE_PUMP else if(istype(make_from, /obj/machinery/atmospherics/trinary/filter/m_filter)) @@ -90,8 +92,6 @@ Buildable meters src.pipe_type = PIPE_SCRUBBER else if(istype(make_from, /obj/machinery/atmospherics/binary/passive_gate)) src.pipe_type = PIPE_PASSIVE_GATE - else if(istype(make_from, /obj/machinery/atmospherics/binary/volume_pump)) - src.pipe_type = PIPE_VOLUME_PUMP else if(istype(make_from, /obj/machinery/atmospherics/unary/heat_exchanger)) src.pipe_type = PIPE_HEAT_EXCHANGE else if(istype(make_from, /obj/machinery/atmospherics/tvalve)) @@ -679,7 +679,7 @@ Buildable meters P.node2.build_network() if(PIPE_VOLUME_PUMP) //volume pump - var/obj/machinery/atmospherics/binary/volume_pump/P = new(src.loc) + var/obj/machinery/atmospherics/binary/pump/high_power/P = new(src.loc) P.dir = dir P.initialize_directions = pipe_dir if (pipename) diff --git a/nano/templates/gas_pump.tmpl b/nano/templates/gas_pump.tmpl index 0199fa96ad..9cb8431f5d 100644 --- a/nano/templates/gas_pump.tmpl +++ b/nano/templates/gas_pump.tmpl @@ -14,7 +14,7 @@
{{:~link('SET', null, {'set_press' : 'set'}, null)}} -
 {{:pressure_set}} kPa 
+
 {{:(pressure_set/100)}} kPa 
@@ -37,7 +37,7 @@
- {{:last_flow_rate}} L/s + {{:(last_flow_rate/10)}} L/s
\ No newline at end of file