#401 pocket handling of computer data
This commit is contained in:
parent
4fb39213f2
commit
0bfe767710
@ -35,8 +35,8 @@ iocontrol.LINK_STATE = LINK_STATE
|
||||
|
||||
---@class pocket_ioctl
|
||||
local io = {
|
||||
version = "unknown",
|
||||
ps = psil.create()
|
||||
version = "unknown", -- pocket version
|
||||
ps = psil.create() -- pocket PSIL
|
||||
}
|
||||
|
||||
local config = nil ---@type pkt_config
|
||||
@ -91,6 +91,9 @@ function iocontrol.init_core(pkt_comms, nav, cfg)
|
||||
tone_indicators = {} ---@type IndicatorLight[] indicators to update from supervisor tone states
|
||||
}
|
||||
|
||||
-- computer list
|
||||
io.diag.get_comps = function () comms.diag__get_computers() end
|
||||
|
||||
-- API access
|
||||
---@class pocket_ioctl_api
|
||||
io.api = {
|
||||
|
||||
@ -871,6 +871,52 @@ function iorx.record_radiation_data(data)
|
||||
fac.ps.publish("radiation_monitors", textutils.serialize(connected))
|
||||
end
|
||||
|
||||
local comp_record = {}
|
||||
|
||||
-- update the computers app with the network data from INFO_LIST_CMP
|
||||
---@param data table
|
||||
function iorx.record_network_data(data)
|
||||
local ps = io.facility.ps
|
||||
local connected = {}
|
||||
|
||||
-- add/update connected computers
|
||||
for i = 1, #data do
|
||||
local entry = data[i]
|
||||
local id = entry[2]
|
||||
local pfx = "comp_" .. id
|
||||
|
||||
connected[id] = true
|
||||
|
||||
ps.publish(pfx .. "_type", entry[1])
|
||||
ps.publish(pfx .. "_addr", id)
|
||||
ps.publish(pfx .. "_fw", entry[3])
|
||||
ps.publish(pfx .. "_rtt", entry[4])
|
||||
|
||||
if not comp_record[id] then
|
||||
comp_record[id] = true
|
||||
|
||||
-- trigger the app to create the new element
|
||||
ps.publish("comp_connect", id)
|
||||
end
|
||||
end
|
||||
|
||||
-- reset the published value
|
||||
ps.publish("comp_connect", false)
|
||||
|
||||
-- remove disconnected computers
|
||||
for id, state in pairs(comp_record) do
|
||||
if state and not connected[id] then
|
||||
comp_record[id] = false
|
||||
|
||||
-- trigger the app to delete the element
|
||||
ps.publish("comp_disconnect", id)
|
||||
end
|
||||
end
|
||||
|
||||
-- reset the published value
|
||||
ps.publish("comp_disconnect", false)
|
||||
end
|
||||
|
||||
return function (io_obj)
|
||||
io = io_obj
|
||||
return iorx
|
||||
|
||||
@ -558,6 +558,11 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
|
||||
if self.sv.linked then _send_sv(MGMT_TYPE.DIAG_ALARM_SET, { id, state }) end
|
||||
end
|
||||
|
||||
-- supervisor get connected computers
|
||||
function public.diag__get_computers()
|
||||
if self.sv.linked then _send_sv(MGMT_TYPE.INFO_LIST_CMP, {}) end
|
||||
end
|
||||
|
||||
-- coordinator get facility app data
|
||||
function public.api__get_facility()
|
||||
if self.api.linked then _send_api(CRDN_TYPE.API_GET_FAC_DTL, {}) end
|
||||
|
||||
@ -22,7 +22,7 @@ local pocket = require("pocket.pocket")
|
||||
local renderer = require("pocket.renderer")
|
||||
local threads = require("pocket.threads")
|
||||
|
||||
local POCKET_VERSION = "v0.13.5-beta"
|
||||
local POCKET_VERSION = "v0.13.6-beta"
|
||||
|
||||
local println = util.println
|
||||
local println_ts = util.println_ts
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user