InfOS/Programs/monitor-system/domain/cleanroom/protect-recipes-usecase.lua
Gabriel Moreira Minossi 4c11905281 Capitalizing or encapsulating global variables
Making the linter happy
2021-01-06 13:03:57 -03:00

33 lines
692 B
Lua
Executable File

-- Import section
Alarm = require("api.sound.alarm")
--
local function halt(machines)
Alarm()
for _, machine in ipairs(machines) do
machine:setWorkAllowed(false)
end
end
local function resume(machines)
for _, machine in ipairs(machines) do
machine:setWorkAllowed(true)
end
end
local function exec(cleanroom, machines)
if (tonumber(cleanroom:getEfficiencyPercentage()) < 100) then
if (not cleanroom.isHalted) then
halt(machines)
cleanroom.isHalted = true
end
else
if (cleanroom.isHalted) then
resume(machines)
cleanroom.isHalted = false
end
end
end
return exec