mirror of
https://github.com/S4mpsa/InfOS.git
synced 2025-09-08 14:46:24 -04:00
Changing getMultiblockstatusUsecase
to consider a single machine.
Returning progress, state, problems, efficiency and consumption
This commit is contained in:
parent
fc6b6db776
commit
94ea75be6a
@ -1,22 +1,41 @@
|
|||||||
-- Import section
|
-- Import section
|
||||||
|
Machine = require("data.datasource.machine")
|
||||||
Alarm = require("api.sound.alarm")
|
Alarm = require("api.sound.alarm")
|
||||||
--
|
--
|
||||||
|
|
||||||
local function exec(multiblocks)
|
local function exec(address, name)
|
||||||
local statuses = {}
|
local multiblock = Machine.getMachine(address, name, Machine.types.multiblock)
|
||||||
for _, multiblock in ipairs(multiblocks) do
|
local status = {}
|
||||||
local problems = multiblock:getNumberOfProblems()
|
local problems = multiblock:getNumberOfProblems()
|
||||||
if problems > 0 then
|
|
||||||
Alarm()
|
local state = {}
|
||||||
|
if multiblock:isMachineEnabled() then
|
||||||
|
if multiblock:hasWork() then
|
||||||
|
state = Machine.states.ON
|
||||||
|
else
|
||||||
|
state = Machine.states.IDLE
|
||||||
|
end
|
||||||
|
else
|
||||||
|
state = Machine.states.OFF
|
||||||
end
|
end
|
||||||
|
|
||||||
statuses[multiblock.name] = {
|
if problems > 0 then
|
||||||
|
state = Machine.states.BROKEN
|
||||||
|
end
|
||||||
|
|
||||||
|
local totalProgress = multiblock:getProgress()
|
||||||
|
local maxProgress = totalProgress.maximum
|
||||||
|
local progress = totalProgress.current
|
||||||
|
|
||||||
|
status[multiblock.name] = {
|
||||||
|
progress = progress,
|
||||||
|
maxProgress = maxProgress,
|
||||||
problems = problems,
|
problems = problems,
|
||||||
probablyUses = multiblock:getEnergyUsage(),
|
probablyUses = multiblock:getEnergyUsage(),
|
||||||
efficiencyPercentage = multiblock:getEfficiencyPercentage()
|
efficiencyPercentage = multiblock:getEfficiencyPercentage(),
|
||||||
|
state = state
|
||||||
}
|
}
|
||||||
end
|
return status
|
||||||
return statuses
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return exec
|
return exec
|
||||||
|
Loading…
x
Reference in New Issue
Block a user