68 lines
1.8 KiB
Lua
68 lines
1.8 KiB
Lua
local kernel = require("kernel")
|
|
|
|
reactor = peripheral.find("fissionReactorLogicAdapter")
|
|
turbine = peripheral.find("turbineValve")
|
|
turbineVent = peripheral.find("turbineVent")
|
|
monitor = peripheral.find("monitor")
|
|
|
|
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")
|
|
|
|
|
|
local function runMonitors()
|
|
while true do
|
|
parallel.waitForAll(
|
|
tempDriver.watch,
|
|
coolantDriver.watch,
|
|
statusDriver.watch,
|
|
turbineDriver.watch,
|
|
burnRateDriver.watch
|
|
)
|
|
end
|
|
end
|
|
|
|
local function runDisplay()
|
|
monitor.clear()
|
|
monitor.setTextScale(1)
|
|
while true do
|
|
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
|
|
monitor.setCursorPos(1, i)
|
|
item.driver.report()
|
|
monitor.setCursorPos(1, i + 1)
|
|
end
|
|
|
|
sleep(0.10) -- Update every tenth second
|
|
end
|
|
end
|
|
|
|
local function run()
|
|
while not reactor do
|
|
print("Waiting for reactor signal...")
|
|
sleep(1)
|
|
end
|
|
while not turbine do
|
|
print("Waiting for turbine signal...")
|
|
sleep(1)
|
|
end
|
|
while not monitor do
|
|
print("Waiting for monitor signal...")
|
|
sleep(1)
|
|
end
|
|
|
|
parallel.waitForAll(runMonitors, runDisplay)
|
|
end
|
|
|
|
return { run = run}
|