From 1d70df0e1780662e2e94d305f772d807c7aa7862 Mon Sep 17 00:00:00 2001 From: sovnya Date: Sat, 7 Oct 2023 14:36:18 +0200 Subject: [PATCH 01/18] feat: Mekanism Bio Generator input adapter look i have no idea if this works, but from eyeballing `methods.csv` and reading lines in ComputerCraft itself I am fairly certain that this might work although i could be wrong because mekanism sucks sometimes. --- .../mekanism/BioGeneratorInputAdapter.lua | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua diff --git a/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua b/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua new file mode 100644 index 0000000..3e0f61b --- /dev/null +++ b/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua @@ -0,0 +1,69 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local BioGeneratorInputAdapter = o.class(InputAdapter) +BioGeneratorInputAdapter.type = 'BioGeneratorInputAdapter' + +function BioGeneratorInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'mekbiogen:' + + -- TODO make these constants + local allCategories = { + 'basic', + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function BioGeneratorInputAdapter:read () + self:boot() + + local source, generator = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'energy', value = mekanismEnergyHelper.joulesToFE(generator.getEnergy()), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = (generator.getEnergyFilledPercentage()), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fuel_capacity', value = generator.getBioFuelCapacity(), unit = "mB", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fuel_amount', value = generator.getBioFuel().amount, unit = "mB", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'fuel_filled_percentage', value = generator.getBioFuelFilledPercentage(), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fuel_needed', value = generator.getBioFuelNeeded(), unit = 'mB/t', source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return BioGeneratorInputAdapter + From f650a571045edb0cc0c695432d1d731c919486a8 Mon Sep 17 00:00:00 2001 From: sovnya Date: Sat, 7 Oct 2023 14:36:55 +0200 Subject: [PATCH 02/18] feat: Mekanism Chemical Tank input adapter not something special really, just the bare minimum to monitor a chemical tank --- .../mekanism/ChemicalTankInputAdapter.lua | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua diff --git a/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua b/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua new file mode 100644 index 0000000..95ed63a --- /dev/null +++ b/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua @@ -0,0 +1,66 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local ChemicalTankInputAdapter = o.class(InputAdapter) +ChemicalTankInputAdapter.type = 'ChemicalTankInputAdapter' + +function ChemicalTankInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'mekchemtank:' + + -- TODO make these constants + local allCategories = { + 'basic', + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function ChemicalTankInputAdapter:read () + self:boot() + + local source, tank = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'capacity', value = tank.getCapacity(), unit = "mB", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'stored', value = tank.getStored().amount, unit = "mB", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'filled_percentage', value = tank.getFilledPercentage(), unit = nil, source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return BioGeneratorInputAdapter + From fab7e55387b171df0fc4682d27fd5385cd8b5885 Mon Sep 17 00:00:00 2001 From: sovnya Date: Sat, 7 Oct 2023 14:39:31 +0200 Subject: [PATCH 03/18] fix: Incorrect return table how the fuck did i miss that.. --- src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua b/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua index 95ed63a..772a0ee 100644 --- a/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua +++ b/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua @@ -62,5 +62,5 @@ function ChemicalTankInputAdapter:read () return metrics end -return BioGeneratorInputAdapter +return ChemicalTankInputAdapter From 5d0d36a0d3e24385020eba7dd22c1bdb42052d50 Mon Sep 17 00:00:00 2001 From: sovnya Date: Sat, 7 Oct 2023 14:45:04 +0200 Subject: [PATCH 04/18] feat: Add production rate to bio generator --- src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua b/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua index 3e0f61b..1a877bf 100644 --- a/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua +++ b/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua @@ -57,6 +57,7 @@ function BioGeneratorInputAdapter:read () metrics:insert(Metric{ name = self.prefix .. 'fuel_amount', value = generator.getBioFuel().amount, unit = "mB", source = source }) -- might error might not, no clue! metrics:insert(Metric{ name = self.prefix .. 'fuel_filled_percentage', value = generator.getBioFuelFilledPercentage(), unit = nil, source = source }) metrics:insert(Metric{ name = self.prefix .. 'fuel_needed', value = generator.getBioFuelNeeded(), unit = 'mB/t', source = source }) + metrics:insert(Metric{ name = self.prefix .. 'production_rate', value = mekanismEnergyHelper.joulesToFE(generator.getProductionRate()), unit = nil, source = source }) end loaded[v] = true From 2c8ea8649f1d0a2bd8cf45e55c7786e8cb210d02 Mon Sep 17 00:00:00 2001 From: sovnya Date: Sat, 7 Oct 2023 14:46:17 +0200 Subject: [PATCH 05/18] feat: Mekanism Gas Generator input adapter --- .../mekanism/GasGeneratorInputAdapter.lua | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua diff --git a/src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua b/src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua new file mode 100644 index 0000000..2e243d5 --- /dev/null +++ b/src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua @@ -0,0 +1,70 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local GasGeneratorInputAdapter = o.class(InputAdapter) +GasGeneratorInputAdapter.type = 'GasGeneratorInputAdapter' + +function GasGeneratorInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'mekgasgen:' + + -- TODO make these constants + local allCategories = { + 'basic', + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function GasGeneratorInputAdapter:read () + self:boot() + + local source, generator = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'energy', value = mekanismEnergyHelper.joulesToFE(generator.getEnergy()), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = (generator.getEnergyFilledPercentage()), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'production_rate', value = mekanismEnergyHelper.joulesToFE(generator.getProductionRate()), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fuel_capacity', value = generator.getFuelCapacity(), unit = "mB", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fuel_amount', value = generator.getFuel().amount, unit = "mB", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'fuel_filled_percentage', value = generator.getFuelFilledPercentage(), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fuel_needed', value = generator.getFuelNeeded(), unit = 'mB/t', source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return GasGeneratorInputAdapter + From daa85e18f617b0d2d58e011ccb547356f632e43a Mon Sep 17 00:00:00 2001 From: sovnya Date: Sat, 7 Oct 2023 15:10:40 +0200 Subject: [PATCH 06/18] feat: Mekanism Digital Miner input adapter poggersss --- .../mekanism/DigitalMinerInputAdapter.lua | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua diff --git a/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua b/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua new file mode 100644 index 0000000..047f137 --- /dev/null +++ b/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua @@ -0,0 +1,67 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local DigitalMinerInputAdapter = o.class(InputAdapter) +DigitalMinerInputAdapter.type = 'DigitalMinerInputAdapter' + +function DigitalMinerInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'mekdigitalminer:' + + -- TODO make these constants + local allCategories = { + 'basic', + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function DigitalMinerInputAdapter:read () + self:boot() + + local source, miner = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'energy', value = mekanismEnergyHelper.joulesToFE(miner.getEnergy()), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = (miner.getEnergyFilledPercentage()), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_usage', value = mekanismEnergyHelper.joulesToFE(miner.getEnergyUsage()), unit = "FE/t", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'get_to_mine', value = miner.getToMine(), unit = "items", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'is_running', value = (miner.isRunning() and 1 or 0), unit = nil, source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return DigitalMinerInputAdapter \ No newline at end of file From cd6f5e59ecc2c8137d80eb66a3bb808384533ad2 Mon Sep 17 00:00:00 2001 From: sovnya Date: Sat, 7 Oct 2023 15:29:51 +0200 Subject: [PATCH 07/18] feat: Mekanism dynamic tank input adapter All complaints go to: https://github.com/SkyTheCodeMaster --- .../mekanism/DynamicTankInputAdapter.lua | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua diff --git a/src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua b/src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua new file mode 100644 index 0000000..aa0a6d7 --- /dev/null +++ b/src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua @@ -0,0 +1,68 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local DynamicTankInputAdapter = o.class(InputAdapter) +DynamicTankInputAdapter.type = 'DynamicTankInputAdapter' + +function DynamicTankInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'mekchemtank:' + + -- TODO make these constants + local allCategories = { + 'basic', + 'chemical' + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function DynamicTankInputAdapter:read () + self:boot() + + local source, tank = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'capacity', value = tank.getTankCapacity(), unit = "mB", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'stored', value = tank.getStored().amount, unit = "mB", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'filled_percentage', value = tank.getFilledPercentage(), unit = nil, source = source }) + elseif v == 'chemical' then -- dunno what this does /shrug + metrics:insert(Metric{ name = self.prefix .. 'chemical_capacity', value = tank.getChemicalTankCapacity(), unit = "mB", source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return DynamicTankInputAdapter \ No newline at end of file From 6d5f1c2d297c7dc0557d0baf0c39548cc5df2196 Mon Sep 17 00:00:00 2001 From: sovnya Date: Sat, 7 Oct 2023 17:50:59 +0200 Subject: [PATCH 08/18] fix: Use B and B/t for gas/chemicals/fluids --- src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua | 6 +++--- src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua | 4 ++-- src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua | 8 ++++---- src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua b/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua index 1a877bf..9e8e89e 100644 --- a/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua +++ b/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua @@ -53,10 +53,10 @@ function BioGeneratorInputAdapter:read () elseif v == 'basic' then metrics:insert(Metric{ name = self.prefix .. 'energy', value = mekanismEnergyHelper.joulesToFE(generator.getEnergy()), unit = "FE", source = source }) metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = (generator.getEnergyFilledPercentage()), unit = nil, source = source }) - metrics:insert(Metric{ name = self.prefix .. 'fuel_capacity', value = generator.getBioFuelCapacity(), unit = "mB", source = source }) - metrics:insert(Metric{ name = self.prefix .. 'fuel_amount', value = generator.getBioFuel().amount, unit = "mB", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'fuel_capacity', value = (generator.getBioFuelCapacity() / 1000), unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fuel_amount', value = (generator.getBioFuel().amount / 1000), unit = "B", source = source }) -- might error might not, no clue! metrics:insert(Metric{ name = self.prefix .. 'fuel_filled_percentage', value = generator.getBioFuelFilledPercentage(), unit = nil, source = source }) - metrics:insert(Metric{ name = self.prefix .. 'fuel_needed', value = generator.getBioFuelNeeded(), unit = 'mB/t', source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fuel_needed', value = (generator.getBioFuelNeeded() / 1000), unit = 'B/t', source = source }) metrics:insert(Metric{ name = self.prefix .. 'production_rate', value = mekanismEnergyHelper.joulesToFE(generator.getProductionRate()), unit = nil, source = source }) end diff --git a/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua b/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua index 772a0ee..9d071be 100644 --- a/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua +++ b/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua @@ -51,8 +51,8 @@ function ChemicalTankInputAdapter:read () -- Literally all we have lmao elseif v == 'basic' then - metrics:insert(Metric{ name = self.prefix .. 'capacity', value = tank.getCapacity(), unit = "mB", source = source }) - metrics:insert(Metric{ name = self.prefix .. 'stored', value = tank.getStored().amount, unit = "mB", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'capacity', value = (tank.getCapacity() / 1000), unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'stored', value = (tank.getStored().amount / 1000), unit = "B", source = source }) -- might error might not, no clue! metrics:insert(Metric{ name = self.prefix .. 'filled_percentage', value = tank.getFilledPercentage(), unit = nil, source = source }) end diff --git a/src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua b/src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua index aa0a6d7..d55a15e 100644 --- a/src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua +++ b/src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua @@ -52,11 +52,11 @@ function DynamicTankInputAdapter:read () -- Literally all we have lmao elseif v == 'basic' then - metrics:insert(Metric{ name = self.prefix .. 'capacity', value = tank.getTankCapacity(), unit = "mB", source = source }) - metrics:insert(Metric{ name = self.prefix .. 'stored', value = tank.getStored().amount, unit = "mB", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'capacity', value = (tank.getTankCapacity() / 1000), unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'stored', value = (tank.getStored().amount / 1000), unit = "B", source = source }) -- might error might not, no clue! metrics:insert(Metric{ name = self.prefix .. 'filled_percentage', value = tank.getFilledPercentage(), unit = nil, source = source }) elseif v == 'chemical' then -- dunno what this does /shrug - metrics:insert(Metric{ name = self.prefix .. 'chemical_capacity', value = tank.getChemicalTankCapacity(), unit = "mB", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'chemical_capacity', value = (tank.getChemicalTankCapacity() / 1000), unit = "B", source = source }) end loaded[v] = true @@ -65,4 +65,4 @@ function DynamicTankInputAdapter:read () return metrics end -return DynamicTankInputAdapter \ No newline at end of file +return DynamicTankInputAdapter diff --git a/src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua b/src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua index 2e243d5..5a53f33 100644 --- a/src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua +++ b/src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua @@ -54,10 +54,10 @@ function GasGeneratorInputAdapter:read () metrics:insert(Metric{ name = self.prefix .. 'energy', value = mekanismEnergyHelper.joulesToFE(generator.getEnergy()), unit = "FE", source = source }) metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = (generator.getEnergyFilledPercentage()), unit = nil, source = source }) metrics:insert(Metric{ name = self.prefix .. 'production_rate', value = mekanismEnergyHelper.joulesToFE(generator.getProductionRate()), unit = nil, source = source }) - metrics:insert(Metric{ name = self.prefix .. 'fuel_capacity', value = generator.getFuelCapacity(), unit = "mB", source = source }) - metrics:insert(Metric{ name = self.prefix .. 'fuel_amount', value = generator.getFuel().amount, unit = "mB", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'fuel_capacity', value = (generator.getFuelCapacity() / 1000), unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fuel_amount', value = (generator.getFuel().amount / 1000), unit = "B", source = source }) -- might error might not, no clue! metrics:insert(Metric{ name = self.prefix .. 'fuel_filled_percentage', value = generator.getFuelFilledPercentage(), unit = nil, source = source }) - metrics:insert(Metric{ name = self.prefix .. 'fuel_needed', value = generator.getFuelNeeded(), unit = 'mB/t', source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fuel_needed', value = (generator.getFuelNeeded() / 1000), unit = 'B/t', source = source }) end loaded[v] = true From e816ede8f109afb7d3c0c870b2fa964040422b8a Mon Sep 17 00:00:00 2001 From: sovnya Date: Sat, 7 Oct 2023 19:16:06 +0200 Subject: [PATCH 09/18] chore: Add new input adapters to input.lua --- src/telem/lib/input.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/telem/lib/input.lua b/src/telem/lib/input.lua index b80329c..07f4699 100644 --- a/src/telem/lib/input.lua +++ b/src/telem/lib/input.lua @@ -12,5 +12,10 @@ return { inductionMatrix = require 'telem.lib.input.mekanism.InductionMatrixInputAdapter', industrialTurbine = require 'telem.lib.input.mekanism.IndustrialTurbineInputAdapter', fusionReactor = require 'telem.lib.input.mekanism.FusionReactorInputAdapter', + chemicalTank = require 'telem.lib.input.mekanism.ChemicalTankInputAdapter', + bioGenerator = require 'telem.lib.input.mekanism.BioGeneratorInputAdapter', + dynamicTank = require 'telem.lib.input.mekanism.DynamicTankInputAdapter', + digitalMiner = require 'telem.lib.input.mekanism.DigitalMinerInputAdapter', + gasGenerator = require 'telem.lib.input.mekanism.GasGeneratorInputAdapter', } -} \ No newline at end of file +} From 7e2a1c0969a420f91f0a577f575fd50503c7c950 Mon Sep 17 00:00:00 2001 From: sovnya Date: Sun, 8 Oct 2023 13:21:02 +0200 Subject: [PATCH 10/18] feat: Add laser and laser amp input adapters --- .../mekanism/LaserAmplifierInputAdapter.lua | 67 +++++++++++++++++++ .../lib/input/mekanism/LaserInputAdapter.lua | 67 +++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 src/telem/lib/input/mekanism/LaserAmplifierInputAdapter.lua create mode 100644 src/telem/lib/input/mekanism/LaserInputAdapter.lua diff --git a/src/telem/lib/input/mekanism/LaserAmplifierInputAdapter.lua b/src/telem/lib/input/mekanism/LaserAmplifierInputAdapter.lua new file mode 100644 index 0000000..af754e5 --- /dev/null +++ b/src/telem/lib/input/mekanism/LaserAmplifierInputAdapter.lua @@ -0,0 +1,67 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local LaserAmplifierInputAdapter = o.class(InputAdapter) +LaserAmplifierInputAdapter.type = 'LaserAmplifierInputAdapter' + +function LaserAmplifierInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'meklaseramp:' + + -- TODO make these constants + local allCategories = { + 'basic', + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function LaserAmplifierInputAdapter:read () + self:boot() + + local source, laser = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'energy', value = laser.getEnergy(), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_max', value = laser.getMaxEnergy(), unit = "FE", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'energy_needed', value = laser.getEnergyNeeded(), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = laser.getEnergyFilledPercentage(), unit = nil, source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return LaserAmplifierInputAdapter + diff --git a/src/telem/lib/input/mekanism/LaserInputAdapter.lua b/src/telem/lib/input/mekanism/LaserInputAdapter.lua new file mode 100644 index 0000000..3536643 --- /dev/null +++ b/src/telem/lib/input/mekanism/LaserInputAdapter.lua @@ -0,0 +1,67 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local LaserInputAdapter = o.class(InputAdapter) +LaserInputAdapter.type = 'LaserInputAdapter' + +function LaserInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'meklaser:' + + -- TODO make these constants + local allCategories = { + 'basic', + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function LaserInputAdapter:read () + self:boot() + + local source, laser = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'energy', value = laser.getEnergy(), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_max', value = laser.getMaxEnergy(), unit = "FE", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'energy_needed', value = laser.getEnergyNeeded(), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = laser.getEnergyFilledPercentage(), unit = nil, source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return LaserInputAdapter + From d8cb736c4a0aaa927e095d2a3fef51b374daa736 Mon Sep 17 00:00:00 2001 From: sovnya Date: Sun, 8 Oct 2023 13:27:01 +0200 Subject: [PATCH 11/18] feat: Add universal cable input adapter This supports all of the types afaik --- .../mekanism/UniversalCableInputAdapter.lua | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/telem/lib/input/mekanism/UniversalCableInputAdapter.lua diff --git a/src/telem/lib/input/mekanism/UniversalCableInputAdapter.lua b/src/telem/lib/input/mekanism/UniversalCableInputAdapter.lua new file mode 100644 index 0000000..52f3b2d --- /dev/null +++ b/src/telem/lib/input/mekanism/UniversalCableInputAdapter.lua @@ -0,0 +1,67 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local UniversalCableInputAdapter = o.class(InputAdapter) +UniversalCableInputAdapter.type = 'UniversalCableInputAdapter' + +function UniversalCableInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'mekunicable:' + + -- TODO make these constants + local allCategories = { + 'basic', + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function UniversalCableInputAdapter:read () + self:boot() + + local source, cable = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'buffer', value = cable.getBuffer(), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_capacity', value = cable.getCapacity(), unit = "FE", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'energy_needed', value = cable.getNeeded(), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = cable.getFilledPercentage(), unit = nil, source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return UniversalCableInputAdapter + From 483bb0bdd90b22647507cf54e8dddc4967a166ec Mon Sep 17 00:00:00 2001 From: sovnya Date: Sun, 8 Oct 2023 13:32:27 +0200 Subject: [PATCH 12/18] feat: Add PressurizedTube input adapter its a direct copy paste of the previous addition --- .../mekanism/PressurizedTubeInputAdapter.lua | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/telem/lib/input/mekanism/PressurizedTubeInputAdapter.lua diff --git a/src/telem/lib/input/mekanism/PressurizedTubeInputAdapter.lua b/src/telem/lib/input/mekanism/PressurizedTubeInputAdapter.lua new file mode 100644 index 0000000..5cd57f7 --- /dev/null +++ b/src/telem/lib/input/mekanism/PressurizedTubeInputAdapter.lua @@ -0,0 +1,67 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local PressurizedTubeInputAdapter = o.class(InputAdapter) +PressurizedTubeInputAdapter.type = 'PressurizedTubeInputAdapter' + +function PressurizedTubeInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'mekpressurizedtube:' + + -- TODO make these constants + local allCategories = { + 'basic', + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function PressurizedTubeInputAdapter:read () + self:boot() + + local source, tube = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'buffer', value = tube.getBuffer() / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'capacity', value = tube.getCapacity() / 1000, unit = "B", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'needed', value = tube.getNeeded() / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'filled_percentage', value = tube.getFilledPercentage(), unit = nil, source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return PressurizedTubeInputAdapter + From 85d70055037106230e3920a2f29e2e72bbb50843 Mon Sep 17 00:00:00 2001 From: sovnya Date: Sun, 8 Oct 2023 13:35:32 +0200 Subject: [PATCH 13/18] feat: Add Mechanical Pipe input adapter these were so easy wtf --- .../mekanism/MechanicalPipeInputAdapter.lua | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/telem/lib/input/mekanism/MechanicalPipeInputAdapter.lua diff --git a/src/telem/lib/input/mekanism/MechanicalPipeInputAdapter.lua b/src/telem/lib/input/mekanism/MechanicalPipeInputAdapter.lua new file mode 100644 index 0000000..94f667d --- /dev/null +++ b/src/telem/lib/input/mekanism/MechanicalPipeInputAdapter.lua @@ -0,0 +1,67 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local MechanicalPipeInputAdapter = o.class(InputAdapter) +MechanicalPipeInputAdapter.type = 'MechanicalPipeInputAdapter' + +function MechanicalPipeInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'mekmechpipe:' + + -- TODO make these constants + local allCategories = { + 'basic', + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function MechanicalPipeInputAdapter:read () + self:boot() + + local source, tube = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'buffer', value = tube.getBuffer() / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'capacity', value = tube.getCapacity() / 1000, unit = "B", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'needed', value = tube.getNeeded() / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'filled_percentage', value = tube.getFilledPercentage(), unit = nil, source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return MechanicalPipeInputAdapter + From a2266b390e9e72e90f515180ffd8b2bf616e89bf Mon Sep 17 00:00:00 2001 From: sovnya Date: Sun, 8 Oct 2023 13:44:28 +0200 Subject: [PATCH 14/18] feat: Add Isotopic Centrifuge input adapter pog --- .../IsotopicCentrifugeInputAdapter.lua | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/telem/lib/input/mekanism/IsotopicCentrifugeInputAdapter.lua diff --git a/src/telem/lib/input/mekanism/IsotopicCentrifugeInputAdapter.lua b/src/telem/lib/input/mekanism/IsotopicCentrifugeInputAdapter.lua new file mode 100644 index 0000000..e5a106e --- /dev/null +++ b/src/telem/lib/input/mekanism/IsotopicCentrifugeInputAdapter.lua @@ -0,0 +1,77 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local IsotopicCentrifugeInputAdapter = o.class(InputAdapter) +IsotopicCentrifugeInputAdapter.type = 'IsotopicCentrifugeInputAdapter' + +function IsotopicCentrifugeInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'mekunicable:' + + -- TODO make these constants + local allCategories = { + 'basic', + 'input', + 'output' + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function IsotopicCentrifugeInputAdapter:read () + self:boot() + + local source, centrifuge = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'energy', value = centrifuge.getEnergy(), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_needed', value = centrifuge.getEnergyNeeded(), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_usage', value = centrifuge.getEnergyUsage(), unit = "FE/t", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = centrifuge.getEnergyFilledPercentage(), unit = nil, source = source }) + elseif v == 'input' then + metrics:insert(Metric{ name = self.prefix .. 'input', value = centrifuge.getInput().amount / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'input_capacity', value = centrifuge.getInputCapacity() / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'input_filled_percentage', value = centrifuge.getInputFilledPercentage(), unit = nil, source = source }) + elseif v == 'output' then + metrics:insert(Metric{ name = self.prefix .. 'output', value = centrifuge.getOutput().amount / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'output_capacity', value = centrifuge.getOutputCapacity() / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'output_filled_percentage', value = centrifuge.getOutputFilledPercentage(), unit = nil, source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return IsotopicCentrifugeInputAdapter + From 04378faa57a2b0c865c7e6ccbbd2fe7ca285f458 Mon Sep 17 00:00:00 2001 From: sovnya Date: Sun, 8 Oct 2023 14:01:15 +0200 Subject: [PATCH 15/18] feat: Add Quantum Entangloporter input adapter oh my god i hate this so much thank god it is over --- .../QuantumEntangloporterInputAdapter.lua | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/telem/lib/input/mekanism/QuantumEntangloporterInputAdapter.lua diff --git a/src/telem/lib/input/mekanism/QuantumEntangloporterInputAdapter.lua b/src/telem/lib/input/mekanism/QuantumEntangloporterInputAdapter.lua new file mode 100644 index 0000000..89853ed --- /dev/null +++ b/src/telem/lib/input/mekanism/QuantumEntangloporterInputAdapter.lua @@ -0,0 +1,103 @@ +local o = require 'telem.lib.ObjectModel' +local t = require 'telem.lib.util' + +local InputAdapter = require 'telem.lib.InputAdapter' +local Metric = require 'telem.lib.Metric' +local MetricCollection = require 'telem.lib.MetricCollection' + +local QuantumEntangloporterInputAdapter = o.class(InputAdapter) +QuantumEntangloporterInputAdapter.type = 'QuantumEntangloporterInputAdapter' + +function QuantumEntangloporterInputAdapter:constructor (peripheralName, categories) + self:super('constructor') + + -- TODO this will be a configurable feature later + self.prefix = 'mekquantumentanglo:' + + -- TODO make these constants + local allCategories = { + 'basic', + 'fluid', + 'gas', + 'infuse', + 'item', + 'pigment', + 'slurry', + 'loss', + } + + if not categories then + self.categories = { 'basic' } + elseif categories == '*' then + self.categories = allCategories + else + self.categories = categories + end + + -- boot components + self:setBoot(function () + self.components = {} + + self:addComponentByPeripheralID(peripheralName) + end)() +end + +function QuantumEntangloporterInputAdapter:read () + self:boot() + + local source, quantum_entangloporter = next(self.components) + + local metrics = MetricCollection() + + local loaded = {} + + for _,v in ipairs(self.categories) do + -- skip, already loaded + if loaded[v] then + -- do nothing + + -- Literally all we have lmao + elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'energy_amount', value = quantum_entangloporter.getEnergy(), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_needed', value = quantum_entangloporter.getEnergyNeeded(), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = quantum_entangloporter.getEnergyFilledPercentage(), unit = nil, source = source }) + elseif v == 'fluid' then + metrics:insert(Metric{ name = self.prefix .. 'fluid_amount', value = quantum_entangloporter.getBufferFluid().amount / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fluid_capacity', value = quantum_entangloporter.getBufferFluidCapacity() / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fluid_filled_percentage', value = quantum_entangloporter.getBufferFluidFilledPercentage(), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'fluid_needed', value = quantum_entangloporter.getBufferFluidNeeded() / 1000, unit = "B", source = source }) + elseif v == 'gas' then + metrics:insert(Metric{ name = self.prefix .. 'gas_amount', value = quantum_entangloporter.getBufferGas().amount / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'gas_capacity', value = quantum_entangloporter.getBufferGasCapacity() / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'gas_filled_percentage', value = quantum_entangloporter.getBufferGasFilledPercentage(), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'gas_needed', value = quantum_entangloporter.getBufferGasNeeded() / 1000, unit = "B", source = source }) + elseif v == 'infuse' then + metrics:insert(Metric{ name = self.prefix .. 'infuse_amount', value = quantum_entangloporter.getBufferInfuse().amount / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'infuse_capacity', value = quantum_entangloporter.getBufferInfuseCapacity() / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'infuse_filled_percentage', value = quantum_entangloporter.getBufferInfuseFilledPercentage(), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'infuse_needed', value = quantum_entangloporter.getBufferInfuseNeeded() / 1000, unit = "B", source = source }) + elseif v == 'item' then + metrics:insert(Metric{ name = self.prefix .. 'item_amount', value = quantum_entangloporter.getBufferItem().count, unit = nil, source = source }) + elseif v == 'pigment' then + metrics:insert(Metric{ name = self.prefix .. 'pigment_amount', value = quantum_entangloporter.getBufferPigment().amount / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'pigment_capacity', value = quantum_entangloporter.getBufferPigmentCapacity() / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'pigment_filled_percentage', value = quantum_entangloporter.getBufferPigmentFilledPercentage(), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'pigment_needed', value = quantum_entangloporter.getBufferPigmentNeeded() / 1000, unit = "B", source = source }) + elseif v == 'slurry' then + metrics:insert(Metric{ name = self.prefix .. 'slurry_amount', value = quantum_entangloporter.getBufferSlurry().amount / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'slurry_capacity', value = quantum_entangloporter.getBufferSlurryCapacity() / 1000, unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'slurry_filled_percentage', value = quantum_entangloporter.getBufferSlurryFilledPercentage(), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'slurry_needed', value = quantum_entangloporter.getBufferSlurryNeeded() / 1000, unit = "B", source = source }) + elseif v == 'loss' then + metrics:insert(Metric{ name = self.prefix .. 'transfer_loss', value = quantum_entangloporter.getTransferLoss(), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'environmental_loss', value = quantum_entangloporter.getEnvironmentalLoss(), unit = nil, source = source }) + end + + loaded[v] = true + end + + return metrics +end + +return QuantumEntangloporterInputAdapter + From 6814f0d031703d0c4c69997a9e64c5bd46dbbc9f Mon Sep 17 00:00:00 2001 From: Autist69420 <56086819+Autist69420@users.noreply.github.com> Date: Tue, 24 Oct 2023 09:59:53 +0000 Subject: [PATCH 16/18] fix: Patch up bio generator to comply with bits requests. --- .../input/mekanism/BioGeneratorInputAdapter.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua b/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua index 9e8e89e..66a4520 100644 --- a/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua +++ b/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua @@ -17,6 +17,8 @@ function BioGeneratorInputAdapter:constructor (peripheralName, categories) -- TODO make these constants local allCategories = { 'basic', + 'fuel', + 'energy' } if not categories then @@ -51,13 +53,15 @@ function BioGeneratorInputAdapter:read () -- Literally all we have lmao elseif v == 'basic' then + metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = (generator.getEnergyFilledPercentage()), unit = "FE", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'bio_fuel_filled_percentage', value = generator.getBioFuelFilledPercentage(), unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'production_rate', value = mekanismEnergyHelper.joulesToFE(generator.getProductionRate()), unit = "FE/t", source = source }) + elseif v == 'energy' then metrics:insert(Metric{ name = self.prefix .. 'energy', value = mekanismEnergyHelper.joulesToFE(generator.getEnergy()), unit = "FE", source = source }) - metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = (generator.getEnergyFilledPercentage()), unit = nil, source = source }) - metrics:insert(Metric{ name = self.prefix .. 'fuel_capacity', value = (generator.getBioFuelCapacity() / 1000), unit = "B", source = source }) - metrics:insert(Metric{ name = self.prefix .. 'fuel_amount', value = (generator.getBioFuel().amount / 1000), unit = "B", source = source }) -- might error might not, no clue! - metrics:insert(Metric{ name = self.prefix .. 'fuel_filled_percentage', value = generator.getBioFuelFilledPercentage(), unit = nil, source = source }) - metrics:insert(Metric{ name = self.prefix .. 'fuel_needed', value = (generator.getBioFuelNeeded() / 1000), unit = 'B/t', source = source }) - metrics:insert(Metric{ name = self.prefix .. 'production_rate', value = mekanismEnergyHelper.joulesToFE(generator.getProductionRate()), unit = nil, source = source }) + elseif v == 'fuel' then + metrics:insert(Metric{ name = self.prefix .. 'bio_fuel_capacity', value = (generator.getBioFuelCapacity() / 1000), unit = "B", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'bio_fuel', value = (generator.getBioFuel().amount / 1000), unit = "B", source = source }) -- might error might not, no clue! + metrics:insert(Metric{ name = self.prefix .. 'bio_fuel_needed', value = (generator.getBioFuelNeeded() / 1000), unit = 'B/t', source = source }) end loaded[v] = true From b243c62b1855dc1cd631c82f683cdf102298e0df Mon Sep 17 00:00:00 2001 From: Autist69420 <56086819+Autist69420@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:04:38 +0000 Subject: [PATCH 17/18] fix: Patch up digital miner input adapter per bits requests --- .../lib/input/mekanism/DigitalMinerInputAdapter.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua b/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua index 047f137..a7e1558 100644 --- a/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua +++ b/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua @@ -17,6 +17,7 @@ function DigitalMinerInputAdapter:constructor (peripheralName, categories) -- TODO make these constants local allCategories = { 'basic', + 'energy' } if not categories then @@ -49,13 +50,14 @@ function DigitalMinerInputAdapter:read () if loaded[v] then -- do nothing - -- Literally all we have lmao + -- TODO: Maybe add `formation`and `advanced` later? elseif v == 'basic' then - metrics:insert(Metric{ name = self.prefix .. 'energy', value = mekanismEnergyHelper.joulesToFE(miner.getEnergy()), unit = "FE", source = source }) metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = (miner.getEnergyFilledPercentage()), unit = nil, source = source }) metrics:insert(Metric{ name = self.prefix .. 'energy_usage', value = mekanismEnergyHelper.joulesToFE(miner.getEnergyUsage()), unit = "FE/t", source = source }) - metrics:insert(Metric{ name = self.prefix .. 'get_to_mine', value = miner.getToMine(), unit = "items", source = source }) - metrics:insert(Metric{ name = self.prefix .. 'is_running', value = (miner.isRunning() and 1 or 0), unit = nil, source = source }) + metrics:insert(Metric{ name = self.prefix .. 'item', value = miner.getToMine(), unit = "items", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'running', value = (miner.isRunning() and 1 or 0), unit = nil, source = source }) + elseif v == 'energy' + metrics:insert(Metric{ name = self.prefix .. 'energy', value = mekanismEnergyHelper.joulesToFE(miner.getEnergy()), unit = "FE", source = source }) end loaded[v] = true From d4e44df48a19598f5d7979fae3085b376fc75172 Mon Sep 17 00:00:00 2001 From: Autist69420 <56086819+Autist69420@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:05:53 +0000 Subject: [PATCH 18/18] fix: Fix up mistake in DigitalMinerInputAdapter --- src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua b/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua index a7e1558..5f5b594 100644 --- a/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua +++ b/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua @@ -54,7 +54,7 @@ function DigitalMinerInputAdapter:read () elseif v == 'basic' then metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = (miner.getEnergyFilledPercentage()), unit = nil, source = source }) metrics:insert(Metric{ name = self.prefix .. 'energy_usage', value = mekanismEnergyHelper.joulesToFE(miner.getEnergyUsage()), unit = "FE/t", source = source }) - metrics:insert(Metric{ name = self.prefix .. 'item', value = miner.getToMine(), unit = "items", source = source }) + metrics:insert(Metric{ name = self.prefix .. 'to_mine', value = miner.getToMine(), unit = "item", source = source }) metrics:insert(Metric{ name = self.prefix .. 'running', value = (miner.isRunning() and 1 or 0), unit = nil, source = source }) elseif v == 'energy' metrics:insert(Metric{ name = self.prefix .. 'energy', value = mekanismEnergyHelper.joulesToFE(miner.getEnergy()), unit = "FE", source = source })