diff --git a/pocket/ui/apps/devices.lua b/pocket/ui/apps/devices.lua new file mode 100644 index 0000000..e69de29 diff --git a/scada-common/comms.lua b/scada-common/comms.lua index 18f2d48..8ce4bd8 100644 --- a/scada-common/comms.lua +++ b/scada-common/comms.lua @@ -55,7 +55,8 @@ local MGMT_TYPE = { DIAG_TONE_GET = 6, -- (API) diagnostic: get alarm tones DIAG_TONE_SET = 7, -- (API) diagnostic: set alarm tones DIAG_ALARM_SET = 8, -- (API) diagnostic: set alarm to simulate audio for - INFO_LIST_CMP = 9 -- (API) info: list all computers on the network + INFO_LIST_CMP = 9, -- (API) info: list all computers on the network + INFO_LIST_PERI = 10 -- (API) info: list all peripherals on the network } ---@enum CRDN_TYPE diff --git a/supervisor/session/pocket.lua b/supervisor/session/pocket.lua index 7500110..96ab138 100644 --- a/supervisor/session/pocket.lua +++ b/supervisor/session/pocket.lua @@ -226,6 +226,46 @@ function pocket.new_session(id, s_addr, i_seq_num, in_queue, out_queue, timeout, end _send_mgmt(MGMT_TYPE.INFO_LIST_CMP, devices) + elseif pkt.type == MGMT_TYPE.INFO_LIST_PERI then + local data = {} + + local fac = db.facility + local proc = process.get_control_states().process + + -- unit data + for i = 1, #db.units do + local u = db.units[i] + + data[i] = {} + + data[i].boilers = {} + for idx, blr in ipairs(u.boiler_data_tbl) do + data[i].boilers[idx] = {} + + if blr.formed ~= nil then + data[i].boilers[idx] = { blr.formed, blr.build.min_pos, blr.build.max_pos, blr.build.length, blr.build.width, blr.build.height } + end + end + + data[i].turbines = {} + for idx, trb in ipairs(u.turbine_data_tbl) do + data[i].turbines[idx] = {} + + if trb.formed ~= nil then + data[i].turbines[idx] = { trb.formed, trb.build.min_pos, trb.build.max_pos, trb.build.length, trb.build.width, trb.build.height } + end + end + + data[i].tanks = {} + for idx, trb in ipairs(u.tank_data_tbl) do + data[i].turbines[idx] = {} + + if trb.formed ~= nil then + data[i].turbines[idx] = { trb.formed, trb.build.min_pos, trb.build.max_pos, trb.build.length, trb.build.width, trb.build.height } + end + end + end + else log.debug(log_tag .. "handler received unsupported SCADA_MGMT packet type " .. pkt.type) end