#47 supervisor luadoc, bugfixes

This commit is contained in:
Mikayla Fischler
2022-05-11 12:31:19 -04:00
parent 95c4d51e67
commit 0d090fe9e2
6 changed files with 176 additions and 111 deletions

View File

@@ -1,8 +1,8 @@
local unit = {}
-- create a new reactor unit
---@param for_reactor integer
unit.new = function (for_reactor)
local public = {}
local self = {
r_id = for_reactor,
plc_s = nil,
@@ -11,6 +11,7 @@ unit.new = function (for_reactor)
energy_storage = {},
redstone = {},
db = {
---@class annunciator
annunciator = {
-- RPS
-- reactor
@@ -37,18 +38,36 @@ unit.new = function (for_reactor)
}
}
---@class reactor_unit
local public = {}
-- PRIVATE FUNCTIONS --
-- update the annunciator
local _update_annunciator = function ()
self.db.annunciator.PLCOnline = (self.plc_s ~= nil) and (self.plc_s.open)
self.db.annunciator.ReactorTrip = false
end
-- PUBLIC FUNCTIONS --
-- link the PLC
---@param plc_session plc_session_struct
public.link_plc_session = function (plc_session)
self.plc_s = plc_session
end
-- link a turbine RTU
public.add_turbine = function (turbine)
table.insert(self.turbines, turbine)
end
-- link a boiler RTU
public.add_boiler = function (boiler)
table.insert(self.boilers, boiler)
end
-- link a redstone RTU capability
public.add_redstone = function (field, accessor)
-- ensure field exists
if self.redstone[field] == nil then
@@ -59,11 +78,7 @@ unit.new = function (for_reactor)
table.insert(self.redstone[field], accessor)
end
local _update_annunciator = function ()
self.db.annunciator.PLCOnline = (self.plc_s ~= nil) and (self.plc_s.open)
self.db.annunciator.ReactorTrip = false
end
-- update (iterate) this session
public.update = function ()
-- unlink PLC if session was closed
if not self.plc_s.open then
@@ -74,6 +89,7 @@ unit.new = function (for_reactor)
_update_annunciator()
end
-- get the annunciator status
public.get_annunciator = function () return self.db.annunciator end
return public