#118 refactored RTU unit types
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local mqueue = require("scada-common.mqueue")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local svqtypes = require("supervisor.session.svqtypes")
|
||||
@@ -12,7 +13,7 @@ local SCADA_MGMT_TYPE = comms.SCADA_MGMT_TYPE
|
||||
local SCADA_CRDN_TYPE = comms.SCADA_CRDN_TYPE
|
||||
local UNIT_COMMAND = comms.UNIT_COMMAND
|
||||
local FAC_COMMAND = comms.FAC_COMMAND
|
||||
local RTU_UNIT_TYPE = comms.RTU_UNIT_TYPE
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
|
||||
local SV_Q_CMDS = svqtypes.SV_Q_CMDS
|
||||
local SV_Q_DATA = svqtypes.SV_Q_DATA
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local mqueue = require("scada-common.mqueue")
|
||||
local rsio = require("scada-common.rsio")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local svqtypes = require("supervisor.session.svqtypes")
|
||||
@@ -20,7 +20,7 @@ local rtu = {}
|
||||
|
||||
local PROTOCOL = comms.PROTOCOL
|
||||
local SCADA_MGMT_TYPE = comms.SCADA_MGMT_TYPE
|
||||
local RTU_UNIT_TYPE = comms.RTU_UNIT_TYPE
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
@@ -113,7 +113,7 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
|
||||
end
|
||||
|
||||
local type_string = util.strval(u_type)
|
||||
if type(u_type) == "number" then type_string = util.strval(comms.advert_type_to_rtu_t(u_type)) end
|
||||
if type(u_type) == "number" then type_string = types.rtu_type_to_string(u_type) end
|
||||
|
||||
-- create unit by type
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
@@ -7,7 +6,7 @@ local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
local boilerv = {}
|
||||
|
||||
local RTU_UNIT_TYPE = comms.RTU_UNIT_TYPE
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
local MODBUS_FCODE = types.MODBUS_FCODE
|
||||
|
||||
local TXN_TYPES = {
|
||||
@@ -39,7 +38,7 @@ local PERIODICS = {
|
||||
function boilerv.new(session_id, unit_id, advert, out_queue)
|
||||
-- type check
|
||||
if advert.type ~= RTU_UNIT_TYPE.BOILER_VALVE then
|
||||
log.error("attempt to instantiate boilerv RTU for type '" .. advert.type .. "'. this is a bug.")
|
||||
log.error("attempt to instantiate boilerv RTU for type '" .. types.rtu_type_to_string(advert.type) .. "'. this is a bug.")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
@@ -7,7 +6,7 @@ local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
local envd = {}
|
||||
|
||||
local RTU_UNIT_TYPE = comms.RTU_UNIT_TYPE
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
local MODBUS_FCODE = types.MODBUS_FCODE
|
||||
|
||||
local TXN_TYPES = {
|
||||
@@ -30,7 +29,7 @@ local PERIODICS = {
|
||||
function envd.new(session_id, unit_id, advert, out_queue)
|
||||
-- type check
|
||||
if advert.type ~= RTU_UNIT_TYPE.ENV_DETECTOR then
|
||||
log.error("attempt to instantiate envd RTU for type '" .. advert.type .. "'. this is a bug.")
|
||||
log.error("attempt to instantiate envd RTU for type '" .. types.rtu_type_to_string(advert.type) .. "'. this is a bug.")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
@@ -7,7 +6,7 @@ local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
local imatrix = {}
|
||||
|
||||
local RTU_UNIT_TYPE = comms.RTU_UNIT_TYPE
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
local MODBUS_FCODE = types.MODBUS_FCODE
|
||||
|
||||
local TXN_TYPES = {
|
||||
@@ -39,7 +38,7 @@ local PERIODICS = {
|
||||
function imatrix.new(session_id, unit_id, advert, out_queue)
|
||||
-- type check
|
||||
if advert.type ~= RTU_UNIT_TYPE.IMATRIX then
|
||||
log.error("attempt to instantiate imatrix RTU for type '" .. advert.type .. "'. this is a bug.")
|
||||
log.error("attempt to instantiate imatrix RTU for type '" .. types.rtu_type_to_string(advert.type) .. "'. this is a bug.")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local mqueue = require("scada-common.mqueue")
|
||||
local rsio = require("scada-common.rsio")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
@@ -9,7 +7,7 @@ local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
local redstone = {}
|
||||
|
||||
local RTU_UNIT_TYPE = comms.RTU_UNIT_TYPE
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
local MODBUS_FCODE = types.MODBUS_FCODE
|
||||
|
||||
local IO_PORT = rsio.IO
|
||||
@@ -54,7 +52,7 @@ local PERIODICS = {
|
||||
function redstone.new(session_id, unit_id, advert, out_queue)
|
||||
-- type check
|
||||
if advert.type ~= RTU_UNIT_TYPE.REDSTONE then
|
||||
log.error("attempt to instantiate redstone RTU for type '" .. advert.type .. "'. this is a bug.")
|
||||
log.error("attempt to instantiate redstone RTU for type '" .. types.rtu_type_to_string(advert.type) .. "'. this is a bug.")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
@@ -7,7 +6,7 @@ local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
local sna = {}
|
||||
|
||||
local RTU_UNIT_TYPE = comms.RTU_UNIT_TYPE
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
local MODBUS_FCODE = types.MODBUS_FCODE
|
||||
|
||||
local TXN_TYPES = {
|
||||
@@ -36,7 +35,7 @@ local PERIODICS = {
|
||||
function sna.new(session_id, unit_id, advert, out_queue)
|
||||
-- type check
|
||||
if advert.type ~= RTU_UNIT_TYPE.SNA then
|
||||
log.error("attempt to instantiate sna RTU for type '" .. advert.type .. "'. this is a bug.")
|
||||
log.error("attempt to instantiate sna RTU for type '" .. types.rtu_type_to_string(advert.type) .. "'. this is a bug.")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
@@ -7,7 +6,7 @@ local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
local sps = {}
|
||||
|
||||
local RTU_UNIT_TYPE = comms.RTU_UNIT_TYPE
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
local MODBUS_FCODE = types.MODBUS_FCODE
|
||||
|
||||
local TXN_TYPES = {
|
||||
@@ -39,7 +38,7 @@ local PERIODICS = {
|
||||
function sps.new(session_id, unit_id, advert, out_queue)
|
||||
-- type check
|
||||
if advert.type ~= RTU_UNIT_TYPE.SPS then
|
||||
log.error("attempt to instantiate sps RTU for type '" .. advert.type .. "'. this is a bug.")
|
||||
log.error("attempt to instantiate sps RTU for type '" .. types.rtu_type_to_string(advert.type) .. "'. this is a bug.")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local mqueue = require("scada-common.mqueue")
|
||||
local types = require("scada-common.types")
|
||||
@@ -9,7 +8,7 @@ local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
local turbinev = {}
|
||||
|
||||
local RTU_UNIT_TYPE = comms.RTU_UNIT_TYPE
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
local DUMPING_MODE = types.DUMPING_MODE
|
||||
local MODBUS_FCODE = types.MODBUS_FCODE
|
||||
|
||||
@@ -51,7 +50,7 @@ local PERIODICS = {
|
||||
function turbinev.new(session_id, unit_id, advert, out_queue)
|
||||
-- type check
|
||||
if advert.type ~= RTU_UNIT_TYPE.TURBINE_VALVE then
|
||||
log.error("attempt to instantiate turbinev RTU for type '" .. advert.type .. "'. this is a bug.")
|
||||
log.error("attempt to instantiate turbinev RTU for type '" .. types.rtu_type_to_string(advert.type) .. "'. this is a bug.")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user