#86 type bug fix
This commit is contained in:
parent
564b89d19c
commit
621adbbcbc
@ -26,7 +26,8 @@ local DT_KEYS = {
|
|||||||
function unit.new(for_reactor, num_boilers, num_turbines)
|
function unit.new(for_reactor, num_boilers, num_turbines)
|
||||||
local self = {
|
local self = {
|
||||||
r_id = for_reactor,
|
r_id = for_reactor,
|
||||||
plc_s = nil, ---@class plc_session
|
plc_s = nil, ---@class plc_session_struct
|
||||||
|
plc_i = nil, ---@class plc_session
|
||||||
counts = { boilers = num_boilers, turbines = num_turbines },
|
counts = { boilers = num_boilers, turbines = num_turbines },
|
||||||
turbines = {},
|
turbines = {},
|
||||||
boilers = {},
|
boilers = {},
|
||||||
@ -104,9 +105,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
|
|
||||||
-- clear a delta
|
-- clear a delta
|
||||||
---@param key string value key
|
---@param key string value key
|
||||||
local function _reset_dt(key)
|
local function _reset_dt(key) self.deltas[key] = nil end
|
||||||
self.deltas[key] = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get the delta t of a value
|
-- get the delta t of a value
|
||||||
---@param key string value key
|
---@param key string value key
|
||||||
@ -122,7 +121,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
-- update all delta computations
|
-- update all delta computations
|
||||||
local function _dt__compute_all()
|
local function _dt__compute_all()
|
||||||
if self.plc_s ~= nil then
|
if self.plc_s ~= nil then
|
||||||
local plc_db = self.plc_s.get_db()
|
local plc_db = self.plc_i.get_db()
|
||||||
|
|
||||||
-- @todo Meknaism 10.1+ will change fuel/waste to need _amnt
|
-- @todo Meknaism 10.1+ will change fuel/waste to need _amnt
|
||||||
_compute_dt(DT_KEYS.ReactorTemp, plc_db.mek_status.temp)
|
_compute_dt(DT_KEYS.ReactorTemp, plc_db.mek_status.temp)
|
||||||
@ -166,7 +165,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
self.db.annunciator.PLCOnline = (self.plc_s ~= nil) and (self.plc_s.open)
|
self.db.annunciator.PLCOnline = (self.plc_s ~= nil) and (self.plc_s.open)
|
||||||
|
|
||||||
if self.plc_s ~= nil then
|
if self.plc_s ~= nil then
|
||||||
local plc_db = self.plc_s.get_db()
|
local plc_db = self.plc_i.get_db()
|
||||||
|
|
||||||
-- update annunciator
|
-- update annunciator
|
||||||
self.db.annunciator.ReactorTrip = plc_db.rps_tripped
|
self.db.annunciator.ReactorTrip = plc_db.rps_tripped
|
||||||
@ -208,13 +207,15 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
|
|
||||||
-- check heating rate low
|
-- check heating rate low
|
||||||
if self.plc_s ~= nil then
|
if self.plc_s ~= nil then
|
||||||
|
local r_db = self.plc_i.get_db()
|
||||||
|
|
||||||
-- check for inactive boilers while reactor is active
|
-- check for inactive boilers while reactor is active
|
||||||
for i = 1, #self.boilers do
|
for i = 1, #self.boilers do
|
||||||
local boiler = self.boilers[i] ---@type unit_session
|
local boiler = self.boilers[i] ---@type unit_session
|
||||||
local idx = boiler.get_device_idx()
|
local idx = boiler.get_device_idx()
|
||||||
local db = boiler.get_db() ---@type boiler_session_db
|
local db = boiler.get_db() ---@type boiler_session_db
|
||||||
|
|
||||||
if self.plc_s.get_db().mek_status.status then
|
if r_db.mek_status.status then
|
||||||
self.db.annunciator.HeatingRateLow[idx] = db.state.boil_rate == 0
|
self.db.annunciator.HeatingRateLow[idx] = db.state.boil_rate == 0
|
||||||
else
|
else
|
||||||
self.db.annunciator.HeatingRateLow[idx] = false
|
self.db.annunciator.HeatingRateLow[idx] = false
|
||||||
@ -222,7 +223,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- check for rate mismatch
|
-- check for rate mismatch
|
||||||
local expected_boil_rate = self.plc_s.get_db().mek_status.heating_rate / 10.0
|
local expected_boil_rate = r_db.mek_status.heating_rate / 10.0
|
||||||
self.db.annunciator.BoilRateMismatch = math.abs(expected_boil_rate - total_boil_rate) > 25.0
|
self.db.annunciator.BoilRateMismatch = math.abs(expected_boil_rate - total_boil_rate) > 25.0
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -324,6 +325,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
---@param plc_session plc_session_struct
|
---@param plc_session plc_session_struct
|
||||||
function public.link_plc_session(plc_session)
|
function public.link_plc_session(plc_session)
|
||||||
self.plc_s = plc_session
|
self.plc_s = plc_session
|
||||||
|
self.plc_i = plc_session.instance
|
||||||
|
|
||||||
-- reset deltas
|
-- reset deltas
|
||||||
_reset_dt(DT_KEYS.ReactorTemp)
|
_reset_dt(DT_KEYS.ReactorTemp)
|
||||||
@ -398,7 +400,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
local build = {}
|
local build = {}
|
||||||
|
|
||||||
if self.plc_s ~= nil then
|
if self.plc_s ~= nil then
|
||||||
build.reactor = self.plc_s.get_struct()
|
build.reactor = self.plc_i.get_struct()
|
||||||
end
|
end
|
||||||
|
|
||||||
build.boilers = {}
|
build.boilers = {}
|
||||||
@ -421,7 +423,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
|||||||
local status = {}
|
local status = {}
|
||||||
|
|
||||||
if self.plc_s ~= nil then
|
if self.plc_s ~= nil then
|
||||||
local reactor = self.plc_s
|
local reactor = self.plc_i
|
||||||
status = { reactor.get_status(), reactor.get_rps(), reactor.get_general_status() }
|
status = { reactor.get_status(), reactor.get_rps(), reactor.get_general_status() }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ local svsessions = require("supervisor.session.svsessions")
|
|||||||
local config = require("supervisor.config")
|
local config = require("supervisor.config")
|
||||||
local supervisor = require("supervisor.supervisor")
|
local supervisor = require("supervisor.supervisor")
|
||||||
|
|
||||||
local SUPERVISOR_VERSION = "beta-v0.5.7"
|
local SUPERVISOR_VERSION = "beta-v0.5.8"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user