From fc6b6db7761138f7ec68bb83ed314e98bf57e9c3 Mon Sep 17 00:00:00 2001 From: Gabriel Moreira Minossi Date: Sat, 16 Jan 2021 18:59:49 -0300 Subject: [PATCH] Adding machine states to `machine.lua` --- .../monitor-system/data/datasource/machine.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Programs/monitor-system/data/datasource/machine.lua b/Programs/monitor-system/data/datasource/machine.lua index 4d0668c..f0bb49c 100644 --- a/Programs/monitor-system/data/datasource/machine.lua +++ b/Programs/monitor-system/data/datasource/machine.lua @@ -1,27 +1,40 @@ -- Import section local mock = require("data.mock.mock-energy-provider") EnergyProvider = require("data.datasource.energy-provider") +MultiBlock = require("data.datasource.multi-block") Inherits = require("utils.inherits") -- local machine = Inherits(EnergyProvider) local machines = {} + machine.types = { energy = "energy", multiblock = "multiblock", 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) if machines[address] then return machines[address] else local mach = {} if type == machine.types.energy then - print(machine.name) + mach = EnergyProvider:new(address, name) elseif type == machine.types.multiblock then + mach = MultiBlock:new(address, name) end - mach = machine:new(address, name) machines[address] = mach return mach end