Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipeline匹配算法/动作附加字段建议放入二级字典 #298

Open
Tracked by #248
FSPaul2498 opened this issue Jul 29, 2024 · 5 comments
Open
Tracked by #248

pipeline匹配算法/动作附加字段建议放入二级字典 #298

FSPaul2498 opened this issue Jul 29, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@FSPaul2498
Copy link

建议将匹配算法/动作的相关附加字段,合并进这两个字段值字典(类似pre_wait_freezes: uint | object的形式),个人认为这样将具有更好的可读性和逻辑性。(特别是当pipeline被反复编辑时,recognition相关附加字段和action相关附加字段往往会随时间被打乱顺序,程序可以正常解读原字典,但会增大后续人员的阅读理解成本,容易导致漏读误读)
修改前:

{
  "TaskA": {
    "recognition": "TemplateMatch",
    "roi": [0, 0, 0, 0],
    "template": "btn.png",
    "threshold": 0.7,
    "order_by": "Vertical",
    "index": 2,
    "action": "Swipe",
    "begin": [0, 0, 0, 0],
    "begin_offset": [0, 0, 0, 0],
    "end": [0, 0, 0, 0],
    "end_offset": [0, 0, 0, 0],
    "duration": 200,
    "next": [],
    "is_sub": true,
    "inverse": false,
    "enabled": true,
    "timeout": 20000,
    "timeout_next": [],
    "post_wait_freezes": 100
  }
}

修改后:

{
  "TaskDemo": {
    "recognition": {
      "algo": "TemplateMatch",
      "roi": [0, 0, 0, 0],
      "template": "btn.png",
      "threshold": 0.7,
      "order_by": "Vertical",
      "index": 2
    },
    "action": {
      "do": "Swipe",
      "begin": [0, 0, 0, 0],
      "begin_offset": [0, 0, 0, 0],
      "end": [0, 0, 0, 0],
      "end_offset": [0, 0, 0, 0],
      "duration": 200
    },
    "next": [],
    "is_sub": true,
    "inverse": false,
    "enabled": true,
    "timeout": 20000,
    "timeout_next": [],
    "post_wait_freezes": 100
  }
}
@FSPaul2498
Copy link
Author

看到正在规划2.0的相关功能优化改动,也许可以将此包含在2.0的优化内容中

@neko-para
Copy link
Contributor

这个方案和现有的功能要严重冲突. 目前, MaaFramework在post任务时, 支持传入一个diff对象, 其格式和Pipeline一致. MaaFramework会将diff对象中, 每个任务的每一项覆盖到Pipeline中. 在现有模式下, 通过diff可以直接修改任务的具体的某一项配置, 但改为折叠模式后, 要替换只能提供完整的任务结构, 不符合预期; 要么, 就需要实现深覆盖, 语义不是特别明确, 且改动量较大.

@MistEO
Copy link
Member

MistEO commented Jul 30, 2024

这个方案和现有的功能要严重冲突. 目前, MaaFramework在post任务时, 支持传入一个diff对象, 其格式和Pipeline一致. MaaFramework会将diff对象中, 每个任务的每一项覆盖到Pipeline中. 在现有模式下, 通过diff可以直接修改任务的具体的某一项配置, 但改为折叠模式后, 要替换只能提供完整的任务结构, 不符合预期; 要么, 就需要实现深覆盖, 语义不是特别明确, 且改动量较大.

我觉得到也可以支持下,只是 json 格式变动而已。现在是结构体按字段覆盖的,不是 json merge

@neko-para
Copy link
Contributor

🤔

@MistEO MistEO mentioned this issue Jul 30, 2024
25 tasks
@moomiji
Copy link
Contributor

moomiji commented Aug 20, 2024

由于字段执行的顺序在 json 中非常不明确,我认为该提议及如下修改是必要的,主要依据请看 https://github.com/orgs/MaaXYZ/discussions/35

{
  "TaskDemo": {
    "recognition": {
      "inverse": false,
      "algo": "TemplateMatch",
      "roi": [0, 0, 0, 0],
      "template": "btn.png",
      "threshold": 0.7,
      "order_by": "Vertical",
      "index": 2
    },
    "action": {
      "do": "Swipe",
      "begin": [0, 0, 0, 0],
      "begin_offset": [0, 0, 0, 0],
      "end": [0, 0, 0, 0],
      "end_offset": [0, 0, 0, 0],
      "duration": 200,
      "post_wait_freezes": 100,
      "times_limit": 2
    },
    "next": [],
    "is_sub": true,
    "enabled": true,
    "timeout": 20000,
    "timeout_next": []
  }
}

我认为 recognition 也可以添加 times_limit 字段,用于避免一直重复识别。

@MistEO MistEO added the enhancement New feature or request label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants