mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#531 pocket energy scale options
This commit is contained in:
parent
340c6689a9
commit
d58a6a3369
@ -33,7 +33,8 @@ local RIGHT = core.ALIGN.RIGHT
|
|||||||
|
|
||||||
-- changes to the config data/format to let the user know
|
-- changes to the config data/format to let the user know
|
||||||
local changes = {
|
local changes = {
|
||||||
{ "v0.9.2", { "Added temperature scale options" } }
|
{ "v0.9.2", { "Added temperature scale options" } },
|
||||||
|
{ "v0.11.3", { "Added energy scale options" } }
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class pkt_configurator
|
---@class pkt_configurator
|
||||||
@ -76,6 +77,7 @@ local tool_ctl = {
|
|||||||
---@class pkt_config
|
---@class pkt_config
|
||||||
local tmp_cfg = {
|
local tmp_cfg = {
|
||||||
TempScale = 1,
|
TempScale = 1,
|
||||||
|
EnergyScale = 1,
|
||||||
SVR_Channel = nil, ---@type integer
|
SVR_Channel = nil, ---@type integer
|
||||||
CRD_Channel = nil, ---@type integer
|
CRD_Channel = nil, ---@type integer
|
||||||
PKT_Channel = nil, ---@type integer
|
PKT_Channel = nil, ---@type integer
|
||||||
@ -94,7 +96,8 @@ local settings_cfg = {}
|
|||||||
|
|
||||||
-- all settings fields, their nice names, and their default values
|
-- all settings fields, their nice names, and their default values
|
||||||
local fields = {
|
local fields = {
|
||||||
{ "TempScale", "Temperature Scale", 1 },
|
{ "TempScale", "Temperature Scale", types.TEMP_SCALE.KELVIN },
|
||||||
|
{ "EnergyScale", "Energy Scale", types.ENERGY_SCALE.FE },
|
||||||
{ "SVR_Channel", "SVR Channel", 16240 },
|
{ "SVR_Channel", "SVR Channel", 16240 },
|
||||||
{ "CRD_Channel", "CRD Channel", 16243 },
|
{ "CRD_Channel", "CRD Channel", 16243 },
|
||||||
{ "PKT_Channel", "PKT Channel", 16244 },
|
{ "PKT_Channel", "PKT Channel", 16244 },
|
||||||
@ -175,13 +178,17 @@ local function config_view(display)
|
|||||||
|
|
||||||
TextBox{parent=ui_cfg,x=1,y=2,text=" Pocket UI",fg_bg=cpair(colors.black,colors.lime)}
|
TextBox{parent=ui_cfg,x=1,y=2,text=" Pocket UI",fg_bg=cpair(colors.black,colors.lime)}
|
||||||
|
|
||||||
TextBox{parent=ui_c_1,x=1,y=1,height=3,text="You may use the options below to customize formats."}
|
TextBox{parent=ui_c_1,x=1,y=1,height=3,text="You may customize units below."}
|
||||||
|
|
||||||
TextBox{parent=ui_c_1,x=1,y=5,text="Temperature Scale"}
|
TextBox{parent=ui_c_1,x=1,y=4,text="Temperature Scale"}
|
||||||
local temp_scale = RadioButton{parent=ui_c_1,x=1,y=6,default=ini_cfg.TempScale,options=types.TEMP_SCALE_NAMES,callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.lime}
|
local temp_scale = RadioButton{parent=ui_c_1,x=1,y=5,default=ini_cfg.TempScale,options=types.TEMP_SCALE_NAMES,callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.lime}
|
||||||
|
|
||||||
|
TextBox{parent=ui_c_1,x=1,y=10,text="Energy Scale"}
|
||||||
|
local energy_scale = RadioButton{parent=ui_c_1,x=1,y=11,default=ini_cfg.EnergyScale,options=types.ENERGY_SCALE_NAMES,callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.lime}
|
||||||
|
|
||||||
local function submit_ui_opts()
|
local function submit_ui_opts()
|
||||||
tmp_cfg.TempScale = temp_scale.get_value()
|
tmp_cfg.TempScale = temp_scale.get_value()
|
||||||
|
tmp_cfg.EnergyScale = energy_scale.get_value()
|
||||||
main_pane.set_value(3)
|
main_pane.set_value(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -378,6 +385,8 @@ local function config_view(display)
|
|||||||
load_settings(settings_cfg, true)
|
load_settings(settings_cfg, true)
|
||||||
load_settings(ini_cfg)
|
load_settings(ini_cfg)
|
||||||
|
|
||||||
|
try_set(temp_scale, ini_cfg.TempScale)
|
||||||
|
try_set(energy_scale, ini_cfg.EnergyScale)
|
||||||
try_set(svr_chan, ini_cfg.SVR_Channel)
|
try_set(svr_chan, ini_cfg.SVR_Channel)
|
||||||
try_set(crd_chan, ini_cfg.CRD_Channel)
|
try_set(crd_chan, ini_cfg.CRD_Channel)
|
||||||
try_set(pkt_chan, ini_cfg.PKT_Channel)
|
try_set(pkt_chan, ini_cfg.PKT_Channel)
|
||||||
@ -504,7 +513,9 @@ local function config_view(display)
|
|||||||
elseif f[1] == "LogMode" then
|
elseif f[1] == "LogMode" then
|
||||||
val = util.trinary(raw == log.MODE.APPEND, "append", "replace")
|
val = util.trinary(raw == log.MODE.APPEND, "append", "replace")
|
||||||
elseif f[1] == "TempScale" then
|
elseif f[1] == "TempScale" then
|
||||||
val = types.TEMP_SCALE_NAMES[raw]
|
val = util.strval(types.TEMP_SCALE_NAMES[raw])
|
||||||
|
elseif f[1] == "EnergyScale" then
|
||||||
|
val = util.strval(types.ENERGY_SCALE_NAMES[raw])
|
||||||
end
|
end
|
||||||
|
|
||||||
if val == "nil" then val = "<not set>" end
|
if val == "nil" then val = "<not set>" end
|
||||||
|
@ -10,6 +10,9 @@ local util = require("scada-common.util")
|
|||||||
|
|
||||||
local ALARM = types.ALARM
|
local ALARM = types.ALARM
|
||||||
local ALARM_STATE = types.ALARM_STATE
|
local ALARM_STATE = types.ALARM_STATE
|
||||||
|
|
||||||
|
local ENERGY_SCALE = types.ENERGY_SCALE
|
||||||
|
local ENERGY_UNITS = types.ENERGY_SCALE_UNITS
|
||||||
local TEMP_SCALE = types.TEMP_SCALE
|
local TEMP_SCALE = types.TEMP_SCALE
|
||||||
local TEMP_UNITS = types.TEMP_SCALE_UNITS
|
local TEMP_UNITS = types.TEMP_SCALE_UNITS
|
||||||
|
|
||||||
@ -88,8 +91,10 @@ end
|
|||||||
-- initialize facility-dependent components of pocket iocontrol
|
-- initialize facility-dependent components of pocket iocontrol
|
||||||
---@param conf facility_conf configuration
|
---@param conf facility_conf configuration
|
||||||
---@param temp_scale TEMP_SCALE temperature unit
|
---@param temp_scale TEMP_SCALE temperature unit
|
||||||
function iocontrol.init_fac(conf, temp_scale)
|
---@param energy_scale ENERGY_SCALE energy unit
|
||||||
|
function iocontrol.init_fac(conf, temp_scale, energy_scale)
|
||||||
io.temp_label = TEMP_UNITS[temp_scale]
|
io.temp_label = TEMP_UNITS[temp_scale]
|
||||||
|
io.energy_label = ENERGY_UNITS[energy_scale]
|
||||||
|
|
||||||
-- temperature unit label and conversion function (from Kelvin)
|
-- temperature unit label and conversion function (from Kelvin)
|
||||||
if temp_scale == TEMP_SCALE.CELSIUS then
|
if temp_scale == TEMP_SCALE.CELSIUS then
|
||||||
@ -103,6 +108,18 @@ function iocontrol.init_fac(conf, temp_scale)
|
|||||||
io.temp_convert = function (t) return t end
|
io.temp_convert = function (t) return t end
|
||||||
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
|
-- facility data structure
|
||||||
---@class pioctl_facility
|
---@class pioctl_facility
|
||||||
io.facility = {
|
io.facility = {
|
||||||
|
@ -36,6 +36,7 @@ function pocket.load_config()
|
|||||||
if not settings.load("/pocket.settings") then return false end
|
if not settings.load("/pocket.settings") then return false end
|
||||||
|
|
||||||
config.TempScale = settings.get("TempScale")
|
config.TempScale = settings.get("TempScale")
|
||||||
|
config.EnergyScale = settings.get("EnergyScale")
|
||||||
|
|
||||||
config.SVR_Channel = settings.get("SVR_Channel")
|
config.SVR_Channel = settings.get("SVR_Channel")
|
||||||
config.CRD_Channel = settings.get("CRD_Channel")
|
config.CRD_Channel = settings.get("CRD_Channel")
|
||||||
@ -52,6 +53,8 @@ function pocket.load_config()
|
|||||||
|
|
||||||
cfv.assert_type_int(config.TempScale)
|
cfv.assert_type_int(config.TempScale)
|
||||||
cfv.assert_range(config.TempScale, 1, 4)
|
cfv.assert_range(config.TempScale, 1, 4)
|
||||||
|
cfv.assert_type_int(config.EnergyScale)
|
||||||
|
cfv.assert_range(config.EnergyScale, 1, 3)
|
||||||
|
|
||||||
cfv.assert_channel(config.SVR_Channel)
|
cfv.assert_channel(config.SVR_Channel)
|
||||||
cfv.assert_channel(config.CRD_Channel)
|
cfv.assert_channel(config.CRD_Channel)
|
||||||
@ -675,7 +678,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
|
|||||||
-- get configuration
|
-- get configuration
|
||||||
local conf = { num_units = fac_config[1], cooling = fac_config[2] }
|
local conf = { num_units = fac_config[1], cooling = fac_config[2] }
|
||||||
|
|
||||||
iocontrol.init_fac(conf, config.TempScale)
|
iocontrol.init_fac(conf, config.TempScale, config.EnergyScale)
|
||||||
|
|
||||||
log.info("coordinator connection established")
|
log.info("coordinator connection established")
|
||||||
self.establish_delay_counter = 0
|
self.establish_delay_counter = 0
|
||||||
|
@ -20,7 +20,7 @@ local pocket = require("pocket.pocket")
|
|||||||
local renderer = require("pocket.renderer")
|
local renderer = require("pocket.renderer")
|
||||||
local threads = require("pocket.threads")
|
local threads = require("pocket.threads")
|
||||||
|
|
||||||
local POCKET_VERSION = "v0.11.2-alpha"
|
local POCKET_VERSION = "v0.11.3-alpha"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
@ -59,13 +59,13 @@ return function (app, u_page, panes, tbn_pane, u_id, t_id, ps, update)
|
|||||||
ccool.register(ps, "energy_fill", ccool.update)
|
ccool.register(ps, "energy_fill", ccool.update)
|
||||||
|
|
||||||
TextBox{parent=tbn_div,text="Production",x=3,y=3,width=17,fg_bg=label}
|
TextBox{parent=tbn_div,text="Production",x=3,y=3,width=17,fg_bg=label}
|
||||||
local prod_rate = PowerIndicator{parent=tbn_div,x=3,y=4,lu_colors=lu_col,label="",format="%11.2f",value=0,rate=true,width=17,fg_bg=text_fg}
|
local prod_rate = PowerIndicator{parent=tbn_div,x=3,y=4,lu_colors=lu_col,label="",unit=db.energy_label,format="%11.2f",value=0,rate=true,width=17,fg_bg=text_fg}
|
||||||
TextBox{parent=tbn_div,text="Flow Rate",x=3,y=5,width=17,fg_bg=label}
|
TextBox{parent=tbn_div,text="Flow Rate",x=3,y=5,width=17,fg_bg=label}
|
||||||
local flow_rate = DataIndicator{parent=tbn_div,x=3,y=6,lu_colors=lu_col,label="",unit="mB/t",format="%11.0f",value=0,commas=true,width=17,fg_bg=text_fg}
|
local flow_rate = DataIndicator{parent=tbn_div,x=3,y=6,lu_colors=lu_col,label="",unit="mB/t",format="%11.0f",value=0,commas=true,width=17,fg_bg=text_fg}
|
||||||
TextBox{parent=tbn_div,text="Steam Input Rate",x=3,y=7,width=17,fg_bg=label}
|
TextBox{parent=tbn_div,text="Steam Input Rate",x=3,y=7,width=17,fg_bg=label}
|
||||||
local input_rate = DataIndicator{parent=tbn_div,x=3,y=8,lu_colors=lu_col,label="",unit="mB/t",format="%11.0f",value=0,commas=true,width=17,fg_bg=text_fg}
|
local input_rate = DataIndicator{parent=tbn_div,x=3,y=8,lu_colors=lu_col,label="",unit="mB/t",format="%11.0f",value=0,commas=true,width=17,fg_bg=text_fg}
|
||||||
|
|
||||||
prod_rate.register(ps, "prod_rate", function (val) prod_rate.update(util.joules_to_fe(val)) end)
|
prod_rate.register(ps, "prod_rate", function (val) prod_rate.update(db.energy_convert(val)) end)
|
||||||
flow_rate.register(ps, "flow_rate", flow_rate.update)
|
flow_rate.register(ps, "flow_rate", flow_rate.update)
|
||||||
input_rate.register(ps, "steam_input_rate", input_rate.update)
|
input_rate.register(ps, "steam_input_rate", input_rate.update)
|
||||||
|
|
||||||
@ -99,10 +99,10 @@ return function (app, u_page, panes, tbn_pane, u_id, t_id, ps, update)
|
|||||||
|
|
||||||
TextBox{parent=tbn_ext_div,text="Energy Fill",x=1,y=6,width=12,fg_bg=label}
|
TextBox{parent=tbn_ext_div,text="Energy Fill",x=1,y=6,width=12,fg_bg=label}
|
||||||
local charge_p = DataIndicator{parent=tbn_ext_div,x=14,y=6,lu_colors=lu_col,label="",unit="%",format="%6.2f",value=0,width=8,fg_bg=text_fg}
|
local charge_p = DataIndicator{parent=tbn_ext_div,x=14,y=6,lu_colors=lu_col,label="",unit="%",format="%6.2f",value=0,width=8,fg_bg=text_fg}
|
||||||
local charge_amnt = PowerIndicator{parent=tbn_ext_div,x=1,y=7,lu_colors=lu_col,label="",format="%17.4f",value=0,width=21,fg_bg=text_fg}
|
local charge_amnt = PowerIndicator{parent=tbn_ext_div,x=1,y=7,lu_colors=lu_col,label="",unit=db.energy_label,format="%17.4f",value=0,width=21,fg_bg=text_fg}
|
||||||
|
|
||||||
charge_p.register(ps, "energy_fill", function (x) charge_p.update(x * 100) end)
|
charge_p.register(ps, "energy_fill", function (x) charge_p.update(x * 100) end)
|
||||||
charge_amnt.register(ps, "energy", charge_amnt.update)
|
charge_amnt.register(ps, "energy", function (val) charge_amnt.update(db.energy_convert(val)) end)
|
||||||
|
|
||||||
TextBox{parent=tbn_ext_div,text="Rotation Rate",x=1,y=9,width=13,fg_bg=label}
|
TextBox{parent=tbn_ext_div,text="Rotation Rate",x=1,y=9,width=13,fg_bg=label}
|
||||||
local rotation = DataIndicator{parent=tbn_ext_div,x=1,y=10,lu_colors=lu_col,label="",unit="",format="%21.12f",value=0,width=21,fg_bg=text_fg}
|
local rotation = DataIndicator{parent=tbn_ext_div,x=1,y=10,lu_colors=lu_col,label="",unit="",format="%21.12f",value=0,width=21,fg_bg=text_fg}
|
||||||
|
Loading…
Reference in New Issue
Block a user