Files
11717823df Power Code Cleanup + Conversion to Regional Powernets [Refactor Only] (#20598)
* initial edits

* more cleanup, yipee

* moving shit around

* dme fixes

* fixes file ticking issue

* more dme fixes + duplicate files???

* Apply suggestions from code review

Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>

* glass floor fixes

* Apply suggestions from code review

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

* requested reviews

* the most painful bugfix of my life

* forgot to remove some debug stuff

* fixed issues with excess power

* fuck powernets (fix)

* Update code/modules/power/powernets/README.md

Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com>

---------

Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com>
2023-05-31 20:55:10 -05:00

32 lines
2.1 KiB
Markdown

# Understanding Powernets
Much like any other massive numbers system in SS13, the power (or powernet) system is complex and confusing to work with, only being trumped in complexity by atmospherics/LINDA. This README serves as a powernets 101 guide and breaks down how the system works.
## Two Types of Powernets
There are two types of powernets in our code
1. Regional Powernets
2. Local Powernets
They are two completely different datum types from eachother and serve different completely different purposes. In a nutshell, regional powernets are dynamically sized and deal with physical machinery, cables, and generators whereas local powernets are statically locked into a single area each and work directly with APCs to handle individual machines interactions with the larger regional powernet.
## Regional Powernet
An inter-area datum which handles 1 continuous set of cables (`var/list/cables`) and all the connected machinery/nodes on that set of cable (`var/list/nodes`).
On this datum you'll notice a lot of different vars handling power input, output, consumption, demand, etc
### Regional Powernet Process Call Stack
Starting in SSmachines,
`/datum/controller/subsystem/machines/fire(resumed = 0)`
the `fire()` proc will call process `process_powernets()`
`/datum/controller/subsystem/machines/proc/process_powernets(resumed = 0)`
This proc will then call `process_power()` on every single registered regional powernet
### The Power Variables
`var/available_power` - the currently available power in the powernet in watts THIS PROCESS CYCLE
`var/power_demand` - the power being consumed from available power in watts THIS PROCESS CYCLE
`var/queued_power_production` - the power in watts that will be available to be consumed in the NEXT PROCESS CYCLE
--> All power producing generators dump their production into this variable
`var/queued_power_demand` - the power in watts that will be guaranteed to be consumed in the NEXT PROCESS CYCLE
--> Anything machine/item that needs to have priority consumption draws from the queue'd cycle first in order to ensure it gets priority power (electrocution, powersinks, etc)