mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
PLC bugfixes/optimizations, removed some debug prints
This commit is contained in:
parent
f067da31b4
commit
7f0f423450
@ -230,6 +230,24 @@ function comms_init(id, modem, local_port, server_port, reactor, iss)
|
|||||||
|
|
||||||
-- variable reactor status information, excluding heating rate
|
-- variable reactor status information, excluding heating rate
|
||||||
local _reactor_status = function ()
|
local _reactor_status = function ()
|
||||||
|
local coolant = self.reactor.getCoolant()
|
||||||
|
local coolant_name = ""
|
||||||
|
local coolant_amnt = 0
|
||||||
|
|
||||||
|
local hcoolant = self.reactor.getHeatedCoolant()
|
||||||
|
local hcoolant_name = ""
|
||||||
|
local hcoolant_amnt = 0
|
||||||
|
|
||||||
|
if coolant ~= nil then
|
||||||
|
coolant_name = coolant.name
|
||||||
|
coolant_amnt = coolant.amount
|
||||||
|
end
|
||||||
|
|
||||||
|
if hcoolant ~= nil then
|
||||||
|
hcoolant_name = hcoolant.name
|
||||||
|
hcoolant_amnt = hcoolant.amount
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
self.reactor.getStatus(),
|
self.reactor.getStatus(),
|
||||||
self.reactor.getBurnRate(),
|
self.reactor.getBurnRate(),
|
||||||
@ -240,18 +258,14 @@ function comms_init(id, modem, local_port, server_port, reactor, iss)
|
|||||||
self.reactor.getEnvironmentalLoss(),
|
self.reactor.getEnvironmentalLoss(),
|
||||||
|
|
||||||
self.reactor.getFuel(),
|
self.reactor.getFuel(),
|
||||||
self.reactor.getFuelNeeded(),
|
|
||||||
self.reactor.getFuelFilledPercentage(),
|
self.reactor.getFuelFilledPercentage(),
|
||||||
self.reactor.getWaste(),
|
self.reactor.getWaste(),
|
||||||
self.reactor.getWasteNeeded(),
|
|
||||||
self.reactor.getWasteFilledPercentage(),
|
self.reactor.getWasteFilledPercentage(),
|
||||||
self.reactor.getCoolant()['name'],
|
coolant_name,
|
||||||
self.reactor.getCoolant()['amount'],
|
coolant_amnt,
|
||||||
self.reactor.getCoolantNeeded(),
|
|
||||||
self.reactor.getCoolantFilledPercentage(),
|
self.reactor.getCoolantFilledPercentage(),
|
||||||
self.reactor.getHeatedCoolant()['name'],
|
hcoolant_name,
|
||||||
self.reactor.getHeatedCoolant()['amount'],
|
hcoolant_amnt,
|
||||||
self.reactor.getHeatedCoolantNeeded(),
|
|
||||||
self.reactor.getHeatedCoolantFilledPercentage()
|
self.reactor.getHeatedCoolantFilledPercentage()
|
||||||
}, self.reactor.__p_is_faulted()
|
}, self.reactor.__p_is_faulted()
|
||||||
end
|
end
|
||||||
@ -273,7 +287,7 @@ function comms_init(id, modem, local_port, server_port, reactor, iss)
|
|||||||
changed = true
|
changed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if changed then
|
if changed and not faulted then
|
||||||
self.status_cache = status
|
self.status_cache = status
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -419,10 +433,12 @@ function comms_init(id, modem, local_port, server_port, reactor, iss)
|
|||||||
|
|
||||||
if trip_time < 0 then
|
if trip_time < 0 then
|
||||||
log._warning("PLC KEEP_ALIVE trip time less than 0 (" .. trip_time .. ")")
|
log._warning("PLC KEEP_ALIVE trip time less than 0 (" .. trip_time .. ")")
|
||||||
elseif trip_time > 1000 then
|
elseif trip_time > 1200 then
|
||||||
log._warning("PLC KEEP_ALIVE trip time > 1s (" .. trip_time .. ")")
|
log._warning("PLC KEEP_ALIVE trip time > 1.2s (" .. trip_time .. ")")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- log._debug("RPLC RTT = ".. trip_time .. "ms")
|
||||||
|
|
||||||
_send_keep_alive_ack(timestamp)
|
_send_keep_alive_ack(timestamp)
|
||||||
elseif packet.type == RPLC_TYPES.LINK_REQ then
|
elseif packet.type == RPLC_TYPES.LINK_REQ then
|
||||||
-- link request confirmation
|
-- link request confirmation
|
||||||
|
@ -12,7 +12,7 @@ os.loadAPI("config.lua")
|
|||||||
os.loadAPI("plc.lua")
|
os.loadAPI("plc.lua")
|
||||||
os.loadAPI("threads.lua")
|
os.loadAPI("threads.lua")
|
||||||
|
|
||||||
local R_PLC_VERSION = "alpha-v0.4.5"
|
local R_PLC_VERSION = "alpha-v0.4.6"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
@ -287,11 +287,6 @@ function thread__iss(smem)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
-- debug
|
|
||||||
-- print(util.time() - last_update)
|
|
||||||
-- println("ms")
|
|
||||||
-- last_update = util.time()
|
|
||||||
|
|
||||||
-- delay before next check, only if >50ms since we did already yield
|
-- delay before next check, only if >50ms since we did already yield
|
||||||
local sleep_for = ISS_SLEEP - (util.time() - last_update)
|
local sleep_for = ISS_SLEEP - (util.time() - last_update)
|
||||||
last_update = util.time()
|
last_update = util.time()
|
||||||
@ -353,7 +348,6 @@ function thread__comms(smem)
|
|||||||
local sleep_for = COMMS_SLEEP - (util.time() - last_update)
|
local sleep_for = COMMS_SLEEP - (util.time() - last_update)
|
||||||
last_update = util.time()
|
last_update = util.time()
|
||||||
if sleep_for >= 50 then
|
if sleep_for >= 50 then
|
||||||
println("sleep for " .. (sleep_for / 1000.0))
|
|
||||||
psleep(sleep_for / 1000.0)
|
psleep(sleep_for / 1000.0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -148,7 +148,6 @@ function thread__comms(smem)
|
|||||||
local sleep_for = COMMS_SLEEP - (util.time() - last_update)
|
local sleep_for = COMMS_SLEEP - (util.time() - last_update)
|
||||||
last_update = util.time()
|
last_update = util.time()
|
||||||
if sleep_for >= 50 then
|
if sleep_for >= 50 then
|
||||||
println("sleep for " .. (sleep_for / 1000.0))
|
|
||||||
psleep(sleep_for / 1000.0)
|
psleep(sleep_for / 1000.0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user