54 lines
1.3 KiB
Lua
54 lines
1.3 KiB
Lua
local max = 300
|
|
local min = 250
|
|
|
|
|
|
local function getValue()
|
|
local kelvin = reactor.getTemperature() or 0
|
|
local fahrenheit = (kelvin - 273.15) * 9 / 5 + 32
|
|
return math.floor(fahrenheit * 10000 + 0.5) / 10000
|
|
end
|
|
|
|
local function checkTemperature()
|
|
local temperature = getValue()
|
|
local upperThreshold = max - 5
|
|
local lowerThreshold = min + 5
|
|
|
|
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 color()
|
|
-- local temperature = getValue()
|
|
-- return colors.black
|
|
-- end
|
|
|
|
local function watch()
|
|
|
|
while true do
|
|
print("Temperature: " .. getValue())
|
|
checkTemperature()
|
|
sleep(0.05) -- Update every tenth second
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- local function watch()
|
|
-- checkTemperature()
|
|
-- end
|
|
|
|
local function report()
|
|
local value = getValue()
|
|
local color = colors.black
|
|
monitor.setBackgroundColor(color)
|
|
monitor.clearLine()
|
|
monitor.write("Temperature: " .. value .. "F")
|
|
end
|
|
return { report = report, watch = watch } |