94 lines
2.4 KiB
Lua
94 lines
2.4 KiB
Lua
kernel = require("kernel")
|
|
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,
|
|
environmentDriver.watch)
|
|
end
|
|
|
|
local function runDisplay()
|
|
monitor.clear()
|
|
monitor.setTextScale(1)
|
|
while true do
|
|
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 = "Radiation Level", driver = environmentDriver }
|
|
}
|
|
|
|
|
|
for i, item in ipairs(drivers) do
|
|
item.driver.report()
|
|
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...")
|
|
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
|
|
|
|
monitor.clear();
|
|
startUp();
|
|
parallel.waitForAll(runMonitors, runDisplay)
|
|
end
|
|
|
|
|
|
|
|
return { run = run }
|