cleanup of rtu comms

This commit is contained in:
Mikayla Fischler
2022-05-09 09:34:26 -04:00
parent 96e535fdc4
commit 469ee29b5a
2 changed files with 62 additions and 22 deletions

View File

@@ -1,10 +1,13 @@
local comms = require("scada-common.comms")
local ppm = require("scada-common.ppm")
local types = require("scada-common.types")
local modbus = require("modbus")
local rtu = {}
local rtu_t = types.rtu_t
local PROTOCOLS = comms.PROTOCOLS
local SCADA_MGMT_TYPES = comms.SCADA_MGMT_TYPES
local RTU_ADVERT_TYPES = comms.RTU_ADVERT_TYPES
@@ -281,33 +284,22 @@ rtu.comms = function (modem, local_port, server_port)
local advertisement = {}
for i = 1, #units do
local type = nil
if units[i].type == "boiler" then
type = RTU_ADVERT_TYPES.BOILER
elseif units[i].type == "turbine" then
type = RTU_ADVERT_TYPES.TURBINE
elseif units[i].type == "imatrix" then
type = RTU_ADVERT_TYPES.IMATRIX
elseif units[i].type == "redstone" then
type = RTU_ADVERT_TYPES.REDSTONE
end
local unit = units[i]
local type = comms.rtu_t_to_advert_type(unit.type)
if type ~= nil then
if type == RTU_ADVERT_TYPES.REDSTONE then
insert(advertisement, {
unit = i,
type = type,
index = units[i].index,
reactor = units[i].for_reactor,
rsio = units[i].device
index = unit.index,
reactor = unit.for_reactor,
rsio = unit.device
})
else
insert(advertisement, {
unit = i,
type = type,
index = units[i].index,
reactor = units[i].for_reactor,
index = unit.index,
reactor = unit.for_reactor,
rsio = nil
})
end