updated
This commit is contained in:
43
burnrate_driver.lua
Normal file
43
burnrate_driver.lua
Normal 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 }
|
||||
@@ -12,9 +12,13 @@ end
|
||||
|
||||
|
||||
local function watch()
|
||||
while true do
|
||||
checkCoolantLevel()
|
||||
end
|
||||
end
|
||||
|
||||
local function checkCoolantLevel()
|
||||
local coolantLevel = getValue()
|
||||
print("Coolant: " .. coolantLevel)
|
||||
sleep(1)
|
||||
end
|
||||
|
||||
local function report()
|
||||
|
||||
32
main.lua
32
main.lua
@@ -5,21 +5,22 @@ turbine = peripheral.find("turbineValve")
|
||||
turbineVent = peripheral.find("turbineVent")
|
||||
monitor = peripheral.find("monitor")
|
||||
|
||||
local tempDriver = kernel.addDriver("temperature_driver")
|
||||
local coolantDriver = kernel.addDriver("coolant_driver")
|
||||
local statusDriver = kernel.addDriver("status_driver")
|
||||
local turbineDriver = kernel.addDriver("turbine_driver")
|
||||
tempDriver = kernel.addDriver("temperature_driver")
|
||||
coolantDriver = kernel.addDriver("coolant_driver")
|
||||
statusDriver = kernel.addDriver("status_driver")
|
||||
turbineDriver = kernel.addDriver("turbine_driver")
|
||||
burnRateDriver = kernel.addDriver("burnrate_driver")
|
||||
|
||||
isWarningState = false
|
||||
isCriticalState = false
|
||||
isShutdownState = false
|
||||
|
||||
local function runMonitors()
|
||||
while true do
|
||||
tempDriver.watch(reactor, monitor)
|
||||
coolantDriver.watch(reactor, monitor)
|
||||
statusDriver.watch(reactor, monitor)
|
||||
turbineDriver.watch(turbine, monitor)
|
||||
parallel.waitForAll(
|
||||
tempDriver.watch,
|
||||
coolantDriver.watch,
|
||||
statusDriver.watch,
|
||||
turbineDriver.watch,
|
||||
burnRateDriver.watch
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,20 +28,13 @@ local function runDisplay()
|
||||
monitor.clear()
|
||||
monitor.setTextScale(1)
|
||||
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)
|
||||
local drivers = {
|
||||
{ Label = "Status", driver = statusDriver},
|
||||
{ Label = "Temperature", driver = tempDriver },
|
||||
{ Label = "Coolant", driver = coolantDriver },
|
||||
{ Label = "Turbine", driver = turbineDriver }
|
||||
{ Label = "Burn Rate", driver = burnRateDriver }
|
||||
}
|
||||
|
||||
for i, item in ipairs(drivers) do
|
||||
|
||||
@@ -9,9 +9,13 @@ local function color()
|
||||
end
|
||||
|
||||
local function watch()
|
||||
while true do
|
||||
checkStatus()
|
||||
end
|
||||
end
|
||||
|
||||
local function checkStatus()
|
||||
local value = getValue()
|
||||
print("Status: " .. tostring(value))
|
||||
sleep(1)
|
||||
end
|
||||
|
||||
local function report()
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
local max = 250
|
||||
local min = 212
|
||||
|
||||
|
||||
local function getValue()
|
||||
local kelvin = reactor.getTemperature() or 0
|
||||
@@ -11,8 +14,23 @@ local function color()
|
||||
end
|
||||
|
||||
local function watch()
|
||||
print("Temperature: " .. getValue())
|
||||
sleep(1)
|
||||
while true do
|
||||
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
|
||||
|
||||
local function report()
|
||||
|
||||
@@ -13,18 +13,26 @@ local function color()
|
||||
end
|
||||
|
||||
local function watch()
|
||||
print("Turbine Steam Filled: " .. getValue())
|
||||
while true do
|
||||
checkSteamLevel()
|
||||
end
|
||||
end
|
||||
|
||||
local function checkSteamLevel()
|
||||
local value = getValue()
|
||||
if value > max then
|
||||
print("Warning: Steam above maximum! Taking action.")
|
||||
--reactor.scram();
|
||||
reactor.scram();
|
||||
turbine.setDumpingMode("DUMPING")
|
||||
burnRateDriver.stepDown()
|
||||
elseif value >= minVent and value <= maxVent then
|
||||
print("Steam within vent range. Adjusting vents.")
|
||||
turbine.setDumpingMode("DUMPING")
|
||||
burnRateDriver.stepDown()
|
||||
elseif value >= min and value < minVent then
|
||||
print("Steam within normal operation range.")
|
||||
turbine.setDumpingMode("DUMPING_EXCESS")
|
||||
turbine.setDumpingMode("DUMPING")
|
||||
burnRateDriver.stepDown()
|
||||
elseif value < min then
|
||||
print("Warning: Steam below minimum! Taking action.")
|
||||
turbine.setDumpingMode("IDLE")
|
||||
|
||||
Reference in New Issue
Block a user