This commit is contained in:
2025-06-14 17:02:44 -04:00
parent 3297944cda
commit 904309aa0f
6 changed files with 99 additions and 28 deletions

43
burnrate_driver.lua Normal file
View File

@@ -0,0 +1,43 @@
local max = 15
local init = 5
local rateStep = 0.10
local min = 1
local function getValue()
return reactor.getBurnRate()
end
local function color()
local value = getValue()
return colors.black
end
local function watch()
while true do
end
end
local function stepUp()
local value = getValue()
if value < max then
reactor.setBurnRate(value + rateStep)
end
end
local function stepDown()
local value = getValue()
if value > min then
reactor.setBurnRate(value - rateStep)
end
end
local function report()
local color = color()
monitor.setBackgroundColor(color)
value = getValue()
monitor.clearLine()
monitor.write("Burn Rate: " .. value)
end
return { report = report, watch = watch }

View File

@@ -12,9 +12,13 @@ end
local function watch() local function watch()
while true do
checkCoolantLevel()
end
end
local function checkCoolantLevel()
local coolantLevel = getValue() local coolantLevel = getValue()
print("Coolant: " .. coolantLevel)
sleep(1)
end end
local function report() local function report()

View File

@@ -5,21 +5,22 @@ turbine = peripheral.find("turbineValve")
turbineVent = peripheral.find("turbineVent") turbineVent = peripheral.find("turbineVent")
monitor = peripheral.find("monitor") monitor = peripheral.find("monitor")
local tempDriver = kernel.addDriver("temperature_driver") tempDriver = kernel.addDriver("temperature_driver")
local coolantDriver = kernel.addDriver("coolant_driver") coolantDriver = kernel.addDriver("coolant_driver")
local statusDriver = kernel.addDriver("status_driver") statusDriver = kernel.addDriver("status_driver")
local turbineDriver = kernel.addDriver("turbine_driver") turbineDriver = kernel.addDriver("turbine_driver")
burnRateDriver = kernel.addDriver("burnrate_driver")
isWarningState = false
isCriticalState = false
isShutdownState = false
local function runMonitors() local function runMonitors()
while true do while true do
tempDriver.watch(reactor, monitor) parallel.waitForAll(
coolantDriver.watch(reactor, monitor) tempDriver.watch,
statusDriver.watch(reactor, monitor) coolantDriver.watch,
turbineDriver.watch(turbine, monitor) statusDriver.watch,
turbineDriver.watch,
burnRateDriver.watch
)
end end
end end
@@ -27,20 +28,13 @@ local function runDisplay()
monitor.clear() monitor.clear()
monitor.setTextScale(1) monitor.setTextScale(1)
while true do while true do
if(isWarningState or isCriticalState or isShutdownState) then
monitor.setBackgroundColor(colors.red)
monitor.clear()
monitor.setCursorPos(1, 1)
monitor.write("Reactor in critical state!")
sleep(2)
monitor.clear()
end
monitor.setCursorPos(1, 1) monitor.setCursorPos(1, 1)
local drivers = { local drivers = {
{ Label = "Status", driver = statusDriver}, { Label = "Status", driver = statusDriver},
{ Label = "Temperature", driver = tempDriver }, { Label = "Temperature", driver = tempDriver },
{ Label = "Coolant", driver = coolantDriver }, { Label = "Coolant", driver = coolantDriver },
{ Label = "Turbine", driver = turbineDriver } { Label = "Turbine", driver = turbineDriver }
{ Label = "Burn Rate", driver = burnRateDriver }
} }
for i, item in ipairs(drivers) do for i, item in ipairs(drivers) do

View File

@@ -9,9 +9,13 @@ local function color()
end end
local function watch() local function watch()
while true do
checkStatus()
end
end
local function checkStatus()
local value = getValue() local value = getValue()
print("Status: " .. tostring(value))
sleep(1)
end end
local function report() local function report()

View File

@@ -1,3 +1,6 @@
local max = 250
local min = 212
local function getValue() local function getValue()
local kelvin = reactor.getTemperature() or 0 local kelvin = reactor.getTemperature() or 0
@@ -11,8 +14,23 @@ local function color()
end end
local function watch() local function watch()
print("Temperature: " .. getValue()) while true do
sleep(1) print("Temperature: " .. getValue())
checkTemperature()
end
end
local function checkTemperature()
local temperature = getValue()
local upperThreshold = max - 20
local lowerThreshold = min + 20
if temperature >= upperThreshold then
print("Warning: Temperature approaching upper limit! Taking action.")
burnRateDriver.stepDown()
elseif temperature <= lowerThreshold then
print("Warning: Temperature approaching lower limit! Taking action.")
burnRateDriver.stepUp()
end
end end
local function report() local function report()

View File

@@ -13,18 +13,26 @@ local function color()
end end
local function watch() local function watch()
print("Turbine Steam Filled: " .. getValue()) while true do
checkSteamLevel()
end
end
local function checkSteamLevel()
local value = getValue() local value = getValue()
if value > max then if value > max then
print("Warning: Steam above maximum! Taking action.") print("Warning: Steam above maximum! Taking action.")
--reactor.scram(); reactor.scram();
turbine.setDumpingMode("DUMPING") turbine.setDumpingMode("DUMPING")
burnRateDriver.stepDown()
elseif value >= minVent and value <= maxVent then elseif value >= minVent and value <= maxVent then
print("Steam within vent range. Adjusting vents.") print("Steam within vent range. Adjusting vents.")
turbine.setDumpingMode("DUMPING") turbine.setDumpingMode("DUMPING")
burnRateDriver.stepDown()
elseif value >= min and value < minVent then elseif value >= min and value < minVent then
print("Steam within normal operation range.") print("Steam within normal operation range.")
turbine.setDumpingMode("DUMPING_EXCESS") turbine.setDumpingMode("DUMPING")
burnRateDriver.stepDown()
elseif value < min then elseif value < min then
print("Warning: Steam below minimum! Taking action.") print("Warning: Steam below minimum! Taking action.")
turbine.setDumpingMode("IDLE") turbine.setDumpingMode("IDLE")