Go to file
2022-09-18 22:25:59 -04:00
.vscode support for craftos-pc env by supporting modems instead of wireless modems for comms 2022-07-19 14:02:20 -04:00
coordinator changed reactor status message text on main view 2022-09-13 16:08:11 -04:00
graphics graphics elements comments 2022-09-12 15:58:43 -04:00
lockbox #51 crypto system 2022-05-29 15:05:57 -04:00
pocket fixed require issues caused by using bootloader 2022-05-14 13:32:42 -04:00
reactor-plc #74 #86 removed redundant overridden field (use rps_tripped) 2022-09-08 14:49:01 -04:00
rtu fixed acknowledge packets to use error flag, fixed 'static'-like function scope of modbus functions 2022-09-18 22:02:17 -04:00
scada-common #88 hold on rendering unit detail view until we get a status, added waiting animation 2022-09-10 10:42:56 -04:00
supervisor #95 added boiler/turbine RTUs to supervisor, tons of RTU/MODBUS related bugfixes, adjusted annunciator conditions 2022-09-18 22:25:59 -04:00
test #51 crypto system 2022-05-29 15:05:57 -04:00
.gitignore gitignore for notes directory 2022-07-05 12:49:46 -04:00
initenv.lua simplification of initenv file 2022-05-31 16:05:05 -04:00
LICENSE Create LICENSE 2022-04-22 10:05:36 -04:00
README.md added #29 to known issues 2022-05-19 10:49:17 -04:00
startup.lua fixed require issues caused by using bootloader 2022-05-14 13:32:42 -04:00

cc-mek-scada

Configurable ComputerCraft SCADA system for multi-reactor control of Mekanism fission reactors with a GUI, automatic safety features, waste processing control, and more!

This requires CC: Tweaked and Mekanism v10.0+ (10.1 recommended for full feature set).

SCADA

Supervisory control and data acquisition (SCADA) is a control system architecture comprising computers, networked data communications and graphical user interfaces for high-level supervision of machines and processes. It also covers sensors and other devices, such as programmable logic controllers, which interface with process plant or machinery.

This project implements concepts of a SCADA system in ComputerCraft (because why not? ..okay don't answer that). I recommend reviewing that linked wikipedia page on SCADA if you want to understand the concepts used here.

Architecture

SCADA and industrial automation terminology is used throughout the project, such as:

  • Supervisory Computer: Gathers data and controls the process
  • Coordinating Computer: Used as the HMI component, user requests high-level processing operations
  • RTU: Remote Terminal Unit
  • PLC: Programmable Logic Controller

ComputerCraft Architecture

Coordinator Server

There can only be one of these. This server acts as a hybrid of levels 3 & 4 in the SCADA diagram above. In addition to viewing status and controlling processes with advanced monitors, it can host access for one or more Pocket computers.

Supervisory Computers

There should be one of these per facility system. Currently, that means only one. In the future, multiple supervisors would provide the capability of coordinating between multiple facilities (like a fission facility, fusion facility, etc).

RTUs

RTUs are effectively basic connections between a device and the SCADA system with no internal logic providing the system with I/O capabilities. A single Advanced Computer can represent multiple RTUs as instead I am modeling an RTU as the wired modems connected to that computer rather than the computer itself. Each RTU is referenced separately with an identifier in the modbus communications (see Communications section), so a single computer can distribute instructions to multiple devices. This should save on having a pile of computers everywhere (but if you want to have that, no one's stopping you).

The RTU control code is relatively unique, as instead of having instructions be decoded simply, due to using modbus, I implemented a generalized RTU interface. To fulfill this, each type of I/O operation is linked to a function rather than implementing the logic itself. For example, to connect an input register to a turbine getFlowRate() call, the function reference itself is passed to the connect_input_reg() function. A call to read_input_reg() on that register address will call the turbine.getFlowRate() function and return the result.

PLCs

PLCs are advanced devices that allow for both reporting and control to/from the SCADA system in addition to programed behaviors independent of the SCADA system. Currently there is only one type of PLC, and that is the reactor PLC. This is responsible for reporting on and controlling the reactor as a part of the SCADA system, and independently regulating the safety of the reactor. It checks the status for multiple hazard scenarios and shuts down the reactor if any condition is satisfied.

There can and should only be one of these per reactor. A single Advanced Computer will act as the PLC, with either a direct connection (physical contact) or a wired modem connection to the reactor logic port.

Communications

A vaguely-modbus modbus communication protocol is used for communication with RTUs. Useful terminology for you to know:

  • Discrete Inputs: Single Bit Read-Only (digital inputs)
  • Coils: Single Bit Read/Write (digital I/O)
  • Input Registers: Multi-Byte Read-Only (analog inputs)
  • Holding Registers: Multi-Byte Read/Write (analog I/O)

Security and Encryption

TBD, I am planning on AES symmetric encryption for security + HMAC to prevent replay attacks. This will be done utilizing this codebase: https://github.com/somesocks/lua-lockbox.

This is somewhat important here as otherwise anyone can just control your setup, which is undeseriable. Unlike normal Minecraft PVP chaos, it would be very difficult to identify who is messing with your system, as with an Ender Modem they can do it from effectively anywhere and the server operators would have to check every computer's filesystem to find suspicious code.

The only other possible security mitigation for commanding (no effect on monitoring) is to enforce a maximum authorized transmission range (which I will probably also do, or maybe fall back to), as modem message events contain the transmission distance.

Known Issues

GitHub issue #29: It appears that with Mekanism 10.0, a boiler peripheral may rapidly disconnect/reconnect constantly while running. This will prevent that RTU from operating correctly while also filling up the log file. This may be due to a very specific version interaction of CC: Tweaked and Mekansim, so you are welcome to try this on Mekanism 10.0 servers, but do be aware it may not work.