refactoring

This commit is contained in:
Mikayla Fischler 2022-05-13 11:08:22 -04:00
parent c53ddf1638
commit bf0e92d6e4
2 changed files with 14 additions and 14 deletions

View File

@ -252,8 +252,8 @@ rtu.comms = function (modem, local_port, server_port, conn_watchdog)
local advertisement = {} local advertisement = {}
for i = 1, #units do for i = 1, #units do
local unit = units[i] ---@type rtu_unit_registry_entry local unit = units[i] --@type rtu_unit_registry_entry
local type = comms.rtu_t_to_advert_type(unit.type) local type = comms.rtu_t_to_unit_type(unit.type)
if type ~= nil then if type ~= nil then
local advert = { local advert = {

View File

@ -560,10 +560,10 @@ comms.capi_packet = function ()
return public return public
end end
-- convert rtu_t to RTU advertisement type -- convert rtu_t to RTU unit type
---@param type rtu_t ---@param type rtu_t
---@return RTU_UNIT_TYPES|nil ---@return RTU_UNIT_TYPES|nil
comms.rtu_t_to_advert_type = function (type) comms.rtu_t_to_unit_type = function (type)
if type == rtu_t.redstone then if type == rtu_t.redstone then
return RTU_UNIT_TYPES.REDSTONE return RTU_UNIT_TYPES.REDSTONE
elseif type == rtu_t.boiler then elseif type == rtu_t.boiler then
@ -583,23 +583,23 @@ comms.rtu_t_to_advert_type = function (type)
return nil return nil
end end
-- convert RTU advertisement type to rtu_t -- convert RTU unit type to rtu_t
---@param atype RTU_UNIT_TYPES ---@param utype RTU_UNIT_TYPES
---@return rtu_t|nil ---@return rtu_t|nil
comms.advert_type_to_rtu_t = function (atype) comms.advert_type_to_rtu_t = function (utype)
if atype == RTU_UNIT_TYPES.REDSTONE then if utype == RTU_UNIT_TYPES.REDSTONE then
return rtu_t.redstone return rtu_t.redstone
elseif atype == RTU_UNIT_TYPES.BOILER then elseif utype == RTU_UNIT_TYPES.BOILER then
return rtu_t.boiler return rtu_t.boiler
elseif atype == RTU_UNIT_TYPES.BOILER_VALVE then elseif utype == RTU_UNIT_TYPES.BOILER_VALVE then
return rtu_t.boiler_valve return rtu_t.boiler_valve
elseif atype == RTU_UNIT_TYPES.TURBINE then elseif utype == RTU_UNIT_TYPES.TURBINE then
return rtu_t.turbine return rtu_t.turbine
elseif atype == RTU_UNIT_TYPES.TURBINE_VALVE then elseif utype == RTU_UNIT_TYPES.TURBINE_VALVE then
return rtu_t.turbine_valve return rtu_t.turbine_valve
elseif atype == RTU_UNIT_TYPES.EMACHINE then elseif utype == RTU_UNIT_TYPES.EMACHINE then
return rtu_t.energy_machine return rtu_t.energy_machine
elseif atype == RTU_UNIT_TYPES.IMATRIX then elseif utype == RTU_UNIT_TYPES.IMATRIX then
return rtu_t.induction_matrix return rtu_t.induction_matrix
end end