#148 fixed burn rate ramping, adjusted auto burn rate ramping
This commit is contained in:
parent
fe71615c12
commit
846f9685ad
@ -824,9 +824,12 @@ function plc.comms(id, version, modem, local_port, server_port, reactor, rps, co
|
|||||||
if rps.is_active() then
|
if rps.is_active() then
|
||||||
if rps.get_runtime() > AUTO_TOGGLE_DELAY_MS then
|
if rps.get_runtime() > AUTO_TOGGLE_DELAY_MS then
|
||||||
-- auto scram to disable
|
-- auto scram to disable
|
||||||
|
log.debug("AUTO: stopping the reactor to meet 0.0 burn rate")
|
||||||
if rps.scram() then
|
if rps.scram() then
|
||||||
ack = AUTO_ACK.ZERO_DIS_OK
|
ack = AUTO_ACK.ZERO_DIS_OK
|
||||||
self.auto_last_disable = util.time_ms()
|
self.auto_last_disable = util.time_ms()
|
||||||
|
else
|
||||||
|
log.debug("AUTO: automatic reactor stop failed")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- too soon to disable
|
-- too soon to disable
|
||||||
@ -838,24 +841,32 @@ function plc.comms(id, version, modem, local_port, server_port, reactor, rps, co
|
|||||||
elseif burn_rate <= self.max_burn_rate then
|
elseif burn_rate <= self.max_burn_rate then
|
||||||
if not rps.is_active() then
|
if not rps.is_active() then
|
||||||
-- activate the reactor
|
-- activate the reactor
|
||||||
if not rps.auto_activate() then
|
log.debug("AUTO: activating the reactor")
|
||||||
log.debug("automatic reactor activation failed")
|
if rps.auto_activate() then
|
||||||
|
self.reactor.setBurnRate(0.1)
|
||||||
|
if self.reactor.__p_is_faulted() then
|
||||||
|
log.debug("AUTO: failed to reset burn rate on auto activation")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
log.debug("AUTO: automatic reactor activation failed")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if active, set/ramp burn rate
|
-- if active, set/ramp burn rate
|
||||||
if rps.is_active() then
|
if rps.is_active() then
|
||||||
if ramp then
|
if ramp then
|
||||||
|
log.debug(util.c("AUTO: setting burn rate ramp to ", burn_rate))
|
||||||
setpoints.burn_rate_en = true
|
setpoints.burn_rate_en = true
|
||||||
setpoints.burn_rate = burn_rate
|
setpoints.burn_rate = burn_rate
|
||||||
ack = AUTO_ACK.RAMP_SET_OK
|
ack = AUTO_ACK.RAMP_SET_OK
|
||||||
else
|
else
|
||||||
|
log.debug(util.c("AUTO: setting burn rate directly to ", burn_rate))
|
||||||
self.reactor.setBurnRate(burn_rate)
|
self.reactor.setBurnRate(burn_rate)
|
||||||
ack = util.trinary(self.reactor.__p_is_faulted(), AUTO_ACK.FAIL, AUTO_ACK.DIRECT_SET_OK)
|
ack = util.trinary(self.reactor.__p_is_faulted(), AUTO_ACK.FAIL, AUTO_ACK.DIRECT_SET_OK)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log.debug(burn_rate .. " rate outside of 0 < x <= " .. self.max_burn_rate)
|
log.debug(util.c(burn_rate, " rate outside of 0 < x <= ", self.max_burn_rate))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ local config = require("reactor-plc.config")
|
|||||||
local plc = require("reactor-plc.plc")
|
local plc = require("reactor-plc.plc")
|
||||||
local threads = require("reactor-plc.threads")
|
local threads = require("reactor-plc.threads")
|
||||||
|
|
||||||
local R_PLC_VERSION = "beta-v0.10.0"
|
local R_PLC_VERSION = "beta-v0.10.1"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
|||||||
@ -623,19 +623,19 @@ function threads.thread__setpoint_control(smem)
|
|||||||
local current_burn_rate = reactor.getBurnRate()
|
local current_burn_rate = reactor.getBurnRate()
|
||||||
|
|
||||||
-- we yielded, check enable again
|
-- we yielded, check enable again
|
||||||
if setpoints.burn_rate_en and (current_burn_rate ~= ppm.ACCESS_FAULT) and (current_burn_rate ~= setpoints.burn_rate) then
|
if setpoints.burn_rate_en and (type(current_burn_rate) == "number") and (current_burn_rate ~= setpoints.burn_rate) then
|
||||||
-- calculate new burn rate
|
-- calculate new burn rate
|
||||||
local new_burn_rate = current_burn_rate
|
local new_burn_rate = current_burn_rate
|
||||||
|
|
||||||
if setpoints.burn_rate > current_burn_rate then
|
if setpoints.burn_rate > current_burn_rate then
|
||||||
-- need to ramp up
|
-- need to ramp up
|
||||||
local new_burn_rate = current_burn_rate + (BURN_RATE_RAMP_mB_s * min_elapsed_s)
|
new_burn_rate = current_burn_rate + (BURN_RATE_RAMP_mB_s * min_elapsed_s)
|
||||||
if new_burn_rate > setpoints.burn_rate then
|
if new_burn_rate > setpoints.burn_rate then
|
||||||
new_burn_rate = setpoints.burn_rate
|
new_burn_rate = setpoints.burn_rate
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- need to ramp down
|
-- need to ramp down
|
||||||
local new_burn_rate = current_burn_rate - (BURN_RATE_RAMP_mB_s * min_elapsed_s)
|
new_burn_rate = current_burn_rate - (BURN_RATE_RAMP_mB_s * min_elapsed_s)
|
||||||
if new_burn_rate < setpoints.burn_rate then
|
if new_burn_rate < setpoints.burn_rate then
|
||||||
new_burn_rate = setpoints.burn_rate
|
new_burn_rate = setpoints.burn_rate
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user