Skip to content
Mikayla edited this page Mar 2, 2023 · 6 revisions

Redstone I/O

This component of the common code wraps basic redstone digital and analog input and output. All the currently supported "channels" are listed below. This, and all the other redstone I/O code, can be found in /scada-common/rsio.lua.

---@enum IO_PORT redstone I/O logic port
local IO_PORT = {
    -- digital inputs --

    -- facility
    F_SCRAM       = 1,  -- active low, facility-wide scram
    F_ACK         = 2,  -- active high, facility alarm acknowledge

    -- reactor
    R_SCRAM       = 3,  -- active low, reactor scram
    R_RESET       = 4,  -- active high, reactor RPS reset
    R_ENABLE      = 5,  -- active high, reactor enable

    -- unit
    U_ACK         = 6,  -- active high, unit alarm acknowledge

    -- digital outputs --

    -- facility
    F_ALARM       = 7,  -- active high, facility alarm (any high priority unit alarm)

    -- 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

    -- 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_DMG_CRIT    = 16, -- active high, if the reactor damage is critical
    R_HIGH_TEMP   = 17, -- active high, if the reactor is at a high temperature
    R_NO_COOLANT  = 18, -- active high, if the reactor has no 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

    -- unit outputs
    U_ALARM       = 24, -- active high, unit alarm
    U_EMER_COOL   = 25  -- active low, emergency coolant control
}

The advantage this component provides is abstracting away the logic levels. For example, checking if an E-Stop is pressed (redstone signal is not present) can be done by checking if the port "is active", rather than having to know that for that particular input, logic LOW is pressed and logic HIGH is unpressed. For an output example, closing a valve is a an active low operation, since applying a redstone valve opens/disconnects a Mekanism redstone-sensitive tube/pipe.

This component also provides scaling functions for analog inputs and outputs, but this project currently doesn't use any analog I/O.

Clone this wiki locally