-
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
f9e1796
commit 03e2d24
Showing
16 changed files
with
473 additions
and
344 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
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
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,27 @@ | ||
-- 字段 | ||
local log_debug = logger.debug | ||
local log_err = logger.err | ||
|
||
local Node = class() | ||
local prop = property(Node) | ||
prop:accessor("name", "") -- name | ||
prop:accessor("entity", "") -- 实体对象 | ||
prop:accessor("bind_type", "") -- 绑定类型(0 属性关联 1 协议关联 2 自定义) | ||
prop:accessor("property_module", "") -- 属性-模块 | ||
prop:accessor("property_name", "") -- 属性-名称 | ||
prop:accessor("accord_msg_id", "") -- 协议消息id | ||
prop:accessor("accord_field", "") -- 协议消息字段 | ||
prop:accessor("custom_language", "") -- 自定义语言 | ||
prop:accessor("custom_content", "") -- 自定义内容 | ||
function Node:__init(conf) | ||
self.name = conf.name | ||
self.bind_type = conf.bind_type | ||
self.entity = conf.entity | ||
self.property_module = conf.property.module | ||
self.property_name = conf.property.name | ||
self.accord_msg_id = conf.accord.msg_id | ||
self.accord_field = conf.accord.fields | ||
self.custom_language = conf.custom.language | ||
self.custom_content = conf.custom.content | ||
end | ||
return Node |
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,26 @@ | ||
-- 流程 | ||
local log_debug = logger.debug | ||
local log_err = logger.err | ||
|
||
local Line = class() | ||
local prop = property(Line) | ||
prop:accessor("from", nil) -- 起始节点 | ||
prop:accessor("from_name", nil) -- 起始节点名称 | ||
prop:accessor("to", nil) -- 目标节点 | ||
prop:accessor("to_name", nil) -- 目标节点名称 | ||
prop:accessor("operator", "") -- 运算符 | ||
prop:accessor("value", "") -- 运算值 | ||
prop:accessor("done", false) -- 完成标记(未完成 false 完成 true) | ||
function Line:__init(conf) | ||
self.from = conf.from | ||
self.from_name = conf.from_name | ||
self.to = conf.to | ||
self.to_name = conf.to_name | ||
self.operator = conf.operator | ||
self.value = conf.value | ||
end | ||
|
||
function Line:is_done() | ||
return self.done | ||
end | ||
return Line |
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,120 @@ | ||
-- 节点 | ||
local log_debug = logger.debug | ||
local log_err = logger.err | ||
|
||
local Field = import("autotest/field.lua") | ||
|
||
local Node = class() | ||
local prop = property(Node) | ||
prop:accessor("id", "") -- id | ||
prop:accessor("name", "") -- 名称 | ||
prop:accessor("type", 0) -- 类型(req、ntf、case、if、switch、gm、delayer) | ||
prop:accessor("msg_id", 0) -- 消息号 | ||
prop:accessor("msg_name", "") -- 消息名称 | ||
prop:accessor("case_uuid", "") -- 用例id | ||
prop:accessor("case_name", "") -- 用例名称 | ||
prop:accessor("cond_operator", "") -- 条件运算符 | ||
prop:accessor("cond_value", 0) -- 条件值 | ||
prop:accessor("gm_command", "") -- gm命令 | ||
prop:accessor("delayer_time", 0) -- 延迟时间 | ||
prop:accessor("fields", {}) -- 字段 | ||
prop:accessor("conds", {}) -- 条件 | ||
prop:accessor("in_node", {}) -- 输入节点 | ||
prop:accessor("out_node", {}) -- 输出节点 | ||
|
||
function Node:__init(conf) | ||
self.id = conf.id | ||
self.name = conf.name | ||
self.type = conf.type | ||
self.msg_id = conf.form.accord.id | ||
self.case_uuid = conf.form.case.uuid | ||
self.case_name = conf.form.case.name | ||
self.cond_operator = conf.form.cond.operator | ||
self.cond_value = conf.form.cond.cond_value | ||
self.gm_command = conf.form.gm.command | ||
self.delayer_time = conf.form.delayer.time | ||
self:init_fields(conf) | ||
self:init_in_node(conf) | ||
self:init_out_node(conf) | ||
self:init_conds(conf) | ||
end | ||
|
||
-- 初始化字段 | ||
function Node:init_fields(conf) | ||
-- 字段数据 | ||
for _, item in pairs(conf.form.dSourceFormMap) do | ||
local field = Field(item) | ||
self.fields[field:get_name()] = field | ||
end | ||
end | ||
|
||
-- 初始化输入节点 | ||
function Node:init_in_node(conf) | ||
for key,line in pairs(conf.inLine) do | ||
local node = { | ||
from = line.from, | ||
to = line.to, | ||
from_name = line.from_name, | ||
to_name = line.to_name, | ||
} | ||
if line.operator then | ||
node.operator = line.operator | ||
node.value = line.value | ||
node.label = line.label | ||
end | ||
self.in_node[key] = node | ||
end | ||
end | ||
|
||
-- 初始化输出节点 | ||
function Node:init_out_node(conf) | ||
for key,line in pairs(conf.outLine) do | ||
local node = { | ||
from = line.from, | ||
to = line.to, | ||
from_name = line.from_name, | ||
to_name = line.to_name, | ||
} | ||
if line.operator then | ||
node.operator = line.operator | ||
node.value = line.value | ||
node.label = line.label | ||
end | ||
self.out_node[key] = node | ||
end | ||
end | ||
|
||
-- 初始化条件 | ||
function Node:init_conds(conf) | ||
self.conds = Field(conf.form.dSourceForm) | ||
end | ||
|
||
-- 获取发送数据包 | ||
function Node:send_data(robot) | ||
local data = {} | ||
for name,field in pairs(self.fields) do | ||
local bind_type = 0 | ||
local value = nil | ||
-- 属性关联 | ||
if bind_type == 0 then | ||
data[name] = value | ||
-- 协议关联 | ||
elseif bind_type == 1 then | ||
data[name] = robot:msg_package(field.accord_msg_id) | ||
if not data[name] then | ||
log_err("[Node][send_data] msg is error, robot:{} task_id:{} name:{} bind_type:{} msg:{}", | ||
robot:get_openid(), robot:get_task_id(), name, bind_type, data[name]) | ||
return false | ||
end | ||
-- 自定义 | ||
elseif bind_type == 2 then | ||
else | ||
log_err("[Node][send_data] bind_type is error, robot:{} task_id:{} name:{} bind_type:{}", | ||
robot:get_openid(), robot:get_task_id(), name, bind_type) | ||
return false | ||
end | ||
end | ||
return data | ||
end | ||
|
||
return Node |
Oops, something went wrong.