#623 PLC option to invert emergency coolant control
This commit is contained in:
parent
12664c6190
commit
2998371b89
@ -82,8 +82,9 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, style, exit)
|
|||||||
local plc_c_2 = Div{parent=plc_cfg,x=2,y=4,width=49}
|
local plc_c_2 = Div{parent=plc_cfg,x=2,y=4,width=49}
|
||||||
local plc_c_3 = Div{parent=plc_cfg,x=2,y=4,width=49}
|
local plc_c_3 = Div{parent=plc_cfg,x=2,y=4,width=49}
|
||||||
local plc_c_4 = Div{parent=plc_cfg,x=2,y=4,width=49}
|
local plc_c_4 = Div{parent=plc_cfg,x=2,y=4,width=49}
|
||||||
|
local plc_c_5 = Div{parent=plc_cfg,x=2,y=4,width=49}
|
||||||
|
|
||||||
local plc_pane = MultiPane{parent=plc_cfg,x=1,y=4,panes={plc_c_1,plc_c_2,plc_c_3,plc_c_4}}
|
local plc_pane = MultiPane{parent=plc_cfg,x=1,y=4,panes={plc_c_1,plc_c_2,plc_c_3,plc_c_4,plc_c_5}}
|
||||||
|
|
||||||
TextBox{parent=plc_cfg,x=1,y=2,text=" PLC Configuration",fg_bg=cpair(colors.black,colors.orange)}
|
TextBox{parent=plc_cfg,x=1,y=2,text=" PLC Configuration",fg_bg=cpair(colors.black,colors.orange)}
|
||||||
|
|
||||||
@ -152,13 +153,20 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, style, exit)
|
|||||||
|
|
||||||
function self.bundled_emcool(en) if en then color.enable() else color.disable() end end
|
function self.bundled_emcool(en) if en then color.enable() else color.disable() end end
|
||||||
|
|
||||||
|
TextBox{parent=plc_c_5,x=1,y=1,height=5,text="Advanced Options"}
|
||||||
|
local invert = Checkbox{parent=plc_c_5,x=1,y=3,label="Invert",default=ini_cfg.EmerCoolInvert,box_fg_bg=cpair(colors.orange,colors.black),callback=function()end}
|
||||||
|
TextBox{parent=plc_c_5,x=3,y=4,height=4,text="Digital I/O is already inverted (or not) based on intended use. If you have a non-standard setup, you can use this option to avoid needing a redstone inverter.",fg_bg=cpair(colors.gray,colors.lightGray)}
|
||||||
|
PushButton{parent=plc_c_5,x=1,y=14,text="\x1b Back",callback=function()plc_pane.set_value(4)end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg}
|
||||||
|
|
||||||
local function submit_emcool()
|
local function submit_emcool()
|
||||||
tmp_cfg.EmerCoolSide = side_options_map[side.get_value()]
|
tmp_cfg.EmerCoolSide = side_options_map[side.get_value()]
|
||||||
tmp_cfg.EmerCoolColor = util.trinary(bundled.get_value(), color_options_map[color.get_value()], nil)
|
tmp_cfg.EmerCoolColor = util.trinary(bundled.get_value(), color_options_map[color.get_value()], nil)
|
||||||
|
tmp_cfg.EmerCoolInvert = invert.get_value()
|
||||||
next_from_plc()
|
next_from_plc()
|
||||||
end
|
end
|
||||||
|
|
||||||
PushButton{parent=plc_c_4,x=1,y=14,text="\x1b Back",callback=function()plc_pane.set_value(3)end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg}
|
PushButton{parent=plc_c_4,x=1,y=14,text="\x1b Back",callback=function()plc_pane.set_value(3)end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg}
|
||||||
|
PushButton{parent=plc_c_4,x=33,y=14,min_width=10,text="Advanced",callback=function()plc_pane.set_value(5)end,fg_bg=cpair(colors.black,colors.yellow),active_fg_bg=btn_act_fg_bg,dis_fg_bg=btn_dis_fg_bg}
|
||||||
PushButton{parent=plc_c_4,x=44,y=14,text="Next \x1a",callback=submit_emcool,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg}
|
PushButton{parent=plc_c_4,x=44,y=14,text="Next \x1a",callback=submit_emcool,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg}
|
||||||
|
|
||||||
--#endregion
|
--#endregion
|
||||||
@ -461,6 +469,7 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, style, exit)
|
|||||||
try_set(side, side_to_idx(ini_cfg.EmerCoolSide))
|
try_set(side, side_to_idx(ini_cfg.EmerCoolSide))
|
||||||
try_set(bundled, ini_cfg.EmerCoolColor ~= nil)
|
try_set(bundled, ini_cfg.EmerCoolColor ~= nil)
|
||||||
if ini_cfg.EmerCoolColor ~= nil then try_set(color, color_to_idx(ini_cfg.EmerCoolColor)) end
|
if ini_cfg.EmerCoolColor ~= nil then try_set(color, color_to_idx(ini_cfg.EmerCoolColor)) end
|
||||||
|
try_set(invert, ini_cfg.EmerCoolInvert)
|
||||||
try_set(svr_chan, ini_cfg.SVR_Channel)
|
try_set(svr_chan, ini_cfg.SVR_Channel)
|
||||||
try_set(plc_chan, ini_cfg.PLC_Channel)
|
try_set(plc_chan, ini_cfg.PLC_Channel)
|
||||||
try_set(timeout, ini_cfg.ConnTimeout)
|
try_set(timeout, ini_cfg.ConnTimeout)
|
||||||
@ -533,9 +542,11 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, style, exit)
|
|||||||
if tmp_cfg.EmerCoolEnable then
|
if tmp_cfg.EmerCoolEnable then
|
||||||
tmp_cfg.EmerCoolSide = config.EMERGENCY_COOL.side
|
tmp_cfg.EmerCoolSide = config.EMERGENCY_COOL.side
|
||||||
tmp_cfg.EmerCoolColor = config.EMERGENCY_COOL.color
|
tmp_cfg.EmerCoolColor = config.EMERGENCY_COOL.color
|
||||||
|
tmp_cfg.EmerCoolInvert = false
|
||||||
else
|
else
|
||||||
tmp_cfg.EmerCoolSide = nil
|
tmp_cfg.EmerCoolSide = nil
|
||||||
tmp_cfg.EmerCoolColor = nil
|
tmp_cfg.EmerCoolColor = nil
|
||||||
|
tmp_cfg.EmerCoolInvert = false
|
||||||
end
|
end
|
||||||
|
|
||||||
tmp_cfg.SVR_Channel = config.SVR_CHANNEL
|
tmp_cfg.SVR_Channel = config.SVR_CHANNEL
|
||||||
|
|||||||
@ -32,7 +32,8 @@ local changes = {
|
|||||||
{ "v1.6.2", { "AuthKey minimum length is now 8 (if set)" } },
|
{ "v1.6.2", { "AuthKey minimum length is now 8 (if set)" } },
|
||||||
{ "v1.6.8", { "ConnTimeout can now have a fractional part" } },
|
{ "v1.6.8", { "ConnTimeout can now have a fractional part" } },
|
||||||
{ "v1.6.15", { "Added front panel UI theme", "Added color accessibility modes" } },
|
{ "v1.6.15", { "Added front panel UI theme", "Added color accessibility modes" } },
|
||||||
{ "v1.7.3", { "Added standard with black off state color mode", "Added blue indicator color modes" } }
|
{ "v1.7.3", { "Added standard with black off state color mode", "Added blue indicator color modes" } },
|
||||||
|
{ "v1.8.21", { "Added option to invert emergency coolant redstone control" } }
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class plc_configurator
|
---@class plc_configurator
|
||||||
@ -76,6 +77,7 @@ local tmp_cfg = {
|
|||||||
EmerCoolEnable = false,
|
EmerCoolEnable = false,
|
||||||
EmerCoolSide = nil, ---@type string|nil
|
EmerCoolSide = nil, ---@type string|nil
|
||||||
EmerCoolColor = nil, ---@type color|nil
|
EmerCoolColor = nil, ---@type color|nil
|
||||||
|
EmerCoolInvert = false, ---@type boolean
|
||||||
SVR_Channel = nil, ---@type integer
|
SVR_Channel = nil, ---@type integer
|
||||||
PLC_Channel = nil, ---@type integer
|
PLC_Channel = nil, ---@type integer
|
||||||
ConnTimeout = nil, ---@type number
|
ConnTimeout = nil, ---@type number
|
||||||
@ -100,6 +102,7 @@ local fields = {
|
|||||||
{ "EmerCoolEnable", "Emergency Coolant", false },
|
{ "EmerCoolEnable", "Emergency Coolant", false },
|
||||||
{ "EmerCoolSide", "Emergency Coolant Side", nil },
|
{ "EmerCoolSide", "Emergency Coolant Side", nil },
|
||||||
{ "EmerCoolColor", "Emergency Coolant Color", nil },
|
{ "EmerCoolColor", "Emergency Coolant Color", nil },
|
||||||
|
{ "EmerCoolInvert", "Emergency Coolant Invert", false },
|
||||||
{ "SVR_Channel", "SVR Channel", 16240 },
|
{ "SVR_Channel", "SVR Channel", 16240 },
|
||||||
{ "PLC_Channel", "PLC Channel", 16241 },
|
{ "PLC_Channel", "PLC Channel", 16241 },
|
||||||
{ "ConnTimeout", "Connection Timeout", 5 },
|
{ "ConnTimeout", "Connection Timeout", 5 },
|
||||||
|
|||||||
@ -43,6 +43,7 @@ function plc.load_config()
|
|||||||
config.EmerCoolEnable = settings.get("EmerCoolEnable")
|
config.EmerCoolEnable = settings.get("EmerCoolEnable")
|
||||||
config.EmerCoolSide = settings.get("EmerCoolSide")
|
config.EmerCoolSide = settings.get("EmerCoolSide")
|
||||||
config.EmerCoolColor = settings.get("EmerCoolColor")
|
config.EmerCoolColor = settings.get("EmerCoolColor")
|
||||||
|
config.EmerCoolInvert = settings.get("EmerCoolInvert")
|
||||||
|
|
||||||
config.SVR_Channel = settings.get("SVR_Channel")
|
config.SVR_Channel = settings.get("SVR_Channel")
|
||||||
config.PLC_Channel = settings.get("PLC_Channel")
|
config.PLC_Channel = settings.get("PLC_Channel")
|
||||||
@ -98,6 +99,7 @@ function plc.validate_config(cfg)
|
|||||||
if cfg.EmerCoolEnable then
|
if cfg.EmerCoolEnable then
|
||||||
cfv.assert_eq(rsio.is_valid_side(cfg.EmerCoolSide), true)
|
cfv.assert_eq(rsio.is_valid_side(cfg.EmerCoolSide), true)
|
||||||
cfv.assert_eq(cfg.EmerCoolColor == nil or rsio.is_color(cfg.EmerCoolColor), true)
|
cfv.assert_eq(cfg.EmerCoolColor == nil or rsio.is_color(cfg.EmerCoolColor), true)
|
||||||
|
cfv.assert_type_bool(cfg.EmerCoolInvert)
|
||||||
end
|
end
|
||||||
|
|
||||||
return cfv.valid()
|
return cfv.valid()
|
||||||
@ -166,7 +168,8 @@ function plc.rps_init(reactor, is_formed)
|
|||||||
local function _set_emer_cool(state)
|
local function _set_emer_cool(state)
|
||||||
-- check if this was configured: if it's a table, fields have already been validated.
|
-- check if this was configured: if it's a table, fields have already been validated.
|
||||||
if config.EmerCoolEnable then
|
if config.EmerCoolEnable then
|
||||||
local level = rsio.digital_write_active(rsio.IO.U_EMER_COOL, state)
|
-- use ~= as XOR for simple inversion
|
||||||
|
local level = rsio.digital_write_active(rsio.IO.U_EMER_COOL, config.EmerCoolInvert ~= state)
|
||||||
|
|
||||||
if level ~= false then
|
if level ~= false then
|
||||||
if rsio.is_color(config.EmerCoolColor) then
|
if rsio.is_color(config.EmerCoolColor) then
|
||||||
|
|||||||
@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc")
|
|||||||
local renderer = require("reactor-plc.renderer")
|
local renderer = require("reactor-plc.renderer")
|
||||||
local threads = require("reactor-plc.threads")
|
local threads = require("reactor-plc.threads")
|
||||||
|
|
||||||
local R_PLC_VERSION = "v1.8.20"
|
local R_PLC_VERSION = "v1.8.21"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user