Adding listMiners usecase

This commit is contained in:
Gabriel Moreira Minossi 2021-01-03 14:49:37 -03:00
parent b38f8297fd
commit fb4c96a7ff
3 changed files with 28 additions and 3 deletions

View File

@ -2,7 +2,7 @@
parser = require("utils.parser")
inherits = require("utils.inherits")
SingleBlock = require("data.datasource.single-block")
local mock = require("data.mock.mock-multi-block")
local mock = require("data.mock.mock-miner")
--
local Miner =
@ -16,10 +16,10 @@ local Miner =
function Miner:getName()
local sensorInformation = self:getSensorInformation()
return parser.parseProblems(sensorInformation[1])
return parser.parseName(sensorInformation[1])
end
function Miner:getWoarkArea()
function Miner:getWorkArea()
local sensorInformation = self:getSensorInformation()
return parser.parseWorkArea(sensorInformation[2])
end

View File

@ -0,0 +1,25 @@
-- Import section
event = require("event")
local minerDatasource = require("data.datasource.miner")
--
local minerList = {}
local newMiners = {}
local function addToMinerList(_, address, machine)
if minerDatasource.getName(machine.getSensorInformation()) == "Multiblock Miner" then
if minerList[address] == nil then
newMiners[address] = machine
else
newMiners[address] = nil
end
minerList[address] = machine
end
end
event.listen("component_added", addToMinerList)
local function exec()
return minerList, newMiners
end
return exec