mirror of
https://github.com/S4mpsa/InfOS.git
synced 2025-09-08 06:38:57 -04:00
Adding listMiners usecase
This commit is contained in:
parent
b38f8297fd
commit
fb4c96a7ff
@ -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
|
||||
|
25
Programs/monitor-system/domain/miner/list-miners-usecase.lua
Normal file
25
Programs/monitor-system/domain/miner/list-miners-usecase.lua
Normal 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
|
Loading…
x
Reference in New Issue
Block a user