From d688f9a1c62b6464c9ca3e3eeb868d154175d1b6 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Thu, 28 Apr 2022 22:41:08 -0400 Subject: [PATCH] supervisor code cleanup, adjusted prints --- supervisor/session/plc.lua | 6 ++---- supervisor/session/svsessions.lua | 1 - supervisor/startup.lua | 2 +- supervisor/supervisor.lua | 7 +++++++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/supervisor/session/plc.lua b/supervisor/session/plc.lua index 48c4a53..8c08b86 100644 --- a/supervisor/session/plc.lua +++ b/supervisor/session/plc.lua @@ -181,10 +181,8 @@ function new_session(id, for_reactor, in_queue, out_queue) local srv_now = util.time() self.last_rtt = srv_now - srv_start - if self.last_rtt < 0 then - log._warning(log_header .. "PLC KEEP_ALIVE round trip time less than 0 (" .. self.last_rtt .. ")") - elseif self.last_rtt > 1200 then - log._warning(log_header .. "PLC KEEP_ALIVE round trip time > 1.2s (" .. self.last_rtt .. ")") + if self.last_rtt > 500 then + log._warning(log_header .. "PLC KEEP_ALIVE round trip time > 500ms (" .. self.last_rtt .. ")") end -- log._debug(log_header .. "RPLC RTT = ".. self.last_rtt .. "ms") diff --git a/supervisor/session/svsessions.lua b/supervisor/session/svsessions.lua index 76fdea3..72f12d4 100644 --- a/supervisor/session/svsessions.lua +++ b/supervisor/session/svsessions.lua @@ -70,7 +70,6 @@ function get_reactor_session(reactor) end function establish_plc_session(local_port, remote_port, for_reactor) - util.println(remote_port) if get_reactor_session(for_reactor) == nil then local plc_s = { open = true, diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 71f0eae..1e5396d 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -18,7 +18,7 @@ os.loadAPI("session/svsessions.lua") os.loadAPI("supervisor.lua") -local SUPERVISOR_VERSION = "alpha-v0.1.7" +local SUPERVISOR_VERSION = "alpha-v0.1.8" local print = util.print local println = util.println diff --git a/supervisor/supervisor.lua b/supervisor/supervisor.lua index 571ab49..b8addc2 100644 --- a/supervisor/supervisor.lua +++ b/supervisor/supervisor.lua @@ -1,6 +1,7 @@ -- #REQUIRES comms.lua -- #REQUIRES modbus.lua -- #REQUIRES mqueue.lua +-- #REQUIRES util.lua -- #REQUIRES svsessions.lua local PROTOCOLS = comms.PROTOCOLS @@ -11,6 +12,11 @@ local RTU_ADVERT_TYPES = comms.RTU_ADVERT_TYPES local SESSION_TYPE = svsessions.SESSION_TYPE +local print = util.print +local println = util.println +local print_ts = util.print_ts +local println_ts = util.println_ts + -- supervisory controller communications function superv_comms(num_reactors, modem, dev_listen, coord_listen) local self = { @@ -137,6 +143,7 @@ function superv_comms(num_reactors, modem, dev_listen, coord_listen) _send_plc_linking(r_port, { RPLC_LINKING.COLLISION }) else -- got an ID; assigned to a reactor successfully + println("connected to reactor " .. packet.data[1] .. " PLC (port " .. r_port .. ")") log._debug("PLC_LNK: allowed for device at " .. r_port) _send_plc_linking(r_port, { RPLC_LINKING.ALLOW }) end