#557 work on message data

This commit is contained in:
Mikayla 2025-01-07 23:21:48 +00:00
parent 872082b970
commit 4cb6f9ca0f

View File

@ -260,11 +260,33 @@ function pocket.new_session(id, s_addr, i_seq_num, in_queue, out_queue, timeout)
{ fac.auto_ready, fac.auto_active, fac.auto_ramping, fac.auto_saturated }, { fac.auto_ready, fac.auto_active, fac.auto_ramping, fac.auto_saturated },
{ fac.auto_current_waste_product, fac.auto_pu_fallback_active }, { fac.auto_current_waste_product, fac.auto_pu_fallback_active },
util.table_len(fac.tank_data_tbl), util.table_len(fac.tank_data_tbl),
fac.induction_data_tbl[1] ~= nil, fac.induction_data_tbl[1] ~= nil, ---@fixme this means nothing
fac.sps_data_tbl[1] ~= nil, fac.sps_data_tbl[1] ~= nil ---@fixme this means nothing
} }
_send(CRDN_TYPE.API_GET_FAC, data) _send(CRDN_TYPE.API_GET_FAC, data)
elseif pkt.type == CRDN_TYPE.API_GET_FAC_DTL then
local fac = db.facility
local tank_statuses = {}
for i = 1, #fac.tank_ps_tbl do table.insert(tank_statuses, fac.tank_ps_tbl[i].get("computed_status")) end
local data = {
fac.all_sys_ok,
fac.rtu_count,
{ fac.auto_current_waste_product, fac.auto_pu_fallback_active },
fac.auto_scram,
fac.ascram_status,
tank_statuses,
fac.tank_data_tbl,
fac.induction_ps_tbl[1].get("computed_status") or types.IMATRIX_STATE.OFFLINE,
fac.induction_data_tbl[1],
fac.sps_ps_tbl[1].get("computed_status") or types.SPS_STATE.OFFLINE,
fac.sps_data_tbl[1]
}
_send(CRDN_TYPE.API_GET_FAC_DTL, data)
elseif pkt.type == CRDN_TYPE.API_GET_UNIT then elseif pkt.type == CRDN_TYPE.API_GET_UNIT then
if pkt.length == 1 and type(pkt.data[1]) == "number" then if pkt.length == 1 and type(pkt.data[1]) == "number" then
local u = db.units[pkt.data[1]] local u = db.units[pkt.data[1]]