2022-05-04 17:37:01 +00:00
|
|
|
--
|
2022-05-03 14:44:18 +00:00
|
|
|
-- Global Types
|
2022-05-04 17:37:01 +00:00
|
|
|
--
|
2022-05-03 14:44:18 +00:00
|
|
|
|
2022-05-10 21:06:27 +00:00
|
|
|
---@class types
|
2022-05-04 17:37:01 +00:00
|
|
|
local types = {}
|
|
|
|
|
2022-05-13 13:38:32 +00:00
|
|
|
-- CLASSES --
|
|
|
|
|
2022-05-12 19:37:42 +00:00
|
|
|
---@class tank_fluid
|
2023-02-19 17:20:16 +00:00
|
|
|
---@field name fluid
|
2022-05-13 13:38:32 +00:00
|
|
|
---@field amount integer
|
2022-05-12 19:37:42 +00:00
|
|
|
|
2023-02-14 20:15:34 +00:00
|
|
|
-- create a new tank fluid
|
2023-02-21 15:31:05 +00:00
|
|
|
---@nodiscard
|
2023-02-14 20:15:34 +00:00
|
|
|
---@param n string name
|
|
|
|
---@param a integer amount
|
|
|
|
---@return radiation_reading
|
|
|
|
function types.new_tank_fluid(n, a) return { name = n, amount = a } end
|
|
|
|
|
|
|
|
-- create a new empty tank fluid
|
2023-02-21 15:31:05 +00:00
|
|
|
---@nodiscard
|
2023-02-14 20:15:34 +00:00
|
|
|
---@return tank_fluid
|
|
|
|
function types.new_empty_gas() return { type = "mekanism:empty_gas", amount = 0 } end
|
|
|
|
|
2023-02-14 03:11:31 +00:00
|
|
|
---@class radiation_reading
|
|
|
|
---@field radiation number
|
|
|
|
---@field unit string
|
|
|
|
|
2023-02-14 20:15:34 +00:00
|
|
|
-- create a new radiation reading
|
2023-02-21 15:31:05 +00:00
|
|
|
---@nodiscard
|
2023-02-14 20:15:34 +00:00
|
|
|
---@param r number radiaiton level
|
|
|
|
---@param u string radiation unit
|
|
|
|
---@return radiation_reading
|
|
|
|
function types.new_radiation_reading(r, u) return { radiation = r, unit = u } end
|
|
|
|
|
|
|
|
-- create a new zeroed radiation reading
|
2023-02-21 15:31:05 +00:00
|
|
|
---@nodiscard
|
2023-02-14 20:15:34 +00:00
|
|
|
---@return radiation_reading
|
|
|
|
function types.new_zero_radiation_reading() return { radiation = 0, unit = "nSv" } end
|
|
|
|
|
2023-05-10 00:29:07 +00:00
|
|
|
---@class coordinate_2d
|
|
|
|
---@field x integer
|
|
|
|
---@field y integer
|
|
|
|
|
2022-05-12 19:37:42 +00:00
|
|
|
---@class coordinate
|
2022-05-13 13:38:32 +00:00
|
|
|
---@field x integer
|
|
|
|
---@field y integer
|
|
|
|
---@field z integer
|
|
|
|
|
2023-02-14 20:15:34 +00:00
|
|
|
-- create a new coordinate
|
2023-02-21 15:31:05 +00:00
|
|
|
---@nodiscard
|
2023-02-14 20:15:34 +00:00
|
|
|
---@param x integer
|
|
|
|
---@param y integer
|
|
|
|
---@param z integer
|
|
|
|
---@return coordinate
|
|
|
|
function types.new_coordinate(x, y, z) return { x = x, y = y, z = z } end
|
|
|
|
|
|
|
|
-- create a new zero coordinate
|
2023-02-21 15:31:05 +00:00
|
|
|
---@nodiscard
|
2023-02-14 20:15:34 +00:00
|
|
|
---@return coordinate
|
|
|
|
function types.new_zero_coordinate() return { x = 0, y = 0, z = 0 } end
|
|
|
|
|
2022-05-13 13:38:32 +00:00
|
|
|
---@class rtu_advertisement
|
2023-02-21 16:05:57 +00:00
|
|
|
---@field type RTU_UNIT_TYPE
|
2023-11-06 15:21:42 +00:00
|
|
|
---@field index integer|false
|
2022-05-13 13:38:32 +00:00
|
|
|
---@field reactor integer
|
|
|
|
---@field rsio table|nil
|
|
|
|
|
2022-06-06 03:24:18 +00:00
|
|
|
-- ALIASES --
|
|
|
|
|
|
|
|
---@alias color integer
|
|
|
|
|
2022-05-21 16:24:43 +00:00
|
|
|
-- ENUMERATION TYPES --
|
2023-02-21 15:31:05 +00:00
|
|
|
--#region
|
2022-05-21 16:24:43 +00:00
|
|
|
|
2024-05-27 23:31:24 +00:00
|
|
|
---@enum TEMP_SCALE
|
|
|
|
types.TEMP_SCALE = {
|
|
|
|
KELVIN = 1,
|
|
|
|
CELSIUS = 2,
|
|
|
|
FAHRENHEIT = 3,
|
|
|
|
RANKINE = 4
|
|
|
|
}
|
|
|
|
|
|
|
|
types.TEMP_SCALE_NAMES = {
|
|
|
|
"Kelvin",
|
|
|
|
"Celsius",
|
|
|
|
"Fahrenheit",
|
|
|
|
"Rankine"
|
|
|
|
}
|
|
|
|
|
|
|
|
types.TEMP_SCALE_UNITS = {
|
|
|
|
"K",
|
|
|
|
"\xb0C",
|
|
|
|
"\xb0F",
|
|
|
|
"\xb0R"
|
|
|
|
}
|
|
|
|
|
2023-06-05 21:47:43 +00:00
|
|
|
---@enum PANEL_LINK_STATE
|
|
|
|
types.PANEL_LINK_STATE = {
|
|
|
|
LINKED = 1,
|
|
|
|
DENIED = 2,
|
|
|
|
COLLISION = 3,
|
|
|
|
BAD_VERSION = 4,
|
|
|
|
DISCONNECTED = 5
|
|
|
|
}
|
|
|
|
|
2023-02-21 17:27:16 +00:00
|
|
|
---@enum RTU_UNIT_TYPE
|
|
|
|
types.RTU_UNIT_TYPE = {
|
|
|
|
VIRTUAL = 0, -- virtual device
|
|
|
|
REDSTONE = 1, -- redstone I/O
|
|
|
|
BOILER_VALVE = 2, -- boiler mekanism 10.1+
|
|
|
|
TURBINE_VALVE = 3, -- turbine, mekanism 10.1+
|
2023-07-11 21:27:03 +00:00
|
|
|
DYNAMIC_VALVE = 4, -- dynamic tank, mekanism 10.1+
|
|
|
|
IMATRIX = 5, -- induction matrix
|
|
|
|
SPS = 6, -- SPS
|
|
|
|
SNA = 7, -- SNA
|
|
|
|
ENV_DETECTOR = 8 -- environment detector
|
2023-02-21 17:27:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
types.RTU_UNIT_NAMES = {
|
|
|
|
"redstone",
|
|
|
|
"boiler_valve",
|
|
|
|
"turbine_valve",
|
2023-07-11 21:27:03 +00:00
|
|
|
"dynamic_valve",
|
2023-02-21 17:27:16 +00:00
|
|
|
"induction_matrix",
|
|
|
|
"sps",
|
|
|
|
"sna",
|
|
|
|
"environment_detector"
|
|
|
|
}
|
|
|
|
|
|
|
|
-- safe conversion of RTU UNIT TYPE to string
|
|
|
|
---@nodiscard
|
|
|
|
---@param utype RTU_UNIT_TYPE
|
|
|
|
---@return string
|
|
|
|
function types.rtu_type_to_string(utype)
|
|
|
|
if utype == types.RTU_UNIT_TYPE.VIRTUAL then
|
|
|
|
return "virtual"
|
|
|
|
elseif utype == types.RTU_UNIT_TYPE.REDSTONE or
|
|
|
|
utype == types.RTU_UNIT_TYPE.BOILER_VALVE or
|
|
|
|
utype == types.RTU_UNIT_TYPE.TURBINE_VALVE or
|
2023-07-11 21:27:03 +00:00
|
|
|
utype == types.RTU_UNIT_TYPE.DYNAMIC_VALVE or
|
2023-02-21 17:27:16 +00:00
|
|
|
utype == types.RTU_UNIT_TYPE.IMATRIX or
|
|
|
|
utype == types.RTU_UNIT_TYPE.SPS or
|
|
|
|
utype == types.RTU_UNIT_TYPE.SNA or
|
|
|
|
utype == types.RTU_UNIT_TYPE.ENV_DETECTOR then
|
|
|
|
return types.RTU_UNIT_NAMES[utype]
|
|
|
|
else
|
|
|
|
return ""
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
---@enum TRI_FAIL
|
2022-05-21 16:24:43 +00:00
|
|
|
types.TRI_FAIL = {
|
2023-02-21 17:40:34 +00:00
|
|
|
OK = 1,
|
|
|
|
PARTIAL = 2,
|
|
|
|
FULL = 3
|
2022-05-21 16:24:43 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
---@enum PROCESS
|
2023-01-26 23:26:26 +00:00
|
|
|
types.PROCESS = {
|
2023-02-25 04:59:39 +00:00
|
|
|
INACTIVE = 0,
|
|
|
|
MAX_BURN = 1,
|
|
|
|
BURN_RATE = 2,
|
|
|
|
CHARGE = 3,
|
|
|
|
GEN_RATE = 4,
|
|
|
|
MATRIX_FAULT_IDLE = 5,
|
|
|
|
SYSTEM_ALARM_IDLE = 6,
|
|
|
|
GEN_RATE_FAULT_IDLE = 7
|
2023-02-11 19:27:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
types.PROCESS_NAMES = {
|
|
|
|
"INACTIVE",
|
|
|
|
"MAX_BURN",
|
|
|
|
"BURN_RATE",
|
|
|
|
"CHARGE",
|
|
|
|
"GEN_RATE",
|
|
|
|
"MATRIX_FAULT_IDLE",
|
2023-02-14 20:15:34 +00:00
|
|
|
"SYSTEM_ALARM_IDLE",
|
2023-02-11 19:27:29 +00:00
|
|
|
"GEN_RATE_FAULT_IDLE"
|
2023-01-26 23:26:26 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
---@enum WASTE_MODE
|
2022-12-01 04:31:14 +00:00
|
|
|
types.WASTE_MODE = {
|
|
|
|
AUTO = 1,
|
2023-07-06 05:36:06 +00:00
|
|
|
MANUAL_PLUTONIUM = 2,
|
|
|
|
MANUAL_POLONIUM = 3,
|
|
|
|
MANUAL_ANTI_MATTER = 4
|
2022-12-01 04:31:14 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 17:40:34 +00:00
|
|
|
types.WASTE_MODE_NAMES = {
|
|
|
|
"AUTO",
|
2023-07-06 05:36:06 +00:00
|
|
|
"MANUAL_PLUTONIUM",
|
|
|
|
"MANUAL_POLONIUM",
|
|
|
|
"MANUAL_ANTI_MATTER"
|
|
|
|
}
|
|
|
|
|
|
|
|
---@enum WASTE_PRODUCT
|
|
|
|
types.WASTE_PRODUCT = {
|
|
|
|
PLUTONIUM = 1,
|
|
|
|
POLONIUM = 2,
|
|
|
|
ANTI_MATTER = 3
|
|
|
|
}
|
|
|
|
|
|
|
|
types.WASTE_PRODUCT_NAMES = {
|
2023-02-21 17:40:34 +00:00
|
|
|
"PLUTONIUM",
|
|
|
|
"POLONIUM",
|
|
|
|
"ANTI_MATTER"
|
|
|
|
}
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
---@enum ALARM
|
2022-11-26 21:18:31 +00:00
|
|
|
types.ALARM = {
|
|
|
|
ContainmentBreach = 1,
|
|
|
|
ContainmentRadiation = 2,
|
|
|
|
ReactorLost = 3,
|
|
|
|
CriticalDamage = 4,
|
|
|
|
ReactorDamage = 5,
|
|
|
|
ReactorOverTemp = 6,
|
|
|
|
ReactorHighTemp = 7,
|
|
|
|
ReactorWasteLeak = 8,
|
|
|
|
ReactorHighWaste = 9,
|
|
|
|
RPSTransient = 10,
|
|
|
|
RCSTransient = 11,
|
|
|
|
TurbineTrip = 12
|
|
|
|
}
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
types.ALARM_NAMES = {
|
2022-11-26 21:18:31 +00:00
|
|
|
"ContainmentBreach",
|
|
|
|
"ContainmentRadiation",
|
|
|
|
"ReactorLost",
|
|
|
|
"CriticalDamage",
|
|
|
|
"ReactorDamage",
|
|
|
|
"ReactorOverTemp",
|
|
|
|
"ReactorHighTemp",
|
|
|
|
"ReactorWasteLeak",
|
|
|
|
"ReactorHighWaste",
|
|
|
|
"RPSTransient",
|
|
|
|
"RCSTransient",
|
|
|
|
"TurbineTrip"
|
|
|
|
}
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
---@enum ALARM_PRIORITY
|
2022-11-26 21:18:31 +00:00
|
|
|
types.ALARM_PRIORITY = {
|
2023-02-21 17:40:34 +00:00
|
|
|
CRITICAL = 1,
|
|
|
|
EMERGENCY = 2,
|
|
|
|
URGENT = 3,
|
|
|
|
TIMELY = 4
|
2022-11-26 21:18:31 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
types.ALARM_PRIORITY_NAMES = {
|
2022-11-26 21:18:31 +00:00
|
|
|
"CRITICAL",
|
|
|
|
"EMERGENCY",
|
|
|
|
"URGENT",
|
|
|
|
"TIMELY"
|
|
|
|
}
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
---@enum ALARM_STATE
|
2022-11-26 21:18:31 +00:00
|
|
|
types.ALARM_STATE = {
|
2023-02-21 17:40:34 +00:00
|
|
|
INACTIVE = 1,
|
|
|
|
TRIPPED = 2,
|
|
|
|
ACKED = 3,
|
|
|
|
RING_BACK = 4
|
|
|
|
}
|
|
|
|
|
|
|
|
types.ALARM_STATE_NAMES = {
|
|
|
|
"INACTIVE",
|
|
|
|
"TRIPPED",
|
|
|
|
"ACKED",
|
|
|
|
"RING_BACK"
|
2022-11-26 21:18:31 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
--#endregion
|
|
|
|
|
2022-05-13 13:38:32 +00:00
|
|
|
-- STRING TYPES --
|
2023-02-21 15:31:05 +00:00
|
|
|
--#region
|
2022-05-12 19:37:42 +00:00
|
|
|
|
2023-10-20 03:22:04 +00:00
|
|
|
---@alias side
|
|
|
|
---|"top"
|
|
|
|
---|"bottom"
|
|
|
|
---|"left"
|
|
|
|
---|"right"
|
|
|
|
---|"front"
|
|
|
|
---|"back"
|
|
|
|
|
2022-07-19 19:18:11 +00:00
|
|
|
---@alias os_event
|
|
|
|
---| "alarm"
|
|
|
|
---| "char"
|
|
|
|
---| "computer_command"
|
|
|
|
---| "disk"
|
|
|
|
---| "disk_eject"
|
|
|
|
---| "http_check"
|
|
|
|
---| "http_failure"
|
|
|
|
---| "http_success"
|
|
|
|
---| "key"
|
|
|
|
---| "key_up"
|
|
|
|
---| "modem_message"
|
|
|
|
---| "monitor_resize"
|
|
|
|
---| "monitor_touch"
|
|
|
|
---| "mouse_click"
|
|
|
|
---| "mouse_drag"
|
|
|
|
---| "mouse_scroll"
|
|
|
|
---| "mouse_up"
|
2023-09-23 16:53:05 +00:00
|
|
|
---| "double_click" (custom)
|
2022-07-19 19:18:11 +00:00
|
|
|
---| "paste"
|
|
|
|
---| "peripheral"
|
|
|
|
---| "peripheral_detach"
|
|
|
|
---| "rednet_message"
|
|
|
|
---| "redstone"
|
|
|
|
---| "speaker_audio_empty"
|
|
|
|
---| "task_complete"
|
|
|
|
---| "term_resize"
|
|
|
|
---| "terminate"
|
|
|
|
---| "timer"
|
|
|
|
---| "turtle_inventory"
|
|
|
|
---| "websocket_closed"
|
|
|
|
---| "websocket_failure"
|
|
|
|
---| "websocket_message"
|
|
|
|
---| "websocket_success"
|
2023-09-23 16:53:05 +00:00
|
|
|
---| "clock_start" (custom)
|
2022-09-03 17:10:09 +00:00
|
|
|
|
2023-02-19 17:20:16 +00:00
|
|
|
---@alias fluid
|
|
|
|
---| "mekanism:empty_gas"
|
|
|
|
---| "minecraft:water"
|
|
|
|
---| "mekanism:sodium"
|
|
|
|
---| "mekanism:superheated_sodium"
|
|
|
|
|
2023-02-21 16:32:56 +00:00
|
|
|
types.FLUID = {
|
|
|
|
EMPTY_GAS = "mekanism:empty_gas",
|
|
|
|
WATER = "minecraft:water",
|
|
|
|
SODIUM = "mekanism:sodium",
|
|
|
|
SUPERHEATED_SODIUM = "mekanism:superheated_sodium"
|
2023-02-19 17:20:16 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
---@alias rps_trip_cause
|
|
|
|
---| "ok"
|
2023-03-05 03:32:13 +00:00
|
|
|
---| "high_dmg"
|
2023-02-21 15:31:05 +00:00
|
|
|
---| "high_temp"
|
2023-03-05 03:19:53 +00:00
|
|
|
---| "low_coolant"
|
2023-02-21 16:29:04 +00:00
|
|
|
---| "ex_waste"
|
|
|
|
---| "ex_heated_coolant"
|
2023-02-21 15:31:05 +00:00
|
|
|
---| "no_fuel"
|
|
|
|
---| "fault"
|
|
|
|
---| "timeout"
|
|
|
|
---| "manual"
|
|
|
|
---| "automatic"
|
|
|
|
---| "sys_fail"
|
|
|
|
---| "force_disabled"
|
|
|
|
|
2023-02-21 16:29:04 +00:00
|
|
|
types.RPS_TRIP_CAUSE = {
|
|
|
|
OK = "ok",
|
2023-03-05 03:32:13 +00:00
|
|
|
HIGH_DMG = "high_dmg",
|
2023-02-21 16:29:04 +00:00
|
|
|
HIGH_TEMP = "high_temp",
|
2023-03-05 03:19:53 +00:00
|
|
|
LOW_COOLANT = "low_coolant",
|
2023-02-21 16:29:04 +00:00
|
|
|
EX_WASTE = "ex_waste",
|
|
|
|
EX_HCOOLANT = "ex_heated_coolant",
|
|
|
|
NO_FUEL = "no_fuel",
|
|
|
|
FAULT = "fault",
|
|
|
|
TIMEOUT = "timeout",
|
|
|
|
MANUAL = "manual",
|
|
|
|
AUTOMATIC = "automatic",
|
|
|
|
SYS_FAIL = "sys_fail",
|
|
|
|
FORCE_DISABLED = "force_disabled"
|
2022-05-03 14:44:18 +00:00
|
|
|
}
|
2022-05-03 15:27:40 +00:00
|
|
|
|
2023-07-11 21:27:03 +00:00
|
|
|
---@alias container_mode
|
|
|
|
---| "BOTH"
|
|
|
|
---| "FILL"
|
|
|
|
---| "EMPTY"
|
|
|
|
|
|
|
|
types.CONTAINER_MODE = {
|
|
|
|
BOTH = "BOTH",
|
|
|
|
FILL = "FILL",
|
|
|
|
EMPTY = "EMPTY"
|
|
|
|
}
|
|
|
|
|
2023-02-21 16:30:49 +00:00
|
|
|
---@alias dumping_mode
|
2023-02-21 15:31:05 +00:00
|
|
|
---| "IDLE"
|
|
|
|
---| "DUMPING"
|
|
|
|
---| "DUMPING_EXCESS"
|
|
|
|
|
2022-05-13 13:38:32 +00:00
|
|
|
types.DUMPING_MODE = {
|
|
|
|
IDLE = "IDLE",
|
|
|
|
DUMPING = "DUMPING",
|
|
|
|
DUMPING_EXCESS = "DUMPING_EXCESS"
|
|
|
|
}
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
--#endregion
|
2022-05-03 15:27:40 +00:00
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
-- MODBUS --
|
|
|
|
--#region
|
|
|
|
|
|
|
|
-- MODBUS function codes
|
|
|
|
---@enum MODBUS_FCODE
|
2022-05-04 17:37:01 +00:00
|
|
|
types.MODBUS_FCODE = {
|
2022-05-03 15:27:40 +00:00
|
|
|
READ_COILS = 0x01,
|
|
|
|
READ_DISCRETE_INPUTS = 0x02,
|
|
|
|
READ_MUL_HOLD_REGS = 0x03,
|
|
|
|
READ_INPUT_REGS = 0x04,
|
|
|
|
WRITE_SINGLE_COIL = 0x05,
|
|
|
|
WRITE_SINGLE_HOLD_REG = 0x06,
|
|
|
|
WRITE_MUL_COILS = 0x0F,
|
|
|
|
WRITE_MUL_HOLD_REGS = 0x10,
|
|
|
|
ERROR_FLAG = 0x80
|
|
|
|
}
|
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
-- MODBUS exception codes
|
|
|
|
---@enum MODBUS_EXCODE
|
2022-05-04 17:37:01 +00:00
|
|
|
types.MODBUS_EXCODE = {
|
2023-09-03 21:54:39 +00:00
|
|
|
OK = 0x00,
|
2022-05-03 15:27:40 +00:00
|
|
|
ILLEGAL_FUNCTION = 0x01,
|
|
|
|
ILLEGAL_DATA_ADDR = 0x02,
|
|
|
|
ILLEGAL_DATA_VALUE = 0x03,
|
|
|
|
SERVER_DEVICE_FAIL = 0x04,
|
|
|
|
ACKNOWLEDGE = 0x05,
|
|
|
|
SERVER_DEVICE_BUSY = 0x06,
|
|
|
|
NEG_ACKNOWLEDGE = 0x07,
|
|
|
|
MEMORY_PARITY_ERROR = 0x08,
|
|
|
|
GATEWAY_PATH_UNAVAILABLE = 0x0A,
|
|
|
|
GATEWAY_TARGET_TIMEOUT = 0x0B
|
|
|
|
}
|
2022-05-04 17:37:01 +00:00
|
|
|
|
2023-02-21 15:31:05 +00:00
|
|
|
--#endregion
|
|
|
|
|
2022-05-04 17:37:01 +00:00
|
|
|
return types
|