mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#232 option to disable flow view screen for legacy setups
This commit is contained in:
parent
504ee0594f
commit
d179920565
@ -26,6 +26,9 @@ config.SOUNDER_VOLUME = 1.0
|
|||||||
-- true for 24 hour time on main view screen
|
-- true for 24 hour time on main view screen
|
||||||
config.TIME_24_HOUR = true
|
config.TIME_24_HOUR = true
|
||||||
|
|
||||||
|
-- disable flow view (for legacy layouts)
|
||||||
|
config.DISABLE_FLOW_VIEW = false
|
||||||
|
|
||||||
-- log path
|
-- log path
|
||||||
config.LOG_PATH = "/log.txt"
|
config.LOG_PATH = "/log.txt"
|
||||||
-- log mode
|
-- log mode
|
||||||
@ -33,6 +36,6 @@ config.LOG_PATH = "/log.txt"
|
|||||||
-- 1 = NEW (replaces existing file on start)
|
-- 1 = NEW (replaces existing file on start)
|
||||||
config.LOG_MODE = 0
|
config.LOG_MODE = 0
|
||||||
-- true to log verbose debug messages
|
-- true to log verbose debug messages
|
||||||
config.LOG_DEBUG = false
|
config.LOG_DEBUG = true
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
@ -49,8 +49,9 @@ end
|
|||||||
|
|
||||||
-- configure monitor layout
|
-- configure monitor layout
|
||||||
---@param num_units integer number of units expected
|
---@param num_units integer number of units expected
|
||||||
|
---@param disable_flow_view boolean disable flow view (legacy)
|
||||||
---@return boolean success, monitors_struct? monitors
|
---@return boolean success, monitors_struct? monitors
|
||||||
function coordinator.configure_monitors(num_units)
|
function coordinator.configure_monitors(num_units, disable_flow_view)
|
||||||
---@class monitors_struct
|
---@class monitors_struct
|
||||||
local monitors = {
|
local monitors = {
|
||||||
primary = nil,
|
primary = nil,
|
||||||
@ -72,7 +73,7 @@ function coordinator.configure_monitors(num_units)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- we need a certain number of monitors (1 per unit + 1 primary display + 1 flow display)
|
-- we need a certain number of monitors (1 per unit + 1 primary display + 1 flow display)
|
||||||
local num_displays_needed = num_units + 2
|
local num_displays_needed = num_units + util.trinary(disable_flow_view, 1, 2)
|
||||||
if #names < num_displays_needed then
|
if #names < num_displays_needed then
|
||||||
local message = "not enough monitors connected (need " .. num_displays_needed .. ")"
|
local message = "not enough monitors connected (need " .. num_displays_needed .. ")"
|
||||||
println(message)
|
println(message)
|
||||||
@ -125,6 +126,7 @@ function coordinator.configure_monitors(num_units)
|
|||||||
-- FLOW MONITOR DISPLAY --
|
-- FLOW MONITOR DISPLAY --
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
if not disable_flow_view then
|
||||||
local iface_flow_display = settings.get("FLOW_DISPLAY") ---@type boolean|string|nil
|
local iface_flow_display = settings.get("FLOW_DISPLAY") ---@type boolean|string|nil
|
||||||
|
|
||||||
if not util.table_contains(names, iface_flow_display) then
|
if not util.table_contains(names, iface_flow_display) then
|
||||||
@ -145,6 +147,7 @@ function coordinator.configure_monitors(num_units)
|
|||||||
|
|
||||||
monitors.flow = ppm.get_periph(iface_flow_display)
|
monitors.flow = ppm.get_periph(iface_flow_display)
|
||||||
monitors.flow_name = iface_flow_display
|
monitors.flow_name = iface_flow_display
|
||||||
|
end
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
-- UNIT DISPLAYS --
|
-- UNIT DISPLAYS --
|
||||||
|
@ -338,12 +338,22 @@ function iocontrol.fp_has_speaker(has_speaker) io.fp.ps.publish("has_speaker", h
|
|||||||
function iocontrol.fp_link_state(state) io.fp.ps.publish("link_state", state) end
|
function iocontrol.fp_link_state(state) io.fp.ps.publish("link_state", state) end
|
||||||
|
|
||||||
-- report monitor connection state
|
-- report monitor connection state
|
||||||
---@param id integer unit ID or 0 for main
|
---@param id string|integer unit ID for unit monitor, "main" for main monitor, or "flow" for flow monitor
|
||||||
function iocontrol.fp_monitor_state(id, connected)
|
function iocontrol.fp_monitor_state(id, connected)
|
||||||
local name = "main_monitor"
|
local name = nil
|
||||||
if id > 0 then name = "unit_monitor_" .. id end
|
|
||||||
|
if id == "main" then
|
||||||
|
name = "main_monitor"
|
||||||
|
elseif id == "flow" then
|
||||||
|
name = "flow_monitor"
|
||||||
|
elseif type(id) == "number" then
|
||||||
|
name = "unit_monitor_" .. id
|
||||||
|
end
|
||||||
|
|
||||||
|
if name ~= nil then
|
||||||
io.fp.ps.publish(name, connected)
|
io.fp.ps.publish(name, connected)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- report PKT firmware version and PKT session connection state
|
-- report PKT firmware version and PKT session connection state
|
||||||
---@param session_id integer PKT session
|
---@param session_id integer PKT session
|
||||||
|
@ -32,7 +32,8 @@ local engine = {
|
|||||||
main_display = nil, ---@type graphics_element|nil
|
main_display = nil, ---@type graphics_element|nil
|
||||||
flow_display = nil, ---@type graphics_element|nil
|
flow_display = nil, ---@type graphics_element|nil
|
||||||
unit_displays = {}
|
unit_displays = {}
|
||||||
}
|
},
|
||||||
|
disable_flow_view = false
|
||||||
}
|
}
|
||||||
|
|
||||||
-- init a display to the "default", but set text scale to 0.5
|
-- init a display to the "default", but set text scale to 0.5
|
||||||
@ -50,13 +51,20 @@ local function _init_display(monitor)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- disable the flow view
|
||||||
|
---@param disable boolean
|
||||||
|
function renderer.legacy_disable_flow_view(disable)
|
||||||
|
engine.disable_flow_view = disable
|
||||||
|
end
|
||||||
|
|
||||||
-- link to the monitor peripherals
|
-- link to the monitor peripherals
|
||||||
---@param monitors monitors_struct
|
---@param monitors monitors_struct
|
||||||
function renderer.set_displays(monitors)
|
function renderer.set_displays(monitors)
|
||||||
engine.monitors = monitors
|
engine.monitors = monitors
|
||||||
|
|
||||||
-- report to front panel as connected
|
-- report to front panel as connected
|
||||||
iocontrol.fp_monitor_state(0, true)
|
iocontrol.fp_monitor_state("main", engine.monitors.primary ~= nil)
|
||||||
|
iocontrol.fp_monitor_state("flow", engine.monitors.flow ~= nil)
|
||||||
for i = 1, #engine.monitors.unit_displays do iocontrol.fp_monitor_state(i, true) end
|
for i = 1, #engine.monitors.unit_displays do iocontrol.fp_monitor_state(i, true) end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -64,7 +72,7 @@ end
|
|||||||
function renderer.init_displays()
|
function renderer.init_displays()
|
||||||
-- init primary and flow monitors
|
-- init primary and flow monitors
|
||||||
_init_display(engine.monitors.primary)
|
_init_display(engine.monitors.primary)
|
||||||
_init_display(engine.monitors.flow)
|
if not engine.disable_flow_view then _init_display(engine.monitors.flow) end
|
||||||
|
|
||||||
-- init unit displays
|
-- init unit displays
|
||||||
for _, monitor in ipairs(engine.monitors.unit_displays) do
|
for _, monitor in ipairs(engine.monitors.unit_displays) do
|
||||||
@ -91,6 +99,14 @@ function renderer.validate_main_display_width()
|
|||||||
return w == 164
|
return w == 164
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- check flow display width
|
||||||
|
---@nodiscard
|
||||||
|
---@return boolean width_okay
|
||||||
|
function renderer.validate_flow_display_width()
|
||||||
|
local w, _ = engine.monitors.flow.getSize()
|
||||||
|
return w == 164
|
||||||
|
end
|
||||||
|
|
||||||
-- check display sizes
|
-- check display sizes
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
---@return boolean valid all unit display dimensions OK
|
---@return boolean valid all unit display dimensions OK
|
||||||
|
@ -84,7 +84,7 @@ local function main()
|
|||||||
iocontrol.init_fp(COORDINATOR_VERSION, comms.version)
|
iocontrol.init_fp(COORDINATOR_VERSION, comms.version)
|
||||||
|
|
||||||
-- setup monitors
|
-- setup monitors
|
||||||
local configured, monitors = coordinator.configure_monitors(config.NUM_UNITS)
|
local configured, monitors = coordinator.configure_monitors(config.NUM_UNITS, config.DISABLE_FLOW_VIEW == true)
|
||||||
if not configured or monitors == nil then
|
if not configured or monitors == nil then
|
||||||
println("startup> monitor setup failed")
|
println("startup> monitor setup failed")
|
||||||
log.fatal("monitor configuration failed")
|
log.fatal("monitor configuration failed")
|
||||||
@ -92,6 +92,7 @@ local function main()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- init renderer
|
-- init renderer
|
||||||
|
renderer.legacy_disable_flow_view(config.DISABLE_FLOW_VIEW == true)
|
||||||
renderer.set_displays(monitors)
|
renderer.set_displays(monitors)
|
||||||
renderer.init_displays()
|
renderer.init_displays()
|
||||||
|
|
||||||
@ -99,6 +100,10 @@ local function main()
|
|||||||
println("startup> main display must be 8 blocks wide")
|
println("startup> main display must be 8 blocks wide")
|
||||||
log.fatal("main display not wide enough")
|
log.fatal("main display not wide enough")
|
||||||
return
|
return
|
||||||
|
elseif (config.DISABLE_FLOW_VIEW ~= true) and not renderer.validate_flow_display_width() then
|
||||||
|
println("startup> flow display must be 8 blocks wide")
|
||||||
|
log.fatal("flow display not wide enough")
|
||||||
|
return
|
||||||
elseif not renderer.validate_unit_display_sizes() then
|
elseif not renderer.validate_unit_display_sizes() then
|
||||||
println("startup> one or more unit display dimensions incorrect; they must be 4x4 blocks")
|
println("startup> one or more unit display dimensions incorrect; they must be 4x4 blocks")
|
||||||
log.fatal("unit display dimensions incorrect")
|
log.fatal("unit display dimensions incorrect")
|
||||||
|
@ -73,6 +73,9 @@ local function init(panel, num_units)
|
|||||||
local main_monitor = LED{parent=monitors,label="MAIN MONITOR",colors=cpair(colors.green,colors.green_off)}
|
local main_monitor = LED{parent=monitors,label="MAIN MONITOR",colors=cpair(colors.green,colors.green_off)}
|
||||||
main_monitor.register(ps, "main_monitor", main_monitor.update)
|
main_monitor.register(ps, "main_monitor", main_monitor.update)
|
||||||
|
|
||||||
|
local flow_monitor = LED{parent=monitors,label="FLOW MONITOR",colors=cpair(colors.green,colors.green_off)}
|
||||||
|
flow_monitor.register(ps, "flow_monitor", flow_monitor.update)
|
||||||
|
|
||||||
monitors.line_break()
|
monitors.line_break()
|
||||||
|
|
||||||
for i = 1, num_units do
|
for i = 1, num_units do
|
||||||
|
Loading…
Reference in New Issue
Block a user