Merge branch 'devel' into 193-pocket-main-application

This commit is contained in:
Mikayla Fischler 2023-04-19 20:37:19 -04:00
commit c49ad63d6a
16 changed files with 77 additions and 37 deletions

View File

@ -0,0 +1,13 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
},
"customizations": {
"vscode": {
"extensions": [
"sumneko.lua",
"jackmacwindows.vscode-computercraft"
]
}
}
}

View File

@ -41,7 +41,7 @@ jobs:
uses: actions/upload-pages-artifact@v1
with:
# Upload shields JSON
path: '.'
path: 'shields/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

View File

@ -22,20 +22,20 @@ There was also an apparent bug with boilers disconnecting and reconnecting when
### Core
![Bootloader](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fshields%2Fbootloader.json)
![Comms](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fshields%2Fcomms.json)
![Bootloader](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fbootloader.json)
![Comms](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fcomms.json)
### Utilities
![Installer](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fshields%2Finstaller.json)
![Installer](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Finstaller.json)
### Applications
![Reactor PLC](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fshields%2Freactor-plc.json)
![RTU](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fshields%2Frtu.json)
![Supervisor](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fshields%2Fsupervisor.json)
![Coordinator](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fshields%2Fcoordinator.json)
![Pocket](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fshields%2Fpocket.json)
![Reactor PLC](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Freactor-plc.json)
![RTU](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Frtu.json)
![Supervisor](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fsupervisor.json)
![Coordinator](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fcoordinator.json)
![Pocket](https://img.shields.io/endpoint?url=https%3A%2F%2Fmikaylafischler.github.io%2Fcc-mek-scada%2Fpocket.json)
## Installation

View File

@ -590,7 +590,7 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, range
elseif packet.type == SCADA_CRDN_TYPE.UNIT_STATUSES then
-- update statuses
if not iocontrol.update_unit_statuses(packet.data) then
log.error("received invalid UNIT_STATUSES packet")
log.debug("received invalid UNIT_STATUSES packet")
end
elseif packet.type == SCADA_CRDN_TYPE.UNIT_CMD then
-- unit command acknowledgement
@ -626,7 +626,7 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, range
log.debug("SCADA_CRDN unit command ack packet length mismatch")
end
else
log.warning("received unknown SCADA_CRDN packet type " .. packet.type)
log.debug("received unknown SCADA_CRDN packet type " .. packet.type)
end
else
log.debug("discarding SCADA_CRDN packet before linked")
@ -681,11 +681,11 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, range
end
elseif est_ack == ESTABLISH_ACK.COLLISION then
if self.last_est_ack ~= est_ack then
log.info("supervisor connection denied due to collision")
log.warning("supervisor connection denied due to collision")
end
elseif est_ack == ESTABLISH_ACK.BAD_VERSION then
if self.last_est_ack ~= est_ack then
log.info("supervisor comms version mismatch")
log.warning("supervisor comms version mismatch")
end
else
log.debug("SCADA_MGMT establish packet reply (len = 1) unsupported")

View File

@ -20,7 +20,7 @@ local sounder = require("coordinator.sounder")
local apisessions = require("coordinator.session.apisessions")
local COORDINATOR_VERSION = "v0.13.1"
local COORDINATOR_VERSION = "v0.13.2"
local println = util.println
local println_ts = util.println_ts

View File

@ -76,7 +76,8 @@ end
-- transmit RPS data across the bus
---@param tripped boolean RPS tripped
---@param status table RPS status
function databus.tx_rps(tripped, status)
---@param emer_cool_active boolean RPS activated the emergency coolant
function databus.tx_rps(tripped, status, emer_cool_active)
dbus_iface.ps.publish("rps_scram", tripped)
dbus_iface.ps.publish("rps_damage", status[1])
dbus_iface.ps.publish("rps_high_temp", status[2])
@ -89,6 +90,7 @@ function databus.tx_rps(tripped, status)
dbus_iface.ps.publish("rps_manual", status[9])
dbus_iface.ps.publish("rps_automatic", status[10])
dbus_iface.ps.publish("rps_sysfail", status[11])
dbus_iface.ps.publish("emer_cool", emer_cool_active)
end
-- link a function to receive data from the bus

View File

@ -4,6 +4,7 @@
local util = require("scada-common.util")
local config = require("reactor-plc.config")
local databus = require("reactor-plc.databus")
local style = require("reactor-plc.panel.style")
@ -35,6 +36,10 @@ local function init(monitor)
local header = TextBox{parent=panel,y=1,text="REACTOR PLC - UNIT ?",alignment=TEXT_ALIGN.CENTER,height=1,fg_bg=style.header}
databus.rx_field("unit_id", function (id) header.set_value(util.c("REACTOR PLC - UNIT ", id)) end)
--
-- system indicators
--
local system = Div{parent=panel,width=14,height=18,x=2,y=3}
local init_ok = LED{parent=system,label="STATUS",colors=cpair(colors.green,colors.red)}
@ -67,6 +72,10 @@ local function init(monitor)
databus.rx_field("routine__comms_rx", rt_cmrx.update)
databus.rx_field("routine__spctl", rt_sctl.update)
--
-- status & controls
--
local status = Div{parent=panel,width=19,height=18,x=17,y=3}
local active = LED{parent=status,x=2,width=12,label="RCT ACTIVE",colors=cpair(colors.green,colors.green_off)}
@ -83,6 +92,16 @@ local function init(monitor)
databus.rx_field("reactor_active", active.update)
databus.rx_field("rps_scram", scram.update)
-- only show emergency coolant LED if emergency coolant is configured for this device
if type(config.EMERGENCY_COOL) == "table" then
local emer_cool = LED{parent=status,x=9,width=14,label="EMER COOLANT",colors=cpair(colors.yellow,colors.yellow_off)}
databus.rx_field("emer_cool", emer_cool.update)
end
--
-- about footer
--
local about = Rectangle{parent=panel,width=32,height=3,x=2,y=16,border=border(1,colors.ivory),thin=true,fg_bg=cpair(colors.black,colors.white)}
local fw_v = TextBox{parent=about,x=2,y=1,text="FW: v00.00.00",alignment=TEXT_ALIGN.LEFT,height=1}
local comms_v = TextBox{parent=about,x=17,y=1,text="NT: v00.00.00",alignment=TEXT_ALIGN.LEFT,height=1}
@ -90,6 +109,10 @@ local function init(monitor)
databus.rx_field("version", function (version) fw_v.set_value(util.c("FW: ", version)) end)
databus.rx_field("comms_version", function (version) comms_v.set_value(util.c("NT: v", version)) end)
--
-- rps list
--
local rps = Rectangle{parent=panel,width=16,height=16,x=36,y=3,border=border(1,colors.lightGray),thin=true,fg_bg=cpair(colors.black,colors.lightGray)}
local rps_man = LED{parent=rps,label="MANUAL",colors=cpair(colors.red,colors.red_off)}
local rps_auto = LED{parent=rps,label="AUTOMATIC",colors=cpair(colors.red,colors.red_off)}

View File

@ -22,7 +22,7 @@ style.header = cpair(colors.black, colors.lightGray)
style.colors = {
{ c = colors.red, hex = 0xdf4949 }, -- RED ON
{ c = colors.orange, hex = 0xffb659 },
{ c = colors.yellow, hex = 0xf9fb53 },
{ c = colors.yellow, hex = 0xf9fb53 }, -- YELLOW ON
{ c = colors.lime, hex = 0x16665a }, -- GREEN OFF
{ c = colors.green, hex = 0x6be551 }, -- GREEN ON
{ c = colors.cyan, hex = 0x34bac8 },

View File

@ -381,7 +381,7 @@ function plc.rps_init(reactor, is_formed, emer_cool)
_set_emer_cool(self.state[state_keys.low_coolant])
-- report RPS status
databus.tx_rps(self.tripped, self.state)
databus.tx_rps(self.tripped, self.state, self.emer_cool_active)
return self.tripped, status, first_trip
end
@ -640,8 +640,6 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
if not reactor.__p_is_faulted() then
_send(RPLC_TYPE.MEK_STRUCT, mek_data)
self.resend_build = false
else
log.error("failed to send structure: PPM fault")
end
end
@ -761,7 +759,7 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
pkt = mgmt_pkt.get()
end
else
log.error("illegal packet type " .. s_pkt.protocol(), true)
log.debug("illegal packet type " .. s_pkt.protocol(), true)
end
end
@ -776,8 +774,10 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
-- print a log message to the terminal as long as the UI isn't running
local function println_ts(message) if not plc_state.fp_ok then util.println_ts(message) end end
local l_port = packet.scada_frame.local_port()
-- handle packets now that we have prints setup
if packet.scada_frame.local_port() == local_port then
if l_port == local_port then
-- check sequence number
if self.r_seq_num == nil then
self.r_seq_num = packet.scada_frame.seq_num()
@ -925,7 +925,7 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
log.debug("RPLC set automatic burn rate packet length mismatch or non-numeric burn rate")
end
else
log.warning("received unknown RPLC packet type " .. packet.type)
log.debug("received unknown RPLC packet type " .. packet.type)
end
else
log.debug("discarding RPLC packet before linked")
@ -947,7 +947,7 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
log.debug("re-sent initial status data")
elseif est_ack == ESTABLISH_ACK.DENY then
println_ts("received unsolicited link denial, unlinking")
log.info("unsolicited establish request denied")
log.warning("unsolicited establish request denied")
elseif est_ack == ESTABLISH_ACK.COLLISION then
println_ts("received unsolicited link collision, unlinking")
log.warning("unsolicited establish request collision")
@ -956,7 +956,7 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
log.warning("unsolicited establish request version mismatch")
else
println_ts("invalid unsolicited link response")
log.error("unsolicited unknown establish request response")
log.debug("unsolicited unknown establish request response")
end
self.linked = est_ack == ESTABLISH_ACK.ALLOW
@ -992,7 +992,7 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
println_ts("server connection closed by remote host")
log.warning("server connection closed by remote host")
else
log.warning("received unsupported SCADA_MGMT packet type " .. packet.type)
log.debug("received unsupported SCADA_MGMT packet type " .. packet.type)
end
elseif packet.type == SCADA_MGMT_TYPE.ESTABLISH then
-- link request confirmation
@ -1042,6 +1042,8 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
-- should be unreachable assuming packet is from parse_packet()
log.error("illegal packet type " .. protocol, true)
end
else
log.debug("received packet on unconfigured channel " .. l_port, true)
end
end

View File

@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc")
local renderer = require("reactor-plc.renderer")
local threads = require("reactor-plc.threads")
local R_PLC_VERSION = "v1.1.5"
local R_PLC_VERSION = "v1.1.8"
local println = util.println
local println_ts = util.println_ts

View File

@ -313,7 +313,7 @@ function rtu.comms(version, modem, local_port, server_port, range, conn_watchdog
pkt = mgmt_pkt.get()
end
else
log.error("illegal packet type " .. s_pkt.protocol(), true)
log.debug("illegal packet type " .. s_pkt.protocol(), true)
end
end
@ -379,7 +379,7 @@ function rtu.comms(version, modem, local_port, server_port, range, conn_watchdog
else
-- unit ID out of range?
reply = modbus.reply__gw_unavailable(packet)
log.error("received MODBUS packet for non-existent unit")
log.debug("received MODBUS packet for non-existent unit")
end
public.send_modbus(reply)
@ -447,7 +447,7 @@ function rtu.comms(version, modem, local_port, server_port, range, conn_watchdog
public.send_advertisement(units)
else
-- not supported
log.warning("received unsupported SCADA_MGMT message type " .. packet.type)
log.debug("received unsupported SCADA_MGMT message type " .. packet.type)
end
else
log.debug("discarding non-link SCADA_MGMT packet before linked")

View File

@ -25,7 +25,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
local sps_rtu = require("rtu.dev.sps_rtu")
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
local RTU_VERSION = "v0.13.3"
local RTU_VERSION = "v0.13.4"
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE

View File

@ -412,7 +412,7 @@ function coordinator.new_session(id, in_queue, out_queue, timeout, facility)
_send(SCADA_CRDN_TYPE.FAC_BUILDS, { facility.get_build(cmd.val.type == RTU_UNIT_TYPE.IMATRIX) })
end
else
log.warning(log_header .. "unsupported data command received in in_queue (this is a bug)")
log.error(log_header .. "unsupported data command received in in_queue (this is a bug)", true)
end
end
end

View File

@ -273,7 +273,7 @@ function plc.new_session(id, reactor_id, in_queue, out_queue, timeout)
if pkt.length == 1 then
return pkt.data[1]
else
log.warning(log_header .. "RPLC ACK length mismatch")
log.debug(log_header .. "RPLC ACK length mismatch")
return nil
end
end
@ -296,7 +296,7 @@ function plc.new_session(id, reactor_id, in_queue, out_queue, timeout)
---@cast pkt rplc_frame
-- check reactor ID
if pkt.id ~= reactor_id then
log.warning(log_header .. "RPLC packet with ID not matching reactor ID: reactor " .. reactor_id .. " != " .. pkt.id)
log.warning(log_header .. "discarding RPLC packet with ID not matching reactor ID: reactor " .. reactor_id .. " != " .. pkt.id)
return
end
@ -635,7 +635,7 @@ function plc.new_session(id, reactor_id, in_queue, out_queue, timeout)
_send(RPLC_TYPE.RPS_AUTO_RESET, {})
end
else
log.warning(log_header .. "unsupported command received in in_queue (this is a bug)")
log.error(log_header .. "unsupported command received in in_queue (this is a bug)", true)
end
elseif message.qtype == mqueue.TYPE.DATA then
-- instruction with body
@ -682,7 +682,7 @@ function plc.new_session(id, reactor_id, in_queue, out_queue, timeout)
end
end
else
log.warning(log_header .. "unsupported data command received in in_queue (this is a bug)")
log.error(log_header .. "unsupported data command received in in_queue (this is a bug)", true)
end
end
end

View File

@ -14,7 +14,7 @@ local supervisor = require("supervisor.supervisor")
local svsessions = require("supervisor.session.svsessions")
local SUPERVISOR_VERSION = "v0.15.1"
local SUPERVISOR_VERSION = "v0.15.2"
local println = util.println
local println_ts = util.println_ts

View File

@ -337,7 +337,7 @@ function supervisor.comms(version, num_reactors, cooling_conf, modem, dev_listen
log.debug("illegal packet type " .. protocol .. " on coordinator listening channel")
end
else
log.warning("received packet on unconfigured channel " .. l_port)
log.debug("received packet on unconfigured channel " .. l_port, true)
end
end
end