This commit is contained in:
2025-06-15 16:23:13 -04:00
parent dcb75ee52c
commit ead0e6379e
9 changed files with 118 additions and 108 deletions

View File

@@ -8,19 +8,6 @@ local function getValue()
return reactor.getBurnRate() or init
end
local function color()
local value = getValue()
return colors.black
end
local function watch()
while true do
sleep(0.05) -- Update every tenth second
end
end
local function stepUp()
local value = getValue()
@@ -49,17 +36,22 @@ local function stepDown()
reactor.setBurnRate(value - rateStep)
end
end
local function startUp()
end
local function shutdown()
end
local function watch()
print("Setting Default Burn Rate to: " .. init)
reactor.setBurnRate(init)
end
local function report()
local color = color()
local color = colors.black
monitor.setBackgroundColor(color)
value = getValue()
monitor.clearLine()
setNewLine()
monitor.write("Burn Rate: " .. value)
end
return { report = report, watch = watch, stepUp = stepUp, stepDown = stepDown, slowStepDown = slowStepDown, slowStepUp = slowStepUp }
return { report = report, watch = watch, stepUp = stepUp, stepDown = stepDown, slowStepDown = slowStepDown, slowStepUp = slowStepUp, startUp = startUp, shutdown = shutdown }

View File

@@ -30,17 +30,21 @@ local function watch()
end
end
-- local function watch()
-- checkCoolantLevel()
-- end
local function startUp()
end
local function shutdown()
end
local function report()
local value = getValue()
local color = colors.black
monitor.setBackgroundColor(color)
monitor.clearLine()
setNewLine()
monitor.write("Coolant: " .. value .. "%")
end
return { report = report, watch = watch}
return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }

26
environment_driver.lua Normal file
View File

@@ -0,0 +1,26 @@
local function getValue()
return environment.getRadiationLevel().radiation
end
local function watch()
while true do
sleep(0.05) -- Update every tenth second
end
end
local function startUp()
end
local function shutdown()
end
local function report()
local value = getValue()
local color = colors.black
monitor.setBackgroundColor(color)
setNewLine()
monitor.write("Radiation Level: " .. tostring(value))
end
return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }

View File

@@ -1,27 +0,0 @@
modem = peripheral.wrap("right")
environment = peripheral.wrap("left")
local function runMonitor()
while true do
local rads = environment.getRadiation();
print("Radiation Level: " .. rads.radiation)
print("Radiation Unit: " .. rads.unit)
sleep(1)
end
end
local function run()
while not modem do
print("Waiting for modem signal...")
sleep(1)
end
while not environment do
print("Waiting for environment signal...")
sleep(1)
end
parallel.waitForAll(runMonitor)
end
return { run = run}

View File

@@ -1,4 +0,0 @@
local kernel = require("kernel")
local main = kernel.addDriver("environment_main")
sleep(5)
main.run()

View File

@@ -3,48 +3,72 @@ reactor = peripheral.find("fissionReactorLogicAdapter")
turbine = peripheral.find("turbineValve")
turbineVent = peripheral.find("turbineVent")
monitor = peripheral.find("monitor")
environment = peripheral.find("environmentDetector")
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")
environmentDriver = kernel.addDriver("environment_driver")
function setNewLine()
local x,y = monitor.getCursorPos()
monitor.setCursorPos(1, y + 1)
monitor.clearLine()
end
local function runMonitors()
parallel.waitForAll(tempDriver.watch, coolantDriver.watch, statusDriver.watch, turbineDriver.watch, burnRateDriver.watch)
-- while true do
-- tempDriver.watch()
-- coolantDriver.watch()
-- statusDriver.watch()
-- turbineDriver.watch()
-- burnRateDriver.watch()
-- sleep(0.05)
-- end
parallel.waitForAll(
tempDriver.watch,
coolantDriver.watch,
statusDriver.watch,
turbineDriver.watch,
burnRateDriver.watch,
environmentDriver.watch)
end
local function runDisplay()
monitor.clear()
monitor.setTextScale(1)
while true do
monitor.setCursorPos(1, 1)
monitor.setCursorPos(1, 0)
local drivers = {
{ Label = "Status", driver = statusDriver},
{ Label = "Temperature", driver = tempDriver },
{ Label = "Coolant", driver = coolantDriver },
{ Label = "Turbine", driver = turbineDriver },
{ Label = "Burn Rate", driver = burnRateDriver }
{ Label = "Burn Rate", driver = burnRateDriver },
{ Label = "Radiation Level", driver = burnRateDriver }
}
for i, item in ipairs(drivers) do
monitor.setCursorPos(1, i)
item.driver.report()
monitor.setCursorPos(1, i + 1)
end
sleep(0.05) -- Update every tenth second
end
end
local function startUp()
parallel.waitForAll(tempDriver.startUp,
coolantDriver.startUp,
statusDriver.startUp,
turbineDriver.startUp,
burnRateDriver.startUp,
environmentDriver.startUp)
end
local function shutDown()
parallel.waitForAll(tempDriver.shutDown,
coolantDriver.shutDown,
statusDriver.shutDown,
turbineDriver.shutDown,
burnRateDriver.shutDown,
environmentDriver.shutDown)
end
local function run()
while not reactor do
print("Waiting for reactor signal...")
@@ -59,13 +83,11 @@ local function run()
sleep(1)
end
-- Wait for all driver objects to be available
while not (tempDriver and coolantDriver and statusDriver and turbineDriver and burnRateDriver) do
print("Waiting for all drivers to be initialized...")
sleep(1)
end
monitor.clear();
startUp();
parallel.waitForAll(runMonitors, runDisplay)
end
return { run = run }

View File

@@ -4,41 +4,37 @@ local function getValue()
end
-- local function watch()
-- while true do
-- checkStatus()
-- sleep(0.05) -- Update every tenth second
-- end
-- end
local function checkStatus()
local value = getValue()
end
-- local function watch()
-- checkStatus()
-- end
local function watch()
reactor.setBurnRate(2)
local status = reactor.getStatus()
if(not status) then
reactor.activate()
return
end
while true do
checkStatus()
sleep(0.05) -- Update every tenth second
end
end
local function startUp()
reactor.setBurnRate(2)
local status = reactor.getStatus()
if(not status) then
reactor.activate()
return
end
end
local function shutdown()
reactor.setBurnRate(0)
reactor.deactivate()
end
local function report()
local value = getValue()
local color = colors.black
monitor.setBackgroundColor(color)
monitor.clearLine()
setNewLine()
monitor.write("Reactor Status: " .. tostring(value))
end
return { report = report, watch = watch }
return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }

View File

@@ -22,13 +22,8 @@ local function checkTemperature()
end
end
-- local function color()
-- local temperature = getValue()
-- return colors.black
-- end
local function watch()
while true do
print("Temperature: " .. getValue())
checkTemperature()
@@ -37,18 +32,19 @@ local function watch()
end
local function startUp()
end
local function shutdown()
end
-- local function watch()
-- checkTemperature()
-- end
local function report()
local value = getValue()
local color = colors.black
monitor.setBackgroundColor(color)
monitor.clearLine()
setNewLine()
monitor.write("Temperature: " .. value .. "F")
end
return { report = report, watch = watch }
return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }

View File

@@ -35,9 +35,11 @@ local function checkSteamLevel()
end
end
-- local function watch()
-- checkSteamLevel()
-- end
local function startUp()
end
local function shutdown()
end
local function watch()
while true do
@@ -50,9 +52,12 @@ local function report()
local color = color()
monitor.setBackgroundColor(color)
value = getValue()
monitor.clearLine()
setNewLine()
monitor.write("Turbine Steam: " .. value .. "%")
--monitor.write("Turbine Vent: " .. turbine.getDumpingMode() .. "%")
setNewLine()
monitor.write("Turbine Vent: " .. turbine.getDumpingMode())
end
return { report = report, watch = watch }
return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }