mirror of
https://github.com/S4mpsa/InfOS.git
synced 2025-08-03 18:06:04 -04:00
Adding types to machine.lua
Fixing `powerWidget.getMiddleString` bug
This commit is contained in:
parent
c4a46b15dc
commit
598cfeb95b
@ -251,16 +251,16 @@ end
|
||||
function widget.createPowerWidget(address)
|
||||
local getPowerStatus = require("domain.energy.get-energy-status-usecase")
|
||||
local function update(self)
|
||||
for key, value in pairs(getPowerStatus(address, "power")) do
|
||||
for key, value in pairs(getPowerStatus(address, self.name)) do
|
||||
self[key] = value
|
||||
end
|
||||
end
|
||||
|
||||
local function getMiddleString(self)
|
||||
local time = self.timeToFull or self.timeToEmpty .. " s"
|
||||
local time = self.timeToFull or self.timeToEmpty or 0
|
||||
return (self.dProgress > 0 and "+" or "") ..
|
||||
self.dProgress ..
|
||||
" EU/s. " .. (self.dProgress > 0 and " Full in: " or "Empty in: ") .. Utility.splitNumber(time)
|
||||
" EU/s. " .. (self.dProgress >= 0 and " Full in: " or "Empty in: ") .. Utility.splitNumber(time) .. " s"
|
||||
end
|
||||
|
||||
local powerWidget = {
|
||||
|
30
Programs/monitor-system/data/datasource/machine.lua
Normal file
30
Programs/monitor-system/data/datasource/machine.lua
Normal file
@ -0,0 +1,30 @@
|
||||
-- Import section
|
||||
local mock = require("data.mock.mock-energy-provider")
|
||||
EnergyProvider = require("data.datasource.energy-provider")
|
||||
Inherits = require("utils.inherits")
|
||||
--
|
||||
|
||||
local machine = Inherits(EnergyProvider)
|
||||
local machines = {}
|
||||
machine.types = {
|
||||
energy = "energy",
|
||||
multiblock = "multiblock",
|
||||
singleblock = "singleblock"
|
||||
}
|
||||
|
||||
function machine.getMachine(address, name, type)
|
||||
if machines[address] then
|
||||
return machines[address]
|
||||
else
|
||||
local mach = {}
|
||||
if type == machine.types.energy then
|
||||
print(machine.name)
|
||||
elseif type == machine.types.multiblock then
|
||||
end
|
||||
mach = machine:new(address, name)
|
||||
machines[address] = mach
|
||||
return mach
|
||||
end
|
||||
end
|
||||
|
||||
return machine
|
@ -1,27 +0,0 @@
|
||||
-- Import section
|
||||
local mock = require("data.mock.mock-energy-provider")
|
||||
EnergyProvider = require("data.datasource.energy-provider")
|
||||
Inherits = require("utils.inherits")
|
||||
--
|
||||
|
||||
local machine =
|
||||
Inherits(
|
||||
EnergyProvider,
|
||||
{
|
||||
mock = mock,
|
||||
name = "Generic Machine"
|
||||
}
|
||||
)
|
||||
local machines = {}
|
||||
|
||||
function machine.getMachine(address, name)
|
||||
if machines[address] then
|
||||
return machines[address]
|
||||
else
|
||||
local mach = machine:new(address, name)
|
||||
machines[address] = mach
|
||||
return mach
|
||||
end
|
||||
end
|
||||
|
||||
return machine
|
Loading…
x
Reference in New Issue
Block a user