event_loop.lua
local logger = require("modules/logger")
otii.clear()
local debuglog = logger.get_logger()
debuglog.enable(false)
local project = otii.get_active_project()
if not project then
project = otii.create_project()
assert(project, "cannot create project")
end
local devices = otii.get_devices("Arc")
assert(#devices > 0, "No available devices")
local box = otii.open_device(devices[1].id)
assert(box, "Cannot open device")
box:enable_channel("mc", true)
local server = otii.create_local_server("com.qoitech.otiicli", function(data)
otii.writeln(data)
if data == "start" then
project:start()
debuglog.log("Started")
elseif data == "stop" then
project:stop()
debuglog.log("Stopped")
elseif data == "on" then
project:enable_main_power(true)
debuglog.log("Enable main power")
elseif data == "off" then
project:enable_main_power(false)
debuglog.log("Disable main power")
elseif data == "debug" then
debuglog.enable(true)
elseif data == "exit" then
otii.stop(0)
else
otii.writeln("Unknown command!")
end
end)
local count = 60
local timer = otii.create_timer(1000, function()
otii.writeln("Timer " .. tostring(count))
count = count - 1
if count == 0 then
otii.stop(0)
end
end)
otii.run()
timer:delete()
server:close()
project:close()