mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Optimizes air alarm power updating
This commit is contained in:
@@ -47,9 +47,6 @@
|
||||
#define RCON_AUTO 2
|
||||
#define RCON_YES 3
|
||||
|
||||
//1000 joules equates to about 1 degree every 2 seconds for a single tile of air.
|
||||
#define MAX_ENERGY_CHANGE 1000
|
||||
|
||||
#define MAX_TEMPERATURE 90
|
||||
#define MIN_TEMPERATURE -40
|
||||
|
||||
@@ -67,8 +64,8 @@
|
||||
icon_state = "alarm0"
|
||||
anchored = 1
|
||||
use_power = 1
|
||||
idle_power_usage = 4
|
||||
active_power_usage = 8
|
||||
idle_power_usage = 80
|
||||
active_power_usage = 1000 //For heating/cooling rooms. 1000 joules equates to about 1 degree every 2 seconds for a single tile of air.
|
||||
power_channel = ENVIRON
|
||||
req_one_access = list(access_atmospherics, access_engine_equip)
|
||||
var/breach_detection = 1 // Whether to use automatic breach detection or not
|
||||
@@ -178,16 +175,22 @@
|
||||
var/datum/gas_mixture/environment = location.return_air()
|
||||
|
||||
//Handle temperature adjustment here.
|
||||
if(environment.temperature < target_temperature - 2 || environment.temperature > target_temperature + 2 || regulating_temperature)
|
||||
//If it goes too far, we should adjust ourselves back before stopping.
|
||||
if(get_danger_level(target_temperature, TLV["temperature"]))
|
||||
return
|
||||
|
||||
if(!regulating_temperature)
|
||||
if (!regulating_temperature)
|
||||
//check for when we should start adjusting temperature
|
||||
if(!get_danger_level(target_temperature, TLV["temperature"]) && abs(environment.temperature - target_temperature) > 2.0)
|
||||
update_use_power(2)
|
||||
regulating_temperature = 1
|
||||
visible_message("\The [src] clicks as it starts [environment.temperature > target_temperature ? "cooling" : "heating"] the room.",\
|
||||
"You hear a click and a faint electronic hum.")
|
||||
|
||||
else
|
||||
//check for when we should stop adjusting temperature
|
||||
if (get_danger_level(target_temperature, TLV["temperature"]) || abs(environment.temperature - target_temperature) <= 0.5)
|
||||
update_use_power(1)
|
||||
regulating_temperature = 0
|
||||
visible_message("\The [src] clicks quietly as it stops [environment.temperature > target_temperature ? "cooling" : "heating"] the room.",\
|
||||
"You hear a click as a faint electronic humming stops.")
|
||||
|
||||
if (regulating_temperature)
|
||||
if(target_temperature > T0C + MAX_TEMPERATURE)
|
||||
target_temperature = T0C + MAX_TEMPERATURE
|
||||
|
||||
@@ -199,30 +202,25 @@
|
||||
if(gas)
|
||||
|
||||
if (gas.temperature <= target_temperature) //gas heating
|
||||
var/energy_used = min( gas.get_thermal_energy_change(target_temperature) , MAX_ENERGY_CHANGE)
|
||||
var/energy_used = min( gas.get_thermal_energy_change(target_temperature) , active_power_usage)
|
||||
|
||||
gas.add_thermal_energy(energy_used)
|
||||
use_power(energy_used, ENVIRON)
|
||||
//use_power(energy_used, ENVIRON) //handle by update_use_power instead
|
||||
else //gas cooling
|
||||
var/heat_transfer = min(abs(gas.get_thermal_energy_change(target_temperature)), MAX_ENERGY_CHANGE)
|
||||
var/heat_transfer = min(abs(gas.get_thermal_energy_change(target_temperature)), active_power_usage)
|
||||
|
||||
//Assume the heat is being pumped into the hull which is fixed at 20 C
|
||||
//none of this is really proper thermodynamics but whatever
|
||||
|
||||
var/cop = gas.temperature/T20C //coefficient of performance -> power used = heat_transfer/cop
|
||||
|
||||
heat_transfer = min(heat_transfer, cop * MAX_ENERGY_CHANGE) //this ensures that we don't use more than MAX_ENERGY_CHANGE amount of power - the machine can only do so much cooling
|
||||
heat_transfer = min(heat_transfer, cop * active_power_usage) //this ensures that we don't use more than active_power_usage amount of power
|
||||
|
||||
heat_transfer = -gas.add_thermal_energy(-heat_transfer) //get the actual heat transfer
|
||||
|
||||
use_power(heat_transfer / cop, ENVIRON)
|
||||
//use_power(heat_transfer / cop, ENVIRON) //handle by update_use_power instead
|
||||
|
||||
environment.merge(gas)
|
||||
|
||||
if(abs(environment.temperature - target_temperature) <= 0.5)
|
||||
regulating_temperature = 0
|
||||
visible_message("\The [src] clicks quietly as it stops [environment.temperature > target_temperature ? "cooling" : "heating"] the room.",\
|
||||
"You hear a click as a faint electronic humming stops.")
|
||||
|
||||
var/old_level = danger_level
|
||||
var/old_pressurelevel = pressure_dangerlevel
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
density = 0
|
||||
|
||||
var/id_tag
|
||||
var/radio_power_use = 50 //power used to xmit signals
|
||||
//var/radio_power_use = 50 //power used to xmit signals
|
||||
|
||||
var/frequency = 1379
|
||||
var/datum/radio_frequency/radio_connection
|
||||
@@ -67,7 +67,7 @@
|
||||
/obj/machinery/embedded_controller/radio/post_signal(datum/signal/signal)
|
||||
signal.transmission_method = TRANSMISSION_RADIO
|
||||
if(radio_connection)
|
||||
use_power(radio_power_use)
|
||||
//use_power(radio_power_use) //neat idea, but causes way too much lag.
|
||||
return radio_connection.post_signal(src, signal)
|
||||
else
|
||||
del(signal)
|
||||
|
||||
Reference in New Issue
Block a user