#93 don't send out-of-range burn rates (won't get a good ack), fixed unit command packet ordering

This commit is contained in:
Mikayla Fischler 2022-10-07 11:28:56 -04:00
parent 529951f998
commit 5dfbe650c6
3 changed files with 19 additions and 13 deletions

View File

@ -182,8 +182,8 @@ function coordinator.new_session(id, in_queue, out_queue, facility_units)
elseif pkt.type == SCADA_CRDN_TYPES.COMMAND_UNIT then elseif pkt.type == SCADA_CRDN_TYPES.COMMAND_UNIT then
if pkt.length >= 2 then if pkt.length >= 2 then
-- get command and unit id -- get command and unit id
local cmd = pkt.data[1] local uid = pkt.data[1]
local uid = pkt.data[2] local cmd = pkt.data[2]
-- continue if valid unit id -- continue if valid unit id
if util.is_int(uid) and uid > 0 and uid <= #self.units then if util.is_int(uid) and uid > 0 and uid <= #self.units then

View File

@ -519,18 +519,24 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
local cmd = message.message ---@type queue_data local cmd = message.message ---@type queue_data
if cmd.key == PLC_S_DATA.BURN_RATE then if cmd.key == PLC_S_DATA.BURN_RATE then
-- update burn rate -- update burn rate
self.commanded_burn_rate = cmd.val cmd.val = math.floor(cmd.val * 10) / 10 -- round to 10ths place
self.ramping_rate = false if cmd.val > 0 and cmd.val <= self.sDB.mek_struct.max_burn then
self.acks.burn_rate = false self.commanded_burn_rate = cmd.val
self.retry_times.burn_rate_req = util.time() + INITIAL_WAIT self.ramping_rate = false
_send(RPLC_TYPES.MEK_BURN_RATE, { self.commanded_burn_rate, self.ramping_rate }) self.acks.burn_rate = false
self.retry_times.burn_rate_req = util.time() + INITIAL_WAIT
_send(RPLC_TYPES.MEK_BURN_RATE, { self.commanded_burn_rate, self.ramping_rate })
end
elseif cmd.key == PLC_S_DATA.RAMP_BURN_RATE then elseif cmd.key == PLC_S_DATA.RAMP_BURN_RATE then
-- ramp to burn rate -- ramp to burn rate
self.commanded_burn_rate = cmd.val cmd.val = math.floor(cmd.val * 10) / 10 -- round to 10ths place
self.ramping_rate = true if cmd.val > 0 and cmd.val <= self.sDB.mek_struct.max_burn then
self.acks.burn_rate = false self.commanded_burn_rate = cmd.val
self.retry_times.burn_rate_req = util.time() + INITIAL_WAIT self.ramping_rate = true
_send(RPLC_TYPES.MEK_BURN_RATE, { self.commanded_burn_rate, self.ramping_rate }) self.acks.burn_rate = false
self.retry_times.burn_rate_req = util.time() + INITIAL_WAIT
_send(RPLC_TYPES.MEK_BURN_RATE, { self.commanded_burn_rate, self.ramping_rate })
end
end end
end end
end end

View File

@ -13,7 +13,7 @@ local svsessions = require("supervisor.session.svsessions")
local config = require("supervisor.config") local config = require("supervisor.config")
local supervisor = require("supervisor.supervisor") local supervisor = require("supervisor.supervisor")
local SUPERVISOR_VERSION = "beta-v0.6.1" local SUPERVISOR_VERSION = "beta-v0.6.2"
local print = util.print local print = util.print
local println = util.println local println = util.println