local max = 310
local min = 300


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 - 1
    local lowerThreshold = min + 1

    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.slowStepUp()
    end
end


local function watch()
    while true do
        print("Temperature: " .. getValue())
        checkTemperature()
        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("Temperature: " .. value .. "F")
end
return { report = report, watch = watch, startup = startup, shutdown = shutdown }