Merge pull request #352 from MikaylaFischler/devel

2023.10.04 Hotfix
This commit is contained in:
Mikayla 2023-10-04 20:03:06 -04:00 committed by GitHub
commit 8b1775b0af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 47 deletions

View File

@ -16,8 +16,8 @@ local max_distance = nil
---@class comms
local comms = {}
-- protocol version (non-protocol changes tracked by util.lua version)
comms.version = "2.4.0"
-- protocol/data version (protocol/data independent changes tracked by util.lua version)
comms.version = "2.4.1"
---@enum PROTOCOL
local PROTOCOL = {

View File

@ -7,9 +7,7 @@ local util = require("scada-common.util")
---@class rsio
local rsio = {}
----------------------
-- RS I/O CONSTANTS --
----------------------
--#region RS I/O Constants
---@enum IO_LVL I/O logic level
local IO_LVL = {
@ -53,30 +51,31 @@ local IO_PORT = {
-- facility
F_ALARM = 7, -- active high, facility-wide alarm (any high priority unit alarm)
F_ALARM_ANY = 8, -- active high, any alarm regardless of priority
-- waste
WASTE_PU = 8, -- active low, waste -> plutonium -> pellets route
WASTE_PO = 9, -- active low, waste -> polonium route
WASTE_POPL = 10, -- active low, polonium -> pellets route
WASTE_AM = 11, -- active low, polonium -> anti-matter route
WASTE_PU = 9, -- active low, waste -> plutonium -> pellets route
WASTE_PO = 10, -- active low, waste -> polonium route
WASTE_POPL = 11, -- active low, polonium -> pellets route
WASTE_AM = 12, -- active low, polonium -> anti-matter route
-- reactor
R_ACTIVE = 12, -- active high, if the reactor is active
R_AUTO_CTRL = 13, -- active high, if the reactor burn rate is automatic
R_SCRAMMED = 14, -- active high, if the reactor is scrammed
R_AUTO_SCRAM = 15, -- active high, if the reactor was automatically scrammed
R_HIGH_DMG = 16, -- active high, if the reactor damage is high
R_HIGH_TEMP = 17, -- active high, if the reactor is at a high temperature
R_LOW_COOLANT = 18, -- active high, if the reactor has very low coolant
R_EXCESS_HC = 19, -- active high, if the reactor has excess heated coolant
R_EXCESS_WS = 20, -- active high, if the reactor has excess waste
R_INSUFF_FUEL = 21, -- active high, if the reactor has insufficent fuel
R_PLC_FAULT = 22, -- active high, if the reactor PLC reports a device access fault
R_PLC_TIMEOUT = 23, -- active high, if the reactor PLC has not been heard from
R_ACTIVE = 13, -- active high, reactor is active
R_AUTO_CTRL = 14, -- active high, reactor burn rate is automatic
R_SCRAMMED = 15, -- active high, reactor is scrammed
R_AUTO_SCRAM = 16, -- active high, reactor was automatically scrammed
R_HIGH_DMG = 17, -- active high, reactor damage is high
R_HIGH_TEMP = 18, -- active high, reactor is at a high temperature
R_LOW_COOLANT = 19, -- active high, reactor has very low coolant
R_EXCESS_HC = 20, -- active high, reactor has excess heated coolant
R_EXCESS_WS = 21, -- active high, reactor has excess waste
R_INSUFF_FUEL = 22, -- active high, reactor has insufficent fuel
R_PLC_FAULT = 23, -- active high, reactor PLC reports a device access fault
R_PLC_TIMEOUT = 24, -- active high, reactor PLC has not been heard from
-- unit outputs
U_ALARM = 24, -- active high, unit alarm
U_EMER_COOL = 25 -- active low, emergency coolant control
U_ALARM = 25, -- active high, unit alarm
U_EMER_COOL = 26 -- active low, emergency coolant control
}
rsio.IO_LVL = IO_LVL
@ -84,9 +83,9 @@ rsio.IO_DIR = IO_DIR
rsio.IO_MODE = IO_MODE
rsio.IO = IO_PORT
-----------------------
-- UTILITY FUNCTIONS --
-----------------------
--#endregion
--#region Utility Functions
-- port to string
---@nodiscard
@ -100,6 +99,7 @@ function rsio.to_string(port)
"R_ENABLE",
"U_ACK",
"F_ALARM",
"F_ALARM_ANY",
"WASTE_PU",
"WASTE_PO",
"WASTE_POPL",
@ -153,6 +153,8 @@ local RS_DIO_MAP = {
-- F_ALARM
{ _in = _I_ACTIVE_HIGH, _out = _O_ACTIVE_HIGH, mode = IO_DIR.OUT },
-- F_ALARM_ANY
{ _in = _I_ACTIVE_HIGH, _out = _O_ACTIVE_HIGH, mode = IO_DIR.OUT },
-- WASTE_PU
{ _in = _I_ACTIVE_LOW, _out = _O_ACTIVE_LOW, mode = IO_DIR.OUT },
@ -207,6 +209,7 @@ function rsio.get_io_mode(port)
IO_MODE.DIGITAL_IN, -- R_ENABLE
IO_MODE.DIGITAL_IN, -- U_ACK
IO_MODE.DIGITAL_OUT, -- F_ALARM
IO_MODE.DIGITAL_OUT, -- F_ALARM_ANY
IO_MODE.DIGITAL_OUT, -- WASTE_PU
IO_MODE.DIGITAL_OUT, -- WASTE_PO
IO_MODE.DIGITAL_OUT, -- WASTE_POPL
@ -234,9 +237,9 @@ function rsio.get_io_mode(port)
end
end
--------------------
-- GENERIC CHECKS --
--------------------
--#endregion
--#region Generic Checks
local RS_SIDES = rs.getSides()
@ -269,9 +272,9 @@ function rsio.is_color(color)
return util.is_int(color) and (color > 0) and (_B_AND(color, (color - 1)) == 0)
end
-----------------
-- DIGITAL I/O --
-----------------
--#endregion
--#region Digital I/O
-- get digital I/O level reading from a redstone boolean input value
---@nodiscard
@ -285,9 +288,7 @@ end
---@nodiscard
---@param level IO_LVL logic level
---@return boolean
function rsio.digital_write(level)
return level == IO_LVL.HIGH
end
function rsio.digital_write(level) return level == IO_LVL.HIGH end
-- returns the level corresponding to active
---@nodiscard
@ -317,9 +318,9 @@ function rsio.digital_is_active(port, level)
end
end
----------------
-- ANALOG I/O --
----------------
--#endregion
--#region Analog I/O
-- read an analog value scaled from min to max
---@nodiscard
@ -343,4 +344,6 @@ function rsio.analog_write(value, min, max)
return math.floor(scaled_value * 15)
end
--#endregion
return rsio

View File

@ -8,7 +8,7 @@ local cc_strings = require("cc.strings")
local util = {}
-- scada-common version
util.version = "1.1.2"
util.version = "1.1.3"
-- ENVIRONMENT CONSTANTS --

View File

@ -746,18 +746,21 @@ function facility.new(num_reactors, cooling_conf)
-- handle facility ack
if self.io_ctl.digital_read(IO.F_ACK) then public.ack_all() end
-- update facility alarm output (check if emergency+ alarms are active)
local has_alarm = false
-- update facility alarm outputs
local has_prio_alarm, has_any_alarm = false, false
for i = 1, #self.units do
local u = self.units[i] ---@type reactor_unit
local u = self.units[i] ---@type reactor_unit
if u.has_alarm_min_prio(PRIO.EMERGENCY) then
has_alarm = true
has_prio_alarm, has_any_alarm = true, true
break
elseif u.has_alarm_min_prio(PRIO.TIMELY) then
has_any_alarm = true
end
end
self.io_ctl.digital_write(IO.F_ALARM, has_alarm)
self.io_ctl.digital_write(IO.F_ALARM, has_prio_alarm)
self.io_ctl.digital_write(IO.F_ALARM_ANY, has_any_alarm)
end
----------------

View File

@ -390,6 +390,15 @@ function plc.new_session(id, s_addr, reactor_id, in_queue, out_queue, timeout, f
cmd = UNIT_COMMAND.START,
ack = ack
})
elseif pkt.type == RPLC_TYPE.RPS_DISABLE then
-- disable acknowledgement
local ack = _get_ack(pkt)
if ack then
self.acks.disable = true
self.sDB.control_state = false
elseif ack == false then
log.debug(log_header .. "disable failed!")
end
elseif pkt.type == RPLC_TYPE.RPS_SCRAM then
-- manual SCRAM acknowledgement
local ack = _get_ack(pkt)
@ -791,7 +800,7 @@ function plc.new_session(id, s_addr, reactor_id, in_queue, out_queue, timeout, f
-- reactor disable request retry
if not self.acks.disable then
if rtimes.disable_req - util.time() <= 0 then
if rtimes.disable_req - util.time() <= 0 then
_send(RPLC_TYPE.RPS_DISABLE, {})
rtimes.disable_req = util.time() + RETRY_PERIOD
end
@ -800,7 +809,7 @@ function plc.new_session(id, s_addr, reactor_id, in_queue, out_queue, timeout, f
-- SCRAM request retry
if not self.acks.scram then
if rtimes.scram_req - util.time() <= 0 then
if rtimes.scram_req - util.time() <= 0 then
_send(RPLC_TYPE.RPS_SCRAM, {})
rtimes.scram_req = util.time() + RETRY_PERIOD
end

View File

@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor")
local svsessions = require("supervisor.session.svsessions")
local SUPERVISOR_VERSION = "v1.0.6"
local SUPERVISOR_VERSION = "v1.0.8"
local println = util.println
local println_ts = util.println_ts