diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts
index 38539a5..9ddd637 100644
--- a/docs/.vitepress/config.mts
+++ b/docs/.vitepress/config.mts
@@ -60,6 +60,9 @@ export default defineConfig({
text: 'Mekanism',
collapsed: true,
items: [
+ { text: 'Antiprotonic Nucleosynthesizer', link: '/reference/input/mekanism/AntiprotonicNucleosynthesizer' },
+ { text: 'Bin', link: '/reference/input/mekanism/Bin' },
+ { text: 'Bio Generator', link: '/reference/input/mekanism/BioGenerator' },
{ text: 'Fission Reactor', link: '/reference/input/mekanism/FissionReactor' },
{ text: 'Fusion Reactor', link: '/reference/input/mekanism/FusionReactor' },
{ text: 'Induction Matrix', link: '/reference/input/mekanism/InductionMatrix' },
diff --git a/docs/assets/mekanism-bin.png b/docs/assets/mekanism-bin.png
new file mode 100644
index 0000000..1f0314e
Binary files /dev/null and b/docs/assets/mekanism-bin.png differ
diff --git a/docs/reference/input/mekanism/AntiprotonicNucleosynthesizer.md b/docs/reference/input/mekanism/AntiprotonicNucleosynthesizer.md
new file mode 100644
index 0000000..f4c842e
--- /dev/null
+++ b/docs/reference/input/mekanism/AntiprotonicNucleosynthesizer.md
@@ -0,0 +1,153 @@
+# Mekanism Antiprotonic Nucleosynthesizer Input
+
+```lua
+telem.input.mekanism.apns (
+ peripheralID: string,
+ categories?: string[] | '*'
+)
+```
+
+::: warning Mod Dependencies
+Requires **Mekanism**.
+:::
+
+See the Usage section for a complete list of the metrics in each category.
+
+
+
+
+List of metric categories to query. The value `"*"` can be used to include all categories, which are listed below.
+
+```lua
+{ "basic", "advanced", "input", "output", "energy", "recipe" }
+```
+
+
+
+## Usage
+
+```lua{4}
+local telem = require 'telem'
+
+local backplane = telem.backplane()
+ :addInput('my_apns', telem.input.mekanism.apns('right', '*'))
+ :cycleEvery(5)()
+```
+
+Given an Antiprotonic Nucleosynthesizer peripheral on the `right` side of the computer, this appends the following metrics to the backplane (grouped by category here for clarity):
+
+### Basic
+
+
+
+### Advanced
+
+
+
+### Input
+
+
+
+### Energy
+
+
+
+### Recipe
+
+
\ No newline at end of file
diff --git a/docs/reference/input/mekanism/Bin.md b/docs/reference/input/mekanism/Bin.md
new file mode 100644
index 0000000..b00e973
--- /dev/null
+++ b/docs/reference/input/mekanism/Bin.md
@@ -0,0 +1,85 @@
+# Mekanism Bin Input
+
+```lua
+telem.input.mekanism.bin (
+ peripheralID: string,
+ categories?: string[] | '*'
+)
+```
+
+::: warning Mod Dependencies
+Requires **Mekanism**.
+:::
+
+See the Usage section for a complete list of the metrics in each category.
+
+
+
+
+List of metric categories to query. The value `"*"` can be used to include all categories, which are listed below.
+
+```lua
+{ "basic" }
+```
+
+
+
+## Usage
+
+```lua{4}
+local telem = require 'telem'
+
+local backplane = telem.backplane()
+ :addInput('my_bin', telem.input.mekanism.bin('right', '*'))
+ :cycleEvery(5)()
+```
+
+Given a Bin peripheral on the `right` side of the computer, this appends the following metrics to the backplane (grouped by category here for clarity):
+
+### Basic
+
+
+
+## Storage
+If the bin contains items, a storage metric is added for the item. Given a bin with the following contents:
+
+![Mekanism Basic Bin with contents](/assets/mekanism-bin.png)
+
+The following metric would be added:
+
+
\ No newline at end of file
diff --git a/docs/reference/input/mekanism/BioGenerator.md b/docs/reference/input/mekanism/BioGenerator.md
new file mode 100644
index 0000000..dae209d
--- /dev/null
+++ b/docs/reference/input/mekanism/BioGenerator.md
@@ -0,0 +1,135 @@
+# Mekanism Bio Generator Input
+
+```lua
+telem.input.mekanism.bioGenerator (
+ peripheralID: string,
+ categories?: string[] | '*'
+)
+```
+
+::: warning Mod Dependencies
+Requires **Mekanism** and **Mekanism Generators**.
+:::
+
+See the Usage section for a complete list of the metrics in each category.
+
+
+
+
+List of metric categories to query. The value `"*"` can be used to include all categories, which are listed below.
+
+```lua
+{ "basic", "advanced", "fuel", "energy" }
+```
+
+
+
+## Usage
+
+```lua{4}
+local telem = require 'telem'
+
+local backplane = telem.backplane()
+ :addInput('my_biogen', telem.input.mekanism.bioGenerator('right', '*'))
+ :cycleEvery(5)()
+```
+
+Given a Bio Generator peripheral on the `right` side of the computer, this appends the following metrics to the backplane (grouped by category here for clarity):
+
+### Basic
+
+
+
+### Advanced
+
+
+
+### Fuel
+
+
+
+### Energy
+
+
\ No newline at end of file
diff --git a/src/telem/init.lua b/src/telem/init.lua
index 9234e9c..111912d 100644
--- a/src/telem/init.lua
+++ b/src/telem/init.lua
@@ -1,9 +1,9 @@
-- Telem by cyberbit
-- MIT License
--- Version 0.7.2
+-- Version 0.8.0
local _Telem = {
- _VERSION = '0.7.1',
+ _VERSION = '0.8.0',
util = require 'telem.lib.util',
input = require 'telem.lib.input',
output = require 'telem.lib.output',
diff --git a/src/telem/lib/input.lua b/src/telem/lib/input.lua
index ca0ecea..1ae8311 100644
--- a/src/telem/lib/input.lua
+++ b/src/telem/lib/input.lua
@@ -1,19 +1,91 @@
+local function requireInput(target) return require ('telem.lib.input.' .. target) end
+local function requireMek(target) return requireInput('mekanism.' .. target) end
+
return {
- helloWorld = require 'telem.lib.input.HelloWorldInputAdapter',
- custom = require 'telem.lib.input.CustomInputAdapter',
+ helloWorld = requireInput('HelloWorldInputAdapter'),
+ custom = requireInput('CustomInputAdapter'),
-- storage
- itemStorage = require 'telem.lib.input.ItemStorageInputAdapter',
- fluidStorage = require 'telem.lib.input.FluidStorageInputAdapter',
- refinedStorage = require 'telem.lib.input.RefinedStorageInputAdapter',
- meStorage = require 'telem.lib.input.MEStorageInputAdapter',
+ itemStorage = requireInput('ItemStorageInputAdapter'),
+ fluidStorage = requireInput('FluidStorageInputAdapter'),
+ refinedStorage = requireInput('RefinedStorageInputAdapter'),
+ meStorage = requireInput('MEStorageInputAdapter'),
- -- machinery
mekanism = {
- fissionReactor = require 'telem.lib.input.mekanism.FissionReactorInputAdapter',
- inductionMatrix = require 'telem.lib.input.mekanism.InductionMatrixInputAdapter',
- industrialTurbine = require 'telem.lib.input.mekanism.IndustrialTurbineInputAdapter',
- fusionReactor = require 'telem.lib.input.mekanism.FusionReactorInputAdapter',
+ -- machines
+ apns = requireMek('AntiprotonicNucleosynthesizerInputAdapter'),
+ bin = requireMek('BinInputAdapter'),
+ bioGenerator = requireMek('BioGeneratorInputAdapter'),
+ boiler = requireMek('ThermoelectricBoilerInputAdapter'),
+ chemicalCrystallizer = requireMek('ChemicalCrystallizerInputAdapter'),
+ dissolutionChamber = requireMek('ChemicalDissolutionChamberInputAdapter'),
+ chemicalInfuser = requireMek('ChemicalInfuserInputAdapter'),
+ injectionChamber = requireMek('ChemicalInjectionChamberInputAdapter'),
+ chemicalOxidizer = requireMek('ChemicalOxidizerInputAdapter'),
+ chemicalTank = requireMek('ChemicalTankInputAdapter'),
+ chemicalWasher = requireMek('ChemicalWasherInputAdapter'),
+ combiner = requireMek('CombinerInputAdapter'),
+ crusher = requireMek('CrusherInputAdapter'),
+ digitalMiner = requireMek('DigitalMinerInputAdapter'),
+ dynamicTank = requireMek('DynamicTankInputAdapter'),
+ electricPump = requireMek('ElectricPumpInputAdapter'),
+ electrolyticSeparator = requireMek('ElectrolyticSeparatorInputAdapter'),
+ energizedSmelter = requireMek('EnergizedSmelterInputAdapter'),
+ energyCube = requireMek('EnergyCubeInputAdapter'),
+ enrichmentChamber = requireMek('EnrichmentChamberInputAdapter'),
+ fissionReactor = requireMek('FissionReactorInputAdapter'),
+ fluidTank = requireMek('FluidTankInputAdapter'),
+ fluidicPlenisher = requireMek('FluidicPlenisherInputAdapter'),
+ assemblicator = requireMek('FormulaicAssemblicatorInputAdapter'),
+ fuelwoodHeater = requireMek('FuelwoodHeaterInputAdapter'),
+ fusionReactor = requireMek('FusionReactorInputAdapter'),
+ gasGenerator = requireMek('GasGeneratorInputAdapter'),
+ heatGenerator = requireMek('HeatGeneratorInputAdapter'),
+ inductionMatrix = requireMek('InductionMatrixInputAdapter'),
+ industrialTurbine = requireMek('IndustrialTurbineInputAdapter'),
+ isotopicCentrifuge = requireMek('IsotopicCentrifugeInputAdapter'),
+ laser = requireMek('LaserInputAdapter'),
+ laserAmplifier = requireMek('LaserAmplifierInputAdapter'),
+ laserTractorBeam = requireMek('LaserTractorBeamInputAdapter'),
+ logisticalSorter = requireMek('LogisticalSorterInputAdapter'),
+ mechanicalPipe = requireMek('MechanicalPipeInputAdapter'),
+ metallurgicInfuser = requireMek('MetallurgicInfuserInputAdapter'),
+ nutritionalLiquifier = requireMek('NutritionalLiquifierInputAdapter'),
+ oredictionificator = requireMek('OredictionificatorInputAdapter'),
+ osmiumCompressor = requireMek('OsmiumCompressorInputAdapter'),
+ paintingMachine = requireMek('PaintingMachineInputAdapter'),
+ pigmentExtractor = requireMek('PigmentExtractorInputAdapter'),
+ pigmentMixer = requireMek('PigmentMixerInputAdapter'),
+ precisionSawmill = requireMek('PrecisionSawmillInputAdapter'),
+ reactionChamber = requireMek('PressurizedReactionChamberInputAdapter'),
+ pressurizedTube = requireMek('PressurizedTubeInputAdapter'),
+ purificationChamber = requireMek('PurificationChamberInputAdapter'),
+ quantumEntangloporter = requireMek('QuantumEntangloporterInputAdapter'),
+ wasteBarrel = requireMek('RadioactiveWasteBarrelInputAdapter'),
+ resistiveHeater = requireMek('ResistiveHeaterInputAdapter'),
+ condensentrator = requireMek('RotaryCondensentratorInputAdapter'),
+ sps = requireMek('SupercriticalPhaseShifterInputAdapter'),
+ seismicVibrator = requireMek('SeismicVibratorInputAdapter'),
+ solarGenerator = requireMek('SolarGeneratorInputAdapter'),
+ neutronActivator = requireMek('SolarNeutronActivatorInputAdapter'),
+ teleporter = requireMek('TeleporterInputAdapter'),
+ evaporationPlant = requireMek('ThermalEvaporationPlantInputAdapter'),
+ universalCable = requireMek('UniversalCableInputAdapter'),
+ windGenerator = requireMek('WindGeneratorInputAdapter'),
+
+ -- factories
+ combiningFactory = requireMek('CombiningFactoryInputAdapter'),
+ compressingFactory = requireMek('CompressingFactoryInputAdapter'),
+ crushingFactory = requireMek('CrushingFactoryInputAdapter'),
+ enrichingFactory = requireMek('EnrichingFactoryInputAdapter'),
+ infusingFactory = requireMek('InfusingFactoryInputAdapter'),
+ injectingFactory = requireMek('InjectingFactoryInputAdapter'),
+ purifyingFactory = requireMek('PurifyingFactoryInputAdapter'),
+ sawingFactory = requireMek('SawingFactoryInputAdapter'),
+ smeltingFactory = requireMek('SmeltingFactoryInputAdapter'),
+
+ -- QIO
+ qioDriveArray = requireMek('QIODriveArrayInputAdapter'),
},
advancedPeripherals = {
@@ -21,5 +93,5 @@ return {
},
-- modem
- secureModem = require 'telem.lib.input.SecureModemInputAdapter'
-}
\ No newline at end of file
+ secureModem = requireInput('SecureModemInputAdapter'),
+}
diff --git a/src/telem/lib/input/mekanism/AntiprotonicNucleosynthesizerInputAdapter.lua b/src/telem/lib/input/mekanism/AntiprotonicNucleosynthesizerInputAdapter.lua
new file mode 100644
index 0000000..683f396
--- /dev/null
+++ b/src/telem/lib/input/mekanism/AntiprotonicNucleosynthesizerInputAdapter.lua
@@ -0,0 +1,31 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local AntiprotonicNucleosynthesizerInputAdapter = base.mintAdapter('AntiprotonicNucleosynthesizerInputAdapter')
+
+function AntiprotonicNucleosynthesizerInputAdapter:beforeRegister ()
+ self.prefix = 'mekapns:'
+
+ self.queries = {
+ basic = {
+ input_chemical_filled_percentage = fn():call('getInputChemicalFilledPercentage'),
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ input_chemical = fn():call('getInputChemical'):get('amount'):div(1000):fluid(),
+ input_chemical_capacity = fn():call('getInputChemicalCapacity'):div(1000):fluid(),
+ input_chemical_needed = fn():call('getInputChemicalNeeded'):div(1000):fluid(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return AntiprotonicNucleosynthesizerInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/BaseMekanismInputAdapter.lua b/src/telem/lib/input/mekanism/BaseMekanismInputAdapter.lua
index 0057ef3..b24fa0c 100644
--- a/src/telem/lib/input/mekanism/BaseMekanismInputAdapter.lua
+++ b/src/telem/lib/input/mekanism/BaseMekanismInputAdapter.lua
@@ -1,5 +1,7 @@
local o = require 'telem.lib.ObjectModel'
local t = require 'telem.lib.util'
+local fl = require 'telem.vendor'.fluent
+local fn = fl.fn
local InputAdapter = require 'telem.lib.InputAdapter'
local Metric = require 'telem.lib.Metric'
@@ -8,19 +10,134 @@ local MetricCollection = require 'telem.lib.MetricCollection'
local BaseMekanismInputAdapter = o.class(InputAdapter)
BaseMekanismInputAdapter.type = 'BaseMekanismInputAdapter'
-function BaseMekanismInputAdapter:constructor (peripheralName)
+function BaseMekanismInputAdapter:constructor (peripheralName, categories)
self:super('constructor')
self.prefix = 'mek:'
+ self.categories = categories or { 'basic' }
+
+ ---@type table>
self.queries = {}
+ ---@type cyberbit.Fluent[]
+ self.storageQueries = {}
+
-- boot components
self:setBoot(function ()
self.components = {}
self:addComponentByPeripheralID(peripheralName)
end)()
+
+ self:beforeRegister()
+
+ self:register()
+end
+
+function BaseMekanismInputAdapter:beforeRegister ()
+ -- nothing by default, should be overridden by subclasses
+end
+
+function BaseMekanismInputAdapter:register ()
+ local allCategories = fl(self.queries):keys():result()
+
+ if self.categories == '*' then
+ self.categories = allCategories
+ elseif type(self.categories) == 'table' then
+ self.categories = fl(self.categories):intersect(allCategories):result()
+ else
+ error('categories must be a list of categories or "*"')
+ end
+
+ return self
+end
+
+function BaseMekanismInputAdapter:getFactorySize ()
+ local _, component = next(self.components)
+
+ return fn()
+ :from({ 9, 7, 5, 3 })
+ :first(function (_, v)
+ return component and pcall(component.getRecipeProgress, v - 1)
+ end)
+ :result()
+end
+
+--- Adds queries for multiblock structures.
+---
+--- Categories: formation
+function BaseMekanismInputAdapter:withMultiblockQueries ()
+ self.queries.formation = self.queries.formation or {}
+
+ -- multiblock
+ self.queries.formation.formed = fn():call('isFormed'):toFlag()
+
+ -- multiblock (formed)
+ self.queries.formation.height = fn():call('getHeight'):with('unit', 'm')
+ self.queries.formation.length = fn():call('getLength'):with('unit', 'm')
+ self.queries.formation.width = fn():call('getWidth'):with('unit', 'm')
+
+ return self
+end
+
+--- Adds queries for generic machines.
+---
+--- Categories: basic, advanced, energy
+function BaseMekanismInputAdapter:withGenericMachineQueries ()
+ self.queries.basic = self.queries.basic or {}
+ self.queries.advanced = self.queries.advanced or {}
+ self.queries.energy = self.queries.energy or {}
+
+ self.queries.basic.energy_filled_percentage = fn():call('getEnergyFilledPercentage')
+
+ self.queries.advanced.comparator_level = fn():call('getComparatorLevel')
+
+ self.queries.energy.energy = fn():call('getEnergy'):joulesToFE():energy()
+ self.queries.energy.max_energy = fn():call('getMaxEnergy'):joulesToFE():energy()
+ self.queries.energy.energy_needed = fn():call('getEnergyNeeded'):joulesToFE():energy()
+
+ -- getDirection
+ -- getRedstoneMode
+
+ return self
+end
+
+--- Adds queries for generators.
+---
+--- Categories: basic, energy
+function BaseMekanismInputAdapter:withGeneratorQueries ()
+ self.queries.basic = self.queries.basic or {}
+ self.queries.energy = self.queries.energy or {}
+
+ self.queries.basic.production_rate = fn():call('getProductionRate'):joulesToFE():energyRate()
+
+ self.queries.energy.max_energy_output = fn():call('getMaxOutput'):joulesToFE():energyRate()
+
+ return self
+end
+
+--- Adds queries for machines with recipes. If `factorySize` is provided,
+--- each process will have its own recipe progress metric.
+---
+--- Categories: recipe
+---@param factorySize? integer Factory size
+function BaseMekanismInputAdapter:withRecipeProgressQueries (factorySize)
+ self.queries.recipe = self.queries.recipe or {}
+
+ self.queries.recipe.ticks_required = fn():call('getTicksRequired'):with('unit', 't')
+
+ if not factorySize then
+ self.queries.recipe.recipe_progress = fn():call('getRecipeProgress'):with('unit', 't')
+ else
+ assert(type(factorySize) == 'number', 'factorySize must be a number')
+
+ for i = 0, factorySize - 1 do
+ self.queries.recipe['recipe_progress_' .. i] = fn():call('getRecipeProgress', i):with('unit', 't')
+ end
+ end
+
+ return self
end
local function queueHelper (results, index, query)
@@ -37,6 +154,7 @@ function BaseMekanismInputAdapter:read ()
local tempMetrics = {}
local queue = {}
+ -- execute single-metric queries from a queue
for _, category in ipairs(self.categories) do
for k, v in pairs(self.queries[category]) do
table.insert(queue, queueHelper(
@@ -49,7 +167,85 @@ function BaseMekanismInputAdapter:read ()
parallel.waitForAll(table.unpack(queue))
+ -- execute storage queries, which may return multiple metrics
+ -- these have no category and are always included
+ for k, v in pairs(self.storageQueries) do
+ local tempResult = v:from(component):result()
+
+ for _, metric in ipairs(tempResult) do
+ metric.name = 'storage:' .. metric.name
+ metric.source = source
+
+ table.insert(tempMetrics, metric)
+ end
+ end
+
return MetricCollection(table.unpack(tempMetrics))
end
+------ Static Methods ------
+
+function BaseMekanismInputAdapter.mintAdapter (type)
+ local adapter = o.class(BaseMekanismInputAdapter)
+ adapter.type = type
+
+ function adapter:constructor (peripheralName, categories)
+ self:super('constructor', peripheralName, categories)
+ end
+
+ return adapter
+end
+
+function BaseMekanismInputAdapter.mintSlotUsageQuery (getSlotsMethodName, getSlotItemMethodName)
+ local function processSlot(method, slots, component, slot)
+ return function ()
+ slots[slot] = component[method](slot) or false
+ end
+ end
+
+ return fn()
+ :transform(function (v)
+ local slots = {}
+
+ local queue = {}
+ for i = 0, v[getSlotsMethodName]() - 1 do
+ table.insert(queue, processSlot(getSlotItemMethodName, slots, v, i))
+ end
+
+ parallel.waitForAll(table.unpack(queue))
+
+ return slots
+ end)
+ :reduce(function (initial, _, v)
+ if v and v.count and tonumber(v.count) > 0 then
+ return initial + 1
+ else
+ return initial
+ end
+ end, 0)
+end
+
+function BaseMekanismInputAdapter.mintSlotCountQuery (slotCount, getSlotItemMethodName)
+ local function processSlot(method, slots, component, slot)
+ return function ()
+ slots[slot] = component[method](slot) or false
+ end
+ end
+
+ return fn()
+ :transform(function (v)
+ local slots = {}
+
+ local queue = {}
+ for i = 0, slotCount - 1 do
+ table.insert(queue, processSlot(getSlotItemMethodName, slots, v, i))
+ end
+
+ parallel.waitForAll(table.unpack(queue))
+
+ return slots
+ end)
+ :sum('count')
+end
+
return BaseMekanismInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/BinInputAdapter.lua b/src/telem/lib/input/mekanism/BinInputAdapter.lua
new file mode 100644
index 0000000..4bb88e2
--- /dev/null
+++ b/src/telem/lib/input/mekanism/BinInputAdapter.lua
@@ -0,0 +1,35 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+local Metric = require 'telem.lib.Metric'
+
+local BinInputAdapter = base.mintAdapter('BinInputAdapter')
+
+function BinInputAdapter:beforeRegister ()
+ self.prefix = 'mekbin:'
+
+ self.queries = {
+ basic = {
+ stored = fn():call('getStored'):get('count'):with('unit', 'item'),
+ capacity = fn():call('getCapacity'):with('unit', 'item'),
+ },
+ }
+
+ self.storageQueries = {
+ fn():call('getStored'):transform(function (v)
+ if v.count == 0 then
+ return {}
+ end
+
+ return { Metric{ name = v.name, value = v.count, unit = 'item' } }
+ end)
+ }
+
+ -- getComparatorLevel
+ -- getDirection
+
+ -- TODO only supports comparator and direction
+ -- self:withGenericMachineQueries()
+end
+
+return BinInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua b/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua
new file mode 100644
index 0000000..045cf04
--- /dev/null
+++ b/src/telem/lib/input/mekanism/BioGeneratorInputAdapter.lua
@@ -0,0 +1,26 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local BioGeneratorInputAdapter = base.mintAdapter('BioGeneratorInputAdapter')
+
+function BioGeneratorInputAdapter:beforeRegister ()
+ self.prefix = 'mekbiogen:'
+
+ self.queries = {
+ basic = {
+ bio_fuel_filled_percentage = fn():call('getBioFuelFilledPercentage'),
+ bio_fuel_item_count = fn():call('getFuelItem'):get('count'):with('unit', 'item'),
+ },
+ fuel = {
+ bio_fuel = fn():call('getBioFuel'):get('amount'):div(1000):fluid(),
+ bio_fuel_capacity = fn():call('getBioFuelCapacity'):div(1000):fluid(),
+ bio_fuel_needed = fn():call('getBioFuelNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withGeneratorQueries()
+end
+
+return BioGeneratorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ChemicalCrystallizerInputAdapter.lua b/src/telem/lib/input/mekanism/ChemicalCrystallizerInputAdapter.lua
new file mode 100644
index 0000000..f7f3494
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ChemicalCrystallizerInputAdapter.lua
@@ -0,0 +1,33 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ChemicalCrystallizerInputAdapter = base.mintAdapter('ChemicalCrystallizerInputAdapter')
+
+function ChemicalCrystallizerInputAdapter:beforeRegister ()
+ self.prefix = 'mekcrystallizer:'
+
+ self.queries = {
+ basic = {
+ input_filled_percentage = fn():call('getInputFilledPercentage'),
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ input = fn():call('getInput'):get('amount'):div(1000):fluid(),
+ input_capacity = fn():call('getInputCapacity'):div(1000):fluid(),
+ input_needed = fn():call('getInputNeeded'):div(1000):fluid(),
+ },
+ output = {
+ output_count = fn():call('getOutput'):get('count'):with('unit', 'item'),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return ChemicalCrystallizerInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ChemicalDissolutionChamberInputAdapter.lua b/src/telem/lib/input/mekanism/ChemicalDissolutionChamberInputAdapter.lua
new file mode 100644
index 0000000..1adb2f1
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ChemicalDissolutionChamberInputAdapter.lua
@@ -0,0 +1,38 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ChemicalDissolutionChamberInputAdapter = base.mintAdapter('ChemicalDissolutionChamberInputAdapter')
+
+function ChemicalDissolutionChamberInputAdapter:beforeRegister ()
+ self.prefix = 'mekdissolution:'
+
+ self.queries = {
+ basic = {
+ input_gas_filled_percentage = fn():call('getGasInputFilledPercentage'),
+ input_gas_item_count = fn():call('getInputGasItem'):get('count'):with('unit', 'item'),
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ output_filled_percentage = fn():call('getOutputFilledPercentage'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ input_gas = fn():call('getGasInput'):get('amount'):div(1000):fluid(),
+ input_gas_capacity = fn():call('getGasInputCapacity'):div(1000):fluid(),
+ input_gas_needed = fn():call('getGasInputNeeded'):div(1000):fluid(),
+ },
+ output = {
+ output = fn():call('getOutput'):get('amount'):div(1000):fluid(),
+ output_capacity = fn():call('getOutputCapacity'):div(1000):fluid(),
+ output_needed = fn():call('getOutputNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return ChemicalDissolutionChamberInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ChemicalInfuserInputAdapter.lua b/src/telem/lib/input/mekanism/ChemicalInfuserInputAdapter.lua
new file mode 100644
index 0000000..ad30735
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ChemicalInfuserInputAdapter.lua
@@ -0,0 +1,41 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ChemicalInfuserInputAdapter = base.mintAdapter('ChemicalInfuserInputAdapter')
+
+function ChemicalInfuserInputAdapter:beforeRegister ()
+ self.prefix = 'mekcheminfuse:'
+
+ self.queries = {
+ basic = {
+ input_left_item_count = fn():call('getLeftInputItem'):get('count'):with('unit', 'item'),
+ input_left_filled_percentage = fn():call('getLeftInputFilledPercentage'),
+ input_right_filled_percentage = fn():call('getRightInputFilledPercentage'),
+ input_right_item_count = fn():call('getRightInputItem'):get('count'):with('unit', 'item'),
+ output_filled_percentage = fn():call('getOutputFilledPercentage'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ input_left = fn():call('getLeftInput'):get('amount'):div(1000):fluid(),
+ input_left_capacity = fn():call('getLeftInputCapacity'):div(1000):fluid(),
+ input_left_needed = fn():call('getLeftInputNeeded'):div(1000):fluid(),
+ input_right = fn():call('getRightInput'):get('amount'):div(1000):fluid(),
+ input_right_capacity = fn():call('getRightInputCapacity'):div(1000):fluid(),
+ input_right_needed = fn():call('getRightInputNeeded'):div(1000):fluid(),
+ },
+ output = {
+ output = fn():call('getOutput'):get('amount'):div(1000):fluid(),
+ output_capacity = fn():call('getOutputCapacity'):div(1000):fluid(),
+ output_needed = fn():call('getOutputNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return ChemicalInfuserInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ChemicalInjectionChamberInputAdapter.lua b/src/telem/lib/input/mekanism/ChemicalInjectionChamberInputAdapter.lua
new file mode 100644
index 0000000..ac355c4
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ChemicalInjectionChamberInputAdapter.lua
@@ -0,0 +1,32 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ChemicalInjectionChamberInputAdapter = base.mintAdapter('ChemicalInjectionChamberInputAdapter')
+
+function ChemicalInjectionChamberInputAdapter:beforeRegister ()
+ self.prefix = 'mekinject:'
+
+ self.queries = {
+ basic = {
+ chemical_filled_percentage = fn():call('getChemicalFilledPercentage'),
+ input_count = fn():call('getInput'):get('count'):with('unit', 'item'),
+ chemical_item_count = fn():call('getChemicalItem'):get('count'):with('unit', 'item'),
+ output_count = fn():call('getOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ chemical = fn():call('getChemical'):get('amount'):div(1000):fluid(),
+ chemical_capacity = fn():call('getChemicalCapacity'):div(1000):fluid(),
+ chemical_needed = fn():call('getChemicalNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return ChemicalInjectionChamberInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ChemicalOxidizerInputAdapter.lua b/src/telem/lib/input/mekanism/ChemicalOxidizerInputAdapter.lua
new file mode 100644
index 0000000..ff7a380
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ChemicalOxidizerInputAdapter.lua
@@ -0,0 +1,31 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ChemicalOxidizerInputAdapter = base.mintAdapter('ChemicalOxidizerInputAdapter')
+
+function ChemicalOxidizerInputAdapter:beforeRegister ()
+ self.prefix = 'mekoxidizer:'
+
+ self.queries = {
+ basic = {
+ input_count = fn():call('getInput'):get('count'):with('unit', 'item'),
+ output_filled_percentage = fn():call('getOutputFilledPercentage'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ output = {
+ output = fn():call('getOutput'):get('amount'):div(1000):fluid(),
+ output_capacity = fn():call('getOutputCapacity'):div(1000):fluid(),
+ output_needed = fn():call('getOutputNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return ChemicalOxidizerInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua b/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua
new file mode 100644
index 0000000..476026f
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ChemicalTankInputAdapter.lua
@@ -0,0 +1,40 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+local Metric = require 'telem.lib.Metric'
+
+local ChemicalTankInputAdapter = base.mintAdapter('ChemicalTankInputAdapter')
+
+function ChemicalTankInputAdapter:beforeRegister ()
+ self.prefix = 'mekchemtank:'
+
+ self.queries = {
+ basic = {
+ fill_item_count = fn():call('getFillItem'):get('count'):with('unit', 'item'),
+ filled_percentage = fn():call('getFilledPercentage'),
+ drain_item_count = fn():call('getDrainItem'):get('count'):with('unit', 'item'),
+ },
+ advanced = {
+ dumping_mode = fn():call('getDumpingMode'):toLookup({ IDLE = 1, DUMPING_EXCESS = 2, DUMPING = 3 }),
+ },
+ storage = {
+ stored = fn():call('getStored'):get('amount'):div(1000):fluid(),
+ capacity = fn():call('getCapacity'):div(1000):fluid(),
+ needed = fn():call('getNeeded'):div(1000):fluid(),
+ },
+ }
+
+ self.storageQueries = {
+ fn():call('getStored'):transform(function (v)
+ return { Metric{ name = v.name, value = v.amount / 1000, unit = 'B' } }
+ end)
+ }
+
+ -- getComparatorLevel
+ -- getRedstoneMode
+
+ -- TODO does not support energy
+ -- self:withGenericMachineQueries()
+end
+
+return ChemicalTankInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ChemicalWasherInputAdapter.lua b/src/telem/lib/input/mekanism/ChemicalWasherInputAdapter.lua
new file mode 100644
index 0000000..6ce8e52
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ChemicalWasherInputAdapter.lua
@@ -0,0 +1,40 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ChemicalWasherInputAdapter = base.mintAdapter('ChemicalWasherInputAdapter')
+
+function ChemicalWasherInputAdapter:beforeRegister ()
+ self.prefix = 'mekwasher:'
+
+ self.queries = {
+ basic = {
+ fluid_filled_percentage = fn():call('getFluidFilledPercentage'),
+ input_slurry_filled_percentage = fn():call('getSlurryInputFilledPercentage'),
+ output_slurry_filled_percentage = fn():call('getSlurryOutputFilledPercentage'),
+ input_fluid_item_count = fn():call('getFluidItemInput'):get('count'):with('unit', 'item'),
+ output_fluid_item_count = fn():call('getFluidItemOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ fluid = fn():call('getFluid'):get('amount'):div(1000):fluid(),
+ fluid_capacity = fn():call('getFluidCapacity'):div(1000):fluid(),
+ fluid_needed = fn():call('getFluidNeeded'):div(1000):fluid(),
+ input_slurry = fn():call('getSlurryInput'):get('amount'):div(1000):fluid(),
+ input_slurry_capacity = fn():call('getSlurryInputCapacity'):div(1000):fluid(),
+ input_slurry_needed = fn():call('getSlurryInputNeeded'):div(1000):fluid(),
+ },
+ output = {
+ output_slurry = fn():call('getSlurryOutput'):get('amount'):div(1000):fluid(),
+ output_slurry_capacity = fn():call('getSlurryOutputCapacity'):div(1000):fluid(),
+ output_slurry_needed = fn():call('getSlurryOutputNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return ChemicalWasherInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/CombinerInputAdapter.lua b/src/telem/lib/input/mekanism/CombinerInputAdapter.lua
new file mode 100644
index 0000000..de3f0cf
--- /dev/null
+++ b/src/telem/lib/input/mekanism/CombinerInputAdapter.lua
@@ -0,0 +1,26 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local CombinerInputAdapter = base.mintAdapter('CombinerInputAdapter')
+
+function CombinerInputAdapter:beforeRegister ()
+ self.prefix = 'mekcombine:'
+
+ self.queries = {
+ basic = {
+ input_main_count = fn():call('getMainInput'):get('count'):with('unit', 'item'),
+ input_secondary_count = fn():call('getSecondaryInput'):get('count'):with('unit', 'item'),
+ output_count = fn():call('getOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return CombinerInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/CombiningFactoryInputAdapter.lua b/src/telem/lib/input/mekanism/CombiningFactoryInputAdapter.lua
new file mode 100644
index 0000000..01a1045
--- /dev/null
+++ b/src/telem/lib/input/mekanism/CombiningFactoryInputAdapter.lua
@@ -0,0 +1,31 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local CombiningFactoryInputAdapter = base.mintAdapter('CombiningFactoryInputAdapter')
+
+function CombiningFactoryInputAdapter:beforeRegister ()
+ self.prefix = 'mekcombine:'
+
+ local factorySize = self:getFactorySize()
+
+ self.queries = {
+ basic = {
+ input_main_count_sum = base.mintSlotCountQuery(factorySize, 'getInput'):with('unit', 'item'),
+ input_secondary_count = fn():call('getSecondaryInput'):get('count'):with('unit', 'item'),
+ output_count_sum = base.mintSlotCountQuery(factorySize, 'getOutput'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ advanced = {
+ auto_sort = fn():call('isAutoSortEnabled'):toFlag(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries(factorySize)
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return CombiningFactoryInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/CompressingFactoryInputAdapter.lua b/src/telem/lib/input/mekanism/CompressingFactoryInputAdapter.lua
new file mode 100644
index 0000000..01bd17e
--- /dev/null
+++ b/src/telem/lib/input/mekanism/CompressingFactoryInputAdapter.lua
@@ -0,0 +1,37 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local CompressingFactoryInputAdapter = base.mintAdapter('CompressingFactoryInputAdapter')
+
+function CompressingFactoryInputAdapter:beforeRegister ()
+ self.prefix = 'mekcompress:'
+
+ local factorySize = self:getFactorySize()
+
+ self.queries = {
+ basic = {
+ chemical_item_count = fn():call('getChemicalItem'):get('count'):with('unit', 'item'),
+ chemical_filled_percentage = fn():call('getChemicalFilledPercentage'),
+ input_count_sum = base.mintSlotCountQuery(factorySize, 'getInput'):with('unit', 'item'),
+ output_count_sum = base.mintSlotCountQuery(factorySize, 'getOutput'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ advanced = {
+ auto_sort = fn():call('isAutoSortEnabled'):toFlag(),
+ },
+ input = {
+ chemical = fn():call('getChemical'):get('amount'):div(1000):fluid(),
+ chemical_capacity = fn():call('getChemicalCapacity'):div(1000):fluid(),
+ chemical_needed = fn():call('getChemicalNeeded'):div(1000):fluid(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries(factorySize)
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return CompressingFactoryInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/CrusherInputAdapter.lua b/src/telem/lib/input/mekanism/CrusherInputAdapter.lua
new file mode 100644
index 0000000..084e0a4
--- /dev/null
+++ b/src/telem/lib/input/mekanism/CrusherInputAdapter.lua
@@ -0,0 +1,25 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local CrusherInputAdapter = base.mintAdapter('CrusherInputAdapter')
+
+function CrusherInputAdapter:beforeRegister ()
+ self.prefix = 'mekcrush:'
+
+ self.queries = {
+ basic = {
+ input_count = fn():call('getInput'):get('count'):with('unit', 'item'),
+ output_count = fn():call('getOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return CrusherInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/CrushingFactoryInputAdapter.lua b/src/telem/lib/input/mekanism/CrushingFactoryInputAdapter.lua
new file mode 100644
index 0000000..d9ac545
--- /dev/null
+++ b/src/telem/lib/input/mekanism/CrushingFactoryInputAdapter.lua
@@ -0,0 +1,30 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local CrushingFactoryInputAdapter = base.mintAdapter('CrushingFactoryInputAdapter')
+
+function CrushingFactoryInputAdapter:beforeRegister ()
+ self.prefix = 'mekcrush:'
+
+ local factorySize = self:getFactorySize()
+
+ self.queries = {
+ basic = {
+ input_count_sum = base.mintSlotCountQuery(factorySize, 'getInput'):with('unit', 'item'),
+ output_count_sum = base.mintSlotCountQuery(factorySize, 'getOutput'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ advanced = {
+ auto_sort = fn():call('isAutoSortEnabled'):toFlag(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries(factorySize)
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return CrushingFactoryInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua b/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua
new file mode 100644
index 0000000..648c434
--- /dev/null
+++ b/src/telem/lib/input/mekanism/DigitalMinerInputAdapter.lua
@@ -0,0 +1,35 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local DigitalMinerInputAdapter = base.mintAdapter('DigitalMinerInputAdapter')
+
+function DigitalMinerInputAdapter:beforeRegister ()
+ self.prefix = 'mekminer:'
+
+ self.queries = {
+ basic = {
+ running = fn():call('isRunning'):toFlag(),
+ slot_count = fn():call('getSlotCount'),
+ state = fn():call('getState'):toLookup({ FINISHED = 1, IDLE = 2, PAUSED = 3, SEARCHING = 4 }),
+ to_mine = fn():call('getToMine'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ slot_usage = base.mintSlotUsageQuery('getSlotCount', 'getItemInSlot'),
+ },
+ advanced = {
+ auto_eject = fn():call('getAutoEject'):toFlag(),
+ auto_pull = fn():call('getAutoPull'):toFlag(),
+ inverse_mode = fn():call('getInverseMode'):toFlag(),
+ inverse_mode_requires_replacement = fn():call('getInverseModeRequiresReplacement'):toFlag(),
+ max_radius = fn():call('getMaxRadius'):with('unit', 'm'),
+ max_y = fn():call('getMaxY'),
+ min_y = fn():call('getMinY'),
+ radius = fn():call('getRadius'):with('unit', 'm'),
+ silk_touch = fn():call('getSilkTouch'):toFlag(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+end
+
+return DigitalMinerInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua b/src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua
new file mode 100644
index 0000000..a56f0d2
--- /dev/null
+++ b/src/telem/lib/input/mekanism/DynamicTankInputAdapter.lua
@@ -0,0 +1,38 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+local Metric = require 'telem.lib.Metric'
+
+local DynamicTankInputAdapter = base.mintAdapter('DynamicTankInputAdapter')
+
+function DynamicTankInputAdapter:beforeRegister ()
+ self.prefix = 'mekdyntank:'
+
+ self.queries = {
+ basic = {
+ filled_percentage = fn():call('getFilledPercentage'),
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ },
+ storage = {
+ stored = fn():call('getStored'):get('amount'):div(1000):fluid(),
+ fluid_capacity = fn():call('getTankCapacity'):div(1000):fluid(),
+ chemical_capacity = fn():call('getChemicalTankCapacity'):div(1000):fluid(),
+ },
+ }
+
+ self.storageQueries = {
+ fn():call('getStored'):transform(function (v)
+ return { Metric{ name = v.name, value = v.amount / 1000, unit = 'B' } }
+ end)
+ }
+
+ self:withMultiblockQueries()
+
+ -- getComparatorLevel
+
+ -- TODO only supports comparator
+ -- self:withGenericMachineQueries()
+end
+
+return DynamicTankInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ElectricPumpInputAdapter.lua b/src/telem/lib/input/mekanism/ElectricPumpInputAdapter.lua
new file mode 100644
index 0000000..f450cd5
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ElectricPumpInputAdapter.lua
@@ -0,0 +1,32 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ElectricPumpInputAdapter = base.mintAdapter('ElectricPumpInputAdapter')
+
+function ElectricPumpInputAdapter:beforeRegister ()
+ self.prefix = 'mekpump:'
+
+ self.queries = {
+ basic = {
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ fluid_filled_percentage = fn():call('getFluidFilledPercentage'),
+
+ -- TODO: does not support energy usage? need to verify
+ -- energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ output = {
+ fluid = fn():call('getFluid'):get('amount'):div(1000):fluid(),
+ fluid_capacity = fn():call('getFluidCapacity'):div(1000):fluid(),
+ fluid_needed = fn():call('getFluidNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return ElectricPumpInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ElectrolyticSeparatorInputAdapter.lua b/src/telem/lib/input/mekanism/ElectrolyticSeparatorInputAdapter.lua
new file mode 100644
index 0000000..cb720b9
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ElectrolyticSeparatorInputAdapter.lua
@@ -0,0 +1,41 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ElectrolyticSeparatorInputAdapter = base.mintAdapter('ElectrolyticSeparatorInputAdapter')
+
+function ElectrolyticSeparatorInputAdapter:beforeRegister ()
+ self.prefix = 'mekseparator:'
+
+ self.queries = {
+ basic = {
+ input_filled_percentage = fn():call('getInputFilledPercentage'),
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ output_left_filled_percentage = fn():call('getLeftOutputFilledPercentage'),
+ output_left_item_count = fn():call('getLeftOutputItem'):get('count'):with('unit', 'item'),
+ output_right_filled_percentage = fn():call('getRightOutputFilledPercentage'),
+ output_right_item_count = fn():call('getRightOutputItem'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ input = fn():call('getInput'):get('amount'):div(1000):fluid(),
+ input_capacity = fn():call('getInputCapacity'):div(1000):fluid(),
+ input_needed = fn():call('getInputNeeded'):div(1000):fluid(),
+ },
+ output = {
+ output_left = fn():call('getLeftOutput'):get('amount'):div(1000):fluid(),
+ output_left_capacity = fn():call('getLeftOutputCapacity'):div(1000):fluid(),
+ output_left_needed = fn():call('getLeftOutputNeeded'):div(1000):fluid(),
+ output_right = fn():call('getRightOutput'):get('amount'):div(1000):fluid(),
+ output_right_capacity = fn():call('getRightOutputCapacity'):div(1000):fluid(),
+ output_right_needed = fn():call('getRightOutputNeeded'):div(1000):fluid(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return ElectrolyticSeparatorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/EnergizedSmelterInputAdapter.lua b/src/telem/lib/input/mekanism/EnergizedSmelterInputAdapter.lua
new file mode 100644
index 0000000..2b8b169
--- /dev/null
+++ b/src/telem/lib/input/mekanism/EnergizedSmelterInputAdapter.lua
@@ -0,0 +1,25 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local EnergizedSmelterInputAdapter = base.mintAdapter('EnergizedSmelterInputAdapter')
+
+function EnergizedSmelterInputAdapter:beforeRegister ()
+ self.prefix = 'meksmelt:'
+
+ self.queries = {
+ basic = {
+ input_count = fn():call('getInput'):get('count'):with('unit', 'item'),
+ output_count = fn():call('getOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return EnergizedSmelterInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/EnergyCubeInputAdapter.lua b/src/telem/lib/input/mekanism/EnergyCubeInputAdapter.lua
new file mode 100644
index 0000000..3e07407
--- /dev/null
+++ b/src/telem/lib/input/mekanism/EnergyCubeInputAdapter.lua
@@ -0,0 +1,23 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local EnergyCubeInputAdapter = base.mintAdapter('EnergyCubeInputAdapter')
+
+function EnergyCubeInputAdapter:beforeRegister ()
+ self.prefix = 'mekenergycube:'
+
+ self.queries = {
+ basic = {
+ charge_item_count = fn():call('getChargeItem'):get('count'):with('unit', 'item'),
+ discharge_item_count = fn():call('getDischargeItem'):get('count'):with('unit', 'item'),
+ }
+ }
+
+ self:withGenericMachineQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return EnergyCubeInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/EnrichingFactoryInputAdapter.lua b/src/telem/lib/input/mekanism/EnrichingFactoryInputAdapter.lua
new file mode 100644
index 0000000..def9514
--- /dev/null
+++ b/src/telem/lib/input/mekanism/EnrichingFactoryInputAdapter.lua
@@ -0,0 +1,30 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local EnrichingFactoryInputAdapter = base.mintAdapter('EnrichingFactoryInputAdapter')
+
+function EnrichingFactoryInputAdapter:beforeRegister ()
+ self.prefix = 'mekenrich:'
+
+ local factorySize = self:getFactorySize()
+
+ self.queries = {
+ basic = {
+ input_count_sum = base.mintSlotCountQuery(factorySize, 'getInput'):with('unit', 'item'),
+ output_count_sum = base.mintSlotCountQuery(factorySize, 'getOutput'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ advanced = {
+ auto_sort = fn():call('isAutoSortEnabled'):toFlag(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries(factorySize)
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return EnrichingFactoryInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/EnrichmentChamberInputAdapter.lua b/src/telem/lib/input/mekanism/EnrichmentChamberInputAdapter.lua
new file mode 100644
index 0000000..14892e1
--- /dev/null
+++ b/src/telem/lib/input/mekanism/EnrichmentChamberInputAdapter.lua
@@ -0,0 +1,25 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local EnrichmentChamberInputAdapter = base.mintAdapter('EnrichmentChamberInputAdapter')
+
+function EnrichmentChamberInputAdapter:beforeRegister ()
+ self.prefix = 'mekenrich:'
+
+ self.queries = {
+ basic = {
+ input_count = fn():call('getInput'):get('count'):with('unit', 'item'),
+ output_count = fn():call('getOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return EnrichmentChamberInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/FissionReactorInputAdapter.lua b/src/telem/lib/input/mekanism/FissionReactorInputAdapter.lua
index 77ff942..8e2dd09 100644
--- a/src/telem/lib/input/mekanism/FissionReactorInputAdapter.lua
+++ b/src/telem/lib/input/mekanism/FissionReactorInputAdapter.lua
@@ -1,36 +1,12 @@
-local o = require 'telem.lib.ObjectModel'
-local t = require 'telem.lib.util'
local fn = require 'telem.vendor'.fluent.fn
-local BaseMekanismInputAdapter = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
-local FissionReactorInputAdapter = o.class(BaseMekanismInputAdapter)
-FissionReactorInputAdapter.type = 'FissionReactorInputAdapter'
+local FissionReactorInputAdapter = base.mintAdapter('FissionReactorInputAdapter')
-function FissionReactorInputAdapter:constructor (peripheralName, categories)
- self:super('constructor', peripheralName)
-
- -- TODO this will be a configurable feature later
+function FissionReactorInputAdapter:beforeRegister ()
self.prefix = 'mekfission:'
- -- TODO make these constants
- local allCategories = {
- 'basic',
- 'advanced',
- 'fuel',
- 'coolant',
- 'waste',
- 'formation'
- }
-
- if not categories then
- self.categories = { 'basic' }
- elseif categories == '*' then
- self.categories = allCategories
- else
- self.categories = categories
- end
-
self.queries = {
basic = {
status = fn():call('getStatus'):toFlag(),
@@ -67,21 +43,21 @@ function FissionReactorInputAdapter:constructor (peripheralName, categories)
waste_needed = fn():call('getWasteNeeded'):div(1000):fluid()
},
formation = {
- formed = fn():call('isFormed'):toFlag(),
force_disabled = fn():call('isForceDisabled'):toFlag(),
- height = fn():call('getHeight'):with('unit', 'm'),
- length = fn():call('getLength'):with('unit', 'm'),
- width = fn():call('getWidth'):with('unit', 'm'),
fuel_assemblies = fn():call('getFuelAssemblies'),
fuel_surface_area = fn():call('getFuelSurfaceArea'):with('unit', 'm²'),
heat_capacity = fn():call('getHeatCapacity'):with('unit', 'J/K'),
- boil_efficiency = fn():call('getBoilEfficiency')
+ boil_efficiency = fn():call('getBoilEfficiency'),
}
}
- -- not sure if these are useful, but they return strings anyway which are not Metric compatible, RIP
- -- fission.getLogicMode()
- -- fission.getRedstoneLogicStatus()
+ self:withMultiblockQueries()
+
+ -- getMinPos
+ -- getRedstoneMode
+ -- getMaxPos
+ -- getRedstoneLogicStatus
+ -- getLogicMode
end
return FissionReactorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/FluidTankInputAdapter.lua b/src/telem/lib/input/mekanism/FluidTankInputAdapter.lua
new file mode 100644
index 0000000..80174cf
--- /dev/null
+++ b/src/telem/lib/input/mekanism/FluidTankInputAdapter.lua
@@ -0,0 +1,36 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+local Metric = require 'telem.lib.Metric'
+
+local FluidTankInputAdapter = base.mintAdapter('FluidTankInputAdapter')
+
+function FluidTankInputAdapter:beforeRegister ()
+ self.prefix = 'mekfluidtank:'
+
+ self.queries = {
+ basic = {
+ filled_percentage = fn():call('getFilledPercentage'),
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ },
+ storage = {
+ stored = fn():call('getStored'):get('amount'):div(1000):fluid(),
+ capacity = fn():call('getCapacity'):div(1000):fluid(),
+ needed = fn():call('getNeeded'):div(1000):fluid(),
+ },
+ }
+
+ self.storageQueries = {
+ fn():call('getStored'):transform(function (v)
+ return { Metric{ name = v.name, value = v.amount / 1000, unit = 'B' } }
+ end)
+ }
+
+ -- getComparatorLevel
+
+ -- TODO does not support energy or redstone mode
+ -- self:withGenericMachineQueries()
+end
+
+return FluidTankInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/FluidicPlenisherInputAdapter.lua b/src/telem/lib/input/mekanism/FluidicPlenisherInputAdapter.lua
new file mode 100644
index 0000000..f15f743
--- /dev/null
+++ b/src/telem/lib/input/mekanism/FluidicPlenisherInputAdapter.lua
@@ -0,0 +1,32 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local FluidicPlenisherInputAdapter = base.mintAdapter('FluidicPlenisherInputAdapter')
+
+function FluidicPlenisherInputAdapter:beforeRegister ()
+ self.prefix = 'mekplenisher:'
+
+ self.queries = {
+ basic = {
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ fluid_filled_percentage = fn():call('getFluidFilledPercentage'),
+
+ -- TODO: does not support energy usage? need to verify
+ -- energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ fluid = fn():call('getFluid'):get('amount'):div(1000):fluid(),
+ fluid_capacity = fn():call('getFluidCapacity'):div(1000):fluid(),
+ fluid_needed = fn():call('getFluidNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return FluidicPlenisherInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/FormulaicAssemblicatorInputAdapter.lua b/src/telem/lib/input/mekanism/FormulaicAssemblicatorInputAdapter.lua
new file mode 100644
index 0000000..e107cdb
--- /dev/null
+++ b/src/telem/lib/input/mekanism/FormulaicAssemblicatorInputAdapter.lua
@@ -0,0 +1,38 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local FormulaicAssemblicatorInputAdapter = base.mintAdapter('FormulaicAssemblicatorInputAdapter')
+
+function FormulaicAssemblicatorInputAdapter:beforeRegister ()
+ self.prefix = 'mekassemblicator:'
+
+ self.queries = {
+ basic = {
+ input_slot_usage = base.mintSlotUsageQuery('getSlots', 'getItemInSlot'),
+ input_slot_count = fn():call('getSlots'),
+ output_slot_usage = base.mintSlotUsageQuery('getCraftingOutputSlots', 'getCraftingOutputSlot'),
+ output_slot_count = fn():call('getCraftingOutputSlots'),
+
+ -- TODO: does not support energy usage? need to verify
+ -- energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+
+ advanced = {
+ valid_formula = fn():call('hasValidFormula'):toFlag(),
+
+ -- these throw errors when a valid formula is not installed
+ auto_mode = fn():callElse('getAutoMode', false):toFlag(),
+ stock_control = fn():callElse('getStockControl', false):toFlag(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getExcessRemainingItems
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return FormulaicAssemblicatorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/FuelwoodHeaterInputAdapter.lua b/src/telem/lib/input/mekanism/FuelwoodHeaterInputAdapter.lua
new file mode 100644
index 0000000..9e15a33
--- /dev/null
+++ b/src/telem/lib/input/mekanism/FuelwoodHeaterInputAdapter.lua
@@ -0,0 +1,26 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local FuelwoodHeaterInputAdapter = base.mintAdapter('FuelwoodHeaterInputAdapter')
+
+function FuelwoodHeaterInputAdapter:beforeRegister ()
+ self.prefix = 'mekfuelheater:'
+
+ self.queries = {
+ basic = {
+ fuel_count = fn():call('getFuelItem'):get('count'):with('unit', 'item'),
+ temperature = fn():call('getTemperature'):temp(),
+ },
+ advanced = {
+ environmental_loss = fn():call('getEnvironmentalLoss'),
+ },
+ }
+
+ -- TODO only supports direction
+ -- self:withGenericMachineQueries()
+
+ -- getDirection
+end
+
+return FuelwoodHeaterInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/FusionReactorInputAdapter.lua b/src/telem/lib/input/mekanism/FusionReactorInputAdapter.lua
index 46d998f..6230f4a 100644
--- a/src/telem/lib/input/mekanism/FusionReactorInputAdapter.lua
+++ b/src/telem/lib/input/mekanism/FusionReactorInputAdapter.lua
@@ -1,40 +1,17 @@
-local o = require 'telem.lib.ObjectModel'
-local t = require 'telem.lib.util'
local fn = require 'telem.vendor'.fluent.fn
-local BaseMekanismInputAdapter = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
-local FusionReactorInputAdapter = o.class(BaseMekanismInputAdapter)
-FusionReactorInputAdapter.type = 'FusionReactorInputAdapter'
+local FusionReactorInputAdapter = base.mintAdapter('FusionReactorInputAdapter')
--- alternative call that passes another call as a parameter
-local callIsActiveCooled = function (method)
- return function (v)
- return v[method](v.isActiveCooledLogic())
- end
-end
-
-function FusionReactorInputAdapter:constructor (peripheralName, categories)
- self:super('constructor', peripheralName)
-
- -- TODO this will be a configurable feature later
+function FusionReactorInputAdapter:beforeRegister ()
self.prefix = 'mekfusion:'
- -- TODO make these constants
- local allCategories = {
- 'basic',
- 'advanced',
- 'fuel',
- 'coolant',
- 'formation'
- }
-
- if not categories then
- self.categories = { 'basic' }
- elseif categories == '*' then
- self.categories = allCategories
- else
- self.categories = categories
+ -- alternative call that passes another call as a parameter
+ local callIsActiveCooled = function (method)
+ return function (v)
+ return v[method](v.isActiveCooledLogic())
+ end
end
self.queries = {
@@ -54,10 +31,10 @@ function FusionReactorInputAdapter:constructor (peripheralName, categories)
passive_generation_rate = fn():transform(callIsActiveCooled('getPassiveGeneration')):joulesToFE():energyRate(),
ignition_temperature = fn():transform(callIsActiveCooled('getIgnitionTemperature')):temp(),
},
- advanced = {
- -- transfer_loss = fn():call('getTransferLoss'),
- -- environmental_loss = fn():call('getEnvironmentalLoss'),
- },
+ -- advanced = {
+ -- transfer_loss = fn():call('getTransferLoss'),
+ -- environmental_loss = fn():call('getEnvironmentalLoss'),
+ -- },
coolant = {
water_capacity = fn():call('getWaterCapacity'):div(1000):fluid(),
water_needed = fn():call('getWaterNeeded'):div(1000):fluid(),
@@ -73,13 +50,21 @@ function FusionReactorInputAdapter:constructor (peripheralName, categories)
dt_fuel_needed = fn():call('getDTFuelNeeded'):div(1000):fluid(),
},
formation = {
- formed = fn():call('isFormed'):toFlag(),
- height = fn():call('getHeight'):with('unit', 'm'),
- length = fn():call('getLength'):with('unit', 'm'),
- width = fn():call('getWidth'):with('unit', 'm'),
- active_cooled_logic = fn():call('isActiveCooledLogic'):toFlag(),
+ active_cooled_logic = fn():call('isActiveCooledLogic'):toFlag()
}
}
+
+ self:withMultiblockQueries()
+
+ -- getDTFuel
+ -- getMinPos
+ -- getHohlraum
+ -- getMaxPos
+ -- getTrititum
+ -- getDeuterium
+ -- getSteam
+ -- getWater
+ -- getLogicMode
end
return FusionReactorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua b/src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua
new file mode 100644
index 0000000..d2a72f4
--- /dev/null
+++ b/src/telem/lib/input/mekanism/GasGeneratorInputAdapter.lua
@@ -0,0 +1,27 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local GasGeneratorInputAdapter = base.mintAdapter('GasGeneratorInputAdapter')
+
+function GasGeneratorInputAdapter:beforeRegister ()
+ self.prefix = 'mekgasgen:'
+
+ self.queries = {
+ basic = {
+ fuel_filled_percentage = fn():call('getFuelFilledPercentage'),
+ burn_rate = fn():call('getBurnRate'):div(1000):fluidRate(),
+ fuel_item_count = fn():call('getFuelItem'):get('count'):with('unit', 'item'),
+ },
+ fuel = {
+ fuel = fn():call('getFuel'):get('amount'):div(1000):fluid(),
+ fuel_capacity = fn():call('getFuelCapacity'):div(1000):fluid(),
+ fuel_needed = fn():call('getFuelNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withGeneratorQueries()
+end
+
+return GasGeneratorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/HeatGeneratorInputAdapter.lua b/src/telem/lib/input/mekanism/HeatGeneratorInputAdapter.lua
new file mode 100644
index 0000000..c44617c
--- /dev/null
+++ b/src/telem/lib/input/mekanism/HeatGeneratorInputAdapter.lua
@@ -0,0 +1,31 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local HeatGeneratorInputAdapter = base.mintAdapter('HeatGeneratorInputAdapter')
+
+function HeatGeneratorInputAdapter:beforeRegister ()
+ self.prefix = 'mekheatgen:'
+
+ self.queries = {
+ basic = {
+ fuel_item_count = fn():call('getFuelItem'):get('count'):with('unit', 'item'),
+ lava_filled_percentage = fn():call('getLavaFilledPercentage'),
+ temperature = fn():call('getTemperature'):temp(),
+ },
+ advanced = {
+ transfer_loss = fn():call('getTransferLoss'),
+ environmental_loss = fn():call('getEnvironmentalLoss'),
+ },
+ fuel = {
+ lava = fn():call('getLava'):get('amount'):div(1000):fluid(),
+ lava_capacity = fn():call('getLavaCapacity'):div(1000):fluid(),
+ lava_needed = fn():call('getLavaNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withGeneratorQueries()
+end
+
+return HeatGeneratorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/InductionMatrixInputAdapter.lua b/src/telem/lib/input/mekanism/InductionMatrixInputAdapter.lua
index ccb3962..3b14938 100644
--- a/src/telem/lib/input/mekanism/InductionMatrixInputAdapter.lua
+++ b/src/telem/lib/input/mekanism/InductionMatrixInputAdapter.lua
@@ -1,63 +1,36 @@
-local o = require 'telem.lib.ObjectModel'
-local t = require 'telem.lib.util'
local fn = require 'telem.vendor'.fluent.fn
-local BaseMekanismInputAdapter = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
-local InductionMatrixInputAdapter = o.class(BaseMekanismInputAdapter)
-InductionMatrixInputAdapter.type = 'InductionMatrixInputAdapter'
+local InductionMatrixInputAdapter = base.mintAdapter('InductionMatrixInputAdapter')
-function InductionMatrixInputAdapter:constructor (peripheralName, categories)
- self:super('constructor', peripheralName)
-
- -- TODO this will be a configurable feature later
+function InductionMatrixInputAdapter:beforeRegister ()
self.prefix = 'mekinduction:'
- local allCategories = {
- 'basic',
- 'advanced',
- 'energy',
- 'formation'
- }
-
- if not categories then
- self.categories = { 'basic' }
- elseif categories == '*' then
- self.categories = allCategories
- else
- self.categories = categories
- end
-
self.queries = {
basic = {
- energy_filled_percentage = fn():call('getEnergyFilledPercentage'),
- energy_input = fn():call('getLastInput'):joulesToFE():energyRate(),
- energy_output = fn():call('getLastOutput'):joulesToFE():energyRate(),
- energy_transfer_cap = fn():call('getTransferCap'):joulesToFE():energyRate()
- },
- advanced = {
- comparator_level = fn():call('getComparatorLevel')
- },
- energy = {
- energy = fn():call('getEnergy'):joulesToFE():energy(),
- max_energy = fn():call('getMaxEnergy'):joulesToFE():energy(),
- energy_needed = fn():call('getEnergyNeeded'):joulesToFE():energy()
+ energy_input = fn():call('getLastInput'):joulesToFE():energyRate(),
+ energy_output = fn():call('getLastOutput'):joulesToFE():energyRate(),
+ energy_transfer_cap = fn():call('getTransferCap'):joulesToFE():energyRate(),
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
},
formation = {
- formed = fn():call('isFormed'):toFlag(),
- height = fn():call('getHeight'):with('unit', 'm'),
- length = fn():call('getLength'):with('unit', 'm'),
- width = fn():call('getWidth'):with('unit', 'm'),
- installed_cells = fn():call('getInstalledCells'),
- installed_providers = fn():call('getInstalledProviders')
+ installed_cells = fn():call('getInstalledCells'),
+ installed_providers = fn():call('getInstalledProviders'),
}
}
- -- not sure if these are useful, but they return types which are not Metric compatible, RIP
- -- induction.getInputItem()
- -- induction.getOutputItem()
- -- induction.getMaxPos()
- -- induction.getMinPos()
+ self:withGenericMachineQueries()
+ :withMultiblockQueries()
+
+ -- getMaxPos
+ -- getMinPos
+ -- getMode
+
+ -- for generic, does NOT implement:
+ -- getDirection
+ -- getRedstoneMode
end
return InductionMatrixInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/IndustrialTurbineInputAdapter.lua b/src/telem/lib/input/mekanism/IndustrialTurbineInputAdapter.lua
index eb157f1..2a2ef07 100644
--- a/src/telem/lib/input/mekanism/IndustrialTurbineInputAdapter.lua
+++ b/src/telem/lib/input/mekanism/IndustrialTurbineInputAdapter.lua
@@ -1,52 +1,23 @@
-local o = require 'telem.lib.ObjectModel'
-local t = require 'telem.lib.util'
local fn = require 'telem.vendor'.fluent.fn
-local BaseMekanismInputAdapter = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
-local IndustrialTurbineInputAdapter = o.class(BaseMekanismInputAdapter)
-IndustrialTurbineInputAdapter.type = 'IndustrialTurbineInputAdapter'
+local IndustrialTurbineInputAdapter = base.mintAdapter('IndustrialTurbineInputAdapter')
-function IndustrialTurbineInputAdapter:constructor (peripheralName, categories)
- self:super('constructor', peripheralName)
-
- -- TODO this will be a configurable feature later
+function IndustrialTurbineInputAdapter:beforeRegister ()
self.prefix = 'mekturbine:'
- local allCategories = {
- 'basic',
- 'advanced',
- 'energy',
- 'steam',
- 'formation'
- }
-
- if not categories then
- self.categories = { 'basic' }
- elseif categories == '*' then
- self.categories = allCategories
- else
- self.categories = categories
- end
-
self.queries = {
basic = {
- energy_filled_percentage = fn():call('getEnergyFilledPercentage'),
energy_production_rate = fn():call('getProductionRate'):joulesToFE():energyRate(),
energy_max_production = fn():call('getMaxProduction'):joulesToFE():energyRate(),
steam_filled_percentage = fn():call('getSteamFilledPercentage'),
},
advanced = {
- comparator_level = fn():call('getComparatorLevel'),
dumping_mode = fn():call('getDumpingMode'):toLookup({ IDLE = 1, DUMPING_EXCESS = 2, DUMPING = 3 }),
flow_rate = fn():call('getFlowRate'):div(1000):fluidRate(),
max_flow_rate = fn():call('getMaxFlowRate'):div(1000):fluidRate(),
},
- energy = {
- energy = fn():call('getEnergy'):joulesToFE():energy(),
- max_energy = fn():call('getMaxEnergy'):joulesToFE():energy(),
- energy_needed = fn():call('getEnergyNeeded'):joulesToFE():energy(),
- },
steam = {
steam_input_rate = fn():call('getLastSteamInputRate'):div(1000):fluidRate(),
steam = fn():call('getSteam'):get('amount'):div(1000):fluid(),
@@ -54,10 +25,6 @@ function IndustrialTurbineInputAdapter:constructor (peripheralName, categories)
steam_needed = fn():call('getSteamNeeded'):div(1000):fluid(),
},
formation = {
- formed = fn():call('isFormed'):toFlag(),
- height = fn():call('getHeight'):with('unit', 'm'),
- length = fn():call('getLength'):with('unit', 'm'),
- width = fn():call('getWidth'):with('unit', 'm'),
blades = fn():call('getBlades'),
coils = fn():call('getCoils'),
condensers = fn():call('getCondensers'),
@@ -66,6 +33,12 @@ function IndustrialTurbineInputAdapter:constructor (peripheralName, categories)
max_water_output = fn():call('getMaxWaterOutput'):div(1000):fluidRate(),
},
}
+
+ self:withGenericMachineQueries()
+ :withMultiblockQueries()
+
+ -- getMinPos
+ -- getMaxPos
end
return IndustrialTurbineInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/InfusingFactoryInputAdapter.lua b/src/telem/lib/input/mekanism/InfusingFactoryInputAdapter.lua
new file mode 100644
index 0000000..5082213
--- /dev/null
+++ b/src/telem/lib/input/mekanism/InfusingFactoryInputAdapter.lua
@@ -0,0 +1,37 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local InfusingFactoryInputAdapter = base.mintAdapter('InfusingFactoryInputAdapter')
+
+function InfusingFactoryInputAdapter:beforeRegister ()
+ self.prefix = 'mekmetalinfuse:'
+
+ local factorySize = self:getFactorySize()
+
+ self.queries = {
+ basic = {
+ input_count_sum = base.mintSlotCountQuery(factorySize, 'getInput'):with('unit', 'item'),
+ infuse_item_count = fn():call('getInfuseTypeItem'):get('count'):with('unit', 'item'),
+ infuse_filled_percentage = fn():call('getInfuseTypeFilledPercentage'),
+ output_count_sum = base.mintSlotCountQuery(factorySize, 'getOutput'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ advanced = {
+ auto_sort = fn():call('isAutoSortEnabled'):toFlag(),
+ },
+ input = {
+ infuse = fn():call('getInfuseType'):get('amount'):div(1000):fluid(),
+ infuse_capacity = fn():call('getInfuseTypeCapacity'):div(1000):fluid(),
+ infuse_needed = fn():call('getInfuseTypeNeeded'):div(1000):fluid(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries(factorySize)
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return InfusingFactoryInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/InjectingFactoryInputAdapter.lua b/src/telem/lib/input/mekanism/InjectingFactoryInputAdapter.lua
new file mode 100644
index 0000000..ccfcd19
--- /dev/null
+++ b/src/telem/lib/input/mekanism/InjectingFactoryInputAdapter.lua
@@ -0,0 +1,37 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local InjectingFactoryInputAdapter = base.mintAdapter('InjectingFactoryInputAdapter')
+
+function InjectingFactoryInputAdapter:beforeRegister ()
+ self.prefix = 'mekinject:'
+
+ local factorySize = self:getFactorySize()
+
+ self.queries = {
+ basic = {
+ chemical_item_count = fn():call('getChemicalItem'):get('count'):with('unit', 'item'),
+ chemical_filled_percentage = fn():call('getChemicalFilledPercentage'),
+ input_count_sum = base.mintSlotCountQuery(factorySize, 'getInput'):with('unit', 'item'),
+ output_count_sum = base.mintSlotCountQuery(factorySize, 'getOutput'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ advanced = {
+ auto_sort = fn():call('isAutoSortEnabled'):toFlag(),
+ },
+ input = {
+ chemical = fn():call('getChemical'):get('amount'):div(1000):fluid(),
+ chemical_capacity = fn():call('getChemicalCapacity'):div(1000):fluid(),
+ chemical_needed = fn():call('getChemicalNeeded'):div(1000):fluid(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries(factorySize)
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return InjectingFactoryInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/IsotopicCentrifugeInputAdapter.lua b/src/telem/lib/input/mekanism/IsotopicCentrifugeInputAdapter.lua
new file mode 100644
index 0000000..e57d0e6
--- /dev/null
+++ b/src/telem/lib/input/mekanism/IsotopicCentrifugeInputAdapter.lua
@@ -0,0 +1,33 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local IsotopicCentrifugeInputAdapter = base.mintAdapter('IsotopicCentrifugeInputAdapter')
+
+function IsotopicCentrifugeInputAdapter:beforeRegister ()
+ self.prefix = 'mekcentrifuge:'
+
+ self.queries = {
+ basic = {
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ input_filled_percentage = fn():call('getInputFilledPercentage'),
+ output_filled_percentage = fn():call('getOutputFilledPercentage'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ input = fn():call('getInput'):get('amount'):div(1000):fluid(),
+ input_capacity = fn():call('getInputCapacity'):div(1000):fluid(),
+ input_needed = fn():call('getInputNeeded'):div(1000):fluid(),
+ },
+ output = {
+ output = fn():call('getOutput'):get('amount'):div(1000):fluid(),
+ output_capacity = fn():call('getOutputCapacity'):div(1000):fluid(),
+ output_needed = fn():call('getOutputNeeded'):div(1000):fluid(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+end
+
+return IsotopicCentrifugeInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/LaserAmplifierInputAdapter.lua b/src/telem/lib/input/mekanism/LaserAmplifierInputAdapter.lua
new file mode 100644
index 0000000..f1f8336
--- /dev/null
+++ b/src/telem/lib/input/mekanism/LaserAmplifierInputAdapter.lua
@@ -0,0 +1,22 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local LaserAmplifierInputAdapter = base.mintAdapter('LaserAmplifierInputAdapter')
+
+function LaserAmplifierInputAdapter:beforeRegister ()
+ self.prefix = 'meklaseramp:'
+
+ self.queries = {
+ advanced = {
+ delay = fn():call('getDelay'):with('unit', 't'),
+ min_threshold = fn():call('getMinThreshold'):joulesToFE():energy(),
+ max_threshold = fn():call('getMaxThreshold'):joulesToFE():energy(),
+ redstone_output_mode = fn():call('getRedstoneOutputMode'):toLookup({ ENERGY_CONTENTS = 1, ENTITY_DETECTION = 2, OFF = 3 }),
+ },
+ }
+
+ self:withGenericMachineQueries()
+end
+
+return LaserAmplifierInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/LaserInputAdapter.lua b/src/telem/lib/input/mekanism/LaserInputAdapter.lua
new file mode 100644
index 0000000..3dd9c4c
--- /dev/null
+++ b/src/telem/lib/input/mekanism/LaserInputAdapter.lua
@@ -0,0 +1,25 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local LaserInputAdapter = base.mintAdapter('LaserInputAdapter')
+
+function LaserInputAdapter:beforeRegister ()
+ self.prefix = 'meklaser:'
+
+ self.queries = {
+ basic = {
+ energy_filled_percentage = fn():call('getEnergyFilledPercentage')
+ },
+ energy = {
+ energy = fn():call('getEnergy'):joulesToFE():energy(),
+ max_energy = fn():call('getMaxEnergy'):joulesToFE():energy(),
+ energy_needed = fn():call('getEnergyNeeded'):joulesToFE():energy(),
+ },
+ }
+
+ -- TODO only supports energy and direction
+ -- self:withGenericMachineQueries()
+end
+
+return LaserInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/LaserTractorBeamInputAdapter.lua b/src/telem/lib/input/mekanism/LaserTractorBeamInputAdapter.lua
new file mode 100644
index 0000000..8336529
--- /dev/null
+++ b/src/telem/lib/input/mekanism/LaserTractorBeamInputAdapter.lua
@@ -0,0 +1,22 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local LaserTractorBeamInputAdapter = base.mintAdapter('LaserTractorBeamInputAdapter')
+
+function LaserTractorBeamInputAdapter:beforeRegister ()
+ self.prefix = 'mektractorbeam:'
+
+ self.queries = {
+ basic = {
+ slot_usage = base.mintSlotUsageQuery('getSlotCount', 'getItemInSlot'),
+ slot_count = fn():call('getSlotCount'),
+ }
+ }
+
+ -- TODO not sure the energy metrics mean anything to this component
+
+ self:withGenericMachineQueries()
+end
+
+return LaserTractorBeamInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/LogisticalSorterInputAdapter.lua b/src/telem/lib/input/mekanism/LogisticalSorterInputAdapter.lua
new file mode 100644
index 0000000..b2c5548
--- /dev/null
+++ b/src/telem/lib/input/mekanism/LogisticalSorterInputAdapter.lua
@@ -0,0 +1,17 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local LogisticalSorterInputAdapter = base.mintAdapter('LogisticalSorterInputAdapter')
+
+function LogisticalSorterInputAdapter:beforeRegister ()
+ self.prefix = 'meklogsorter:'
+
+ self.queries = {
+ basic = {
+ comparator_level = fn():call('getComparatorLevel'),
+ },
+ }
+end
+
+return LogisticalSorterInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/MechanicalPipeInputAdapter.lua b/src/telem/lib/input/mekanism/MechanicalPipeInputAdapter.lua
new file mode 100644
index 0000000..2ba541c
--- /dev/null
+++ b/src/telem/lib/input/mekanism/MechanicalPipeInputAdapter.lua
@@ -0,0 +1,22 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local MechanicalPipeInputAdapter = base.mintAdapter('MechanicalPipeInputAdapter')
+
+function MechanicalPipeInputAdapter:beforeRegister ()
+ self.prefix = 'mekpipe:'
+
+ self.queries = {
+ basic = {
+ filled_percentage = fn():call('getFilledPercentage')
+ },
+ transfer = {
+ buffer = fn():call('getBuffer'):get('amount'):div(1000):fluid(),
+ capacity = fn():call('getCapacity'):div(1000):fluid(),
+ needed = fn():call('getNeeded'):div(1000):fluid(),
+ }
+ }
+end
+
+return MechanicalPipeInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/MetallurgicInfuserInputAdapter.lua b/src/telem/lib/input/mekanism/MetallurgicInfuserInputAdapter.lua
new file mode 100644
index 0000000..d1af2eb
--- /dev/null
+++ b/src/telem/lib/input/mekanism/MetallurgicInfuserInputAdapter.lua
@@ -0,0 +1,32 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local MetallurgicInfuserInputAdapter = base.mintAdapter('MetallurgicInfuserInputAdapter')
+
+function MetallurgicInfuserInputAdapter:beforeRegister ()
+ self.prefix = 'mekmetalinfuse:'
+
+ self.queries = {
+ basic = {
+ input_count = fn():call('getInput'):get('count'):with('unit', 'item'),
+ infuse_item_count = fn():call('getInfuseTypeItem'):get('count'):with('unit', 'item'),
+ infuse_filled_percentage = fn():call('getInfuseTypeFilledPercentage'),
+ output_count = fn():call('getOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ infuse = fn():call('getInfuseType'):get('amount'):div(1000):fluid(),
+ infuse_capacity = fn():call('getInfuseTypeCapacity'):div(1000):fluid(),
+ infuse_needed = fn():call('getInfuseTypeNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return MetallurgicInfuserInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/NutritionalLiquifierInputAdapter.lua b/src/telem/lib/input/mekanism/NutritionalLiquifierInputAdapter.lua
new file mode 100644
index 0000000..073a870
--- /dev/null
+++ b/src/telem/lib/input/mekanism/NutritionalLiquifierInputAdapter.lua
@@ -0,0 +1,32 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local NutritionalLiquifierInputAdapter = base.mintAdapter('NutritionalLiquifierInputAdapter')
+
+function NutritionalLiquifierInputAdapter:beforeRegister ()
+ self.prefix = 'mekliquifier:'
+
+ self.queries = {
+ basic = {
+ input_count = fn():call('getInput'):get('count'):with('unit', 'item'),
+ output_filled_percentage = fn():call('getOutputFilledPercentage'),
+ container_fill_item_count = fn():call('getContainerFillItem'):get('count'):with('unit', 'item'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ output = {
+ output = fn():call('getOutput'):get('amount'):div(1000):fluid(),
+ output_capacity = fn():call('getOutputCapacity'):div(1000):fluid(),
+ output_needed = fn():call('getOutputNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return NutritionalLiquifierInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/OredictionificatorInputAdapter.lua b/src/telem/lib/input/mekanism/OredictionificatorInputAdapter.lua
new file mode 100644
index 0000000..5ceabcb
--- /dev/null
+++ b/src/telem/lib/input/mekanism/OredictionificatorInputAdapter.lua
@@ -0,0 +1,18 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local OredictionificatorInputAdapter = base.mintAdapter('OredictionificatorInputAdapter')
+
+function OredictionificatorInputAdapter:beforeRegister ()
+ self.prefix = 'mekoredict:'
+
+ self.queries = {
+ basic = {
+ input_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ output_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ },
+ }
+end
+
+return OredictionificatorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/OsmiumCompressorInputAdapter.lua b/src/telem/lib/input/mekanism/OsmiumCompressorInputAdapter.lua
new file mode 100644
index 0000000..a13a3de
--- /dev/null
+++ b/src/telem/lib/input/mekanism/OsmiumCompressorInputAdapter.lua
@@ -0,0 +1,32 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local OsmiumCompressorInputAdapter = base.mintAdapter('OsmiumCompressorInputAdapter')
+
+function OsmiumCompressorInputAdapter:beforeRegister ()
+ self.prefix = 'mekcompress:'
+
+ self.queries = {
+ basic = {
+ chemical_filled_percentage = fn():call('getChemicalFilledPercentage'),
+ input_count = fn():call('getInput'):get('count'):with('unit', 'item'),
+ chemical_item_count = fn():call('getChemicalItem'):get('count'):with('unit', 'item'),
+ output_count = fn():call('getOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ chemical = fn():call('getChemical'):get('amount'):div(1000):fluid(),
+ chemical_capacity = fn():call('getChemicalCapacity'):div(1000):fluid(),
+ chemical_needed = fn():call('getChemicalNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return OsmiumCompressorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/PaintingMachineInputAdapter.lua b/src/telem/lib/input/mekanism/PaintingMachineInputAdapter.lua
new file mode 100644
index 0000000..ef4750a
--- /dev/null
+++ b/src/telem/lib/input/mekanism/PaintingMachineInputAdapter.lua
@@ -0,0 +1,32 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local PaintingMachineInputAdapter = base.mintAdapter('PaintingMachineInputAdapter')
+
+function PaintingMachineInputAdapter:beforeRegister ()
+ self.prefix = 'mekpainting:'
+
+ self.queries = {
+ basic = {
+ input_pigment_item_count = fn():call('getInputPigmentItem'):get('count'):with('unit', 'item'),
+ input_pigment_filled_percentage = fn():call('getPigmentInputFilledPercentage'),
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ output_count = fn():call('getOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ input_pigment = fn():call('getPigmentInput'):get('amount'):div(1000):fluid(),
+ input_pigment_capacity = fn():call('getPigmentInputCapacity'):div(1000):fluid(),
+ input_pigment_needed = fn():call('getPigmentInputNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return PaintingMachineInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/PigmentExtractorInputAdapter.lua b/src/telem/lib/input/mekanism/PigmentExtractorInputAdapter.lua
new file mode 100644
index 0000000..6dabbcf
--- /dev/null
+++ b/src/telem/lib/input/mekanism/PigmentExtractorInputAdapter.lua
@@ -0,0 +1,31 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local PigmentExtractorInputAdapter = base.mintAdapter('PigmentExtractorInputAdapter')
+
+function PigmentExtractorInputAdapter:beforeRegister ()
+ self.prefix = 'mekpigmentextractor:'
+
+ self.queries = {
+ basic = {
+ input_count = fn():call('getInput'):get('count'):with('unit', 'item'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ output_filled_percentage = fn():call('getOutputFilledPercentage'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ output = {
+ output = fn():call('getOutput'):get('amount'):div(1000):fluid(),
+ output_capacity = fn():call('getOutputCapacity'):div(1000):fluid(),
+ output_needed = fn():call('getOutputNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return PigmentExtractorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/PigmentMixerInputAdapter.lua b/src/telem/lib/input/mekanism/PigmentMixerInputAdapter.lua
new file mode 100644
index 0000000..bcf40f0
--- /dev/null
+++ b/src/telem/lib/input/mekanism/PigmentMixerInputAdapter.lua
@@ -0,0 +1,41 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local PigmentMixerInputAdapter = base.mintAdapter('PigmentMixerInputAdapter')
+
+function PigmentMixerInputAdapter:beforeRegister ()
+ self.prefix = 'mekpigmentmixer:'
+
+ self.queries = {
+ basic = {
+ input_left_item_count = fn():call('getLeftInputItem'):get('count'):with('unit', 'item'),
+ input_right_item_count = fn():call('getRightInputItem'):get('count'):with('unit', 'item'),
+ input_left_filled_percentage = fn():call('getLeftInputFilledPercentage'),
+ input_right_filled_percentage = fn():call('getRightInputFilledPercentage'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ output_filled_percentage = fn():call('getOutputFilledPercentage'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ input_left = fn():call('getLeftInput'):get('amount'):div(1000):fluid(),
+ input_left_capacity = fn():call('getLeftInputCapacity'):div(1000):fluid(),
+ input_left_needed = fn():call('getLeftInputNeeded'):div(1000):fluid(),
+ input_right = fn():call('getRightInput'):get('amount'):div(1000):fluid(),
+ input_right_capacity = fn():call('getRightInputCapacity'):div(1000):fluid(),
+ input_right_needed = fn():call('getRightInputNeeded'):div(1000):fluid(),
+ },
+ output = {
+ output = fn():call('getOutput'):get('amount'):div(1000):fluid(),
+ output_capacity = fn():call('getOutputCapacity'):div(1000):fluid(),
+ output_needed = fn():call('getOutputNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return PigmentMixerInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/PrecisionSawmillInputAdapter.lua b/src/telem/lib/input/mekanism/PrecisionSawmillInputAdapter.lua
new file mode 100644
index 0000000..febcb3e
--- /dev/null
+++ b/src/telem/lib/input/mekanism/PrecisionSawmillInputAdapter.lua
@@ -0,0 +1,26 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local PrecisionSawmillInputAdapter = base.mintAdapter('PrecisionSawmillInputAdapter')
+
+function PrecisionSawmillInputAdapter:beforeRegister ()
+ self.prefix = 'meksaw:'
+
+ self.queries = {
+ basic = {
+ input_count = fn():call('getInput'):get('count'):with('unit', 'item'),
+ output_count = fn():call('getOutput'):get('count'):with('unit', 'item'),
+ output_secondary_count = fn():call('getSecondaryOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return PrecisionSawmillInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/PressurizedReactionChamberInputAdapter.lua b/src/telem/lib/input/mekanism/PressurizedReactionChamberInputAdapter.lua
new file mode 100644
index 0000000..4b82fce
--- /dev/null
+++ b/src/telem/lib/input/mekanism/PressurizedReactionChamberInputAdapter.lua
@@ -0,0 +1,40 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local PressurizedReactionChamberInputAdapter = base.mintAdapter('PressurizedReactionChamberInputAdapter')
+
+function PressurizedReactionChamberInputAdapter:beforeRegister ()
+ self.prefix = 'mekreaction:'
+
+ self.queries = {
+ basic = {
+ input_fluid_filled_percentage = fn():call('getInputFluidFilledPercentage'),
+ input_gas_filled_percentage = fn():call('getInputGasFilledPercentage'),
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ output_gas_filled_percentage = fn():call('getOutputGasFilledPercentage'),
+ },
+ input = {
+ input_fluid = fn():call('getInputFluid'):get('amount'):div(1000):fluid(),
+ input_fluid_capacity = fn():call('getInputFluidCapacity'):div(1000):fluid(),
+ input_fluid_needed = fn():call('getInputFluidNeeded'):div(1000):fluid(),
+ input_gas = fn():call('getInputGas'):get('amount'):div(1000):fluid(),
+ input_gas_capacity = fn():call('getInputGasCapacity'):div(1000):fluid(),
+ input_gas_needed = fn():call('getInputGasNeeded'):div(1000):fluid(),
+ },
+ output = {
+ output_gas = fn():call('getOutputGas'):get('amount'):div(1000):fluid(),
+ output_gas_capacity = fn():call('getOutputGasCapacity'):div(1000):fluid(),
+ output_gas_needed = fn():call('getOutputGasNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return PressurizedReactionChamberInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/PressurizedTubeInputAdapter.lua b/src/telem/lib/input/mekanism/PressurizedTubeInputAdapter.lua
new file mode 100644
index 0000000..5cf91b9
--- /dev/null
+++ b/src/telem/lib/input/mekanism/PressurizedTubeInputAdapter.lua
@@ -0,0 +1,22 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local PressurizedTubeInputAdapter = base.mintAdapter('PressurizedTubeInputAdapter')
+
+function PressurizedTubeInputAdapter:beforeRegister ()
+ self.prefix = 'mektube:'
+
+ self.queries = {
+ basic = {
+ filled_percentage = fn():call('getFilledPercentage')
+ },
+ transfer = {
+ buffer = fn():call('getBuffer'):get('amount'):div(1000):fluid(),
+ capacity = fn():call('getCapacity'):div(1000):fluid(),
+ needed = fn():call('getNeeded'):div(1000):fluid(),
+ }
+ }
+end
+
+return PressurizedTubeInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/PurificationChamberInputAdapter.lua b/src/telem/lib/input/mekanism/PurificationChamberInputAdapter.lua
new file mode 100644
index 0000000..148fee9
--- /dev/null
+++ b/src/telem/lib/input/mekanism/PurificationChamberInputAdapter.lua
@@ -0,0 +1,32 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local PurificationChamberInputAdapter = base.mintAdapter('PurificationChamberInputAdapter')
+
+function PurificationChamberInputAdapter:beforeRegister ()
+ self.prefix = 'mekpurify:'
+
+ self.queries = {
+ basic = {
+ chemical_filled_percentage = fn():call('getChemicalFilledPercentage'),
+ input_count = fn():call('getInput'):get('count'):with('unit', 'item'),
+ chemical_item_count = fn():call('getChemicalItem'):get('count'):with('unit', 'item'),
+ output_count = fn():call('getOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ input = {
+ chemical = fn():call('getChemical'):get('amount'):div(1000):fluid(),
+ chemical_capacity = fn():call('getChemicalCapacity'):div(1000):fluid(),
+ chemical_needed = fn():call('getChemicalNeeded'):div(1000):fluid(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return PurificationChamberInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/PurifyingFactoryInputAdapter.lua b/src/telem/lib/input/mekanism/PurifyingFactoryInputAdapter.lua
new file mode 100644
index 0000000..35d71e0
--- /dev/null
+++ b/src/telem/lib/input/mekanism/PurifyingFactoryInputAdapter.lua
@@ -0,0 +1,37 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local PurifyingFactoryInputAdapter = base.mintAdapter('PurifyingFactoryInputAdapter')
+
+function PurifyingFactoryInputAdapter:beforeRegister ()
+ self.prefix = 'mekpurify:'
+
+ local factorySize = self:getFactorySize()
+
+ self.queries = {
+ basic = {
+ chemical_item_count = fn():call('getChemicalItem'):get('count'):with('unit', 'item'),
+ chemical_filled_percentage = fn():call('getChemicalFilledPercentage'),
+ input_count_sum = base.mintSlotCountQuery(factorySize, 'getInput'):with('unit', 'item'),
+ output_count_sum = base.mintSlotCountQuery(factorySize, 'getOutput'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ advanced = {
+ auto_sort = fn():call('isAutoSortEnabled'):toFlag(),
+ },
+ input = {
+ chemical = fn():call('getChemical'):get('amount'):div(1000):fluid(),
+ chemical_capacity = fn():call('getChemicalCapacity'):div(1000):fluid(),
+ chemical_needed = fn():call('getChemicalNeeded'):div(1000):fluid(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries(factorySize)
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return PurifyingFactoryInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/QIODriveArrayInputAdapter.lua b/src/telem/lib/input/mekanism/QIODriveArrayInputAdapter.lua
new file mode 100644
index 0000000..8f6ff27
--- /dev/null
+++ b/src/telem/lib/input/mekanism/QIODriveArrayInputAdapter.lua
@@ -0,0 +1,73 @@
+local t = require 'telem.lib.util'
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+local Metric = require 'telem.lib.Metric'
+
+local QIODriveArrayInputAdapter = base.mintAdapter('QIODriveArrayInputAdapter')
+
+function QIODriveArrayInputAdapter:beforeRegister ()
+ self.prefix = 'mekqioarray:'
+
+ local _, component = next(self.components)
+ local arraySlots = component.getSlotCount()
+
+ -- TODO frequency queries seem to break when the drive array frequency is changed
+
+ self.queries = {
+ basic = {
+ frequency_selected = fn():callElse('hasFrequency', false):toFlag(),
+ item_filled_percentage = fn():callElse('getFrequencyItemPercentage', 0),
+ type_filled_percentage = fn():callElse('getFrequencyItemTypePercentage', 0),
+ },
+ advanced = {
+ -- placeholder for drive status queries
+ },
+ storage = {
+ item_count = fn():callElse('getFrequencyItemCount', 0):with('unit', 'item'),
+ item_capacity = fn():callElse('getFrequencyItemCapacity', 0):with('unit', 'item'),
+ type_count = fn():callElse('getFrequencyItemTypeCount', 0),
+ type_capacity = fn():callElse('getFrequencyItemTypeCapacity', 0),
+ },
+ }
+
+ for i = 0, arraySlots - 1 do
+ -- NEAR_FULL seems to be about 75% capacity usage
+ self.queries.advanced['drive_status_' .. i] = fn():call('getDriveStatus', i):toLookup({
+ READY = 1, NONE = 2, OFFLINE = 3, NEAR_FULL = 4, FULL = 5,
+ })
+ end
+
+ -- storage queries only indicate the contents of the directly attached array,
+ -- not the contents of the selected frequency. this is a Mekanism limitation
+ self.storageQueries = {
+ fn()
+ :transform(function (v)
+ local slotDetails = {}
+
+ local queue = {}
+ for i = 0, arraySlots - 1 do
+ table.insert(queue, function ()
+ slotDetails[i] = v.getDrive(i) or false
+ end)
+ end
+
+ parallel.waitForAll(table.unpack(queue))
+
+ return slotDetails
+ end)
+ :mapSub(fn():get('nbt.mekData.qioItemMap', {}))
+ :flatten()
+ :mapValues(function (v) return { name = v.Item.id, value = v.amount } end)
+ :sum('value', 'name')
+ :map(function (k, v) return Metric{ name = k, value = v, unit = 'item' } end)
+ :values()
+ }
+
+ -- getDirection
+
+ -- TODO only supports direction
+ -- self:withGenericMachineQueries()
+end
+
+return QIODriveArrayInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/QuantumEntangloporterInputAdapter.lua b/src/telem/lib/input/mekanism/QuantumEntangloporterInputAdapter.lua
new file mode 100644
index 0000000..1a4ab1c
--- /dev/null
+++ b/src/telem/lib/input/mekanism/QuantumEntangloporterInputAdapter.lua
@@ -0,0 +1,60 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local QuantumEntangloporterInputAdapter = base.mintAdapter('QuantumEntangloporterInputAdapter')
+
+function QuantumEntangloporterInputAdapter:beforeRegister ()
+ self.prefix = 'mekentanglo:'
+
+ self.queries = {
+ basic = {
+ fluid_filled_percentage = fn():call('getBufferFluidFilledPercentage'),
+ gas_filled_percentage = fn():call('getBufferGasFilledPercentage'),
+ infuse_filled_percentage = fn():call('getBufferInfuseTypeFilledPercentage'),
+ pigment_filled_percentage = fn():call('getBufferPigmentFilledPercentage'),
+ slurry_filled_percentage = fn():call('getBufferSlurryFilledPercentage'),
+ energy_filled_percentage = fn():call('getEnergyFilledPercentage'),
+ temperature = fn():call('getTemperature'):temp(),
+ },
+ advanced = {
+ transfer_loss = fn():call('getTransferLoss'),
+ environmental_loss = fn():call('getEnvironmentalLoss'),
+ },
+ fluid = {
+ fluid = fn():call('getBufferFluid'):get('amount'):div(1000):fluid(),
+ fluid_capacity = fn():call('getBufferFluidCapacity'):div(1000):fluid(),
+ fluid_needed = fn():call('getBufferFluidNeeded'):div(1000):fluid(),
+ },
+ gas = {
+ gas = fn():call('getBufferGas'):get('amount'):div(1000):fluid(),
+ gas_capacity = fn():call('getBufferGasCapacity'):div(1000):fluid(),
+ gas_needed = fn():call('getBufferGasNeeded'):div(1000):fluid(),
+ },
+ infuse = {
+ infuse = fn():call('getBufferInfuseType'):get('amount'):div(1000):fluid(),
+ infuse_capacity = fn():call('getBufferInfuseTypeCapacity'):div(1000):fluid(),
+ infuse_needed = fn():call('getBufferInfuseTypeNeeded'):div(1000):fluid(),
+ },
+ item = {
+ item_count = fn():call('getBufferItem'):get('count'),
+ },
+ pigment = {
+ pigment = fn():call('getBufferPigment'):get('amount'):div(1000):fluid(),
+ pigment_capacity = fn():call('getBufferPigmentCapacity'):div(1000):fluid(),
+ pigment_needed = fn():call('getBufferPigmentNeeded'):div(1000):fluid(),
+ },
+ slurry = {
+ slurry = fn():call('getBufferSlurry'):get('amount'):div(1000):fluid(),
+ slurry_capacity = fn():call('getBufferSlurryCapacity'):div(1000):fluid(),
+ slurry_needed = fn():call('getBufferSlurryNeeded'):div(1000):fluid(),
+ },
+ energy = {
+ energy = fn():call('getEnergy'):joulesToFE():energy(),
+ max_energy = fn():call('getMaxEnergy'):joulesToFE():energy(),
+ energy_needed = fn():call('getEnergyNeeded'):joulesToFE():energy(),
+ },
+ }
+end
+
+return QuantumEntangloporterInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/RadioactiveWasteBarrelInputAdapter.lua b/src/telem/lib/input/mekanism/RadioactiveWasteBarrelInputAdapter.lua
new file mode 100644
index 0000000..fcb77ce
--- /dev/null
+++ b/src/telem/lib/input/mekanism/RadioactiveWasteBarrelInputAdapter.lua
@@ -0,0 +1,41 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+local Metric = require 'telem.lib.Metric'
+
+local RadioactiveWasteBarrelInputAdapter = base.mintAdapter('RadioactiveWasteBarrelInputAdapter')
+
+function RadioactiveWasteBarrelInputAdapter:beforeRegister ()
+ self.prefix = 'mekwastebarrel:'
+
+ local _, component = next(self.components)
+ local supported = peripheral.getType(component) == 'radioactiveWasteBarrel'
+
+ if not supported then
+ error('Radioactive Waste Barrel is not supported in this version of Mekanism')
+ end
+
+ self.queries = {
+ basic = {
+ filled_percentage = fn():call('getFilledPercentage'),
+ },
+ storage = {
+ stored = fn():call('getStored'):get('amount'):div(1000):fluid(),
+ capacity = fn():call('getCapacity'):div(1000):fluid(),
+ needed = fn():call('getNeeded'):div(1000):fluid(),
+ },
+ }
+
+ self.storageQueries = {
+ fn():call('getStored'):transform(function (v)
+ return { Metric{ name = v.name, value = v.amount / 1000, unit = 'B' } }
+ end)
+ }
+
+ -- getDirection
+
+ -- TODO only supports direction and comparator
+ -- self:withGenericMachineQueries()
+end
+
+return RadioactiveWasteBarrelInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ResistiveHeaterInputAdapter.lua b/src/telem/lib/input/mekanism/ResistiveHeaterInputAdapter.lua
new file mode 100644
index 0000000..ae3781c
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ResistiveHeaterInputAdapter.lua
@@ -0,0 +1,42 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ResistiveHeaterInputAdapter = base.mintAdapter('ResistiveHeaterInputAdapter')
+
+function ResistiveHeaterInputAdapter:beforeRegister ()
+ self.prefix = 'mekresheater:'
+
+ local _, component = next(self.components)
+ local supportsEnergyUsed = type(component.getEnergyUsed) == 'function'
+
+ self.queries = {
+ basic = {
+ energy_filled_percentage = fn():call('getEnergyFilledPercentage'),
+ energy_usage_target = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ temperature = fn():call('getTemperature'):temp(),
+ },
+ advanced = {
+ environmental_loss = fn():call('getEnvironmentalLoss'),
+ },
+ energy = {
+ energy = fn():call('getEnergy'):joulesToFE():energy(),
+ max_energy = fn():call('getMaxEnergy'):joulesToFE():energy(),
+ energy_needed = fn():call('getEnergyNeeded'):joulesToFE():energy(),
+ },
+ }
+
+ -- Mekanism 10.3+ only
+ if supportsEnergyUsed then
+ self.queries.basic.energy_usage = fn():call('getEnergyUsed'):joulesToFE():energyRate()
+ end
+
+
+ -- TODO does not support comparator
+ -- self:withGenericMachineQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return ResistiveHeaterInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/RotaryCondensentratorInputAdapter.lua b/src/telem/lib/input/mekanism/RotaryCondensentratorInputAdapter.lua
new file mode 100644
index 0000000..a08c4fb
--- /dev/null
+++ b/src/telem/lib/input/mekanism/RotaryCondensentratorInputAdapter.lua
@@ -0,0 +1,39 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local RotaryCondensentratorInputAdapter = base.mintAdapter('RotaryCondensentratorInputAdapter')
+
+function RotaryCondensentratorInputAdapter:beforeRegister ()
+ self.prefix = 'mekcondense:'
+
+ self.queries = {
+ basic = {
+ condensentrating = fn():call('isCondensentrating'):toFlag(),
+ gas_input_item_count = fn():call('getGasItemInput'):get('count'):with('unit', 'item'),
+ gas_filled_percentage = fn():call('getGasFilledPercentage'),
+ gas_output_item_count = fn():call('getGasItemOutput'):get('count'):with('unit', 'item'),
+ fluid_input_item_count = fn():call('getFluidItemInput'):get('count'):with('unit', 'item'),
+ fluid_filled_percentage = fn():call('getFluidFilledPercentage'),
+ fluid_output_item_count = fn():call('getFluidItemOutput'):get('count'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ gas = {
+ gas = fn():call('getGas'):get('amount'):div(1000):fluid(),
+ gas_capacity = fn():call('getGasCapacity'):div(1000):fluid(),
+ gas_needed = fn():call('getGasNeeded'):div(1000):fluid(),
+ },
+ fluid = {
+ fluid = fn():call('getFluid'):get('amount'):div(1000):fluid(),
+ fluid_capacity = fn():call('getFluidCapacity'):div(1000):fluid(),
+ fluid_needed = fn():call('getFluidNeeded'):div(1000):fluid(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return RotaryCondensentratorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/SawingFactoryInputAdapter.lua b/src/telem/lib/input/mekanism/SawingFactoryInputAdapter.lua
new file mode 100644
index 0000000..ef0598c
--- /dev/null
+++ b/src/telem/lib/input/mekanism/SawingFactoryInputAdapter.lua
@@ -0,0 +1,31 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local SawingFactoryInputAdapter = base.mintAdapter('SawingFactoryInputAdapter')
+
+function SawingFactoryInputAdapter:beforeRegister ()
+ self.prefix = 'meksaw:'
+
+ local factorySize = self:getFactorySize()
+
+ self.queries = {
+ basic = {
+ input_count_sum = base.mintSlotCountQuery(factorySize, 'getInput'):with('unit', 'item'),
+ output_count_sum = base.mintSlotCountQuery(factorySize, 'getOutput'):with('unit', 'item'),
+ output_secondary_count_sum = base.mintSlotCountQuery(factorySize, 'getSecondaryOutput'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ advanced = {
+ auto_sort = fn():call('isAutoSortEnabled'):toFlag(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries(factorySize)
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return SawingFactoryInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/SeismicVibratorInputAdapter.lua b/src/telem/lib/input/mekanism/SeismicVibratorInputAdapter.lua
new file mode 100644
index 0000000..0c081b2
--- /dev/null
+++ b/src/telem/lib/input/mekanism/SeismicVibratorInputAdapter.lua
@@ -0,0 +1,76 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+local Metric = require 'telem.lib.Metric'
+
+local SeismicVibratorInputAdapter = base.mintAdapter('SeismicVibratorInputAdapter')
+
+function SeismicVibratorInputAdapter:beforeRegister ()
+ self.prefix = 'mekseismic:'
+
+ local _, component = next(self.components)
+ local supportsStorage = type(component.getColumnAt) == 'function'
+
+ self.queries = {
+ basic = {
+ energy_filled_percentage = fn():call('getEnergyFilledPercentage'),
+ },
+ energy = {
+ energy = fn():call('getEnergy'):joulesToFE():energy(),
+ max_energy = fn():call('getMaxEnergy'):joulesToFE():energy(),
+ energy_needed = fn():call('getEnergyNeeded'):joulesToFE():energy(),
+ },
+ }
+
+ -- Mekanism 10.3+ only
+ if supportsStorage then
+ self.storageQueries = {
+ fn()
+ :transform(function (v)
+ local columns = {}
+
+ local queueChunks, chunkSize = {}, 16
+ local chunkIdx = 1
+
+ for x = 0, 15 do
+ for z = 0, 15 do
+ queueChunks[chunkIdx] = queueChunks[chunkIdx] or {}
+
+ table.insert(queueChunks[chunkIdx], function ()
+ columns['c' .. x .. ',' .. z] = v.getColumnAt(x, z) or false
+ end)
+
+ if #queueChunks[chunkIdx] >= chunkSize then
+ chunkIdx = chunkIdx + 1
+ end
+ end
+ end
+
+ for _, chunk in ipairs(queueChunks) do
+ parallel.waitForAll(table.unpack(chunk))
+ end
+
+ return columns
+ end)
+ :flatten()
+ :pluck('block')
+ :reject(function (_, v)
+ return v == 'minecraft:air' or v == 'minecraft:void_air'
+ end)
+ :mapValues(function (v)
+ return { name = v, value = 1 }
+ end)
+ :sum('value', 'name')
+ :map(function (k, v) return Metric{ name = k, value = v, unit = 'item' } end)
+ :values()
+ }
+ end
+
+ -- TODO does not support comparator
+ -- self:withGenericMachineQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return SeismicVibratorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/SmeltingFactoryInputAdapter.lua b/src/telem/lib/input/mekanism/SmeltingFactoryInputAdapter.lua
new file mode 100644
index 0000000..1cdc374
--- /dev/null
+++ b/src/telem/lib/input/mekanism/SmeltingFactoryInputAdapter.lua
@@ -0,0 +1,30 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local SmeltingFactoryInputAdapter = base.mintAdapter('SmeltingFactoryInputAdapter')
+
+function SmeltingFactoryInputAdapter:beforeRegister ()
+ self.prefix = 'meksmelt:'
+
+ local factorySize = self:getFactorySize()
+
+ self.queries = {
+ basic = {
+ input_count_sum = base.mintSlotCountQuery(factorySize, 'getInput'):with('unit', 'item'),
+ output_count_sum = base.mintSlotCountQuery(factorySize, 'getOutput'):with('unit', 'item'),
+ energy_usage = fn():call('getEnergyUsage'):joulesToFE():energyRate(),
+ },
+ advanced = {
+ auto_sort = fn():call('isAutoSortEnabled'):toFlag(),
+ }
+ }
+
+ self:withGenericMachineQueries()
+ :withRecipeProgressQueries(factorySize)
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return SmeltingFactoryInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/SolarGeneratorInputAdapter.lua b/src/telem/lib/input/mekanism/SolarGeneratorInputAdapter.lua
new file mode 100644
index 0000000..e84ac68
--- /dev/null
+++ b/src/telem/lib/input/mekanism/SolarGeneratorInputAdapter.lua
@@ -0,0 +1,23 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local SolarGeneratorInputAdapter = base.mintAdapter('SolarGeneratorInputAdapter')
+
+function SolarGeneratorInputAdapter:beforeRegister ()
+ self.prefix = 'meksolargen:'
+
+ self.queries = {
+ basic = {
+ sees_sun = fn():call('canSeeSun'):toFlag(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withGeneratorQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return SolarGeneratorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/SolarNeutronActivatorInputAdapter.lua b/src/telem/lib/input/mekanism/SolarNeutronActivatorInputAdapter.lua
new file mode 100644
index 0000000..e829717
--- /dev/null
+++ b/src/telem/lib/input/mekanism/SolarNeutronActivatorInputAdapter.lua
@@ -0,0 +1,47 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ChemicalWasherInputAdapter = base.mintAdapter('ChemicalWasherInputAdapter')
+
+function ChemicalWasherInputAdapter:beforeRegister ()
+ self.prefix = 'mekactivator:'
+
+ local _, component = next(self.components)
+ local supportsCanSeeSun = type(component.canSeeSun) == 'function'
+
+ self.queries = {
+ basic = {
+ input_item_count = fn():call('getInputItem'):get('count'):with('unit', 'item'),
+ input_filled_percentage = fn():call('getInputFilledPercentage'),
+ output_filled_percentage = fn():call('getOutputFilledPercentage'),
+ output_item_count = fn():call('getOutputItem'):get('count'):with('unit', 'item'),
+ production_rate = fn():call('getProductionRate'):div(1000):fluidRate(),
+ peak_production_rate = fn():call('getPeakProductionRate'):div(1000):fluidRate(),
+ },
+ input = {
+ input = fn():call('getInput'):get('amount'):div(1000):fluid(),
+ input_capacity = fn():call('getInputCapacity'):div(1000):fluid(),
+ input_needed = fn():call('getInputNeeded'):div(1000):fluid(),
+ },
+ output = {
+ output = fn():call('getOutput'):get('amount'):div(1000):fluid(),
+ output_capacity = fn():call('getOutputCapacity'):div(1000):fluid(),
+ output_needed = fn():call('getOutputNeeded'):div(1000):fluid(),
+ }
+ }
+
+ -- Mekanism 10.3+ only
+ if supportsCanSeeSun then
+ self.queries.basic.sees_sun = fn():call('canSeeSun'):toFlag()
+ end
+
+ -- TODO does not support energy
+ -- self:withGenericMachineQueries()
+
+ -- getComparatorLevel
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return ChemicalWasherInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/SupercriticalPhaseShifterInputAdapter.lua b/src/telem/lib/input/mekanism/SupercriticalPhaseShifterInputAdapter.lua
new file mode 100644
index 0000000..00f77dd
--- /dev/null
+++ b/src/telem/lib/input/mekanism/SupercriticalPhaseShifterInputAdapter.lua
@@ -0,0 +1,48 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local SupercriticalPhaseShifterInputAdapter = base.mintAdapter('SupercriticalPhaseShifterInputAdapter')
+
+function SupercriticalPhaseShifterInputAdapter:beforeRegister ()
+ self.prefix = 'meksps:'
+
+ self.queries = {
+ basic = {
+ input_filled_percentage = fn():call('getInputFilledPercentage'),
+ output_filled_percentage = fn():call('getOutputFilledPercentage'),
+ process_rate = fn():call('getProcessRate'):div(1000):fluidRate(),
+ energy_filled_percentage = fn():call('getEnergyFilledPercentage')
+ },
+
+ -- TODO energy metrics never seem to change, it always appears as if the SPS is not using any energy
+ energy = {
+ energy = fn():call('getEnergy'):joulesToFE():energy(),
+ max_energy = fn():call('getMaxEnergy'):joulesToFE():energy(),
+ energy_needed = fn():call('getEnergyNeeded'):joulesToFE():energy(),
+ },
+ input = {
+ input = fn():call('getInput'):get('amount'):div(1000):fluid(),
+ input_capacity = fn():call('getInputCapacity'):div(1000):fluid(),
+ input_needed = fn():call('getInputNeeded'):div(1000):fluid(),
+ },
+ output = {
+ output = fn():call('getOutput'):get('amount'):div(1000):fluid(),
+ output_capacity = fn():call('getOutputCapacity'):div(1000):fluid(),
+ output_needed = fn():call('getOutputNeeded'):div(1000):fluid(),
+ },
+ formation = {
+ coils = fn():call('getCoils'),
+ },
+ }
+
+ self:withMultiblockQueries()
+
+ -- TODO only supports energy
+ -- self:withGenericMachineQueries()
+
+ -- getMinPos
+ -- getMaxPos
+end
+
+return SupercriticalPhaseShifterInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/TeleporterInputAdapter.lua b/src/telem/lib/input/mekanism/TeleporterInputAdapter.lua
new file mode 100644
index 0000000..e0032bd
--- /dev/null
+++ b/src/telem/lib/input/mekanism/TeleporterInputAdapter.lua
@@ -0,0 +1,24 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local TeleporterInputAdapter = base.mintAdapter('TeleporterInputAdapter')
+
+function TeleporterInputAdapter:beforeRegister ()
+ self.prefix = 'mekteleporter:'
+
+ self.queries = {
+ basic = {
+ status = fn():call('getStatus'):toLookup({ ['ready'] = 1, ['no frequency'] = 2, ['no frame'] = 3, ['no link'] = 4 }),
+ frequency_selected = fn():callElse('hasFrequency', false):toFlag(),
+ active_teleporters_count = fn():callElse('getActiveTeleporters', {}):count(),
+ },
+ }
+
+ -- TODO does not support direction
+ self:withGenericMachineQueries()
+
+ -- getRedstoneMode
+end
+
+return TeleporterInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ThermalEvaporationPlantInputAdapter.lua b/src/telem/lib/input/mekanism/ThermalEvaporationPlantInputAdapter.lua
new file mode 100644
index 0000000..5dbc8c3
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ThermalEvaporationPlantInputAdapter.lua
@@ -0,0 +1,49 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ThermalEvaporationPlantInputAdapter = base.mintAdapter('ThermalEvaporationPlantInputAdapter')
+
+function ThermalEvaporationPlantInputAdapter:beforeRegister ()
+ self.prefix = 'mekevap:'
+
+ self.queries = {
+ basic = {
+ input_filled_percentage = fn():call('getInputFilledPercentage'),
+ output_filled_percentage = fn():call('getOutputFilledPercentage'),
+ input_input_item_count = fn():call('getInputItemInput'):get('count'):with('unit', 'item'),
+ input_output_item_count = fn():call('getInputItemOutput'):get('count'):with('unit', 'item'),
+ output_input_item_count = fn():call('getOutputItemInput'):get('count'):with('unit', 'item'),
+ output_output_item_count = fn():call('getOutputItemOutput'):get('count'):with('unit', 'item'),
+ production_amount = fn():call('getProductionAmount'):div(1000):fluidRate(),
+ temperature = fn():call('getTemperature'):temp(),
+ },
+ advanced = {
+ environmental_loss = fn():call('getEnvironmentalLoss'),
+ },
+ input = {
+ input = fn():call('getInput'):get('amount'):div(1000):fluid(),
+ input_capacity = fn():call('getInputCapacity'):div(1000):fluid(),
+ input_needed = fn():call('getInputNeeded'):div(1000):fluid(),
+ },
+ output = {
+ output = fn():call('getOutput'):get('amount'):div(1000):fluid(),
+ output_capacity = fn():call('getOutputCapacity'):div(1000):fluid(),
+ output_needed = fn():call('getOutputNeeded'):div(1000):fluid(),
+ },
+ formation = {
+ active_solars = fn():call('getActiveSolars'),
+ },
+ }
+
+ self:withMultiblockQueries()
+
+ -- TODO only supports comparator
+ -- self:withGenericMachineQueries()
+
+ -- getMinPos
+ -- getMaxPos
+ -- getComparatorLevel
+end
+
+return ThermalEvaporationPlantInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/ThermoelectricBoilerInputAdapter.lua b/src/telem/lib/input/mekanism/ThermoelectricBoilerInputAdapter.lua
new file mode 100644
index 0000000..56ef232
--- /dev/null
+++ b/src/telem/lib/input/mekanism/ThermoelectricBoilerInputAdapter.lua
@@ -0,0 +1,60 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local ThermoelectricBoilerInputAdapter = base.mintAdapter('ThermoelectricBoilerInputAdapter')
+
+function ThermoelectricBoilerInputAdapter:beforeRegister ()
+ self.prefix = 'mekboiler:'
+
+ local _, component = next(self.components)
+ local supportsEnvironmentalLoss = type(component.getEnvironmentalLoss) == 'function'
+
+ self.queries = {
+ basic = {
+ boil_rate = fn():call('getBoilRate'):div(1000):fluidRate(),
+ max_boil_rate = fn():call('getMaxBoilRate'):div(1000):fluidRate(),
+ temperature = fn():call('getTemperature'):temp(),
+ water_filled_percentage = fn():call('getWaterFilledPercentage'),
+ steam_filled_percentage = fn():call('getSteamFilledPercentage'),
+ cooled_coolant_filled_percentage = fn():call('getCooledCoolantFilledPercentage'),
+ heated_coolant_filled_percentage = fn():call('getHeatedCoolantFilledPercentage'),
+ },
+ water = {
+ water = fn():call('getWater'):get('amount'):div(1000):fluid(),
+ water_capacity = fn():call('getWaterCapacity'):div(1000):fluid(),
+ water_needed = fn():call('getWaterNeeded'):div(1000):fluid(),
+ },
+ steam = {
+ steam = fn():call('getSteam'):get('amount'):div(1000):fluid(),
+ steam_capacity = fn():call('getSteamCapacity'):div(1000):fluid(),
+ steam_needed = fn():call('getSteamNeeded'):div(1000):fluid(),
+ },
+ coolant = {
+ cooled_coolant = fn():call('getCooledCoolant'):get('amount'):div(1000):fluid(),
+ cooled_coolant_capacity = fn():call('getCooledCoolantCapacity'):div(1000):fluid(),
+ cooled_coolant_needed = fn():call('getCooledCoolantNeeded'):div(1000):fluid(),
+ heated_coolant = fn():call('getHeatedCoolant'):get('amount'):div(1000):fluid(),
+ heated_coolant_capacity = fn():call('getHeatedCoolantCapacity'):div(1000):fluid(),
+ heated_coolant_needed = fn():call('getHeatedCoolantNeeded'):div(1000):fluid(),
+ },
+ formation = {
+ superheaters = fn():call('getSuperheaters'),
+ boil_capacity = fn():call('getBoilCapacity'):div(1000):fluidRate(),
+ },
+ }
+
+ -- Mekanism 10.3+ only
+ if supportsEnvironmentalLoss then
+ self.queries.advanced = self.queries.advanced or {}
+ self.queries.advanced.environmental_loss = fn():call('getEnvironmentalLoss')
+ end
+
+ self:withMultiblockQueries()
+
+ -- getComparatorLevel
+ -- getMinPos
+ -- getMaxPos
+end
+
+return ThermoelectricBoilerInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/UniversalCableInputAdapter.lua b/src/telem/lib/input/mekanism/UniversalCableInputAdapter.lua
new file mode 100644
index 0000000..ea39d3d
--- /dev/null
+++ b/src/telem/lib/input/mekanism/UniversalCableInputAdapter.lua
@@ -0,0 +1,22 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local UniversalCableInputAdapter = base.mintAdapter('UniversalCableInputAdapter')
+
+function UniversalCableInputAdapter:beforeRegister ()
+ self.prefix = 'mekcable:'
+
+ self.queries = {
+ basic = {
+ filled_percentage = fn():call('getFilledPercentage')
+ },
+ transfer = {
+ buffer = fn():call('getBuffer'):joulesToFE():energy(),
+ capacity = fn():call('getCapacity'):joulesToFE():energy(),
+ needed = fn():call('getNeeded'):joulesToFE():energy(),
+ }
+ }
+end
+
+return UniversalCableInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/input/mekanism/WindGeneratorInputAdapter.lua b/src/telem/lib/input/mekanism/WindGeneratorInputAdapter.lua
new file mode 100644
index 0000000..9004f4c
--- /dev/null
+++ b/src/telem/lib/input/mekanism/WindGeneratorInputAdapter.lua
@@ -0,0 +1,23 @@
+local fn = require 'telem.vendor'.fluent.fn
+
+local base = require 'telem.lib.input.mekanism.BaseMekanismInputAdapter'
+
+local WindGeneratorInputAdapter = base.mintAdapter('WindGeneratorInputAdapter')
+
+function WindGeneratorInputAdapter:beforeRegister ()
+ self.prefix = 'mekwindgen:'
+
+ self.queries = {
+ basic = {
+ blacklisted_dimension = fn():call('isBlacklistedDimension'):toFlag(),
+ },
+ }
+
+ self:withGenericMachineQueries()
+ :withGeneratorQueries()
+
+ -- getDirection
+ -- getRedstoneMode
+end
+
+return WindGeneratorInputAdapter
\ No newline at end of file
diff --git a/src/telem/lib/middleware/CalcDeltaMiddleware.lua b/src/telem/lib/middleware/CalcDeltaMiddleware.lua
index 9e48e11..c56c92e 100644
--- a/src/telem/lib/middleware/CalcDeltaMiddleware.lua
+++ b/src/telem/lib/middleware/CalcDeltaMiddleware.lua
@@ -9,11 +9,14 @@ local Middleware = require 'telem.lib.BaseMiddleware'
local CalcDeltaMiddleware = o.class(Middleware)
CalcDeltaMiddleware.type = 'CalcDeltaMiddleware'
+local rateIntervalSourceFactors = { utc = 1000, ingame = 72000 }
+
function CalcDeltaMiddleware:constructor(windowSize)
self:super('constructor')
self.windowSize = windowSize or 50
self.rateInterval = 1
+ self.rateIntervalSource = 'utc'
self.forceProcess = false
self.history = {}
@@ -26,12 +29,15 @@ function CalcDeltaMiddleware:force()
return self
end
-function CalcDeltaMiddleware:interval(interval)
+function CalcDeltaMiddleware:interval(interval, source)
local factor, unit = interval:match('^(%d+)(%l)$')
+ source = source or 'utc'
assert(factor, 'CalcDeltaMiddleware:interval :: invalid interval format')
+ assert(source == 'utc' or source == 'ingame', 'CalcDeltaMiddleware:interval :: interval source must be "utc" or "ingame"')
- self.rateInterval = tonumber(factor) * fluent(unit):toLookup({ s = 1, m = 60, h = 3600, d = 86400 }):result()
+ self.rateInterval = tonumber(factor) * fluent(unit):toLookup({ t = 0.05, s = 1, m = 60, h = 3600, d = 86400 }):result()
+ self.rateIntervalSource = source
return self
end
@@ -43,7 +49,7 @@ function CalcDeltaMiddleware:handle(target)
end
function CalcDeltaMiddleware:handleCollection(collection)
- local timestamp = os.epoch('utc') / 1000
+ local timestamp = os.epoch(self.rateIntervalSource) / rateIntervalSourceFactors[self.rateIntervalSource]
for _, v in ipairs(collection.metrics) do
if self.forceProcess or v.source ~= 'middleware' then
diff --git a/src/telem/vendor/fluent-entrypoint.lua b/src/telem/vendor/fluent-entrypoint.lua
index c34d043..6faec2c 100644
--- a/src/telem/vendor/fluent-entrypoint.lua
+++ b/src/telem/vendor/fluent-entrypoint.lua
@@ -67,4 +67,47 @@ function Fluent:metricable()
end)
end
+--- Call a method on the value. Returns the result of the call, or `elseValue` if the call errors.
+---@param method string Method name
+---@param elseValue any Value to set if the call errors
+---@param ... any Method arguments
+function Fluent:callElse (method, elseValue, ...)
+ local args = {...}
+
+ return self:_enqueue(function (this)
+ local success, result = pcall(this.value[method], table.unpack(args))
+
+ if not success then
+ this.value = elseValue
+
+ return
+ end
+
+ this.value = result
+ end)
+end
+
+--- Return the length of the value using `#value`.
+function Fluent:count ()
+ return self:_enqueue(function (this)
+ this.value = #this.value
+ end)
+end
+
+--- Flatten the value's elements into a single list.
+--- Order of elements is not guaranteed.
+function Fluent:flatten ()
+ return self:_enqueue(function (this)
+ local flattened = {}
+
+ for _, v in pairs(this.value) do
+ for _, vv in pairs(v) do
+ table.insert(flattened, vv)
+ end
+ end
+
+ this.value = flattened
+ end)
+end
+
return Fluent
\ No newline at end of file
diff --git a/src/telem/vendor/fluent.lua b/src/telem/vendor/fluent.lua
index 4915858..7c155c2 100644
--- a/src/telem/vendor/fluent.lua
+++ b/src/telem/vendor/fluent.lua
@@ -343,6 +343,69 @@ function Fluent:has (key)
end)
end
+--- Remove any elements from the value that are not in the provided list.
+---
+--- The result keys are determined by the first key of the current value.
+--- If it is numeric, the result will be reindexed numerically.
+--- Otherwise, the current value's keys will be preserved.
+---@param superset any[]
+function Fluent:intersect (superset)
+ return self:_enqueue(function (this)
+ local result = {}
+
+ local iter = type(next(this.value)) == 'number' and ipairs or pairs
+
+ for k, v in iter(this.value) do
+ for _, ov in iter(superset) do
+ if v == ov then
+ if iter == ipairs then
+ table.insert(result, v)
+ else
+ result[k] = v
+ end
+ end
+ end
+ end
+
+ this.value = result
+ end)
+end
+
+--- Return a list of elements from the value that are not in the provided list.
+---
+--- The result keys are determined by the first key of the current value.
+--- If it is numeric, the result will be reindexed numerically.
+--- Otherwise, the current value's keys will be preserved.
+---@param superset any[]
+function Fluent:diff (superset)
+ return self:_enqueue(function (this)
+ local result = {}
+
+ local iter = type(next(this.value)) == 'number' and ipairs or pairs
+
+ for k, v in iter(this.value) do
+ local found = false
+
+ for _, ov in iter(superset) do
+ if v == ov then
+ found = true
+ break
+ end
+ end
+
+ if not found then
+ if iter == ipairs then
+ table.insert(result, v)
+ else
+ result[k] = v
+ end
+ end
+ end
+
+ this.value = result
+ end)
+end
+
--- Get a list of the value's keys.
function Fluent:keys ()
return self:_enqueue(function (this)
@@ -512,11 +575,13 @@ end
---@param initial any
function Fluent:reduce (func, initial)
return self:_enqueue(function (this)
+ local innerInitial = initial
+
for k, v in pairs(this.value) do
- initial = func(initial, k, v)
+ innerInitial = func(innerInitial, k, v)
end
- this.value = initial
+ this.value = innerInitial
end)
end
diff --git a/src/telem/vendor/init.lua b/src/telem/vendor/init.lua
index 7764eef..ff67856 100644
--- a/src/telem/vendor/init.lua
+++ b/src/telem/vendor/init.lua
@@ -1,6 +1,6 @@
-- Telem Vendor Loader by cyberbit
-- MIT License
--- Version 0.7.1
+-- Version 0.8.0
-- Submodules are copyright of their respective authors. For licensing, see https://github.com/cyberbit/telem/blob/main/LICENSE
if package.path:find('telem/vendor') == nil then package.path = package.path .. ';telem/vendor/?;telem/vendor/?.lua;telem/vendor/?/init.lua' end