#172 fixed bug with full builds not being sent

This commit is contained in:
Mikayla Fischler 2023-02-20 14:50:20 -05:00
parent 8df67245c5
commit e2d2a0f1dc
8 changed files with 63 additions and 25 deletions

View File

@ -422,7 +422,22 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, range
-- handle packet -- handle packet
if protocol == PROTOCOLS.SCADA_CRDN then if protocol == PROTOCOLS.SCADA_CRDN then
if self.sv_linked then if self.sv_linked then
if packet.type == SCADA_CRDN_TYPES.FAC_BUILDS then if packet.type == SCADA_CRDN_TYPES.INITIAL_BUILDS then
if packet.length == 2 then
-- record builds
local fac_builds = iocontrol.record_facility_builds(packet.data[1])
local unit_builds = iocontrol.record_unit_builds(packet.data[2])
if fac_builds and unit_builds then
-- acknowledge receipt of builds
_send_sv(PROTOCOLS.SCADA_CRDN, SCADA_CRDN_TYPES.INITIAL_BUILDS, {})
else
log.error("received invalid INITIAL_BUILDS packet")
end
else
log.debug("INITIAL_BUILDS packet length mismatch")
end
elseif packet.type == SCADA_CRDN_TYPES.FAC_BUILDS then
if packet.length == 1 then if packet.length == 1 then
-- record facility builds -- record facility builds
if iocontrol.record_facility_builds(packet.data[1]) then if iocontrol.record_facility_builds(packet.data[1]) then

View File

@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol")
local renderer = require("coordinator.renderer") local renderer = require("coordinator.renderer")
local sounder = require("coordinator.sounder") local sounder = require("coordinator.sounder")
local COORDINATOR_VERSION = "beta-v0.10.0" local COORDINATOR_VERSION = "beta-v0.10.1"
local print = util.print local print = util.print
local println = util.println local println = util.println

View File

@ -1,11 +1,11 @@
{ {
"versions": { "versions": {
"bootloader": "0.2", "bootloader": "0.2",
"comms": "1.3.3", "comms": "1.4.0",
"reactor-plc": "beta-v0.11.0", "reactor-plc": "beta-v0.11.1",
"rtu": "beta-v0.11.1", "rtu": "beta-v0.11.2",
"supervisor": "beta-v0.12.1", "supervisor": "beta-v0.12.2",
"coordinator": "beta-v0.10.0", "coordinator": "beta-v0.10.1",
"pocket": "alpha-v0.0.0" "pocket": "alpha-v0.0.0"
}, },
"files": { "files": {
@ -177,13 +177,13 @@
}, },
"sizes": { "sizes": {
"system": 1982, "system": 1982,
"common": 88021, "common": 88163,
"graphics": 99360, "graphics": 99360,
"lockbox": 100797, "lockbox": 100797,
"reactor-plc": 75902, "reactor-plc": 75902,
"rtu": 81679, "rtu": 81679,
"supervisor": 267633, "supervisor": 268416,
"coordinator": 180849, "coordinator": 181783,
"pocket": 335 "pocket": 335
} }
} }

View File

@ -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.11.0" local R_PLC_VERSION = "beta-v0.11.1"
local print = util.print local print = util.print
local println = util.println local println = util.println

View File

@ -25,7 +25,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
local sps_rtu = require("rtu.dev.sps_rtu") local sps_rtu = require("rtu.dev.sps_rtu")
local turbinev_rtu = require("rtu.dev.turbinev_rtu") local turbinev_rtu = require("rtu.dev.turbinev_rtu")
local RTU_VERSION = "beta-v0.11.1" local RTU_VERSION = "beta-v0.11.2"
local rtu_t = types.rtu_t local rtu_t = types.rtu_t

View File

@ -14,7 +14,7 @@ local insert = table.insert
local max_distance = nil local max_distance = nil
comms.version = "1.3.3" comms.version = "1.4.0"
---@alias PROTOCOLS integer ---@alias PROTOCOLS integer
local PROTOCOLS = { local PROTOCOLS = {
@ -51,12 +51,13 @@ local SCADA_MGMT_TYPES = {
---@alias SCADA_CRDN_TYPES integer ---@alias SCADA_CRDN_TYPES integer
local SCADA_CRDN_TYPES = { local SCADA_CRDN_TYPES = {
FAC_BUILDS = 0, -- facility RTU builds INITIAL_BUILDS = 0, -- initial, complete builds packet to the coordinator
FAC_STATUS = 1, -- state of facility and facility devices FAC_BUILDS = 1, -- facility RTU builds
FAC_CMD = 2, -- faility command FAC_STATUS = 2, -- state of facility and facility devices
UNIT_BUILDS = 3, -- build of each reactor unit (reactor + RTUs) FAC_CMD = 3, -- faility command
UNIT_STATUSES = 4, -- state of each of the reactor units UNIT_BUILDS = 4, -- build of each reactor unit (reactor + RTUs)
UNIT_CMD = 5 -- command a reactor unit UNIT_STATUSES = 5, -- state of each of the reactor units
UNIT_CMD = 6 -- command a reactor unit
} }
---@alias CAPI_TYPES integer ---@alias CAPI_TYPES integer
@ -532,7 +533,8 @@ function comms.crdn_packet()
-- check that type is known -- check that type is known
local function _crdn_type_valid() local function _crdn_type_valid()
return self.type == SCADA_CRDN_TYPES.FAC_BUILDS or return self.type == SCADA_CRDN_TYPES.INITIAL_BUILDS or
self.type == SCADA_CRDN_TYPES.FAC_BUILDS or
self.type == SCADA_CRDN_TYPES.FAC_STATUS or self.type == SCADA_CRDN_TYPES.FAC_STATUS or
self.type == SCADA_CRDN_TYPES.FAC_CMD or self.type == SCADA_CRDN_TYPES.FAC_CMD or
self.type == SCADA_CRDN_TYPES.UNIT_BUILDS or self.type == SCADA_CRDN_TYPES.UNIT_BUILDS or

View File

@ -71,11 +71,13 @@ function coordinator.new_session(id, in_queue, out_queue, timeout, facility)
}, },
-- when to next retry one of these messages -- when to next retry one of these messages
retry_times = { retry_times = {
builds_packet = 0,
f_builds_packet = 0, f_builds_packet = 0,
u_builds_packet = 0 u_builds_packet = 0
}, },
-- message acknowledgements -- message acknowledgements
acks = { acks = {
builds = false,
fac_builds = false, fac_builds = false,
unit_builds = false unit_builds = false
} }
@ -115,16 +117,25 @@ function coordinator.new_session(id, in_queue, out_queue, timeout, facility)
self.seq_num = self.seq_num + 1 self.seq_num = self.seq_num + 1
end end
-- send both facility and unit builds
local function _send_all_builds()
local unit_builds = {}
for i = 1, #self.units do
local unit = self.units[i] ---@type reactor_unit
unit_builds[unit.get_id()] = unit.get_build()
end
_send(SCADA_CRDN_TYPES.INITIAL_BUILDS, { facility.get_build(), unit_builds })
end
-- send facility builds -- send facility builds
local function _send_fac_builds() local function _send_fac_builds()
self.acks.fac_builds = false
_send(SCADA_CRDN_TYPES.FAC_BUILDS, { facility.get_build() }) _send(SCADA_CRDN_TYPES.FAC_BUILDS, { facility.get_build() })
end end
-- send unit builds -- send unit builds
local function _send_unit_builds() local function _send_unit_builds()
self.acks.unit_builds = false
local builds = {} local builds = {}
for i = 1, #self.units do for i = 1, #self.units do
@ -206,7 +217,10 @@ function coordinator.new_session(id, in_queue, out_queue, timeout, facility)
log.debug(log_header .. "handler received unsupported SCADA_MGMT packet type " .. pkt.type) log.debug(log_header .. "handler received unsupported SCADA_MGMT packet type " .. pkt.type)
end end
elseif pkt.scada_frame.protocol() == PROTOCOLS.SCADA_CRDN then elseif pkt.scada_frame.protocol() == PROTOCOLS.SCADA_CRDN then
if pkt.type == SCADA_CRDN_TYPES.FAC_BUILDS then if pkt.type == SCADA_CRDN_TYPES.INITIAL_BUILDS then
-- acknowledgement to coordinator receiving builds
self.acks.builds = true
elseif pkt.type == SCADA_CRDN_TYPES.FAC_BUILDS then
-- acknowledgement to coordinator receiving builds -- acknowledgement to coordinator receiving builds
self.acks.fac_builds = true self.acks.fac_builds = true
elseif pkt.type == SCADA_CRDN_TYPES.FAC_CMD then elseif pkt.type == SCADA_CRDN_TYPES.FAC_CMD then
@ -450,6 +464,13 @@ function coordinator.new_session(id, in_queue, out_queue, timeout, facility)
-- builds packet retries -- builds packet retries
if not self.acks.builds then
if rtimes.builds_packet - util.time() <= 0 then
_send_all_builds()
rtimes.builds_packet = util.time() + RETRY_PERIOD
end
end
if not self.acks.fac_builds then if not self.acks.fac_builds then
if rtimes.f_builds_packet - util.time() <= 0 then if rtimes.f_builds_packet - util.time() <= 0 then
_send_fac_builds() _send_fac_builds()

View File

@ -14,7 +14,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.12.1" local SUPERVISOR_VERSION = "beta-v0.12.2"
local print = util.print local print = util.print
local println = util.println local println = util.println