mirror of
https://github.com/S4mpsa/InfOS.git
synced 2025-09-10 15:46:27 -04:00
Merge pull request #4 from gordominossi/feature/miner-status
Feature/miner status
This commit is contained in:
commit
0c34422d75
@ -2,7 +2,7 @@
|
|||||||
parser = require("utils.parser")
|
parser = require("utils.parser")
|
||||||
inherits = require("utils.inherits")
|
inherits = require("utils.inherits")
|
||||||
SingleBlock = require("data.datasource.single-block")
|
SingleBlock = require("data.datasource.single-block")
|
||||||
local mock = require("data.mock.mock-multi-block")
|
local mock = require("data.mock.mock-miner")
|
||||||
--
|
--
|
||||||
|
|
||||||
local Miner =
|
local Miner =
|
||||||
@ -16,10 +16,10 @@ local Miner =
|
|||||||
|
|
||||||
function Miner:getName()
|
function Miner:getName()
|
||||||
local sensorInformation = self:getSensorInformation()
|
local sensorInformation = self:getSensorInformation()
|
||||||
return parser.parseProblems(sensorInformation[1])
|
return parser.parseName(sensorInformation[1])
|
||||||
end
|
end
|
||||||
|
|
||||||
function Miner:getWoarkArea()
|
function Miner:getWorkArea()
|
||||||
local sensorInformation = self:getSensorInformation()
|
local sensorInformation = self:getSensorInformation()
|
||||||
return parser.parseWorkArea(sensorInformation[2])
|
return parser.parseWorkArea(sensorInformation[2])
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
local function exec(miner)
|
||||||
|
return miner.isMachineActive() and miner.hasWork() -- TODO: differenciate cases
|
||||||
|
end
|
||||||
|
|
||||||
|
return exec
|
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