mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#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:
parent
529951f998
commit
5dfbe650c6
@ -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
|
||||||
|
@ -519,13 +519,18 @@ 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
|
||||||
|
cmd.val = math.floor(cmd.val * 10) / 10 -- round to 10ths place
|
||||||
|
if cmd.val > 0 and cmd.val <= self.sDB.mek_struct.max_burn then
|
||||||
self.commanded_burn_rate = cmd.val
|
self.commanded_burn_rate = cmd.val
|
||||||
self.ramping_rate = false
|
self.ramping_rate = false
|
||||||
self.acks.burn_rate = false
|
self.acks.burn_rate = false
|
||||||
self.retry_times.burn_rate_req = util.time() + INITIAL_WAIT
|
self.retry_times.burn_rate_req = util.time() + INITIAL_WAIT
|
||||||
_send(RPLC_TYPES.MEK_BURN_RATE, { self.commanded_burn_rate, self.ramping_rate })
|
_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
|
||||||
|
cmd.val = math.floor(cmd.val * 10) / 10 -- round to 10ths place
|
||||||
|
if cmd.val > 0 and cmd.val <= self.sDB.mek_struct.max_burn then
|
||||||
self.commanded_burn_rate = cmd.val
|
self.commanded_burn_rate = cmd.val
|
||||||
self.ramping_rate = true
|
self.ramping_rate = true
|
||||||
self.acks.burn_rate = false
|
self.acks.burn_rate = false
|
||||||
@ -534,6 +539,7 @@ function plc.new_session(id, for_reactor, in_queue, out_queue)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- max 100ms spent processing queue
|
-- max 100ms spent processing queue
|
||||||
if util.time() - handle_start > 100 then
|
if util.time() - handle_start > 100 then
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user