mirror of
https://github.com/S4mpsa/InfOS.git
synced 2025-08-04 02:16:05 -04:00
Merge pull request #12 from gordominossi/feature/integration-machines
Feature/integration machines
This commit is contained in:
commit
4139d3b215
@ -1,16 +1,16 @@
|
|||||||
local Parser = {}
|
local parser = {}
|
||||||
|
|
||||||
function Parser.parseProgress(progressString)
|
function parser.parseProgress(progressString)
|
||||||
local current = string.sub(progressString, string.find(progressString, "%ba§"))
|
local current = string.sub(progressString, string.find(progressString, "%ba§"))
|
||||||
current = tonumber((string.gsub(string.gsub(current, "a", ""), "§", "")))
|
current = tonumber((string.gsub(string.gsub(current, "a", ""), "§", "")))
|
||||||
|
|
||||||
local maximum = string.sub(progressString, string.find(progressString, "%be§"))
|
local maximum = string.sub(progressString, string.find(progressString, "%be§", (string.find(progressString, "/"))))
|
||||||
maximum = tonumber((string.gsub(string.gsub(maximum, "e", ""), "§", "")))
|
maximum = tonumber((string.gsub(string.gsub(maximum, "e", ""), "§", "")))
|
||||||
|
|
||||||
return {current = current, maximum = maximum}
|
return {current = current, maximum = maximum}
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parser.parseStoredEnergy(storedEnergyString)
|
function parser.parseStoredEnergy(storedEnergyString)
|
||||||
local noCommaString = string.gsub(storedEnergyString, ",", "")
|
local noCommaString = string.gsub(storedEnergyString, ",", "")
|
||||||
|
|
||||||
local current = string.sub(noCommaString, string.find(noCommaString, "%ba§"))
|
local current = string.sub(noCommaString, string.find(noCommaString, "%ba§"))
|
||||||
@ -22,40 +22,40 @@ function Parser.parseStoredEnergy(storedEnergyString)
|
|||||||
return {current = current, maximum = maximum}
|
return {current = current, maximum = maximum}
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parser.parseAverageInput(averageInputString)
|
function parser.parseAverageInput(averageInputString)
|
||||||
local noCommaString = string.gsub(averageInputString, ",", "")
|
local noCommaString = string.gsub(averageInputString, ",", "")
|
||||||
return tonumber((string.sub(noCommaString, string.find(noCommaString, "%d+"))))
|
return tonumber((string.sub(noCommaString, string.find(noCommaString, "%d+"))))
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parser.parseAverageOutput(averageOutputString)
|
function parser.parseAverageOutput(averageOutputString)
|
||||||
local noCommaString = string.gsub(averageOutputString, ",", "")
|
local noCommaString = string.gsub(averageOutputString, ",", "")
|
||||||
return tonumber((string.sub(noCommaString, string.find(noCommaString, "%d+"))))
|
return tonumber((string.sub(noCommaString, string.find(noCommaString, "%d+"))))
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parser.parseProblems(problemsString)
|
function parser.parseProblems(problemsString)
|
||||||
local problems = string.sub(problemsString, string.find(problemsString, "c%d"))
|
local problems = string.sub(problemsString, string.find(problemsString, "c%d"))
|
||||||
return tonumber((string.gsub(problems, "c", "")))
|
return tonumber((string.gsub(problems, "c", "")))
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parser.parseEfficiency(efficiencyString)
|
function parser.parseEfficiency(efficiencyString)
|
||||||
local noParagraphMarkString = string.gsub(efficiencyString, "§r", "")
|
local noParagraphMarkString = string.gsub(efficiencyString, "§r", "")
|
||||||
local efficiency = string.sub(noParagraphMarkString, string.find(noParagraphMarkString, "%d+%.*%d*%s%%"))
|
local efficiency = string.sub(noParagraphMarkString, string.find(noParagraphMarkString, "%d+%.*%d*%s%%"))
|
||||||
return tonumber((string.gsub(efficiency, "%s%%", "")))
|
return tonumber((string.gsub(efficiency, "%s%%", "")))
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parser.parseName(nameString)
|
function parser.parseName(nameString)
|
||||||
return string.gsub(string.gsub(nameString, "§9", ""), "§r", "")
|
return string.gsub(string.gsub(nameString, "§9", ""), "§r", "")
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parser.parseWorkArea(worAreaString)
|
function parser.parseWorkArea(worAreaString)
|
||||||
local size = string.sub(worAreaString, string.find(worAreaString, "§a%d+x%d+§r"))
|
local size = string.sub(worAreaString, string.find(worAreaString, "§a%d+x%d+§r"))
|
||||||
return string.gsub(string.gsub(size, "§a", ""), "§r", "")
|
return string.gsub(string.gsub(size, "§a", ""), "§r", "")
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parser.parseProbablyUses(probablyUsesString)
|
function parser.parseProbablyUses(probablyUsesString)
|
||||||
local noCommaString = string.gsub(probablyUsesString, ",", "")
|
local noCommaString = string.gsub(probablyUsesString, ",", "")
|
||||||
local estimate = string.sub(noCommaString, string.find(noCommaString, "%bc§"))
|
local estimate = string.sub(noCommaString, string.find(noCommaString, "%bc§"))
|
||||||
return tonumber((string.gsub(string.gsub(estimate, "c", ""), "§", "")))
|
return tonumber((string.gsub(string.gsub(estimate, "c", ""), "§", "")))
|
||||||
end
|
end
|
||||||
|
|
||||||
return Parser
|
return parser
|
||||||
|
@ -95,15 +95,7 @@ local function drawRebootButton()
|
|||||||
Widget.drawBaseWidget(x, y, width, height, "Restart")
|
Widget.drawBaseWidget(x, y, width, height, "Restart")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function clickNavigationButton(self)
|
local function refreshActiveMachineWidgets()
|
||||||
if not self.active then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if self.title == "◀" then
|
|
||||||
elements.machineWidgets.active.index = elements.machineWidgets.active.index - 1
|
|
||||||
else
|
|
||||||
elements.machineWidgets.active.index = elements.machineWidgets.active.index + 1
|
|
||||||
end
|
|
||||||
for i = 1, 9 do
|
for i = 1, 9 do
|
||||||
elements.machineWidgets.active[i] = elements.machineWidgets[9 * (elements.machineWidgets.active.index - 1) + i]
|
elements.machineWidgets.active[i] = elements.machineWidgets[9 * (elements.machineWidgets.active.index - 1) + i]
|
||||||
end
|
end
|
||||||
@ -117,12 +109,29 @@ local function clickNavigationButton(self)
|
|||||||
elements[14] = elements.machineWidgets.active[7]
|
elements[14] = elements.machineWidgets.active[7]
|
||||||
elements[15] = elements.machineWidgets.active[8]
|
elements[15] = elements.machineWidgets.active[8]
|
||||||
elements[16] = elements.machineWidgets.active[9]
|
elements[16] = elements.machineWidgets.active[9]
|
||||||
|
|
||||||
Widget.clear()
|
Widget.clear()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function clickNavigationButton(self)
|
||||||
|
if not self.active then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.title == "◀" then
|
||||||
|
elements.machineWidgets.active.index = elements.machineWidgets.active.index - 1
|
||||||
|
else
|
||||||
|
elements.machineWidgets.active.index = elements.machineWidgets.active.index + 1
|
||||||
|
end
|
||||||
|
refreshActiveMachineWidgets()
|
||||||
|
end
|
||||||
|
|
||||||
function page.create(element)
|
function page.create(element)
|
||||||
drawTitle(element.title)
|
drawTitle(element.title)
|
||||||
|
|
||||||
|
elements.machineWidgets.active = {}
|
||||||
|
elements.machineWidgets.active.index = 1
|
||||||
|
refreshActiveMachineWidgets()
|
||||||
|
|
||||||
local panelIndex = 1
|
local panelIndex = 1
|
||||||
for _, pg in ipairs(pages) do
|
for _, pg in ipairs(pages) do
|
||||||
if pg ~= element then
|
if pg ~= element then
|
||||||
@ -136,12 +145,11 @@ function page.create(element)
|
|||||||
panelIndex = panelIndex + 1
|
panelIndex = panelIndex + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elements[1] = elements.panelSections[1]
|
||||||
elements.machineWidgets.active = {}
|
elements[5] = elements.panelSections[2]
|
||||||
elements.machineWidgets.active.index = 1
|
elements[9] = elements.panelSections[3]
|
||||||
for i = 1, 9 do
|
elements[13] = elements.panelSections[4]
|
||||||
elements.machineWidgets.active[i] = elements.machineWidgets[9 * (elements.machineWidgets.active.index - 1) + i]
|
elements[17] = elements.panelSections[5]
|
||||||
end
|
|
||||||
|
|
||||||
elements.navigationButtons[1] = {
|
elements.navigationButtons[1] = {
|
||||||
title = "◀",
|
title = "◀",
|
||||||
@ -161,6 +169,8 @@ function page.create(element)
|
|||||||
onClick = clickNavigationButton,
|
onClick = clickNavigationButton,
|
||||||
draw = drawNavigationButton
|
draw = drawNavigationButton
|
||||||
}
|
}
|
||||||
|
elements[20] = elements.navigationButtons[1]
|
||||||
|
elements[20.5] = elements.navigationButtons[2]
|
||||||
|
|
||||||
elements.rebootButton = {
|
elements.rebootButton = {
|
||||||
onClick = function()
|
onClick = function()
|
||||||
@ -168,30 +178,10 @@ function page.create(element)
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
drawRebootButton()
|
drawRebootButton()
|
||||||
|
|
||||||
elements[4.5] = elements.rebootButton
|
elements[4.5] = elements.rebootButton
|
||||||
|
|
||||||
elements[6] = elements.machineWidgets.active[1]
|
|
||||||
elements[7] = elements.machineWidgets.active[2]
|
|
||||||
elements[8] = elements.machineWidgets.active[3]
|
|
||||||
elements[10] = elements.machineWidgets.active[4]
|
|
||||||
elements[11] = elements.machineWidgets.active[5]
|
|
||||||
elements[12] = elements.machineWidgets.active[6]
|
|
||||||
elements[14] = elements.machineWidgets.active[7]
|
|
||||||
elements[15] = elements.machineWidgets.active[8]
|
|
||||||
elements[16] = elements.machineWidgets.active[9]
|
|
||||||
|
|
||||||
elements[18] = elements.powerWidget
|
elements[18] = elements.powerWidget
|
||||||
elements[19] = elements.powerWidget
|
elements[19] = elements.powerWidget
|
||||||
|
|
||||||
elements[1] = elements.panelSections[1]
|
|
||||||
elements[5] = elements.panelSections[2]
|
|
||||||
elements[9] = elements.panelSections[3]
|
|
||||||
elements[13] = elements.panelSections[4]
|
|
||||||
elements[17] = elements.panelSections[5]
|
|
||||||
|
|
||||||
elements[20] = elements.navigationButtons[1]
|
|
||||||
elements[20.5] = elements.navigationButtons[2]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function page.fake()
|
function page.fake()
|
||||||
@ -200,8 +190,10 @@ function page.fake()
|
|||||||
page.create(pages.overview)
|
page.create(pages.overview)
|
||||||
end
|
end
|
||||||
|
|
||||||
function page.setup(energyBufferAddress)
|
function page.setup(energyBufferAddress, multiblockAddresses)
|
||||||
elements.machineWidgets = Widget.fakeWidgets()
|
for name, address in pairs(multiblockAddresses) do
|
||||||
|
table.insert(elements.machineWidgets, Widget.createMachineWidget(address, name))
|
||||||
|
end
|
||||||
elements.powerWidget = Widget.createPowerWidget(energyBufferAddress)
|
elements.powerWidget = Widget.createPowerWidget(energyBufferAddress)
|
||||||
page.create(pages.overview)
|
page.create(pages.overview)
|
||||||
end
|
end
|
||||||
@ -211,7 +203,7 @@ function page.update()
|
|||||||
machineWidget:update()
|
machineWidget:update()
|
||||||
end
|
end
|
||||||
for index, activeMachineWidget in ipairs(elements.machineWidgets.active) do
|
for index, activeMachineWidget in ipairs(elements.machineWidgets.active) do
|
||||||
activeMachineWidget.draw(activeMachineWidget, index)
|
activeMachineWidget:draw(index)
|
||||||
end
|
end
|
||||||
|
|
||||||
elements.powerWidget:update()
|
elements.powerWidget:update()
|
||||||
|
@ -15,8 +15,9 @@ local states = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local types = {
|
local types = {
|
||||||
power = "power",
|
POWER = "POWER",
|
||||||
machine = "machine"
|
MULTIBLOCK = "MULTIBLOCK",
|
||||||
|
MACHINE = "MACHINE"
|
||||||
}
|
}
|
||||||
|
|
||||||
local function drawProgress(x, y, width, height, progress, maxProgress, color)
|
local function drawProgress(x, y, width, height, progress, maxProgress, color)
|
||||||
@ -70,7 +71,7 @@ function widget.drawBaseWidget(x, y, width, height, title)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function draw(self, index)
|
local function draw(self, index)
|
||||||
if self.type == types.power then
|
if self.type == types.POWER then
|
||||||
index = 10
|
index = 10
|
||||||
end
|
end
|
||||||
local scale = self.scale or 1
|
local scale = self.scale or 1
|
||||||
@ -198,7 +199,7 @@ function fake.machineWidget.create()
|
|||||||
state = state,
|
state = state,
|
||||||
progress = 0,
|
progress = 0,
|
||||||
maxProgress = state ~= states[3] and state ~= states[4] and math.random(500) or 0,
|
maxProgress = state ~= states[3] and state ~= states[4] and math.random(500) or 0,
|
||||||
type = "machine",
|
type = types.MACHINE,
|
||||||
update = fake.machineWidget.update,
|
update = fake.machineWidget.update,
|
||||||
onClick = fake.machineWidget.onClick,
|
onClick = fake.machineWidget.onClick,
|
||||||
getMiddleString = fake.machineWidget.getMiddleString,
|
getMiddleString = fake.machineWidget.getMiddleString,
|
||||||
@ -206,6 +207,34 @@ function fake.machineWidget.create()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function widget.createMachineWidget(address, name)
|
||||||
|
local getMultiblockStatus = require("domain.multiblock.get-multiblock-status-usecase")
|
||||||
|
local function update(self)
|
||||||
|
for key, value in pairs(getMultiblockStatus(address, self.name)) do
|
||||||
|
self[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local toggleMultiblockWork = require("domain.multiblock.toggle-multiblock-work")
|
||||||
|
local function onClick(self)
|
||||||
|
toggleMultiblockWork(address, self.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
local machineWidget = {
|
||||||
|
name = name,
|
||||||
|
type = types.MULTIBLOCK,
|
||||||
|
update = update,
|
||||||
|
onClick = onClick,
|
||||||
|
getMiddleString = function()
|
||||||
|
end,
|
||||||
|
draw = draw
|
||||||
|
}
|
||||||
|
|
||||||
|
machineWidget:update()
|
||||||
|
|
||||||
|
return machineWidget
|
||||||
|
end
|
||||||
|
|
||||||
fake.powerWidget = {}
|
fake.powerWidget = {}
|
||||||
|
|
||||||
function fake.powerWidget:update()
|
function fake.powerWidget:update()
|
||||||
@ -231,7 +260,7 @@ function fake.powerWidget.create()
|
|||||||
maxProgress = 16000000,
|
maxProgress = 16000000,
|
||||||
dProgress = 1,
|
dProgress = 1,
|
||||||
scale = 2,
|
scale = 2,
|
||||||
type = types.power,
|
type = types.POWER,
|
||||||
update = fake.powerWidget.update,
|
update = fake.powerWidget.update,
|
||||||
onClick = fake.powerWidget.onClick,
|
onClick = fake.powerWidget.onClick,
|
||||||
getMiddleString = fake.powerWidget.getMiddleString,
|
getMiddleString = fake.powerWidget.getMiddleString,
|
||||||
@ -269,7 +298,7 @@ function widget.createPowerWidget(address)
|
|||||||
local powerWidget = {
|
local powerWidget = {
|
||||||
name = "Power",
|
name = "Power",
|
||||||
scale = 2,
|
scale = 2,
|
||||||
type = types.power,
|
type = types.POWER,
|
||||||
update = update,
|
update = update,
|
||||||
onClick = function()
|
onClick = function()
|
||||||
end,
|
end,
|
||||||
|
@ -1,27 +1,40 @@
|
|||||||
-- Import section
|
-- Import section
|
||||||
local mock = require("data.mock.mock-energy-provider")
|
local mock = require("data.mock.mock-energy-provider")
|
||||||
EnergyProvider = require("data.datasource.energy-provider")
|
EnergyProvider = require("data.datasource.energy-provider")
|
||||||
|
MultiBlock = require("data.datasource.multi-block")
|
||||||
Inherits = require("utils.inherits")
|
Inherits = require("utils.inherits")
|
||||||
--
|
--
|
||||||
|
|
||||||
local machine = Inherits(EnergyProvider)
|
local machine = Inherits(EnergyProvider)
|
||||||
local machines = {}
|
local machines = {}
|
||||||
|
|
||||||
machine.types = {
|
machine.types = {
|
||||||
energy = "energy",
|
energy = "energy",
|
||||||
multiblock = "multiblock",
|
multiblock = "multiblock",
|
||||||
singleblock = "singleblock"
|
singleblock = "singleblock"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
machine.states = {
|
||||||
|
ON = {name = "ON", color = Colors.workingColor},
|
||||||
|
FULL = {name = "FULL", color = Colors.workingColor},
|
||||||
|
IDLE = {name = "IDLE", color = Colors.idleColor},
|
||||||
|
FILLING = {name = "FILLING", color = Colors.idleColor},
|
||||||
|
OFF = {name = "OFF", color = Colors.offColor},
|
||||||
|
DRAINING = {name = "DRAINING", color = Colors.offColor},
|
||||||
|
BROKEN = {name = "BROKEN", color = Colors.errorColor},
|
||||||
|
EMPTY = {name = "EMPTY", color = Colors.errorColor}
|
||||||
|
}
|
||||||
|
|
||||||
function machine.getMachine(address, name, type)
|
function machine.getMachine(address, name, type)
|
||||||
if machines[address] then
|
if machines[address] then
|
||||||
return machines[address]
|
return machines[address]
|
||||||
else
|
else
|
||||||
local mach = {}
|
local mach = {}
|
||||||
if type == machine.types.energy then
|
if type == machine.types.energy then
|
||||||
print(machine.name)
|
mach = EnergyProvider:new(address, name)
|
||||||
elseif type == machine.types.multiblock then
|
elseif type == machine.types.multiblock then
|
||||||
|
mach = MultiBlock:new(address, name)
|
||||||
end
|
end
|
||||||
mach = machine:new(address, name)
|
|
||||||
machines[address] = mach
|
machines[address] = mach
|
||||||
return mach
|
return mach
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,16 @@ local MultiBlock =
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function Parser.parseProgress(progressString)
|
||||||
|
local current = string.sub(progressString, string.find(progressString, "%ba§"))
|
||||||
|
current = tonumber((string.gsub(string.gsub(current, "a", ""), "§", "")))
|
||||||
|
|
||||||
|
local maximum = string.sub(progressString, string.find(progressString, "%be§", (string.find(progressString, "/"))))
|
||||||
|
maximum = tonumber((string.gsub(string.gsub(maximum, "e", ""), "§", "")))
|
||||||
|
|
||||||
|
return {current = current, maximum = maximum}
|
||||||
|
end
|
||||||
|
|
||||||
function MultiBlock:getNumberOfProblems()
|
function MultiBlock:getNumberOfProblems()
|
||||||
local sensorInformation = self:getSensorInformation()
|
local sensorInformation = self:getSensorInformation()
|
||||||
return Parser.parseProblems(sensorInformation[5])
|
return Parser.parseProblems(sensorInformation[5])
|
||||||
|
@ -7,20 +7,36 @@ local MockMultiBlock =
|
|||||||
Inherits(
|
Inherits(
|
||||||
MockSingleBlock,
|
MockSingleBlock,
|
||||||
{
|
{
|
||||||
name = "MockMultiBlock"
|
name = "MockMultiBlock",
|
||||||
|
isBroken = false
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
function MockMultiBlock.getSensorInformation()
|
function MockMultiBlock.getSensorInformation()
|
||||||
|
MockMultiBlock.workProgress = MockMultiBlock.workProgress + 1
|
||||||
|
if MockMultiBlock.workProgress > MockMultiBlock.workMaxProgress then
|
||||||
|
MockMultiBlock.workProgress = 0
|
||||||
|
end
|
||||||
|
if MockMultiBlock.workAllowed and not MockMultiBlock.isBroken and math.random(1000) > 999 then
|
||||||
|
MockMultiBlock.workMaxProgress = math.random(500)
|
||||||
|
end
|
||||||
|
MockMultiBlock.isBroken = MockMultiBlock.isBroken or math.random(100000) > 99999
|
||||||
return {
|
return {
|
||||||
"Progress: §a2§r s / §e5§r s",
|
"Progress: §a" .. MockMultiBlock.workProgress .. "§r s / §e" .. MockMultiBlock.workMaxProgress .. "§r s",
|
||||||
"Stored Energy: §a1000§r EU / §e1000§r EU",
|
"Stored Energy: §a1000§r EU / §e1000§r EU",
|
||||||
"Probably uses: §c4§r EU/t",
|
"Probably uses: §c4§r EU/t",
|
||||||
"Max Energy Income: §e128§r EU/t(x2A) Tier: §eMV§r",
|
"Max Energy Income: §e128§r EU/t(x2A) Tier: §eMV§r",
|
||||||
"Problems: §c0§r Efficiency: §e100.0§r %",
|
"Problems: §c" .. (MockMultiBlock.isBroken and 1 or 0) .. "§r Efficiency: §e100.0§r %",
|
||||||
"Pollution reduced to: §a0§r %",
|
"Pollution reduced to: §a0§r %",
|
||||||
n = 6
|
n = 6
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function MockMultiBlock.setWorkAllowed(allow)
|
||||||
|
if MockMultiBlock.isBroken then
|
||||||
|
MockMultiBlock.isBroken = false
|
||||||
|
end
|
||||||
|
MockMultiBlock.workAllowed = allow
|
||||||
|
end
|
||||||
|
|
||||||
return MockMultiBlock
|
return MockMultiBlock
|
||||||
|
@ -1,22 +1,38 @@
|
|||||||
-- Import section
|
-- Import section
|
||||||
Alarm = require("api.sound.alarm")
|
Machine = require("data.datasource.machine")
|
||||||
--
|
--
|
||||||
|
|
||||||
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:isWorkAllowed() 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()
|
||||||
|
|
||||||
|
status = {
|
||||||
|
progress = totalProgress.current,
|
||||||
|
maxProgress = totalProgress.maximum,
|
||||||
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
|
||||||
|
12
Programs/monitor-system/domain/multiblock/toggle-multiblock-work.lua
Executable file
12
Programs/monitor-system/domain/multiblock/toggle-multiblock-work.lua
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
-- Import section
|
||||||
|
Machine = require("data.datasource.machine")
|
||||||
|
Alarm = require("api.sound.alarm")
|
||||||
|
--
|
||||||
|
|
||||||
|
local function exec(address, name)
|
||||||
|
local multiblock = Machine.getMachine(address, name, Machine.types.multiblock)
|
||||||
|
local workAllowed = multiblock:isWorkAllowed()
|
||||||
|
multiblock:setWorkAllowed(not workAllowed)
|
||||||
|
end
|
||||||
|
|
||||||
|
return exec
|
@ -7,7 +7,7 @@ Page = require("api.gui.page")
|
|||||||
EnergyProvider = require("data.datasource.energy-provider")
|
EnergyProvider = require("data.datasource.energy-provider")
|
||||||
|
|
||||||
-- local cleanroomAddresses = require("config.addresses.cleanroom")
|
-- local cleanroomAddresses = require("config.addresses.cleanroom")
|
||||||
-- local multiBlockAddresses = require("config.addresses.multi-blocks")
|
local multiBlockAddresses = require("config.addresses.multi-blocks")
|
||||||
local energyBufferAddresses = require("config.addresses.energy-buffers")
|
local energyBufferAddresses = require("config.addresses.energy-buffers")
|
||||||
|
|
||||||
-- local protectCleanroomRecipes = require("domain.cleanroom.protect-recipes-usecase")
|
-- local protectCleanroomRecipes = require("domain.cleanroom.protect-recipes-usecase")
|
||||||
@ -62,7 +62,7 @@ end
|
|||||||
|
|
||||||
require("api.sound.zelda-secret")()
|
require("api.sound.zelda-secret")()
|
||||||
--]]
|
--]]
|
||||||
Page.setup(energyBufferAddresses.batteryBuffer1)
|
Page.setup(energyBufferAddresses.batteryBuffer1, multiBlockAddresses)
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
Page.update()
|
Page.update()
|
||||||
|
@ -12,9 +12,6 @@ shell.execute("wget -fq " .. tarBin)
|
|||||||
local InfOS = "https://github.com/gordominossi/InfOS/releases/download/v0.2.1/InfOS.tar"
|
local InfOS = "https://github.com/gordominossi/InfOS/releases/download/v0.2.1/InfOS.tar"
|
||||||
|
|
||||||
shell.setWorkingDirectory("/home")
|
shell.setWorkingDirectory("/home")
|
||||||
if not shell.resolve("/home/lib") then
|
|
||||||
shell.execute("mkdir lib")
|
|
||||||
end
|
|
||||||
if not shell.resolve("/home/InfOS") then
|
if not shell.resolve("/home/InfOS") then
|
||||||
shell.execute("mkdir InfOS")
|
shell.execute("mkdir InfOS")
|
||||||
end
|
end
|
||||||
@ -28,7 +25,8 @@ shell.execute("rm -f InfOS.tar")
|
|||||||
|
|
||||||
shell.setWorkingDirectory("/home/")
|
shell.setWorkingDirectory("/home/")
|
||||||
shell.execute("rm -rf lib")
|
shell.execute("rm -rf lib")
|
||||||
shell.execute("cp -r InfOS/Libraries lib")
|
shell.execute("mkdir lib")
|
||||||
|
shell.execute("cp -r InfOS/Libraries/* lib")
|
||||||
shell.execute("rm -f .shrc")
|
shell.execute("rm -f .shrc")
|
||||||
shell.execute("cp InfOS/.shrc .shrc")
|
shell.execute("cp InfOS/.shrc .shrc")
|
||||||
shell.execute("rm -f setup.lua")
|
shell.execute("rm -f setup.lua")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user