updated
This commit is contained in:
42
main.lua
42
main.lua
@@ -4,12 +4,18 @@ local monitor = peripheral.find("monitor")
|
|||||||
local tempDriver = kernel.addDriver("temperature_driver")
|
local tempDriver = kernel.addDriver("temperature_driver")
|
||||||
local coolantDriver = kernel.addDriver("coolant_driver")
|
local coolantDriver = kernel.addDriver("coolant_driver")
|
||||||
local statusDriver = kernel.addDriver("status_driver")
|
local statusDriver = kernel.addDriver("status_driver")
|
||||||
|
local turbineDriver = kernel.addDriver("turbine_driver")
|
||||||
|
|
||||||
|
isWarningState = false
|
||||||
|
isCriticalState = false
|
||||||
|
isShutdownState = false
|
||||||
|
|
||||||
local function runMonitors()
|
local function runMonitors()
|
||||||
while true do
|
while true do
|
||||||
tempDriver.watch(reactor, monitor)
|
tempDriver.watch(reactor, monitor)
|
||||||
coolantDriver.watch(reactor, monitor)
|
coolantDriver.watch(reactor, monitor)
|
||||||
statusDriver.watch(reactor, monitor)
|
statusDriver.watch(reactor, monitor)
|
||||||
|
turbineDriver.watch(reactor, monitor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -17,12 +23,20 @@ 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 },
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, item in ipairs(drivers) do
|
for i, item in ipairs(drivers) do
|
||||||
@@ -50,29 +64,3 @@ local function run()
|
|||||||
end
|
end
|
||||||
|
|
||||||
return { run = run}
|
return { run = run}
|
||||||
|
|
||||||
-- local monitor = peripheral.wrap("top")
|
|
||||||
-- local modem = peripheral.wrap("back")
|
|
||||||
-- print(monitor)
|
|
||||||
-- monitor.clear()
|
|
||||||
-- monitor.setTextScale(1)
|
|
||||||
-- local maxWidth, maxHeight = monitor.getSize()
|
|
||||||
-- local y = 1
|
|
||||||
-- monitor.setCursorPos(1, y)
|
|
||||||
-- local init = "Initalizing stream...."
|
|
||||||
-- monitor.write(init)
|
|
||||||
-- print(init)
|
|
||||||
-- y = y+1
|
|
||||||
-- modem.open(80)
|
|
||||||
|
|
||||||
-- while true do
|
|
||||||
-- local _, _, _, _, message = os.pullEvent("modem_message")
|
|
||||||
-- monitor.setCursorPos(1, y)
|
|
||||||
-- print(message)
|
|
||||||
-- monitor.write(message)
|
|
||||||
-- y=y+1
|
|
||||||
-- if(y > maxHeight) then
|
|
||||||
-- y=maxHeight
|
|
||||||
-- monitor.scroll(1)
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
23
turbine_driver.lua
Normal file
23
turbine_driver.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
local function getValue(reactor)
|
||||||
|
return reactor.getStatus() or false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function color(reactor)
|
||||||
|
local value = getValue(reactor)
|
||||||
|
return colors.black
|
||||||
|
end
|
||||||
|
|
||||||
|
local function watch(reactor, monitor)
|
||||||
|
print("Status: " .. getValue(reactor))
|
||||||
|
sleep(5)
|
||||||
|
isWarningState = true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function report(reactor, monitor)
|
||||||
|
local value = getValue(reactor)
|
||||||
|
local color = color(reactor)
|
||||||
|
monitor.setBackgroundColor(color)
|
||||||
|
monitor.clearLine()
|
||||||
|
monitor.write("Reactor Status: " .. tostring(value))
|
||||||
|
end
|
||||||
|
return { report = report, watch = watch }
|
||||||
Reference in New Issue
Block a user