PPM - MikaylaFischler/cc-mek-scada GitHub Wiki
Protected Peripheral Manager
This system operates as an protected abstraction layer to CompterCraft peripherals, including devices such as modems, monitors, and reactors. Peripheral access is protected using Lua's pcall to prevent exceptions from crashing the main application. Such exceptions/errors are treated as "faults" and are reported. Fault states can be checked using automatically generated functions returned as part of a wrapped peripheral.
Logging of reported faults is rate limited by error so that numerous calls don't fill up a log file quickly. Repeated errors are only re-reported every 20 occurrences.
The specific error message from the failed function call can be checked. Automatic fault clearing will clear fault information after a successful function call, or this can be disabled to keep fault occurrence information available until the fault is manually cleared.
The PPM provides a should_terminate()
function that will report if any device had an exception caused by the computer receiving a Terminate interrupt (ctrl + T
in the computer console usually).
Code for this system can be found within the file /scada-common/ppm.lua
.
Virtual Devices
Virtual devices can be "mounted" as placeholder, which are utilized by the RTU application when it can't find devices that it was configured to use. Arbitrary functions on both virtual and non-virtual devices can be called without raising exceptions as the __index
metamethod has been set to handle and log these as a fault as well.