mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#309 bugfix to apisessions still using old config
This commit is contained in:
parent
e416faf313
commit
195f59178f
@ -937,6 +937,12 @@ local function config_view(display)
|
|||||||
tmp_cfg.FlowDisplay = settings.get("FLOW_DISPLAY")
|
tmp_cfg.FlowDisplay = settings.get("FLOW_DISPLAY")
|
||||||
tmp_cfg.UnitDisplays = settings.get("UNIT_DISPLAYS", {})
|
tmp_cfg.UnitDisplays = settings.get("UNIT_DISPLAYS", {})
|
||||||
|
|
||||||
|
-- if there are extra monitor entries, delete them now
|
||||||
|
-- not doing so will cause the app to fail to start
|
||||||
|
if is_int_min_max(tmp_cfg.UnitCount, 1, 4) then
|
||||||
|
for i = tmp_cfg.UnitCount + 1, 4 do tmp_cfg.UnitDisplays[i] = nil end
|
||||||
|
end
|
||||||
|
|
||||||
if settings.get("ControlStates") == nil then
|
if settings.get("ControlStates") == nil then
|
||||||
local ctrl_states = {
|
local ctrl_states = {
|
||||||
process = settings.get("PROCESS"),
|
process = settings.get("PROCESS"),
|
||||||
|
@ -224,8 +224,8 @@ function coordinator.comms(version, nic, sv_watchdog)
|
|||||||
nic.closeAll()
|
nic.closeAll()
|
||||||
nic.open(config.CRD_Channel)
|
nic.open(config.CRD_Channel)
|
||||||
|
|
||||||
-- link nic to apisessions
|
-- pass config to apisessions
|
||||||
apisessions.init(nic)
|
apisessions.init(nic, config.CRD_Channel, config.PKT_Channel, config.API_Timeout)
|
||||||
|
|
||||||
-- PRIVATE FUNCTIONS --
|
-- PRIVATE FUNCTIONS --
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ local log = require("scada-common.log")
|
|||||||
local mqueue = require("scada-common.mqueue")
|
local mqueue = require("scada-common.mqueue")
|
||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
local config = require("coordinator.config")
|
|
||||||
local iocontrol = require("coordinator.iocontrol")
|
local iocontrol = require("coordinator.iocontrol")
|
||||||
|
|
||||||
local pocket = require("coordinator.session.pocket")
|
local pocket = require("coordinator.session.pocket")
|
||||||
@ -11,7 +10,10 @@ local pocket = require("coordinator.session.pocket")
|
|||||||
local apisessions = {}
|
local apisessions = {}
|
||||||
|
|
||||||
local self = {
|
local self = {
|
||||||
nic = nil,
|
nic = nil, ---@type nic
|
||||||
|
crd_channel = nil, ---@type integer
|
||||||
|
pkt_channel = nil, ---@type integer
|
||||||
|
api_timeout = nil, ---@type number
|
||||||
next_id = 0,
|
next_id = 0,
|
||||||
sessions = {}
|
sessions = {}
|
||||||
}
|
}
|
||||||
@ -32,7 +34,7 @@ local function _api_handle_outq(session)
|
|||||||
if msg ~= nil then
|
if msg ~= nil then
|
||||||
if msg.qtype == mqueue.TYPE.PACKET then
|
if msg.qtype == mqueue.TYPE.PACKET then
|
||||||
-- handle a packet to be sent
|
-- handle a packet to be sent
|
||||||
self.nic.transmit(config.PKT_CHANNEL, config.CRD_CHANNEL, msg.message)
|
self.nic.transmit(self.pkt_channel, self.crd_channel, msg.message)
|
||||||
elseif msg.qtype == mqueue.TYPE.COMMAND then
|
elseif msg.qtype == mqueue.TYPE.COMMAND then
|
||||||
-- handle instruction/notification
|
-- handle instruction/notification
|
||||||
elseif msg.qtype == mqueue.TYPE.DATA then
|
elseif msg.qtype == mqueue.TYPE.DATA then
|
||||||
@ -59,7 +61,7 @@ local function _shutdown(session)
|
|||||||
while session.out_queue.ready() do
|
while session.out_queue.ready() do
|
||||||
local msg = session.out_queue.pop()
|
local msg = session.out_queue.pop()
|
||||||
if msg ~= nil and msg.qtype == mqueue.TYPE.PACKET then
|
if msg ~= nil and msg.qtype == mqueue.TYPE.PACKET then
|
||||||
self.nic.transmit(config.PKT_CHANNEL, config.CRD_CHANNEL, msg.message)
|
self.nic.transmit(self.pkt_channel, self.crd_channel, msg.message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -69,9 +71,15 @@ end
|
|||||||
-- PUBLIC FUNCTIONS --
|
-- PUBLIC FUNCTIONS --
|
||||||
|
|
||||||
-- initialize apisessions
|
-- initialize apisessions
|
||||||
---@param nic nic
|
---@param nic nic network interface
|
||||||
function apisessions.init(nic)
|
---@param crd_channel integer coordinator channel
|
||||||
|
---@param pkt_channel integer pocket channel
|
||||||
|
---@param api_timeout number api session timeout
|
||||||
|
function apisessions.init(nic, crd_channel, pkt_channel, api_timeout)
|
||||||
self.nic = nic
|
self.nic = nic
|
||||||
|
self.crd_channel = crd_channel
|
||||||
|
self.pkt_channel = pkt_channel
|
||||||
|
self.api_timeout = api_timeout
|
||||||
end
|
end
|
||||||
|
|
||||||
-- find a session by remote port
|
-- find a session by remote port
|
||||||
@ -103,7 +111,7 @@ function apisessions.establish_session(source_addr, version)
|
|||||||
|
|
||||||
local id = self.next_id
|
local id = self.next_id
|
||||||
|
|
||||||
pkt_s.instance = pocket.new_session(id, source_addr, pkt_s.in_queue, pkt_s.out_queue, config.API_TIMEOUT)
|
pkt_s.instance = pocket.new_session(id, source_addr, pkt_s.in_queue, pkt_s.out_queue, self.api_timeout)
|
||||||
table.insert(self.sessions, pkt_s)
|
table.insert(self.sessions, pkt_s)
|
||||||
|
|
||||||
local mt = {
|
local mt = {
|
||||||
|
Loading…
Reference in New Issue
Block a user