mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
SCADA supervisor code started
This commit is contained in:
parent
78cbb9e67d
commit
4dfdb218e2
@ -1,18 +1,14 @@
|
||||
|
||||
function server_comms()
|
||||
function coord_comms()
|
||||
local self = {
|
||||
reactor_struct_cache = nil
|
||||
}
|
||||
end
|
||||
|
||||
local record_struct = function (id, mek_data)
|
||||
end
|
||||
|
||||
-- send the structure data by request to pocket computers
|
||||
local send_struct = function ()
|
||||
end
|
||||
|
||||
local command_waste = function ()
|
||||
end
|
||||
function superv_comms()
|
||||
local self = {
|
||||
reactor_struct_cache = nil
|
||||
}
|
||||
end
|
||||
|
||||
function rplc_comms(id, modem, local_port, server_port, reactor)
|
||||
|
18
supervisor/config.lua
Normal file
18
supervisor/config.lua
Normal file
@ -0,0 +1,18 @@
|
||||
-- type ('active','backup')
|
||||
-- 'active' system carries through instructions and control
|
||||
-- 'backup' system serves as a hot backup, still recieving data
|
||||
-- from all PLCs and coordinator(s) while in backup to allow
|
||||
-- instant failover if active goes offline without re-sync
|
||||
SYSTEM_TYPE = 'active'
|
||||
|
||||
-- scada network
|
||||
SCADA_NET_PFX = 16000
|
||||
-- failover synchronization
|
||||
SCADA_FO_CHANNEL = 16001
|
||||
-- listen port for SCADA supervisor access
|
||||
SCADA_SV_CHANNEL = 16002
|
||||
-- listen port for PLC's
|
||||
SCADA_PLC_LISTEN = 16003
|
||||
|
||||
-- expected number of reactors
|
||||
NUM_REACTORS = 4
|
45
supervisor/scada-supervisor.lua
Normal file
45
supervisor/scada-supervisor.lua
Normal file
@ -0,0 +1,45 @@
|
||||
--
|
||||
-- Nuclear Generation Facility SCADA Supervisor
|
||||
--
|
||||
|
||||
os.loadAPI("scada-common/util.lua")
|
||||
os.loadAPI("scada-common/comms.lua")
|
||||
os.loadAPI("supervisor/config.lua")
|
||||
|
||||
local SUPERVISOR_VERSION = "alpha-v0.1"
|
||||
|
||||
local print_ts = util.print_ts
|
||||
|
||||
local modem = peripheral.find("modem")
|
||||
|
||||
print("| SCADA Supervisor - " .. SUPERVISOR_VERSION .. " |")
|
||||
|
||||
-- we need a modem
|
||||
if modem == nil then
|
||||
print("No modem found, exiting...")
|
||||
return
|
||||
end
|
||||
|
||||
-- read config
|
||||
|
||||
-- start comms
|
||||
if not modem.isOpen(config.LISTEN_PORT) then
|
||||
modem.open(config.LISTEN_PORT)
|
||||
end
|
||||
|
||||
local comms = comms.superv_comms(config.NUM_REACTORS, modem, config.SCADA_PLC_LISTEN, config.SCADA_SV_CHANNEL)
|
||||
|
||||
-- base loop clock (4Hz, 5 ticks)
|
||||
local loop_tick = os.startTimer(0.25)
|
||||
|
||||
-- event loop
|
||||
while true do
|
||||
local event, param1, param2, param3, param4, param5 = os.pullEvent()
|
||||
|
||||
-- handle event
|
||||
if event == "timer" and param1 == loop_tick then
|
||||
-- basic event tick, send keep-alives
|
||||
elseif event == "modem_message" then
|
||||
-- got a packet
|
||||
end
|
||||
end
|
3
supervisor/startup.lua
Normal file
3
supervisor/startup.lua
Normal file
@ -0,0 +1,3 @@
|
||||
--
|
||||
-- Multi-Reactor Controller Server & GUI
|
||||
--
|
Loading…
Reference in New Issue
Block a user