refactoring and adjusted spinbox and hazard button elements
This commit is contained in:
@@ -426,9 +426,9 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, sv_wa
|
||||
if packet.length == 3 then
|
||||
local cmd = packet.data[1]
|
||||
local unit_id = packet.data[2]
|
||||
local ack = packet.data[3]
|
||||
local ack = packet.data[3] == true
|
||||
|
||||
local unit = iocontrol.get_db().units[unit_id] ---@type ioctl_entry
|
||||
local unit = iocontrol.get_db().units[unit_id] ---@type ioctl_unit
|
||||
|
||||
if unit ~= nil then
|
||||
if cmd == UNIT_COMMANDS.SCRAM then
|
||||
@@ -444,14 +444,12 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, sv_wa
|
||||
elseif cmd == UNIT_COMMANDS.ACK_ALL_ALARMS then
|
||||
unit.ack_alarms_ack(ack)
|
||||
elseif cmd == UNIT_COMMANDS.SET_GROUP then
|
||||
process.sv_assign(unit_id, ack)
|
||||
elseif cmd == UNIT_COMMANDS.SET_LIMIT then
|
||||
process.sv_limit(unit_id, ack)
|
||||
---@todo how is this going to be handled?
|
||||
else
|
||||
log.debug(util.c("received command ack with unknown command ", cmd))
|
||||
log.debug(util.c("received unit command ack with unknown command ", cmd))
|
||||
end
|
||||
else
|
||||
log.debug(util.c("received command ack with unknown unit ", unit_id))
|
||||
log.debug(util.c("received unit command ack with unknown unit ", unit_id))
|
||||
end
|
||||
else
|
||||
log.debug("SCADA_CRDN unit command ack packet length mismatch")
|
||||
|
||||
@@ -21,9 +21,7 @@ local io = {}
|
||||
---@param comms coord_comms comms reference
|
||||
---@diagnostic disable-next-line: redefined-local
|
||||
function iocontrol.init(conf, comms)
|
||||
-- pass IO control here since it can't be require'd due to a require loop
|
||||
process.init(io, comms)
|
||||
|
||||
---@class ioctl_facility
|
||||
io.facility = {
|
||||
auto_active = false,
|
||||
scram = false,
|
||||
@@ -50,7 +48,7 @@ function iocontrol.init(conf, comms)
|
||||
local function ack(alarm) process.ack_alarm(i, alarm) end
|
||||
local function reset(alarm) process.reset_alarm(i, alarm) end
|
||||
|
||||
---@class ioctl_entry
|
||||
---@class ioctl_unit
|
||||
local entry = {
|
||||
unit_id = i, ---@type integer
|
||||
|
||||
@@ -140,6 +138,9 @@ function iocontrol.init(conf, comms)
|
||||
|
||||
table.insert(io.units, entry)
|
||||
end
|
||||
|
||||
-- pass IO control here since it can't be require'd due to a require loop
|
||||
process.init(io, comms)
|
||||
end
|
||||
|
||||
-- populate facility structure builds
|
||||
@@ -180,7 +181,7 @@ end
|
||||
function iocontrol.record_unit_builds(builds)
|
||||
-- note: if not all units and RTUs are connected, some will be nil
|
||||
for id, build in pairs(builds) do
|
||||
local unit = io.units[id] ---@type ioctl_entry
|
||||
local unit = io.units[id] ---@type ioctl_unit
|
||||
|
||||
if type(build) ~= "table" then
|
||||
log.error(util.c("corrupted unit builds provided, unit ", id, " not a table"))
|
||||
@@ -330,7 +331,7 @@ function iocontrol.update_unit_statuses(statuses)
|
||||
-- get all unit statuses
|
||||
for i = 1, #statuses do
|
||||
local log_header = util.c("iocontrol.update_unit_statuses[unit ", i, "]: ")
|
||||
local unit = io.units[i] ---@type ioctl_entry
|
||||
local unit = io.units[i] ---@type ioctl_unit
|
||||
local status = statuses[i]
|
||||
|
||||
if type(status) ~= "table" or #status ~= 6 then
|
||||
|
||||
@@ -306,7 +306,7 @@ function sounder.eval(units)
|
||||
if units ~= nil then
|
||||
-- check all alarms for all units
|
||||
for i = 1, #units do
|
||||
local unit = units[i] ---@type ioctl_entry
|
||||
local unit = units[i] ---@type ioctl_unit
|
||||
for id = 1, #unit.alarms do
|
||||
alarms[id] = alarms[id] or (unit.alarms[id] == ALARM_STATE.TRIPPED)
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol")
|
||||
local renderer = require("coordinator.renderer")
|
||||
local sounder = require("coordinator.sounder")
|
||||
|
||||
local COORDINATOR_VERSION = "beta-v0.8.8"
|
||||
local COORDINATOR_VERSION = "beta-v0.8.9"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
|
||||
@@ -38,7 +38,7 @@ local function new_view(root, x, y, data, ps, id)
|
||||
local label_fg_bg = cpair(colors.gray, colors.lightGray)
|
||||
local lu_col = cpair(colors.gray, colors.gray)
|
||||
|
||||
local status = StateIndicator{parent=rect,x=11,y=1,states=style.imatrix.states,value=1,min_width=12}
|
||||
local status = StateIndicator{parent=rect,x=10,y=1,states=style.imatrix.states,value=1,min_width=14}
|
||||
local energy = PowerIndicator{parent=rect,x=7,y=3,lu_colors=lu_col,label="Energy: ",format="%8.2f",value=0,width=26,fg_bg=text_fg_bg}
|
||||
local capacity = PowerIndicator{parent=rect,x=7,y=4,lu_colors=lu_col,label="Capacity:",format="%8.2f",value=0,width=26,fg_bg=text_fg_bg}
|
||||
local input = PowerIndicator{parent=rect,x=7,y=5,lu_colors=lu_col,label="Input: ",format="%8.2f",rate=true,value=0,width=26,fg_bg=text_fg_bg}
|
||||
|
||||
@@ -59,7 +59,7 @@ local waste_opts = {
|
||||
---@param parent graphics_element parent
|
||||
---@param id integer
|
||||
local function init(parent, id)
|
||||
local unit = iocontrol.get_db().units[id] ---@type ioctl_entry
|
||||
local unit = iocontrol.get_db().units[id] ---@type ioctl_unit
|
||||
local r_ps = unit.reactor_ps
|
||||
local b_ps = unit.boiler_ps_tbl
|
||||
local t_ps = unit.turbine_ps_tbl
|
||||
@@ -329,7 +329,7 @@ local function init(parent, id)
|
||||
----------------------
|
||||
|
||||
local burn_control = Div{parent=main,x=12,y=28,width=19,height=3,fg_bg=cpair(colors.gray,colors.white)}
|
||||
local burn_rate = SpinboxNumeric{parent=burn_control,x=2,y=1,whole_num_precision=4,fractional_precision=1,arrow_fg_bg=cpair(colors.gray,colors.white),fg_bg=bw_fg_bg}
|
||||
local burn_rate = SpinboxNumeric{parent=burn_control,x=2,y=1,whole_num_precision=4,fractional_precision=1,min=0.1,arrow_fg_bg=cpair(colors.gray,colors.white),fg_bg=bw_fg_bg}
|
||||
TextBox{parent=burn_control,x=9,y=2,text="mB/t"}
|
||||
|
||||
local set_burn = function () unit.set_burn(burn_rate.get_value()) end
|
||||
|
||||
@@ -24,7 +24,7 @@ local pipe = core.graphics.pipe
|
||||
---@param parent graphics_element parent
|
||||
---@param x integer top left x
|
||||
---@param y integer top left y
|
||||
---@param unit ioctl_entry unit database entry
|
||||
---@param unit ioctl_unit unit database entry
|
||||
local function make(parent, x, y, unit)
|
||||
local height = 0
|
||||
local num_boilers = #unit.boiler_data_tbl
|
||||
|
||||
Reference in New Issue
Block a user