mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#260 added dynamic tank RTU
This commit is contained in:
parent
9f3ad3caf0
commit
a5214730ef
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@ local rtu = require("rtu.rtu")
|
|||||||
|
|
||||||
local boilerv_rtu = {}
|
local boilerv_rtu = {}
|
||||||
|
|
||||||
-- create new boiler (mek 10.1+) device
|
-- create new boiler device
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
---@param boiler table
|
---@param boiler table
|
||||||
---@return rtu_device interface, boolean faulted
|
---@return rtu_device interface, boolean faulted
|
||||||
|
51
rtu/dev/dynamicv_rtu.lua
Normal file
51
rtu/dev/dynamicv_rtu.lua
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
local rtu = require("rtu.rtu")
|
||||||
|
|
||||||
|
local dynamicv_rtu = {}
|
||||||
|
|
||||||
|
-- create new dynamic tank device
|
||||||
|
---@nodiscard
|
||||||
|
---@param dynamic_tank table
|
||||||
|
---@return rtu_device interface, boolean faulted
|
||||||
|
function dynamicv_rtu.new(dynamic_tank)
|
||||||
|
local unit = rtu.init_unit()
|
||||||
|
|
||||||
|
-- disable auto fault clearing
|
||||||
|
dynamic_tank.__p_clear_fault()
|
||||||
|
dynamic_tank.__p_disable_afc()
|
||||||
|
|
||||||
|
-- discrete inputs --
|
||||||
|
unit.connect_di(dynamic_tank.isFormed)
|
||||||
|
|
||||||
|
-- coils --
|
||||||
|
unit.connect_coil(function () dynamic_tank.incrementContainerEditMode() end, function () end)
|
||||||
|
unit.connect_coil(function () dynamic_tank.decrementContainerEditMode() end, function () end)
|
||||||
|
|
||||||
|
-- input registers --
|
||||||
|
-- multiblock properties
|
||||||
|
unit.connect_input_reg(dynamic_tank.getLength)
|
||||||
|
unit.connect_input_reg(dynamic_tank.getWidth)
|
||||||
|
unit.connect_input_reg(dynamic_tank.getHeight)
|
||||||
|
unit.connect_input_reg(dynamic_tank.getMinPos)
|
||||||
|
unit.connect_input_reg(dynamic_tank.getMaxPos)
|
||||||
|
-- build properties
|
||||||
|
unit.connect_input_reg(dynamic_tank.getTankCapacity)
|
||||||
|
unit.connect_input_reg(dynamic_tank.getChemicalTankCapacity)
|
||||||
|
-- current state
|
||||||
|
-- tanks/containers
|
||||||
|
unit.connect_input_reg(dynamic_tank.getInputItem)
|
||||||
|
unit.connect_input_reg(dynamic_tank.getOutputItem)
|
||||||
|
unit.connect_input_reg(dynamic_tank.getStored)
|
||||||
|
unit.connect_input_reg(dynamic_tank.getFilledPercentage)
|
||||||
|
|
||||||
|
-- holding registers --
|
||||||
|
unit.connect_holding_reg(dynamic_tank.getContainerEditMode, dynamic_tank.setContainerEditMode)
|
||||||
|
|
||||||
|
-- check if any calls faulted
|
||||||
|
local faulted = dynamic_tank.__p_is_faulted()
|
||||||
|
dynamic_tank.__p_clear_fault()
|
||||||
|
dynamic_tank.__p_enable_afc()
|
||||||
|
|
||||||
|
return unit.interface(), faulted
|
||||||
|
end
|
||||||
|
|
||||||
|
return dynamicv_rtu
|
@ -2,7 +2,7 @@ local rtu = require("rtu.rtu")
|
|||||||
|
|
||||||
local turbinev_rtu = {}
|
local turbinev_rtu = {}
|
||||||
|
|
||||||
-- create new turbine (mek 10.1+) device
|
-- create new turbine device
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
---@param turbine table
|
---@param turbine table
|
||||||
---@return rtu_device interface, boolean faulted
|
---@return rtu_device interface, boolean faulted
|
||||||
|
@ -26,6 +26,7 @@ local UNIT_TYPE_LABELS = {
|
|||||||
"REDSTONE",
|
"REDSTONE",
|
||||||
"BOILER",
|
"BOILER",
|
||||||
"TURBINE",
|
"TURBINE",
|
||||||
|
"DYNAMIC TANK",
|
||||||
"IND MATRIX",
|
"IND MATRIX",
|
||||||
"SPS",
|
"SPS",
|
||||||
"SNA",
|
"SNA",
|
||||||
|
@ -22,6 +22,7 @@ local rtu = require("rtu.rtu")
|
|||||||
local threads = require("rtu.threads")
|
local threads = require("rtu.threads")
|
||||||
|
|
||||||
local boilerv_rtu = require("rtu.dev.boilerv_rtu")
|
local boilerv_rtu = require("rtu.dev.boilerv_rtu")
|
||||||
|
local dynamicv_rtu = require("rtu.dev.dynamicv_rtu")
|
||||||
local envd_rtu = require("rtu.dev.envd_rtu")
|
local envd_rtu = require("rtu.dev.envd_rtu")
|
||||||
local imatrix_rtu = require("rtu.dev.imatrix_rtu")
|
local imatrix_rtu = require("rtu.dev.imatrix_rtu")
|
||||||
local redstone_rtu = require("rtu.dev.redstone_rtu")
|
local redstone_rtu = require("rtu.dev.redstone_rtu")
|
||||||
@ -29,7 +30,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
|||||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||||
|
|
||||||
local RTU_VERSION = "v1.4.1"
|
local RTU_VERSION = "v1.5.0"
|
||||||
|
|
||||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||||
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
||||||
@ -342,6 +343,18 @@ local function main()
|
|||||||
log.fatal(util.c("configure> failed to check if '", name, "' is a formed turbine multiblock"))
|
log.fatal(util.c("configure> failed to check if '", name, "' is a formed turbine multiblock"))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
elseif type == "dynamicValve" then
|
||||||
|
-- dynamic tank multiblock
|
||||||
|
rtu_type = RTU_UNIT_TYPE.DYNAMIC_VALVE
|
||||||
|
rtu_iface, faulted = dynamicv_rtu.new(device)
|
||||||
|
is_multiblock = true
|
||||||
|
formed = device.isFormed()
|
||||||
|
|
||||||
|
if formed == ppm.UNDEFINED_FIELD or formed == ppm.ACCESS_FAULT then
|
||||||
|
println_ts(util.c("configure> failed to check if '", name, "' is formed"))
|
||||||
|
log.fatal(util.c("configure> failed to check if '", name, "' is a formed dynamic tank multiblock"))
|
||||||
|
return false
|
||||||
|
end
|
||||||
elseif type == "inductionPort" then
|
elseif type == "inductionPort" then
|
||||||
-- induction matrix multiblock
|
-- induction matrix multiblock
|
||||||
rtu_type = RTU_UNIT_TYPE.IMATRIX
|
rtu_type = RTU_UNIT_TYPE.IMATRIX
|
||||||
|
@ -10,6 +10,7 @@ local modbus = require("rtu.modbus")
|
|||||||
local renderer = require("rtu.renderer")
|
local renderer = require("rtu.renderer")
|
||||||
|
|
||||||
local boilerv_rtu = require("rtu.dev.boilerv_rtu")
|
local boilerv_rtu = require("rtu.dev.boilerv_rtu")
|
||||||
|
local dynamicv_rtu = require("rtu.dev.dynamicv_rtu")
|
||||||
local envd_rtu = require("rtu.dev.envd_rtu")
|
local envd_rtu = require("rtu.dev.envd_rtu")
|
||||||
local imatrix_rtu = require("rtu.dev.imatrix_rtu")
|
local imatrix_rtu = require("rtu.dev.imatrix_rtu")
|
||||||
local sna_rtu = require("rtu.dev.sna_rtu")
|
local sna_rtu = require("rtu.dev.sna_rtu")
|
||||||
@ -181,21 +182,22 @@ function threads.thread__main(smem)
|
|||||||
databus.tx_unit_hw_type(unit.uid, unit.type)
|
databus.tx_unit_hw_type(unit.uid, unit.type)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- note for multiblock structures: if not formed, indexing the multiblock functions results in a PPM fault
|
||||||
|
|
||||||
if unit.type == RTU_UNIT_TYPE.BOILER_VALVE then
|
if unit.type == RTU_UNIT_TYPE.BOILER_VALVE then
|
||||||
unit.rtu, faulted = boilerv_rtu.new(device)
|
unit.rtu, faulted = boilerv_rtu.new(device)
|
||||||
-- if not formed, indexing the multiblock functions would have resulted in a PPM fault
|
|
||||||
unit.formed = util.trinary(faulted, false, nil)
|
unit.formed = util.trinary(faulted, false, nil)
|
||||||
elseif unit.type == RTU_UNIT_TYPE.TURBINE_VALVE then
|
elseif unit.type == RTU_UNIT_TYPE.TURBINE_VALVE then
|
||||||
unit.rtu, faulted = turbinev_rtu.new(device)
|
unit.rtu, faulted = turbinev_rtu.new(device)
|
||||||
-- if not formed, indexing the multiblock functions would have resulted in a PPM fault
|
unit.formed = util.trinary(faulted, false, nil)
|
||||||
|
elseif unit.type == RTU_UNIT_TYPE.DYNAMIC_VALVE then
|
||||||
|
unit.rtu, faulted = dynamicv_rtu.new(device)
|
||||||
unit.formed = util.trinary(faulted, false, nil)
|
unit.formed = util.trinary(faulted, false, nil)
|
||||||
elseif unit.type == RTU_UNIT_TYPE.IMATRIX then
|
elseif unit.type == RTU_UNIT_TYPE.IMATRIX then
|
||||||
unit.rtu, faulted = imatrix_rtu.new(device)
|
unit.rtu, faulted = imatrix_rtu.new(device)
|
||||||
-- if not formed, indexing the multiblock functions would have resulted in a PPM fault
|
|
||||||
unit.formed = util.trinary(faulted, false, nil)
|
unit.formed = util.trinary(faulted, false, nil)
|
||||||
elseif unit.type == RTU_UNIT_TYPE.SPS then
|
elseif unit.type == RTU_UNIT_TYPE.SPS then
|
||||||
unit.rtu, faulted = sps_rtu.new(device)
|
unit.rtu, faulted = sps_rtu.new(device)
|
||||||
-- if not formed, indexing the multiblock functions would have resulted in a PPM fault
|
|
||||||
unit.formed = util.trinary(faulted, false, nil)
|
unit.formed = util.trinary(faulted, false, nil)
|
||||||
elseif unit.type == RTU_UNIT_TYPE.SNA then
|
elseif unit.type == RTU_UNIT_TYPE.SNA then
|
||||||
unit.rtu, faulted = sna_rtu.new(device)
|
unit.rtu, faulted = sna_rtu.new(device)
|
||||||
@ -441,6 +443,12 @@ function threads.thread__unit_comms(smem, unit)
|
|||||||
unit.rtu, faulted = turbinev_rtu.new(device)
|
unit.rtu, faulted = turbinev_rtu.new(device)
|
||||||
unit.formed = device.isFormed()
|
unit.formed = device.isFormed()
|
||||||
unit.modbus_io = modbus.new(unit.rtu, true)
|
unit.modbus_io = modbus.new(unit.rtu, true)
|
||||||
|
elseif type == "dynamicValve" and unit.type == RTU_UNIT_TYPE.DYNAMIC_VALVE then
|
||||||
|
-- dynamic tank multiblock
|
||||||
|
unit.device = device
|
||||||
|
unit.rtu, faulted = dynamicv_rtu.new(device)
|
||||||
|
unit.formed = device.isFormed()
|
||||||
|
unit.modbus_io = modbus.new(unit.rtu, true)
|
||||||
elseif type == "inductionPort" and unit.type == RTU_UNIT_TYPE.IMATRIX then
|
elseif type == "inductionPort" and unit.type == RTU_UNIT_TYPE.IMATRIX then
|
||||||
-- induction matrix multiblock
|
-- induction matrix multiblock
|
||||||
unit.device = device
|
unit.device = device
|
||||||
|
@ -14,7 +14,7 @@ local max_distance = nil ---@type number|nil maximum acceptable t
|
|||||||
---@class comms
|
---@class comms
|
||||||
local comms = {}
|
local comms = {}
|
||||||
|
|
||||||
comms.version = "2.1.1"
|
comms.version = "2.1.2"
|
||||||
|
|
||||||
---@enum PROTOCOL
|
---@enum PROTOCOL
|
||||||
local PROTOCOL = {
|
local PROTOCOL = {
|
||||||
|
@ -89,16 +89,18 @@ types.RTU_UNIT_TYPE = {
|
|||||||
REDSTONE = 1, -- redstone I/O
|
REDSTONE = 1, -- redstone I/O
|
||||||
BOILER_VALVE = 2, -- boiler mekanism 10.1+
|
BOILER_VALVE = 2, -- boiler mekanism 10.1+
|
||||||
TURBINE_VALVE = 3, -- turbine, mekanism 10.1+
|
TURBINE_VALVE = 3, -- turbine, mekanism 10.1+
|
||||||
IMATRIX = 4, -- induction matrix
|
DYNAMIC_VALVE = 4, -- dynamic tank, mekanism 10.1+
|
||||||
SPS = 5, -- SPS
|
IMATRIX = 5, -- induction matrix
|
||||||
SNA = 6, -- SNA
|
SPS = 6, -- SPS
|
||||||
ENV_DETECTOR = 7 -- environment detector
|
SNA = 7, -- SNA
|
||||||
|
ENV_DETECTOR = 8 -- environment detector
|
||||||
}
|
}
|
||||||
|
|
||||||
types.RTU_UNIT_NAMES = {
|
types.RTU_UNIT_NAMES = {
|
||||||
"redstone",
|
"redstone",
|
||||||
"boiler_valve",
|
"boiler_valve",
|
||||||
"turbine_valve",
|
"turbine_valve",
|
||||||
|
"dynamic_valve",
|
||||||
"induction_matrix",
|
"induction_matrix",
|
||||||
"sps",
|
"sps",
|
||||||
"sna",
|
"sna",
|
||||||
@ -115,6 +117,7 @@ function types.rtu_type_to_string(utype)
|
|||||||
elseif utype == types.RTU_UNIT_TYPE.REDSTONE or
|
elseif utype == types.RTU_UNIT_TYPE.REDSTONE or
|
||||||
utype == types.RTU_UNIT_TYPE.BOILER_VALVE or
|
utype == types.RTU_UNIT_TYPE.BOILER_VALVE or
|
||||||
utype == types.RTU_UNIT_TYPE.TURBINE_VALVE or
|
utype == types.RTU_UNIT_TYPE.TURBINE_VALVE or
|
||||||
|
utype == types.RTU_UNIT_TYPE.DYNAMIC_VALVE or
|
||||||
utype == types.RTU_UNIT_TYPE.IMATRIX or
|
utype == types.RTU_UNIT_TYPE.IMATRIX or
|
||||||
utype == types.RTU_UNIT_TYPE.SPS or
|
utype == types.RTU_UNIT_TYPE.SPS or
|
||||||
utype == types.RTU_UNIT_TYPE.SNA or
|
utype == types.RTU_UNIT_TYPE.SNA or
|
||||||
@ -328,6 +331,17 @@ types.RPS_TRIP_CAUSE = {
|
|||||||
FORCE_DISABLED = "force_disabled"
|
FORCE_DISABLED = "force_disabled"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---@alias container_mode
|
||||||
|
---| "BOTH"
|
||||||
|
---| "FILL"
|
||||||
|
---| "EMPTY"
|
||||||
|
|
||||||
|
types.CONTAINER_MODE = {
|
||||||
|
BOTH = "BOTH",
|
||||||
|
FILL = "FILL",
|
||||||
|
EMPTY = "EMPTY"
|
||||||
|
}
|
||||||
|
|
||||||
---@alias dumping_mode
|
---@alias dumping_mode
|
||||||
---| "IDLE"
|
---| "IDLE"
|
||||||
---| "DUMPING"
|
---| "DUMPING"
|
||||||
|
Loading…
Reference in New Issue
Block a user