#523 coordinator energy scale options
This commit is contained in:
@@ -14,6 +14,9 @@ local pgi = require("coordinator.ui.pgi")
|
||||
|
||||
local ALARM_STATE = types.ALARM_STATE
|
||||
local PROCESS = types.PROCESS
|
||||
|
||||
local ENERGY_SCALE = types.ENERGY_SCALE
|
||||
local ENERGY_UNITS = types.ENERGY_SCALE_UNITS
|
||||
local TEMP_SCALE = types.TEMP_SCALE
|
||||
local TEMP_UNITS = types.TEMP_SCALE_UNITS
|
||||
|
||||
@@ -50,8 +53,10 @@ end
|
||||
---@param conf facility_conf configuration
|
||||
---@param comms coord_comms comms reference
|
||||
---@param temp_scale TEMP_SCALE temperature unit
|
||||
function iocontrol.init(conf, comms, temp_scale)
|
||||
io.temp_label = TEMP_UNITS[temp_scale]
|
||||
---@param energy_scale ENERGY_SCALE energy unit
|
||||
function iocontrol.init(conf, comms, temp_scale, energy_scale)
|
||||
io.temp_label = TEMP_UNITS[temp_scale]
|
||||
io.energy_label = ENERGY_UNITS[energy_scale]
|
||||
|
||||
-- temperature unit label and conversion function (from Kelvin)
|
||||
if temp_scale == TEMP_SCALE.CELSIUS then
|
||||
@@ -65,6 +70,18 @@ function iocontrol.init(conf, comms, temp_scale)
|
||||
io.temp_convert = function (t) return t end
|
||||
end
|
||||
|
||||
-- energy unit label and conversion function (from Joules unless otherwise specified)
|
||||
if energy_scale == ENERGY_SCALE.FE or energy_scale == ENERGY_SCALE.RF then
|
||||
io.energy_convert = util.joules_to_fe_rf
|
||||
io.energy_convert_from_fe = function (t) return t end
|
||||
io.energy_convert_to_fe = function (t) return t end
|
||||
else
|
||||
io.energy_label = "J"
|
||||
io.energy_convert = function (t) return t end
|
||||
io.energy_convert_from_fe = util.fe_rf_to_joules
|
||||
io.energy_convert_to_fe = util.joules_to_fe_rf
|
||||
end
|
||||
|
||||
-- facility data structure
|
||||
---@class ioctl_facility
|
||||
io.facility = {
|
||||
@@ -692,7 +709,7 @@ function iocontrol.update_facility_status(status)
|
||||
ps.publish("is_discharging", out_f > in_f)
|
||||
|
||||
if data and data.build then
|
||||
local cap = util.joules_to_fe(data.build.transfer_cap)
|
||||
local cap = util.joules_to_fe_rf(data.build.transfer_cap)
|
||||
ps.publish("at_max_io", in_f >= cap or out_f >= cap)
|
||||
end
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user