mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#74 close supervisor connection on exit, start of touch event handling
This commit is contained in:
parent
1afafba501
commit
9b21a971fe
@ -44,7 +44,9 @@ function coordinator.configure_monitors(num_units)
|
|||||||
---@class monitors_struct
|
---@class monitors_struct
|
||||||
local monitors = {
|
local monitors = {
|
||||||
primary = nil,
|
primary = nil,
|
||||||
unit_displays = {}
|
primary_name = "",
|
||||||
|
unit_displays = {},
|
||||||
|
unit_name_map = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
local monitors_avail = ppm.get_monitor_list()
|
local monitors_avail = ppm.get_monitor_list()
|
||||||
@ -89,6 +91,7 @@ function coordinator.configure_monitors(num_units)
|
|||||||
util.filter_table(names, function (x) return x ~= iface_primary_display end)
|
util.filter_table(names, function (x) return x ~= iface_primary_display end)
|
||||||
|
|
||||||
monitors.primary = ppm.get_periph(iface_primary_display)
|
monitors.primary = ppm.get_periph(iface_primary_display)
|
||||||
|
monitors.primary_name = iface_primary_display
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
-- UNIT DISPLAYS --
|
-- UNIT DISPLAYS --
|
||||||
@ -139,6 +142,7 @@ function coordinator.configure_monitors(num_units)
|
|||||||
|
|
||||||
for i = 1, #unit_displays do
|
for i = 1, #unit_displays do
|
||||||
monitors.unit_displays[i] = ppm.get_periph(unit_displays[i])
|
monitors.unit_displays[i] = ppm.get_periph(unit_displays[i])
|
||||||
|
monitors.unit_name_map[i] = unit_displays[i]
|
||||||
end
|
end
|
||||||
|
|
||||||
return true, monitors
|
return true, monitors
|
||||||
@ -251,6 +255,12 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, sv_wa
|
|||||||
_open_channels()
|
_open_channels()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- close the connection to the server
|
||||||
|
function public.close()
|
||||||
|
sv_watchdog.cancel()
|
||||||
|
_send_sv(PROTOCOLS.SCADA_MGMT, SCADA_MGMT_TYPES.CLOSE, {})
|
||||||
|
end
|
||||||
|
|
||||||
-- attempt to connect to the subervisor
|
-- attempt to connect to the subervisor
|
||||||
---@param timeout_s number timeout in seconds
|
---@param timeout_s number timeout in seconds
|
||||||
---@param tick_dmesg_waiting function callback to tick dmesg waiting
|
---@param tick_dmesg_waiting function callback to tick dmesg waiting
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local log = require("scada-common.log")
|
local log = require("scada-common.log")
|
||||||
|
|
||||||
local main_view = require("coordinator.ui.layout.main_view")
|
local main_view = require("coordinator.ui.layout.main_view")
|
||||||
local unit_view = require("coordinator.ui.layout.unit_view")
|
local unit_view = require("coordinator.ui.layout.unit_view")
|
||||||
@ -99,4 +99,19 @@ function renderer.close_ui(recolor)
|
|||||||
engine.dmesg_window.redraw()
|
engine.dmesg_window.redraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- handle a touch event
|
||||||
|
---@param event monitor_touch
|
||||||
|
function renderer.handle_touch(event)
|
||||||
|
if event.monitor == engine.monitors.primary_name then
|
||||||
|
ui.main_layout.handle_touch(event)
|
||||||
|
else
|
||||||
|
for id, monitor in pairs(engine.monitors.unit_name_map) do
|
||||||
|
if event.monitor == monitor then
|
||||||
|
local layout = ui.unit_layouts[id] ---@type graphics_element
|
||||||
|
layout.handle_touch(event)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return renderer
|
return renderer
|
||||||
|
@ -8,12 +8,14 @@ local log = require("scada-common.log")
|
|||||||
local ppm = require("scada-common.ppm")
|
local ppm = require("scada-common.ppm")
|
||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
|
local core = require("graphics.core")
|
||||||
|
|
||||||
local apisessions = require("coordinator.apisessions")
|
local apisessions = require("coordinator.apisessions")
|
||||||
local config = require("coordinator.config")
|
local config = require("coordinator.config")
|
||||||
local coordinator = require("coordinator.coordinator")
|
local coordinator = require("coordinator.coordinator")
|
||||||
local renderer = require("coordinator.renderer")
|
local renderer = require("coordinator.renderer")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "alpha-v0.3.5"
|
local COORDINATOR_VERSION = "alpha-v0.3.6"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
@ -211,12 +213,17 @@ while ui_ok do
|
|||||||
-- got a packet
|
-- got a packet
|
||||||
local packet = coord_comms.parse_packet(param1, param2, param3, param4, param5)
|
local packet = coord_comms.parse_packet(param1, param2, param3, param4, param5)
|
||||||
coord_comms.handle_packet(packet)
|
coord_comms.handle_packet(packet)
|
||||||
|
elseif event == "monitor_touch" then
|
||||||
|
-- handle a monitor touch event
|
||||||
|
renderer.handle_touch(core.events.touch(param1, param2, param3))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check for termination request
|
-- check for termination request
|
||||||
if event == "terminate" or ppm.should_terminate() then
|
if event == "terminate" or ppm.should_terminate() then
|
||||||
log_comms("terminate requested, closing sessions...")
|
log_comms("terminate requested, closing supervisor connection")
|
||||||
println_ts("closing sessions...")
|
coord_comms.close()
|
||||||
|
log_comms("closing api sessions...")
|
||||||
|
println_ts("closing api sessions...")
|
||||||
apisessions.close_all()
|
apisessions.close_all()
|
||||||
log_comms("api sessions closed")
|
log_comms("api sessions closed")
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user