mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
supervisor comms init
This commit is contained in:
parent
ffca88845b
commit
14cb7f96fc
@ -5,6 +5,11 @@ PROTOCOLS = {
|
|||||||
COORD_DATA = 3 -- data packets for coordinators to/from supervisory controller
|
COORD_DATA = 3 -- data packets for coordinators to/from supervisory controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCADA_SV_MODES = {
|
||||||
|
ACTIVE = 0,
|
||||||
|
BACKUP = 1
|
||||||
|
}
|
||||||
|
|
||||||
RPLC_TYPES = {
|
RPLC_TYPES = {
|
||||||
KEEP_ALIVE = 0, -- keep alive packets
|
KEEP_ALIVE = 0, -- keep alive packets
|
||||||
LINK_REQ = 1, -- linking requests
|
LINK_REQ = 1, -- linking requests
|
||||||
@ -131,8 +136,15 @@ function coord_comms()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- supervisory controller communications
|
-- supervisory controller communications
|
||||||
function superv_comms()
|
function superv_comms(mode, num_reactors, modem, dev_listen, fo_channel, sv_channel)
|
||||||
local self = {
|
local self = {
|
||||||
|
mode = mode,
|
||||||
|
seq_id = 0,
|
||||||
|
num_reactors = num_reactors,
|
||||||
|
modem = modem,
|
||||||
|
dev_listen = dev_listen,
|
||||||
|
fo_channel = fo_channel,
|
||||||
|
sv_channel = sv_channel,
|
||||||
reactor_struct_cache = nil
|
reactor_struct_cache = nil
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -5,14 +5,12 @@
|
|||||||
-- instant failover if active goes offline without re-sync
|
-- instant failover if active goes offline without re-sync
|
||||||
SYSTEM_TYPE = 'active'
|
SYSTEM_TYPE = 'active'
|
||||||
|
|
||||||
-- scada network
|
-- scada network listen for PLC's and RTU's
|
||||||
SCADA_NET_PFX = 16000
|
SCADA_DEV_LISTEN = 16000
|
||||||
-- failover synchronization
|
-- failover synchronization
|
||||||
SCADA_FO_CHANNEL = 16001
|
SCADA_FO_CHANNEL = 16001
|
||||||
-- listen port for SCADA supervisor access
|
-- listen port for SCADA supervisor access by coordinators
|
||||||
SCADA_SV_CHANNEL = 16002
|
SCADA_SV_CHANNEL = 16002
|
||||||
-- listen port for PLC's
|
|
||||||
SCADA_PLC_LISTEN = 16003
|
|
||||||
|
|
||||||
-- expected number of reactors
|
-- expected number of reactors
|
||||||
NUM_REACTORS = 4
|
NUM_REACTORS = 4
|
||||||
|
@ -20,14 +20,24 @@ if modem == nil then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- read config
|
-- determine active/backup mode
|
||||||
|
local mode = comms.SCADA_SV_MODES.BACKUP
|
||||||
-- start comms
|
if config.SYSTEM_TYPE == "active" then
|
||||||
if not modem.isOpen(config.LISTEN_PORT) then
|
mode = comms.SCADA_SV_MODES.ACTIVE
|
||||||
modem.open(config.LISTEN_PORT)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local comms = comms.superv_comms(config.NUM_REACTORS, modem, config.SCADA_PLC_LISTEN, config.SCADA_SV_CHANNEL)
|
-- start comms, open all channels
|
||||||
|
if not modem.isOpen(config.SCADA_DEV_LISTEN) then
|
||||||
|
modem.open(config.SCADA_DEV_LISTEN)
|
||||||
|
end
|
||||||
|
if not modem.isOpen(config.SCADA_FO_CHANNEL) then
|
||||||
|
modem.open(config.SCADA_FO_CHANNEL)
|
||||||
|
end
|
||||||
|
if not modem.isOpen(config.SCADA_SV_CHANNEL) then
|
||||||
|
modem.open(config.SCADA_SV_CHANNEL)
|
||||||
|
end
|
||||||
|
|
||||||
|
local comms = comms.superv_comms(config.NUM_REACTORS, modem, config.SCADA_DEV_LISTEN, config.SCADA_FO_CHANNEL, config.SCADA_SV_CHANNEL)
|
||||||
|
|
||||||
-- base loop clock (4Hz, 5 ticks)
|
-- base loop clock (4Hz, 5 ticks)
|
||||||
local loop_tick = os.startTimer(0.25)
|
local loop_tick = os.startTimer(0.25)
|
||||||
|
Loading…
Reference in New Issue
Block a user