#186 fixed bug with facility update returning, improved damage status message
This commit is contained in:
@@ -685,7 +685,7 @@ function facility.new(num_reactors, cooling_conf)
|
||||
|
||||
if u.has_alarm_min_prio(PRIO.EMERGENCY) then
|
||||
has_alarm = true
|
||||
return
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ local svsessions = require("supervisor.session.svsessions")
|
||||
local config = require("supervisor.config")
|
||||
local supervisor = require("supervisor.supervisor")
|
||||
|
||||
local SUPERVISOR_VERSION = "v0.13.8"
|
||||
local SUPERVISOR_VERSION = "v0.13.9"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
|
||||
@@ -84,6 +84,7 @@ function unit.new(reactor_id, num_boilers, num_turbines)
|
||||
deltas = {},
|
||||
last_heartbeat = 0,
|
||||
last_radiation = 0,
|
||||
damage_decreasing = false,
|
||||
damage_initial = 0,
|
||||
damage_start = 0,
|
||||
damage_last = 0,
|
||||
|
||||
@@ -93,10 +93,12 @@ function logic.update_annunciator(self)
|
||||
-- track damage
|
||||
if plc_db.mek_status.damage > 0 then
|
||||
if self.damage_start == 0 then
|
||||
self.damage_decreasing = false
|
||||
self.damage_start = util.time_s()
|
||||
self.damage_initial = plc_db.mek_status.damage
|
||||
end
|
||||
else
|
||||
self.damage_decreasing = false
|
||||
self.damage_start = 0
|
||||
self.damage_initial = 0
|
||||
self.damage_last = 0
|
||||
@@ -584,16 +586,25 @@ function logic.update_status_text(self)
|
||||
self.status_text[1] = "CONTAINMENT TAKING DAMAGE"
|
||||
if self.plc_cache.damage >= 100 then
|
||||
self.status_text[2] = "damage critical"
|
||||
elseif (self.plc_cache.damage - self.damage_initial) > 0 then
|
||||
if self.plc_cache.damage > self.damage_last then
|
||||
self.damage_last = self.plc_cache.damage
|
||||
local rate = (self.plc_cache.damage - self.damage_initial) / (util.time_s() - self.damage_start)
|
||||
self.damage_est_last = (100 - self.plc_cache.damage) / rate
|
||||
end
|
||||
elseif self.plc_cache.damage < self.damage_last then
|
||||
self.damage_decreasing = true
|
||||
self.status_text = { "CONTAINMENT TOOK DAMAGE", "damage level lowering..." }
|
||||
elseif (not self.damage_decreasing) or (self.plc_cache.damage > self.damage_last) then
|
||||
self.damage_decreasing = false
|
||||
|
||||
self.status_text[2] = util.c("damage critical in ", util.sprintf("%.1f", self.damage_est_last), "s")
|
||||
if (self.plc_cache.damage - self.damage_initial) > 0 then
|
||||
if self.plc_cache.damage > self.damage_last then
|
||||
self.damage_last = self.plc_cache.damage
|
||||
local rate = (self.plc_cache.damage - self.damage_initial) / (util.time_s() - self.damage_start)
|
||||
self.damage_est_last = (100 - self.plc_cache.damage) / rate
|
||||
end
|
||||
|
||||
self.status_text[2] = util.c("damage critical in ", util.sprintf("%.1f", self.damage_est_last), "s")
|
||||
else
|
||||
self.status_text[2] = "estimating time to critical..."
|
||||
end
|
||||
else
|
||||
self.status_text[2] = "estimating time to critical..."
|
||||
self.status_text = { "CONTAINMENT TOOK DAMAGE", "damage level lowering..." }
|
||||
end
|
||||
elseif is_active(self.alarms.ContainmentRadiation) then
|
||||
self.status_text[1] = "RADIATION DETECTED"
|
||||
|
||||
Reference in New Issue
Block a user