-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5cd94ad
commit f9e1796
Showing
4 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- 脚本 | ||
local log_debug = logger.debug | ||
local log_err = logger.err | ||
|
||
local Script = singleton() | ||
local prop = property(Script) | ||
prop:accessor("id", nil) | ||
|
||
|
||
function Script:__init(id) | ||
self.id = id | ||
end | ||
|
||
return Script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- 任务管理 | ||
local log_debug = logger.debug | ||
local log_err = logger.err | ||
|
||
local size = qtable.size | ||
|
||
local Script = import("autotest/script.lua") | ||
|
||
local ScriptMgr = singleton() | ||
local prop = property(ScriptMgr) | ||
prop:reader("scripts", {}) | ||
|
||
function ScriptMgr:__init() | ||
|
||
end | ||
|
||
function ScriptMgr:create() | ||
|
||
end | ||
|
||
quanta.script_mgr = ScriptMgr() | ||
return ScriptMgr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- 测试任务 | ||
local log_debug = logger.debug | ||
local log_err = logger.err | ||
|
||
local Task = singleton() | ||
local prop = property(Task) | ||
prop:accessor("id", nil) | ||
prop:accessor("name", "") | ||
prop:accessor("srv_host", "") | ||
prop:accessor("srv_port", "") | ||
prop:accessor("robots", {}) | ||
|
||
function Task:__init(id, name) | ||
self.id = id | ||
self.name = name | ||
end | ||
|
||
return Task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
-- 任务管理 | ||
local log_debug = logger.debug | ||
local log_err = logger.err | ||
|
||
local size = qtable.size | ||
|
||
local TestTask = import("autotest/testtask.lua") | ||
|
||
local TaskMgr = singleton() | ||
local prop = property(TaskMgr) | ||
prop:reader("tasks", {}) | ||
|
||
function TaskMgr:__init() | ||
|
||
end | ||
|
||
-- 获取任务 | ||
function TaskMgr:get_task(id) | ||
return self.tasks[id] | ||
end | ||
|
||
-- 获取数量 | ||
function TaskMgr:get_count() | ||
return size(self.tasks) | ||
end | ||
|
||
-- 创建任务 | ||
function TaskMgr:create(id, name, srv_host, srv_port, robots) | ||
log_debug("[TaskMgr][create]: {}:{} {}:{}", id, name, srv_host, srv_port, robots) | ||
local task = self:get_task() | ||
if task then | ||
log_err("[TaskMgr][create] robot {}:{} {}:{}", id, name, srv_host, srv_port, robots) | ||
return nil | ||
end | ||
task = TestTask(id) | ||
task:set_srv_host(srv_host) | ||
task:set_srv_port(srv_port) | ||
task:set_robots(robots) | ||
self.tasks[id] = task | ||
return task | ||
end | ||
|
||
quanta.task_mgr = TaskMgr() | ||
return TaskMgr |