From e2f7318922774e32e28f2b45c4737a2631d9bdf4 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 3 May 2022 10:45:35 -0400 Subject: [PATCH] #27 induction matrix RTU split into two RTUs, supporting pre and post Mekansim 10.1 --- rtu/dev/energymachine_rtu.lua | 33 +++++++++++++++++++++++++++++++++ rtu/dev/imatrix_rtu.lua | 9 +++++++++ rtu/startup.lua | 8 ++++++-- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 rtu/dev/energymachine_rtu.lua diff --git a/rtu/dev/energymachine_rtu.lua b/rtu/dev/energymachine_rtu.lua new file mode 100644 index 0000000..b3f004a --- /dev/null +++ b/rtu/dev/energymachine_rtu.lua @@ -0,0 +1,33 @@ +-- #REQUIRES rtu.lua + +function new(machine) + local self = { + rtu = rtu.rtu_init(), + machine = machine + } + + local rtu_interface = function () + return self.rtu + end + + -- discrete inputs -- + -- none + + -- coils -- + -- none + + -- input registers -- + -- build properties + self.rtu.connect_input_reg(self.machine.getTotalMaxEnergy) + -- containers + self.rtu.connect_input_reg(self.machine.getTotalEnergy) + self.rtu.connect_input_reg(self.machine.getTotalEnergyNeeded) + self.rtu.connect_input_reg(self.machine.getTotalEnergyFilledPercentage) + + -- holding registers -- + -- none + + return { + rtu_interface = rtu_interface + } +end diff --git a/rtu/dev/imatrix_rtu.lua b/rtu/dev/imatrix_rtu.lua index 529a1f8..43f49b4 100644 --- a/rtu/dev/imatrix_rtu.lua +++ b/rtu/dev/imatrix_rtu.lua @@ -17,12 +17,21 @@ function new(imatrix) -- none -- input registers -- + -- @todo check these on Mekanism 10.1+ -- build properties + self.rtu.connect_input_reg(self.imatrix.getTransferCap) + self.rtu.connect_input_reg(self.imatrix.getInstalledCells) + self.rtu.connect_input_reg(self.imatrix.getInstalledProviders) self.rtu.connect_input_reg(self.imatrix.getTotalMaxEnergy) -- containers self.rtu.connect_input_reg(self.imatrix.getTotalEnergy) self.rtu.connect_input_reg(self.imatrix.getTotalEnergyNeeded) self.rtu.connect_input_reg(self.imatrix.getTotalEnergyFilledPercentage) + -- additional fields? check these on 10.1 + self.rtu.connect_input_reg(self.imatrix.getInputItem) + self.rtu.connect_input_reg(self.imatrix.getOutputItem) + self.rtu.connect_input_reg(self.imatrix.getLastInput) + self.rtu.connect_input_reg(self.imatrix.getLastOutput) -- holding registers -- -- none diff --git a/rtu/startup.lua b/rtu/startup.lua index 72d1b7e..5f467e4 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -20,7 +20,7 @@ os.loadAPI("dev/boiler_rtu.lua") os.loadAPI("dev/imatrix_rtu.lua") os.loadAPI("dev/turbine_rtu.lua") -local RTU_VERSION = "alpha-v0.4.11" +local RTU_VERSION = "alpha-v0.4.12" local rtu_t = types.rtu_t @@ -178,7 +178,11 @@ for i = 1, #rtu_devices do rtu_type = rtu_t.turbine rtu_iface = turbine_rtu.new(device) elseif type == "mekanismMachine" then - -- assumed to be an induction matrix multiblock + -- assumed to be an induction matrix multiblock, pre Mekanism 10.1 + rtu_type = rtu_t.energy_machine + rtu_iface = energymachine_rtu.new(device) + elseif type == "inductionMatrix" then + -- induction matrix multiblock, post Mekanism 10.1 rtu_type = rtu_t.induction_matrix rtu_iface = imatrix_rtu.new(device) else