mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#20 process target charge level
This commit is contained in:
parent
da9eead2d5
commit
ff1bd02739
@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol")
|
|||||||
local renderer = require("coordinator.renderer")
|
local renderer = require("coordinator.renderer")
|
||||||
local sounder = require("coordinator.sounder")
|
local sounder = require("coordinator.sounder")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "beta-v0.9.5"
|
local COORDINATOR_VERSION = "beta-v0.9.6"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
@ -64,7 +64,7 @@ local function new_view(root, x, y)
|
|||||||
local auto_ready = IndicatorLight{parent=main,label="Configured Units Ready",colors=cpair(colors.green,colors.red)}
|
local auto_ready = IndicatorLight{parent=main,label="Configured Units Ready",colors=cpair(colors.green,colors.red)}
|
||||||
local auto_act = IndicatorLight{parent=main,label="Process Active",colors=cpair(colors.green,colors.gray)}
|
local auto_act = IndicatorLight{parent=main,label="Process Active",colors=cpair(colors.green,colors.gray)}
|
||||||
local auto_ramp = IndicatorLight{parent=main,label="Process Ramping",colors=cpair(colors.white,colors.gray),flash=true,period=period.BLINK_250_MS}
|
local auto_ramp = IndicatorLight{parent=main,label="Process Ramping",colors=cpair(colors.white,colors.gray),flash=true,period=period.BLINK_250_MS}
|
||||||
local auto_sat = IndicatorLight{parent=main,label="Max Burn Rate",colors=cpair(colors.yellow,colors.gray)}
|
local auto_sat = IndicatorLight{parent=main,label="Min/Max Burn Rate",colors=cpair(colors.yellow,colors.gray)}
|
||||||
local auto_scram = IndicatorLight{parent=main,label="Automatic SCRAM",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS}
|
local auto_scram = IndicatorLight{parent=main,label="Automatic SCRAM",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS}
|
||||||
|
|
||||||
facility.ps.subscribe("auto_ready", auto_ready.update)
|
facility.ps.subscribe("auto_ready", auto_ready.update)
|
||||||
@ -109,11 +109,11 @@ local function new_view(root, x, y)
|
|||||||
|
|
||||||
local chg_target = Div{parent=targets,x=9,y=6,width=23,height=3,fg_bg=cpair(colors.gray,colors.white)}
|
local chg_target = Div{parent=targets,x=9,y=6,width=23,height=3,fg_bg=cpair(colors.gray,colors.white)}
|
||||||
local c_target = SpinboxNumeric{parent=chg_target,x=2,y=1,whole_num_precision=15,fractional_precision=0,min=0,arrow_fg_bg=cpair(colors.gray,colors.white),fg_bg=bw_fg_bg}
|
local c_target = SpinboxNumeric{parent=chg_target,x=2,y=1,whole_num_precision=15,fractional_precision=0,min=0,arrow_fg_bg=cpair(colors.gray,colors.white),fg_bg=bw_fg_bg}
|
||||||
TextBox{parent=chg_target,x=18,y=2,text="kFE"}
|
TextBox{parent=chg_target,x=18,y=2,text="MFE"}
|
||||||
local cur_charge = DataIndicator{parent=targets,x=9,y=9,label="",format="%19d",value=0,unit="kFE",commas=true,lu_colors=cpair(colors.black,colors.black),width=23,fg_bg=cpair(colors.black,colors.brown)}
|
local cur_charge = DataIndicator{parent=targets,x=9,y=9,label="",format="%19d",value=0,unit="MFE",commas=true,lu_colors=cpair(colors.black,colors.black),width=23,fg_bg=cpair(colors.black,colors.brown)}
|
||||||
|
|
||||||
facility.ps.subscribe("process_charge_target", c_target.set_value)
|
facility.ps.subscribe("process_charge_target", c_target.set_value)
|
||||||
facility.induction_ps_tbl[1].subscribe("energy", function (j) cur_charge.update(util.joules_to_fe(j) / 1000) end)
|
facility.induction_ps_tbl[1].subscribe("energy", function (j) cur_charge.update(util.joules_to_fe(j) / 1000000) end)
|
||||||
|
|
||||||
local gen_tag = Div{parent=targets,x=1,y=11,width=8,height=4,fg_bg=cpair(colors.black,colors.purple)}
|
local gen_tag = Div{parent=targets,x=1,y=11,width=8,height=4,fg_bg=cpair(colors.black,colors.purple)}
|
||||||
TextBox{parent=gen_tag,x=2,y=2,text="Gen. Target",width=7,height=2}
|
TextBox{parent=gen_tag,x=2,y=2,text="Gen. Target",width=7,height=2}
|
||||||
|
@ -30,9 +30,9 @@ local START_STATUS = {
|
|||||||
BLADE_MISMATCH = 2
|
BLADE_MISMATCH = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
local charge_Kp = 1.0
|
local charge_Kp = 0.275
|
||||||
local charge_Ki = 0.0
|
local charge_Ki = 0.0
|
||||||
local charge_Kd = 0.0
|
local charge_Kd = 4.5
|
||||||
|
|
||||||
local rate_Kp = 2.45
|
local rate_Kp = 2.45
|
||||||
local rate_Ki = 0.4825
|
local rate_Ki = 0.4825
|
||||||
@ -80,9 +80,9 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
last_time = 0.0,
|
last_time = 0.0,
|
||||||
-- statistics
|
-- statistics
|
||||||
im_stat_init = false,
|
im_stat_init = false,
|
||||||
avg_charge = util.mov_avg(10, 0.0),
|
avg_charge = util.mov_avg(3, 0.0),
|
||||||
avg_inflow = util.mov_avg(10, 0.0),
|
avg_inflow = util.mov_avg(6, 0.0),
|
||||||
avg_outflow = util.mov_avg(10, 0.0)
|
avg_outflow = util.mov_avg(6, 0.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
-- create units
|
-- create units
|
||||||
@ -290,8 +290,6 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
self.start_fail = START_STATUS.NO_UNITS
|
self.start_fail = START_STATUS.NO_UNITS
|
||||||
else
|
else
|
||||||
self.charge_conversion = blade_count * POWER_PER_BLADE
|
self.charge_conversion = blade_count * POWER_PER_BLADE
|
||||||
|
|
||||||
log.debug(util.c("FAC: starting auto control: chg_conv = ", self.charge_conversion, ", blade_count = ", blade_count, ", max_burn = ", self.max_burn_combined))
|
|
||||||
end
|
end
|
||||||
elseif self.mode == PROCESS.INACTIVE then
|
elseif self.mode == PROCESS.INACTIVE then
|
||||||
for i = 1, #self.prio_defs do
|
for i = 1, #self.prio_defs do
|
||||||
@ -357,29 +355,20 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
self.saturated = self.burn_target == self.max_burn_combined or unallocated > 0
|
self.saturated = self.burn_target == self.max_burn_combined or unallocated > 0
|
||||||
elseif self.mode == PROCESS.CHARGE then
|
elseif self.mode == PROCESS.CHARGE then
|
||||||
-- target a level of charge
|
-- target a level of charge
|
||||||
-- convert to kFE to make constants not microscopic
|
|
||||||
local error = (self.charge_setpoint - avg_charge) / 1000000
|
|
||||||
|
|
||||||
if state_changed then
|
if state_changed then
|
||||||
|
self.time_start = now
|
||||||
self.last_time = now
|
self.last_time = now
|
||||||
log.debug(util.c("FAC: CHARGE mode first call completed"))
|
self.last_error = 0
|
||||||
elseif self.waiting_on_ramp then
|
self.accumulator = 0
|
||||||
if _all_units_ramped() then
|
|
||||||
self.waiting_on_ramp = false
|
|
||||||
|
|
||||||
self.time_start = now
|
self.status_text = { "CHARGE MODE", "running control loop" }
|
||||||
self.last_time = now
|
log.info(util.c("FAC: CHARGE mode starting PID control"))
|
||||||
self.last_error = 0
|
elseif self.last_update ~= charge_update then
|
||||||
self.accumulator = 0
|
-- convert to kFE to make constants not microscopic
|
||||||
|
local error = util.round((self.charge_setpoint - avg_charge) / 1000) / 1000
|
||||||
|
|
||||||
self.status_text = { "CHARGE MODE", "running control loop" }
|
-- stop accumulator when saturated to avoid windup
|
||||||
log.info(util.c("FAC: CHARGE mode initial ramp completed"))
|
if not self.saturated then
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not self.waiting_on_ramp and self.last_update ~= rate_update then
|
|
||||||
-- stop accumulator when saturated to avoid windup, deadband accumulator at 1kFE to avoid windup
|
|
||||||
if (not self.saturated) and (math.abs(error) >= 0.001) then
|
|
||||||
self.accumulator = self.accumulator + (error * (now - self.last_time))
|
self.accumulator = self.accumulator + (error * (now - self.last_time))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -398,16 +387,13 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
|
|
||||||
self.saturated = output ~= out_c
|
self.saturated = output ~= out_c
|
||||||
|
|
||||||
log.debug(util.sprintf("PROC_CHRG[%f] { CHRG[%f] ERR[%f] INT[%f] => OUT[%f] OUT_C[%f] <= P[%f] I[%f] D[%d] }",
|
log.debug(util.sprintf("CHARGE[%f] { CHRG[%f] ERR[%f] INT[%f] => OUT[%f] OUT_C[%f] <= P[%f] I[%f] D[%d] }",
|
||||||
runtime, avg_charge, error, integral, output, out_c, P, I, D))
|
runtime, avg_charge, error, integral, output, out_c, P, I, D))
|
||||||
|
|
||||||
_allocate_burn_rate(out_c, self.initial_ramp)
|
_allocate_burn_rate(out_c, true)
|
||||||
|
|
||||||
self.last_time = now
|
self.last_time = now
|
||||||
|
self.last_error = error
|
||||||
if self.initial_ramp then
|
|
||||||
self.waiting_on_ramp = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self.last_update = charge_update
|
self.last_update = charge_update
|
||||||
@ -450,7 +436,7 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
-- convert to MFE (in rounded kFE) to make constants not microscopic
|
-- convert to MFE (in rounded kFE) to make constants not microscopic
|
||||||
local error = util.round((self.gen_rate_setpoint - avg_inflow) / 1000) / 1000
|
local error = util.round((self.gen_rate_setpoint - avg_inflow) / 1000) / 1000
|
||||||
|
|
||||||
-- stop accumulator when saturated to avoid windup, deadband accumulator at 1kFE to avoid windup
|
-- stop accumulator when saturated to avoid windup
|
||||||
if not self.saturated then
|
if not self.saturated then
|
||||||
self.accumulator = self.accumulator + (error * (now - self.last_time))
|
self.accumulator = self.accumulator + (error * (now - self.last_time))
|
||||||
end
|
end
|
||||||
@ -656,7 +642,7 @@ function facility.new(num_reactors, cooling_conf)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if (type(config.charge_target) == "number") and config.charge_target >= 0 then
|
if (type(config.charge_target) == "number") and config.charge_target >= 0 then
|
||||||
self.charge_setpoint = config.charge_target
|
self.charge_setpoint = config.charge_target * 1000000 -- convert MFE to FE
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(config.gen_target) == "number") and config.gen_target >= 0 then
|
if (type(config.gen_target) == "number") and config.gen_target >= 0 then
|
||||||
|
@ -14,7 +14,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.10.6"
|
local SUPERVISOR_VERSION = "beta-v0.10.7"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
Loading…
Reference in New Issue
Block a user