mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#309 cleanup
This commit is contained in:
parent
ca55948286
commit
1cf7375311
@ -225,7 +225,7 @@ function coordinator.comms(version, nic, sv_watchdog)
|
|||||||
nic.open(config.CRD_Channel)
|
nic.open(config.CRD_Channel)
|
||||||
|
|
||||||
-- pass config to apisessions
|
-- pass config to apisessions
|
||||||
apisessions.init(nic, config.CRD_Channel, config.PKT_Channel, config.API_Timeout)
|
apisessions.init(nic, config)
|
||||||
|
|
||||||
-- PRIVATE FUNCTIONS --
|
-- PRIVATE FUNCTIONS --
|
||||||
|
|
||||||
|
@ -11,9 +11,7 @@ local apisessions = {}
|
|||||||
|
|
||||||
local self = {
|
local self = {
|
||||||
nic = nil, ---@type nic
|
nic = nil, ---@type nic
|
||||||
crd_channel = nil, ---@type integer
|
config = nil, ---@type crd_config
|
||||||
pkt_channel = nil, ---@type integer
|
|
||||||
api_timeout = nil, ---@type number
|
|
||||||
next_id = 0,
|
next_id = 0,
|
||||||
sessions = {}
|
sessions = {}
|
||||||
}
|
}
|
||||||
@ -34,7 +32,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(self.pkt_channel, self.crd_channel, msg.message)
|
self.nic.transmit(self.config.PKT_Channel, self.config.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
|
||||||
@ -61,7 +59,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(self.pkt_channel, self.crd_channel, msg.message)
|
self.nic.transmit(self.config.PKT_Channel, self.config.CRD_Channel, msg.message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -72,14 +70,10 @@ end
|
|||||||
|
|
||||||
-- initialize apisessions
|
-- initialize apisessions
|
||||||
---@param nic nic network interface
|
---@param nic nic network interface
|
||||||
---@param crd_channel integer coordinator channel
|
---@param config crd_config coordinator config
|
||||||
---@param pkt_channel integer pocket channel
|
function apisessions.init(nic, config)
|
||||||
---@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.config = config
|
||||||
self.pkt_channel = pkt_channel
|
|
||||||
self.api_timeout = api_timeout
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- find a session by remote port
|
-- find a session by remote port
|
||||||
@ -111,7 +105,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, self.api_timeout)
|
pkt_s.instance = pocket.new_session(id, source_addr, pkt_s.in_queue, pkt_s.out_queue, self.config.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