mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-26 05:27:01 +01:00
Documents and standardizes power and energy units. Fixes a pulse demon bug. (#26560)
* Documents units of electrical power storage and production. Defines KJ. SMES properly convert watt ticks to KJ. Pulse demon bugfix * extra documentation * corrected pulse watt tick to joule conversion location on the pulse demon code * oops * Fixes nomenclature formats * fixes some comments, consolidates power defines in the power defines file
This commit is contained in:
@@ -32,21 +32,21 @@
|
||||
/// The status of the terminals powernet that this APC is connected to: not connected, no power, or recieving power
|
||||
var/main_status = APC_EXTERNAL_POWER_NOTCONNECTED
|
||||
|
||||
/// amount of power used in the last cycle for lighting channel
|
||||
/// amount of power used in the last cycle for lighting channel (Watts)
|
||||
var/last_used_lighting = 0
|
||||
/// amount of power used in the last cycle for equipment channel
|
||||
/// amount of power used in the last cycle for equipment channel (Watts)
|
||||
var/last_used_equipment = 0
|
||||
/// amount of power used in the last cycle for environment channel
|
||||
/// amount of power used in the last cycle for environment channel (Watts)
|
||||
var/last_used_environment = 0
|
||||
/// amount of power used in the last cycle in total
|
||||
/// amount of power used in the last cycle in total (Watts)
|
||||
var/last_used_total = 0
|
||||
|
||||
/*** APC Cell Vars ***/
|
||||
/// the cell type stored in this APC
|
||||
/// the cell type stored in this APC. APC uses cell energy capacity (kilojoules)
|
||||
var/obj/item/stock_parts/cell/cell
|
||||
/// the percentage charge the internal battery will start with
|
||||
var/start_charge = 90
|
||||
/// Base cell has 2500 capacity. Enter the path of a different cell you want to use. cell determines charge rates, max capacity, ect. These can also be changed with other APC vars, but isn't recommended to minimize the risk of accidental usage of dirty editted APCs
|
||||
/// Base cell has a 2500 kJ capacity. Enter the path of a different cell you want to use. cell determines charge rates, max capacity, ect. These can also be changed with other APC vars, but isn't recommended to minimize the risk of accidental usage of dirty edited APCs
|
||||
var/cell_type = 2500
|
||||
|
||||
/*** APC Status Vars ***/
|
||||
|
||||
@@ -10,16 +10,16 @@
|
||||
throw_speed = 2
|
||||
throw_range = 5
|
||||
w_class = WEIGHT_CLASS_SMALL
|
||||
///How much charge the battery currently has
|
||||
/// Battery's current state of charge (kilojoules)
|
||||
var/charge = 0
|
||||
///How much charge the battery can hold
|
||||
/// Battery's maximum state of charge (kilojoules)
|
||||
var/maxcharge = 1000
|
||||
///How much charge the battery should start with
|
||||
/// How much energy the cell starts with (kilojoules)
|
||||
var/starting_charge
|
||||
materials = list(MAT_METAL = 700, MAT_GLASS = 50)
|
||||
///If the battery will explode
|
||||
var/rigged = FALSE
|
||||
///How much charge is given every tick when recharging
|
||||
/// How much energy is given to a recharging cell every tick (kilojoules / tick)
|
||||
var/chargerate = 100
|
||||
///Whether it will recharge automatically
|
||||
var/self_recharge = FALSE
|
||||
@@ -36,7 +36,8 @@
|
||||
START_PROCESSING(SSobj, src)
|
||||
charge = !isnull(starting_charge) ? starting_charge : maxcharge
|
||||
if(ratingdesc)
|
||||
desc += " This one has a power rating of [DisplayPower(maxcharge)], and you should not swallow it."
|
||||
// State of charge is in kJ so we multiply it by 1000 to get Joules
|
||||
desc += " This one has a power rating of [DisplayJoules(maxcharge * 1000)], and you should not swallow it."
|
||||
update_icon(UPDATE_OVERLAYS)
|
||||
|
||||
/obj/item/stock_parts/cell/Destroy()
|
||||
|
||||
@@ -13,38 +13,40 @@
|
||||
/obj/machinery/power/Destroy()
|
||||
disconnect_from_network()
|
||||
return ..()
|
||||
|
||||
/// Adds available power to the next powernet process (Watts)
|
||||
/obj/machinery/power/proc/produce_direct_power(amount)
|
||||
if(powernet)
|
||||
powernet.queued_power_production += amount
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/// Adds power demand to the powernet, machines should use this
|
||||
/// Adds power demand to the powernet (Watts)
|
||||
/// machines should use this proc
|
||||
/obj/machinery/power/proc/consume_direct_power(amount)
|
||||
powernet?.power_demand += amount
|
||||
|
||||
/// Gets surplus power available on this machines powernet, machines should use this proc
|
||||
/// Gets surplus power available on this machine's powernet (Watts)
|
||||
/obj/machinery/power/proc/get_surplus()
|
||||
return powernet ? powernet.calculate_surplus() : 0
|
||||
|
||||
/// Gets surplus power available on this machines powernet, machines should use this proc
|
||||
/// Gets surplus power available on this machine's powernet (Watts)
|
||||
/obj/machinery/power/proc/get_power_balance()
|
||||
return powernet ? powernet.calculate_power_balance() : 0
|
||||
|
||||
/// Gets power available (NOT EXTRA) on this cables powernet, machines should use this
|
||||
/// Gets power available (NOT EXTRA) on this cables powernet (Watts)
|
||||
/// machines should use this proc
|
||||
/obj/machinery/power/proc/get_available_power()
|
||||
return powernet ? powernet.available_power : 0
|
||||
|
||||
/// Adds queued power demand to be met next process cycle
|
||||
/// Adds queued power demand to be met next process cycle (Watts)
|
||||
/obj/machinery/power/proc/add_queued_power_demand(amount)
|
||||
powernet?.queued_power_demand += amount
|
||||
|
||||
/// Gets surplus power queued for next process cycle on this cables powernet
|
||||
/// Gets surplus power queued for next process cycle on this cables powernet (Watts)
|
||||
/obj/machinery/power/proc/get_queued_surplus()
|
||||
return powernet?.calculate_queued_surplus()
|
||||
|
||||
/// Gets available (NOT EXTRA) power queued for next process cycle on this machines powernet
|
||||
/// Gets available (NOT EXTRA) power queued for next process cycle on this machine's powernet (Watts)
|
||||
/obj/machinery/power/proc/get_queued_available_power()
|
||||
return powernet?.queued_power_production
|
||||
|
||||
|
||||
@@ -12,18 +12,18 @@
|
||||
/// All Power Machines that are connected to this powernet
|
||||
var/list/nodes = list()
|
||||
|
||||
/// the current available power in the powernet
|
||||
/// the current available power in the powernet (Watts)
|
||||
var/available_power = 0
|
||||
/// the current load on the powernet, increased by each machine at processing
|
||||
/// the current load on the powernet, increased by each machine at processing (Watts)
|
||||
var/power_demand = 0
|
||||
/// what available power was gathered last tick, then becomes...
|
||||
/// what available power was gathered last tick, then becomes... (Watts)
|
||||
var/queued_power_production = 0
|
||||
/// load applied to powernet between power ticks.
|
||||
/// load applied to powernet between power ticks. (Watts)
|
||||
var/queued_power_demand = 0
|
||||
/// excess power on the powernet (typically avail-load)
|
||||
/// excess power on the powernet (typically avail-load) (Watts)
|
||||
var/excess_power = 0
|
||||
|
||||
/// the available power as it appears on the power console (gradually updated)
|
||||
/// the available power as it appears on the power console (gradually updated) (Watts)
|
||||
var/smoothed_available_power = 0
|
||||
/// the load as it appears on the power console (gradually updated)
|
||||
var/smoothed_demand = 0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#define SMESMAXCHARGELEVEL 200000
|
||||
#define SMESMAXOUTPUT 200000
|
||||
#define SMESRATE 0.05 // rate of internal charge to external power
|
||||
/// Conversion ratio between a Watt-tick and SMES capacity units (should be the same as power cells)
|
||||
#define SMESRATE GLOB.CELLRATE
|
||||
|
||||
/obj/machinery/power/smes
|
||||
name = "power storage unit"
|
||||
@@ -8,17 +9,17 @@
|
||||
icon_state = "smes"
|
||||
density = TRUE
|
||||
|
||||
/// Maximum charge of the SMES
|
||||
var/capacity = 5e6
|
||||
/// Maximum amount of energy the SMES can store (kilojoules)
|
||||
var/capacity = 0.2e6
|
||||
/// Current charge level
|
||||
var/charge = 0
|
||||
/// Set TRUE if SMES attempting to charge, FALSE if not
|
||||
var/input_attempt = TRUE
|
||||
/// Set TRUE if SMES is inputting, FALSE if not
|
||||
var/inputting = TRUE
|
||||
/// Amount of power the SMES attempts to charge by
|
||||
/// How much power the SMES will draw from the grid to recharge itself (Watts)
|
||||
var/input_level = 50000
|
||||
/// Maximum input level
|
||||
/// Maximum input level (Watts)
|
||||
var/input_level_max = 200000
|
||||
/// Charge amount available from input last tick
|
||||
var/input_available = 0
|
||||
@@ -26,9 +27,9 @@
|
||||
var/output_attempt = TRUE
|
||||
/// TRUE = actually outputting, FALSE = not outputting
|
||||
var/outputting = TRUE
|
||||
/// Amount of power the SMES attempts to output
|
||||
/// Amount of power the SMES attempts to output (Watts)
|
||||
var/output_level = 50000
|
||||
/// Cap on output_level
|
||||
/// Cap on output_level (Watts)
|
||||
var/output_level_max = 200000
|
||||
/// Amount of power actually outputted. may be less than output_level if the powernet returns excess power
|
||||
var/output_used = 0
|
||||
@@ -87,7 +88,7 @@
|
||||
output_level_max = 200000 * IO
|
||||
for(var/obj/item/stock_parts/cell/PC in component_parts)
|
||||
C += PC.maxcharge
|
||||
capacity = C / (15000) * 1e6
|
||||
capacity = C * 1e3 / 375
|
||||
|
||||
/obj/machinery/power/smes/update_overlays()
|
||||
. = ..()
|
||||
@@ -448,7 +449,7 @@
|
||||
..()
|
||||
|
||||
/obj/machinery/power/smes/engineering
|
||||
charge = 2e6 // Engineering starts with some charge for singulo
|
||||
charge = 0.08e6 // Engineering starts with some charge for singulo
|
||||
|
||||
/obj/machinery/power/smes/magical
|
||||
name = "magical power storage unit"
|
||||
|
||||
@@ -174,9 +174,6 @@
|
||||
/obj/item/food/sliceable/xenomeatbread //maybe add some dangerous/special food here, ie robobuger?
|
||||
)
|
||||
|
||||
#define kW *1000
|
||||
#define MW kW *1000
|
||||
#define GW MW *1000
|
||||
#define BASE_ENERGY_CONVERSION 4e-6
|
||||
#define BASE_POINTS 2
|
||||
|
||||
@@ -205,8 +202,8 @@
|
||||
luminosity = 1
|
||||
|
||||
/// Correspond to power required for a mining level, first entry for level 1, etc.
|
||||
var/list/power_needs = list(1 kW, 2 kW, 5 kW, 10 kW, 15 kW,
|
||||
25 kW, 50 kW, 100 kW, 250 kW, 500 kW,
|
||||
var/list/power_needs = list(1 KW, 2 KW, 5 KW, 10 KW, 15 KW,
|
||||
25 KW, 50 KW, 100 KW, 250 KW, 500 KW,
|
||||
1 MW, 2 MW, 5 MW, 10 MW, 15 MW,
|
||||
20 MW, 25 MW, 30 MW, 40 MW, 50 MW,
|
||||
60 MW, 70 MW, 80 MW, 90 MW, 100 MW)
|
||||
@@ -583,8 +580,5 @@
|
||||
<p><small>Device highly experimental. Not for sale. Do not operate near small children or vital NT assets. Do not tamper with machine. In case of existential dread, stop machine immediately. \
|
||||
Please document any and all extradimensional incursions. In case of imminent death, please leave said documentation in plain sight for clean-up teams to recover.</small></p>"
|
||||
|
||||
#undef kW
|
||||
#undef MW
|
||||
#undef GW
|
||||
#undef BASE_ENERGY_CONVERSION
|
||||
#undef BASE_POINTS
|
||||
|
||||
Reference in New Issue
Block a user