#118 PLC code cleanup

This commit is contained in:
Mikayla Fischler
2023-02-21 16:57:33 -05:00
parent 82ea35168b
commit ce0198f389
4 changed files with 54 additions and 50 deletions

View File

@@ -28,6 +28,7 @@ local MQ__COMM_CMD = {
}
-- main thread
---@nodiscard
---@param smem plc_shared_memory
---@param init function
function threads.thread__main(smem, init)
@@ -45,9 +46,9 @@ function threads.thread__main(smem, init)
local loop_clock = util.new_clock(MAIN_CLOCK)
-- load in from shared memory
local networked = smem.networked
local plc_state = smem.plc_state
local plc_dev = smem.plc_dev
local networked = smem.networked
local plc_state = smem.plc_state
local plc_dev = smem.plc_dev
-- event loop
while true do
@@ -276,6 +277,7 @@ function threads.thread__main(smem, init)
end
-- RPS operation thread
---@nodiscard
---@param smem plc_shared_memory
function threads.thread__rps(smem)
---@class parallel_thread
@@ -298,10 +300,10 @@ function threads.thread__rps(smem)
-- thread loop
while true do
-- get plc_sys fields (may have been set late due to degraded boot)
local rps = smem.plc_sys.rps
local plc_comms = smem.plc_sys.plc_comms
local rps = smem.plc_sys.rps
local plc_comms = smem.plc_sys.plc_comms
-- get reactor, may have changed do to disconnect/reconnect
local reactor = plc_dev.reactor
local reactor = plc_dev.reactor
-- RPS checks
if plc_state.init_ok then
@@ -416,6 +418,7 @@ function threads.thread__rps(smem)
end
-- communications sender thread
---@nodiscard
---@param smem plc_shared_memory
function threads.thread__comms_tx(smem)
---@class parallel_thread
@@ -491,6 +494,7 @@ function threads.thread__comms_tx(smem)
end
-- communications handler thread
---@nodiscard
---@param smem plc_shared_memory
function threads.thread__comms_rx(smem)
---@class parallel_thread
@@ -565,7 +569,8 @@ function threads.thread__comms_rx(smem)
return public
end
-- apply setpoints
-- ramp control outputs to desired setpoints
---@nodiscard
---@param smem plc_shared_memory
function threads.thread__setpoint_control(smem)
---@class parallel_thread