Improving singlebocks

Improving mock interface
Adding error messages and name to the `new()` method
This commit is contained in:
Gabriel Moreira Minossi 2021-01-08 16:33:26 -03:00
parent 1431a0866c
commit 3f887c295a
2 changed files with 16 additions and 5 deletions

View File

@ -80,7 +80,7 @@ function SingleBlock:getEUMaxStored()
return self.block.getEUMaxStored()
end
function SingleBlock:new(partialAdress)
function SingleBlock:new(partialAdress, name)
local machine = {}
setmetatable(machine, self)
@ -95,9 +95,12 @@ function SingleBlock:new(partialAdress)
end
)
if (not successfull) then
print("Couldn't find the machine " .. partialAdress)
machine.block = self.mock:new()
end
machine.name = name
return machine
end

View File

@ -3,7 +3,15 @@ New = require("utils.new")
--
local MockSingleBlock = {
name = "MockSingleBlock"
name = "MockSingleBlock",
workAllowed = true,
workProgress = 3,
workMaxProgress = 4,
storedEU = 1234,
active = true,
outputVoltage = 0,
outputAmperage = 1,
EUCapacity = 2048
}
function MockSingleBlock.setWorkAllowed(allow)
@ -43,11 +51,11 @@ function MockSingleBlock.getSensorInformation()
end
function MockSingleBlock.getEUOutputAverage()
return 128
return MockSingleBlock.EUOutputAverage
end
function MockSingleBlock.getEUInputAverage()
return 128
return MockSingleBlock.EUInputAverage
end
function MockSingleBlock.getStoredEU()
@ -71,7 +79,7 @@ function MockSingleBlock.hasWork()
end
function MockSingleBlock.getOutputAmperage()
return 2
return MockSingleBlock.outputAmperage
end
function MockSingleBlock.getEUCapacity()