round burn rate to prevent weird floating point issues, added debug prints

This commit is contained in:
Mikayla Fischler 2022-10-20 13:27:33 -04:00
parent 1bf8fe557c
commit 2f55ad76f2
2 changed files with 10 additions and 4 deletions

View File

@ -200,6 +200,8 @@ function plc.rps_init(reactor)
self.reactor_enabled = true
return true
end
else
log.debug(util.c("RPS: failed start, RPS tripped: ", self.trip_cause))
end
return false
@ -280,6 +282,8 @@ function plc.rps_init(reactor)
for i = 1, #self.state do
self.state[i] = false
end
log.info("RPS: reset")
end
return public
@ -677,7 +681,7 @@ function plc.comms(id, version, modem, local_port, server_port, reactor, rps, co
-- set the burn rate
if packet.length == 2 then
local success = false
local burn_rate = packet.data[1]
local burn_rate = math.floor(packet.data[1] * 10) / 10
local ramp = packet.data[2]
-- if no known max burn rate, check again
@ -696,6 +700,8 @@ function plc.comms(id, version, modem, local_port, server_port, reactor, rps, co
self.reactor.setBurnRate(burn_rate)
success = not self.reactor.__p_is_faulted()
end
else
log.debug(burn_rate .. " rate outside of 0 < x <= " .. self.max_burn_rate)
end
end

View File

@ -13,7 +13,7 @@ local config = require("reactor-plc.config")
local plc = require("reactor-plc.plc")
local threads = require("reactor-plc.threads")
local R_PLC_VERSION = "beta-v0.8.8"
local R_PLC_VERSION = "beta-v0.8.9"
local print = util.print
local println = util.println
@ -143,14 +143,14 @@ local function init()
smem_dev.reactor, smem_sys.rps, smem_sys.conn_watchdog)
log.debug("init> comms init")
else
println("boot> starting in offline mode");
println("boot> starting in offline mode")
log.debug("init> running without networking")
end
---@diagnostic disable-next-line: undefined-field
os.queueEvent("clock_start")
println("boot> completed");
println("boot> completed")
log.debug("init> boot completed")
else
println("boot> system in degraded state, awaiting devices...")