fixed rps reset infinte retry, improved time delta calculations, added last_update to rtu device databases
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
@@ -57,6 +58,7 @@ function boilerv.new(session_id, unit_id, advert, out_queue)
|
||||
db = {
|
||||
formed = false,
|
||||
build = {
|
||||
last_update = 0,
|
||||
length = 0,
|
||||
width = 0,
|
||||
height = 0,
|
||||
@@ -72,10 +74,12 @@ function boilerv.new(session_id, unit_id, advert, out_queue)
|
||||
env_loss = 0.0
|
||||
},
|
||||
state = {
|
||||
last_update = 0,
|
||||
temperature = 0.0,
|
||||
boil_rate = 0.0
|
||||
},
|
||||
tanks = {
|
||||
last_update = 0,
|
||||
steam = { type = "mekanism:empty_gas", amount = 0 }, ---@type tank_fluid
|
||||
steam_need = 0,
|
||||
steam_fill = 0.0,
|
||||
@@ -140,6 +144,7 @@ function boilerv.new(session_id, unit_id, advert, out_queue)
|
||||
-- build response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 13 then
|
||||
self.db.build.last_update = util.time_ms()
|
||||
self.db.build.length = m_pkt.data[1]
|
||||
self.db.build.width = m_pkt.data[2]
|
||||
self.db.build.height = m_pkt.data[3]
|
||||
@@ -161,6 +166,7 @@ function boilerv.new(session_id, unit_id, advert, out_queue)
|
||||
-- state response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 2 then
|
||||
self.db.state.last_update = util.time_ms()
|
||||
self.db.state.temperature = m_pkt.data[1]
|
||||
self.db.state.boil_rate = m_pkt.data[2]
|
||||
else
|
||||
@@ -170,18 +176,19 @@ function boilerv.new(session_id, unit_id, advert, out_queue)
|
||||
-- tanks response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 12 then
|
||||
self.db.tanks.steam = m_pkt.data[1]
|
||||
self.db.tanks.steam_need = m_pkt.data[2]
|
||||
self.db.tanks.steam_fill = m_pkt.data[3]
|
||||
self.db.tanks.water = m_pkt.data[4]
|
||||
self.db.tanks.water_need = m_pkt.data[5]
|
||||
self.db.tanks.water_fill = m_pkt.data[6]
|
||||
self.db.tanks.hcool = m_pkt.data[7]
|
||||
self.db.tanks.hcool_need = m_pkt.data[8]
|
||||
self.db.tanks.hcool_fill = m_pkt.data[9]
|
||||
self.db.tanks.ccool = m_pkt.data[10]
|
||||
self.db.tanks.ccool_need = m_pkt.data[11]
|
||||
self.db.tanks.ccool_fill = m_pkt.data[12]
|
||||
self.db.tanks.last_update = util.time_ms()
|
||||
self.db.tanks.steam = m_pkt.data[1]
|
||||
self.db.tanks.steam_need = m_pkt.data[2]
|
||||
self.db.tanks.steam_fill = m_pkt.data[3]
|
||||
self.db.tanks.water = m_pkt.data[4]
|
||||
self.db.tanks.water_need = m_pkt.data[5]
|
||||
self.db.tanks.water_fill = m_pkt.data[6]
|
||||
self.db.tanks.hcool = m_pkt.data[7]
|
||||
self.db.tanks.hcool_need = m_pkt.data[8]
|
||||
self.db.tanks.hcool_fill = m_pkt.data[9]
|
||||
self.db.tanks.ccool = m_pkt.data[10]
|
||||
self.db.tanks.ccool_need = m_pkt.data[11]
|
||||
self.db.tanks.ccool_fill = m_pkt.data[12]
|
||||
else
|
||||
log.debug(log_tag .. "MODBUS transaction reply length mismatch (" .. TXN_TAGS[txn_type] .. ")")
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
@@ -42,6 +43,7 @@ function envd.new(session_id, unit_id, advert, out_queue)
|
||||
},
|
||||
---@class envd_session_db
|
||||
db = {
|
||||
last_update = 0,
|
||||
radiation = {},
|
||||
radiation_raw = 0
|
||||
}
|
||||
@@ -68,7 +70,8 @@ function envd.new(session_id, unit_id, advert, out_queue)
|
||||
elseif txn_type == TXN_TYPES.RAD then
|
||||
-- radiation status response
|
||||
if m_pkt.length == 2 then
|
||||
self.db.radiation = m_pkt.data[1]
|
||||
self.db.last_update = util.time_ms()
|
||||
self.db.radiation = m_pkt.data[1]
|
||||
self.db.radiation_raw = m_pkt.data[2]
|
||||
else
|
||||
log.debug(log_tag .. "MODBUS transaction reply length mismatch (" .. TXN_TAGS[txn_type] .. ")")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
@@ -57,6 +58,7 @@ function imatrix.new(session_id, unit_id, advert, out_queue)
|
||||
db = {
|
||||
formed = false,
|
||||
build = {
|
||||
last_update = 0,
|
||||
length = 0,
|
||||
width = 0,
|
||||
height = 0,
|
||||
@@ -68,10 +70,12 @@ function imatrix.new(session_id, unit_id, advert, out_queue)
|
||||
providers = 0
|
||||
},
|
||||
state = {
|
||||
last_update = 0,
|
||||
last_input = 0,
|
||||
last_output = 0
|
||||
},
|
||||
tanks = {
|
||||
last_update = 0,
|
||||
energy = 0,
|
||||
energy_need = 0,
|
||||
energy_fill = 0.0
|
||||
@@ -127,6 +131,7 @@ function imatrix.new(session_id, unit_id, advert, out_queue)
|
||||
-- build response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 9 then
|
||||
self.db.build.last_update = util.time_ms()
|
||||
self.db.build.length = m_pkt.data[1]
|
||||
self.db.build.width = m_pkt.data[2]
|
||||
self.db.build.height = m_pkt.data[3]
|
||||
@@ -144,6 +149,7 @@ function imatrix.new(session_id, unit_id, advert, out_queue)
|
||||
-- state response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 2 then
|
||||
self.db.state.last_update = util.time_ms()
|
||||
self.db.state.last_input = m_pkt.data[1]
|
||||
self.db.state.last_output = m_pkt.data[2]
|
||||
else
|
||||
@@ -153,6 +159,7 @@ function imatrix.new(session_id, unit_id, advert, out_queue)
|
||||
-- tanks response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 3 then
|
||||
self.db.tanks.last_update = util.time_ms()
|
||||
self.db.tanks.energy = m_pkt.data[1]
|
||||
self.db.tanks.energy_need = m_pkt.data[2]
|
||||
self.db.tanks.energy_fill = m_pkt.data[3]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
@@ -52,14 +53,17 @@ function sna.new(session_id, unit_id, advert, out_queue)
|
||||
---@class sna_session_db
|
||||
db = {
|
||||
build = {
|
||||
last_update = 0,
|
||||
input_cap = 0,
|
||||
output_cap = 0
|
||||
},
|
||||
state = {
|
||||
last_update = 0,
|
||||
production_rate = 0.0,
|
||||
peak_production = 0.0
|
||||
},
|
||||
tanks = {
|
||||
last_update = 0,
|
||||
input = {}, ---@type tank_fluid
|
||||
input_need = 0,
|
||||
input_fill = 0.0,
|
||||
@@ -104,8 +108,9 @@ function sna.new(session_id, unit_id, advert, out_queue)
|
||||
-- build response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 2 then
|
||||
self.db.build.input_cap = m_pkt.data[1]
|
||||
self.db.build.output_cap = m_pkt.data[2]
|
||||
self.db.build.last_update = util.time_ms()
|
||||
self.db.build.input_cap = m_pkt.data[1]
|
||||
self.db.build.output_cap = m_pkt.data[2]
|
||||
self.has_build = true
|
||||
else
|
||||
log.debug(log_tag .. "MODBUS transaction reply length mismatch (" .. TXN_TAGS[txn_type] .. ")")
|
||||
@@ -114,6 +119,7 @@ function sna.new(session_id, unit_id, advert, out_queue)
|
||||
-- state response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 2 then
|
||||
self.db.state.last_update = util.time_ms()
|
||||
self.db.state.production_rate = m_pkt.data[1]
|
||||
self.db.state.peak_production = m_pkt.data[2]
|
||||
else
|
||||
@@ -123,6 +129,7 @@ function sna.new(session_id, unit_id, advert, out_queue)
|
||||
-- tanks response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 6 then
|
||||
self.db.tanks.last_update = util.time_ms()
|
||||
self.db.tanks.input = m_pkt.data[1]
|
||||
self.db.tanks.input_need = m_pkt.data[2]
|
||||
self.db.tanks.input_fill = m_pkt.data[3]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local unit_session = require("supervisor.session.rtu.unit_session")
|
||||
|
||||
@@ -57,6 +58,7 @@ function sps.new(session_id, unit_id, advert, out_queue)
|
||||
db = {
|
||||
formed = false,
|
||||
build = {
|
||||
last_update = 0,
|
||||
length = 0,
|
||||
width = 0,
|
||||
height = 0,
|
||||
@@ -68,9 +70,11 @@ function sps.new(session_id, unit_id, advert, out_queue)
|
||||
max_energy = 0
|
||||
},
|
||||
state = {
|
||||
last_update = 0,
|
||||
process_rate = 0.0
|
||||
},
|
||||
tanks = {
|
||||
last_update = 0,
|
||||
input = {}, ---@type tank_fluid
|
||||
input_need = 0,
|
||||
input_fill = 0.0,
|
||||
@@ -132,15 +136,16 @@ function sps.new(session_id, unit_id, advert, out_queue)
|
||||
-- build response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 9 then
|
||||
self.db.build.length = m_pkt.data[1]
|
||||
self.db.build.width = m_pkt.data[2]
|
||||
self.db.build.height = m_pkt.data[3]
|
||||
self.db.build.min_pos = m_pkt.data[4]
|
||||
self.db.build.max_pos = m_pkt.data[5]
|
||||
self.db.build.coils = m_pkt.data[6]
|
||||
self.db.build.input_cap = m_pkt.data[7]
|
||||
self.db.build.output_cap = m_pkt.data[8]
|
||||
self.db.build.max_energy = m_pkt.data[9]
|
||||
self.db.build.last_update = util.time_ms()
|
||||
self.db.build.length = m_pkt.data[1]
|
||||
self.db.build.width = m_pkt.data[2]
|
||||
self.db.build.height = m_pkt.data[3]
|
||||
self.db.build.min_pos = m_pkt.data[4]
|
||||
self.db.build.max_pos = m_pkt.data[5]
|
||||
self.db.build.coils = m_pkt.data[6]
|
||||
self.db.build.input_cap = m_pkt.data[7]
|
||||
self.db.build.output_cap = m_pkt.data[8]
|
||||
self.db.build.max_energy = m_pkt.data[9]
|
||||
self.has_build = true
|
||||
else
|
||||
log.debug(log_tag .. "MODBUS transaction reply length mismatch (" .. TXN_TAGS[txn_type] .. ")")
|
||||
@@ -149,6 +154,7 @@ function sps.new(session_id, unit_id, advert, out_queue)
|
||||
-- state response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 1 then
|
||||
self.db.state.last_update = util.time_ms()
|
||||
self.db.state.process_rate = m_pkt.data[1]
|
||||
else
|
||||
log.debug(log_tag .. "MODBUS transaction reply length mismatch (" .. TXN_TAGS[txn_type] .. ")")
|
||||
@@ -157,6 +163,7 @@ function sps.new(session_id, unit_id, advert, out_queue)
|
||||
-- tanks response
|
||||
-- load in data if correct length
|
||||
if m_pkt.length == 9 then
|
||||
self.db.tanks.last_update = util.time_ms()
|
||||
self.db.tanks.input = m_pkt.data[1]
|
||||
self.db.tanks.input_need = m_pkt.data[2]
|
||||
self.db.tanks.input_fill = m_pkt.data[3]
|
||||
|
||||
@@ -79,6 +79,7 @@ function turbinev.new(session_id, unit_id, advert, out_queue)
|
||||
db = {
|
||||
formed = false,
|
||||
build = {
|
||||
last_update = 0,
|
||||
length = 0,
|
||||
width = 0,
|
||||
height = 0,
|
||||
@@ -96,12 +97,14 @@ function turbinev.new(session_id, unit_id, advert, out_queue)
|
||||
max_water_output = 0
|
||||
},
|
||||
state = {
|
||||
last_update = 0,
|
||||
flow_rate = 0,
|
||||
prod_rate = 0,
|
||||
steam_input_rate = 0,
|
||||
dumping_mode = DUMPING_MODE.IDLE ---@type DUMPING_MODE
|
||||
},
|
||||
tanks = {
|
||||
last_update = 0,
|
||||
steam = { type = "mekanism:empty_gas", amount = 0 }, ---@type tank_fluid
|
||||
steam_need = 0,
|
||||
steam_fill = 0.0,
|
||||
@@ -178,6 +181,7 @@ function turbinev.new(session_id, unit_id, advert, out_queue)
|
||||
elseif txn_type == TXN_TYPES.BUILD then
|
||||
-- build response
|
||||
if m_pkt.length == 15 then
|
||||
self.db.build.last_update = util.time_ms()
|
||||
self.db.build.length = m_pkt.data[1]
|
||||
self.db.build.width = m_pkt.data[2]
|
||||
self.db.build.height = m_pkt.data[3]
|
||||
@@ -200,6 +204,7 @@ function turbinev.new(session_id, unit_id, advert, out_queue)
|
||||
elseif txn_type == TXN_TYPES.STATE then
|
||||
-- state response
|
||||
if m_pkt.length == 4 then
|
||||
self.db.state.last_update = util.time_ms()
|
||||
self.db.state.flow_rate = m_pkt.data[1]
|
||||
self.db.state.prod_rate = m_pkt.data[2]
|
||||
self.db.state.steam_input_rate = m_pkt.data[3]
|
||||
@@ -210,6 +215,7 @@ function turbinev.new(session_id, unit_id, advert, out_queue)
|
||||
elseif txn_type == TXN_TYPES.TANKS then
|
||||
-- tanks response
|
||||
if m_pkt.length == 6 then
|
||||
self.db.tanks.last_update = util.time_ms()
|
||||
self.db.tanks.steam = m_pkt.data[1]
|
||||
self.db.tanks.steam_need = m_pkt.data[2]
|
||||
self.db.tanks.steam_fill = m_pkt.data[3]
|
||||
|
||||
Reference in New Issue
Block a user