diff --git a/docs/en_us/1.1-QuickStarted.md b/docs/en_us/1.1-QuickStarted.md index a92670da6..ba92973b8 100644 --- a/docs/en_us/1.1-QuickStarted.md +++ b/docs/en_us/1.1-QuickStarted.md @@ -38,10 +38,10 @@ Launch the CLI through the API while registering some custom tasks. This method { "Recognize and Click Confirm Icon": { "next": [ - "My Custom Task" + "My Custom Node" ] }, - "My Custom Task": { + "My Custom Node": { "recognition": "Custom", "custom_recognition": "MyReco", "action": "Custom", @@ -74,7 +74,7 @@ class MyAction(CustomAction): # Perform click action context.controller.post_click(100, 10).wait() # Override the next tasks to execute - context.override_next(task_name, ["TaskA", "TaskB"]) + context.override_next(node_name, ["TaskA", "TaskB"]) ``` ### Write Your Own Code @@ -85,7 +85,7 @@ You can use low-code as a "wrapper" for invocation or register custom callbacks. # This is pseudo code, for reference only, and cannot be run directly # "Recognize and click the start button", "Recognize and click the confirmation icon" and so on are all logic in Json def main(): - detail = tasker.post_pipeline("Recognize and click the start button").wait().get() + detail = tasker.post_task("Recognize and click the start button").wait().get() if detail.completed: tasker.controller.post_click(100, 100).wait() @@ -95,7 +95,7 @@ def main(): save_to_file(image) tasker.resource.register_custom_action("MyAction", MyAction()) - tasker.post_pipeline("Recognize and click the confirmation icon").wait() + tasker.post_task("Recognize and click the confirmation icon").wait() image: np.ndarray = tasker.controller.post_screencap().wait().get() ``` @@ -169,7 +169,7 @@ If needed, you can also fine-tune the official pre-trained models of PaddleOCR y - `logging`: Save the log and generate `debug/maa.log`. Default true. - `recording`: Save recording function, which will save all screenshots and operation data during operation. You can use `DbgController` for reproducible debugging. Default false. - `save_draw`: Saves the image recognition visualization results. All image recognition visualization results drawings during the run will be saved. Default false. - - `show_hit_draw`: Displays the task hit pop-up window. Each time the recognition is successful, a pop-up window will display the recognition result. Default false. + - `show_hit_draw`: Displays the node hit pop-up window. Each time the recognition is successful, a pop-up window will display the recognition result. Default false. - `stdout_level`: The console displays the log level. The default is 2 (Error), which can be set to 0 to turn off all console logs, or to 7 to turn on all console logs. - If you integrate it yourself, you can enable debugging options through the `Toolkit.init_option` / `MaaToolkitConfigInitOption` interface. The generated json file is the same as above. diff --git a/docs/en_us/3.1-PipelineProtocol.md b/docs/en_us/3.1-PipelineProtocol.md index 5ff3bbce6..b4aeb1c60 100644 --- a/docs/en_us/3.1-PipelineProtocol.md +++ b/docs/en_us/3.1-PipelineProtocol.md @@ -4,21 +4,21 @@ ```jsonc { - "TaskA": { + "NodeA": { "next: [ - "TaskB", - "TaskC" + "NodeB", + "NodeC" ] // properties ... }, - "TaskB": { + "NodeB": { // properties ... }, - // other task ... + // other node ... } ``` -When we execute a task (passing the task name to the MaaTaskerPostPipeline interface), it will recognize the tasks in the "next" list one by one (based on the recognition settings for each task). Once a match is found, it will exit the recognition of the "next" list and proceed to execute the matched task. It's similar to traversing and comparing, and as soon as a match is found, it will break and execute the found task. +When we execute a node (passing the entry name to the MaaTaskerPostTask interface), it will recognize the nodes in the "next" list one by one (based on the recognition settings for each node). Once a match is found, it will exit the recognition of the "next" list and proceed to execute the matched node. It's similar to traversing and comparing, and as soon as a match is found, it will break and execute the found node. ## Example @@ -53,11 +53,11 @@ For example, let's say we have a game where different fruits, such as apples, or } ``` -Let's assume there are no apples on the screen, but there are oranges and bananas. In the above JSON, if we execute "StartFruit" (i.e., pass "StartFruit" to the MaaTaskerPostPipeline interface), it will first recognize "Apple." Since there are no apples on the screen, it will continue to recognize "Orange." If it recognizes an orange, it will start executing the "Orange" task, and it won't attempt to recognize "Banana." After executing "Orange" according to its action, it will continue to recognize "Orange's" "next" tasks. +Let's assume there are no apples on the screen, but there are oranges and bananas. In the above JSON, if we execute "StartFruit" (i.e., pass "StartFruit" to the MaaTaskerPostTask interface), it will first recognize "Apple." Since there are no apples on the screen, it will continue to recognize "Orange." If it recognizes an orange, it will start executing the "Orange" node, and it won't attempt to recognize "Banana." After executing "Orange" according to its action, it will continue to recognize "Orange's" "next" nodes. -Within "Orange's" "next," if it recognizes "Cat," it won't continue to recognize "Dog." It will execute the "Cat" action and continue to recognize "Cat's" "next" after the action is completed. If neither "Cat" nor "Dog" is recognized, it will continue to attempt recognition for these two tasks until a timeout occurs. +Within "Orange's" "next," if it recognizes "Cat," it won't continue to recognize "Dog." It will execute the "Cat" action and continue to recognize "Cat's" "next" after the action is completed. If neither "Cat" nor "Dog" is recognized, it will continue to attempt recognition for these two nodes until a timeout occurs. -This loop continues until the "next" of a task is empty, which signifies that the task is complete. +This loop continues until the "next" of a node is empty, which signifies that the task is complete. ## Property Fields @@ -74,65 +74,65 @@ This loop continues until the "next" of a task is empty, which signifies that th See [Action Types](#action-types) for details. - `next`: *string* | *list* - List of tasks to execute next. Optional, default is empty. - It recognizes each task in sequence and executes the first one it recognizes. + List of nodes to execute next. Optional, default is empty. + It recognizes each node in sequence and executes the first one it recognizes. - `interrupt` : *string* | *list* - The list of candidate tasks when all tasks in `next` are not recognized, and similar interrupt operations will be performed. Optional, empty by default. - If all tasks in `next` are not recognized, each task in the interrupt list will be recognized in order, and the first recognized one will be executed. After all subsequent tasks are executed, jump back to this task to try to recognize it again. + The list of candidate nodes when all nodes in `next` are not recognized, and similar interrupt operations will be performed. Optional, empty by default. + If all nodes in `next` are not recognized, each node in the interrupt list will be recognized in order, and the first recognized one will be executed. After all subsequent nodes are executed, jump back to this node to try to recognize it again. For example: A: { next: [B, C], interrupt: [D, E] } - When B and C are not recognized and D is recognized, D and D.next will be fully executed. But when the pipeline of D is fully executed. It will return to task A again and continue to try to recognize B, C, D, E. - This field is mostly used for exception handling. For example, D is to recognize the "network disconnection prompt box". After clicking confirm and waiting for the network connection to succeed, continue the previous task flow. + When B and C are not recognized and D is recognized, D and D.next will be fully executed. But when the pipeline of D is fully executed. It will return to node A again and continue to try to recognize B, C, D, E. + This field is mostly used for exception handling. For example, D is to recognize the "network disconnection prompt box". After clicking confirm and waiting for the network connection to succeed, continue the previous node flow. - `is_sub`: *bool* **(Deprecated in version 2.x, but retains compatibility. `interrupt` is recommended instead.)** - Whether it is a subtask. Optional, default is false. - If it's a subtask, after completing this task (and subsequent tasks such as "next"), it will return to re-recognize the "next" list of this task. - For example: A.next = [B, Sub_C, D], where Sub_C.is_sub = true. If Sub_C is matched, after fully executing Sub_C and subsequent tasks, it will return to re-recognize [B, Sub_C, D] and execute the matching items and subsequent tasks. + Whether it is a sub-node. Optional, default is false. + If it's a sub-node, after completing this node (and subsequent nodes such as "next"), it will return to re-recognize the "next" list of this node. + For example: A.next = [B, Sub_C, D], where Sub_C.is_sub = true. If Sub_C is matched, after fully executing Sub_C and subsequent nodes, it will return to re-recognize [B, Sub_C, D] and execute the matching items and subsequent nodes. - `rate_limit`: *uint* Identification rate limit, in milliseconds. Optional, default 1000. Each round of identification "next" + "interrupt" consumes at least `rate_limit` milliseconds, and sleep will wait if the time is less than that. - `timeout`: *uint* - Timeout for recognizing "next" + "interrupt" tasks, in milliseconds. Optional, Default is 20,000 milliseconds (20 seconds). + Timeout for recognizing "next" + "interrupt" nodes, in milliseconds. Optional, Default is 20,000 milliseconds (20 seconds). The detailed logic is `while(!timeout) { foreach(next + interrupt); sleep_until(rate_limit); }` - `on_error` : *string* | *list* - When recognition timeout or the action fails to execute, the tasks in this list will be executed next. Optional, empty by default. + When recognition timeout or the action fails to execute, the nodes in this list will be executed next. Optional, empty by default. - `timeout_next`: *string* | *list* **(Deprecated in version 2.x, but retains compatibility. `on_error` is recommended instead.)** - List of tasks to execute after a timeout. Optional, default is empty. + List of nodes to execute after a timeout. Optional, default is empty. - `inverse`: *bool* Reverse the recognition result: recognized as not recognized, and not recognized as recognized. Optional, default is false. - Please note that tasks recognized through this setting will have their own clicking actions disabled (because nothing was actually recognized). If there is a need, you can set the `target` separately. + Please note that nodes recognized through this setting will have their own clicking actions disabled (because nothing was actually recognized). If there is a need, you can set the `target` separately. - `enabled`: *bool* - Whether to enable this task. Optional, default is true. - If set to false, this task will be skipped when it appears in the "next" lists of other tasks, meaning it won't be recognized or executed. + Whether to enable this node. Optional, default is true. + If set to false, this node will be skipped when it appears in the "next" lists of other nodes, meaning it won't be recognized or executed. - `pre_delay`: *uint* - Delay in milliseconds between recognizing a task and executing the action. Optional, default is 200 milliseconds. - It is recommended to add intermediate tasks whenever possible and use less delay to maintain both speed and stability. + Delay in milliseconds between recognizing a node and executing the action. Optional, default is 200 milliseconds. + It is recommended to add intermediate nodes whenever possible and use less delay to maintain both speed and stability. - `post_delay`: *uint* - Delay in milliseconds between executing the action and recognizing the "next" tasks. Optional, default is 200 milliseconds. - It is recommended to add intermediate tasks whenever possible and use less delay to maintain both speed and stability. + Delay in milliseconds between executing the action and recognizing the "next" nodes. Optional, default is 200 milliseconds. + It is recommended to add intermediate nodes whenever possible and use less delay to maintain both speed and stability. - `pre_wait_freezes`: *uint* | *object* - Time in milliseconds to wait for the screen to stop changing between recognizing a task and executing the action. Optional, default is 0 (no waiting). + Time in milliseconds to wait for the screen to stop changing between recognizing a node and executing the action. Optional, default is 0 (no waiting). It will exit the action only when the screen has not had significant changes for "pre_wait_freezes" milliseconds in a row. If it's an object, more parameters can be set, see [Waiting for the Screen to Stabilize](#waiting-for-the-screen-to-stabilize) for details. The specific order is `pre_wait_freezes` - `pre_delay` - `action` - `post_wait_freezes` - `post_delay`. - `post_wait_freezes`: *uint* | *object* - Time in milliseconds to wait for the screen to stop changing between executing the action and recognizing the "next" tasks. Optional, default is 0 (no waiting). + Time in milliseconds to wait for the screen to stop changing between executing the action and recognizing the "next" nodes. Optional, default is 0 (no waiting). Other logic is the same as `pre_wait_freezes`. - `focus`: *bool* - Whether to focus on the task, resulting in additional callback messages. Optional, default is false (no messages). - See [Task Notifications](#task-notifications) for details. + Whether to focus on the node, resulting in additional callback messages. Optional, default is false (no messages). + See [Node Notifications](#node-notifications) for details. ## Default Properties @@ -154,7 +154,7 @@ This algorithm property requires additional fields: - `roi`: *array* | *string* Recognition area coordinates. Optional, default [0, 0, 0, 0], i.e. full screen. - *array*: Recognition area coordinates, [x, y, w, h], if you want full screen, you can set it to [0, 0, 0, 0]. - - *string*: Fill in the task name, and identify within the target range identified by a previously executed task. + - *string*: Fill in the node name, and identify within the target range identified by a previously executed node. - `roi_offset`: *array* Move additionally based on `roi` as the range, and add the four values ​​separately. Optional, default [0, 0, 0, 0]. @@ -434,8 +434,8 @@ Additional properties for this action: - `target`: *true* | *string* | *array* The position to click. Optional, default is true. - - *true*: Clicks the target just recognized in this task (i.e., clicks itself). - - *string*: Enter the task name to click a target recognized by a previously executed task. + - *true*: Clicks the target just recognized in this node (i.e., clicks itself). + - *string*: Enter the node name to click a target recognized by a previously executed node. - *array*: Clicks a random point within a fixed coordinate area [x, y, w, h]. To click the entire screen, set it to [0, 0, 0, 0]. - `target_offset`: *array* @@ -551,7 +551,7 @@ Additional properties for this action: ### `StopTask` -Stops the current task chain (the individual task chain passed to MaaTaskerPostPipeline). +Stops the current task chain (the individual task chain passed to MaaTaskerPostTask). ### `Command` @@ -574,13 +574,13 @@ This action attribute requires additional fields: - `{LIBRARY_DIR}`: The path of the folder where the MaaFW library is located. - `detach`: *bool* - Detach the child process, that is, do not wait for the child process to complete, and directly continue with the subsequent tasks. Optional, default false. + Detach the child process, that is, do not wait for the child process to complete, and directly continue with the subsequent nodes. Optional, default false. Example: ```jsonc { - "TaskA": { + "NodeA": { "action": "Command", "exec": "Python", "args": [ @@ -591,7 +591,7 @@ Example: "{BOX}" ] }, - "TaskB": { + "NodeB": { "action": "Command", "exec": "{RESOURCE_DIR}/my_exec/my_exec.exe" } @@ -601,10 +601,10 @@ Example: The actual command is: ```bash -# TaskA -Python C:/MaaXXX/resource/my_script/test.py Haha C:/temp/123.png TaskA [0,0,0,0] +# NodeA +Python C:/MaaXXX/resource/my_script/test.py Haha C:/temp/123.png NodeA [0,0,0,0] -# TaskB +# NodeB C:/MaaXXX/resource/my_exec/my_exec.exe ``` @@ -634,10 +634,10 @@ The field value can be a uint or an object. For example: ```jsonc { - "TaskA": { + "NodeA": { "pre_wait_freezes": 500 }, - "TaskB": { + "NodeB": { "pre_wait_freezes": { // more properties ... } @@ -669,6 +669,6 @@ If the value is an object, you can set additional fields: - `timeout`: *uint* Timeout for recognizing, in milliseconds. Optional, default is 20,000 milliseconds (20 seconds). -## Task Notifications +## Node Notifications See [Callback Protocol](2.2-CallbackProtocol.md) (not written yet). diff --git a/docs/en_us/NodeJS/J1.1-QuickStarted.md b/docs/en_us/NodeJS/J1.1-QuickStarted.md index a5aa68b42..f733be63f 100644 --- a/docs/en_us/NodeJS/J1.1-QuickStarted.md +++ b/docs/en_us/NodeJS/J1.1-QuickStarted.md @@ -59,7 +59,7 @@ async function main() { console.log(msg, detail) } // Load resource - await res.post_path('./resource') + await res.post_bundle('./resource') // Create tasker const tskr = new maa.Tasker() @@ -76,7 +76,7 @@ async function main() { // Launch task. Task1 is declared in pipeline/Task.json if (await tskr - .post_pipeline('Task1') + .post_task('Task1') .wait().success) { console.log('success!') } @@ -87,7 +87,7 @@ main() ## Alter Resource Behavior on NodeJS Side -Take a look at this code `await tskr.post_pipeline('task', 'Task1').wait()` +Take a look at this code `await tskr.post_task('task', 'Task1').wait()` Function `post` can be called with three params. The third one is an object, which has exact the same structure to json in `pipeline`, and will override the original `pipeline`. Thus, you can pass an object here to control the task (even create new task). @@ -97,7 +97,7 @@ Function `post` can be called with three params. The third one is an object, whi // 通过第三个参数, 创建了一个新的任务Task2, 然后执行它 // 此处创建的任务仅在当前执行中有效 await tskr - .post_pipeline('Task2', { + .post_task('Task2', { Task2: { next: [ 'Task1' diff --git "a/docs/zh_cn/1.1-\345\277\253\351\200\237\345\274\200\345\247\213.md" "b/docs/zh_cn/1.1-\345\277\253\351\200\237\345\274\200\345\247\213.md" index eeccb2d9f..8570ee547 100644 --- "a/docs/zh_cn/1.1-\345\277\253\351\200\237\345\274\200\345\247\213.md" +++ "b/docs/zh_cn/1.1-\345\277\253\351\200\237\345\274\200\345\247\213.md" @@ -74,7 +74,7 @@ class MyAction(CustomAction): # 进行点击 context.controller.post_click(100, 10).wait() # 重写接下来要执行的任务 - context.override_next(task_name, ["TaskA", "TaskB"]) + context.override_next(node_name, ["TaskA", "TaskB"]) ``` ### 自行编写代码 @@ -85,7 +85,7 @@ class MyAction(CustomAction): # 此处为伪代码,仅供参考思路,无法直接运行 # "识别并点击开始按钮", "识别并点击确认图标" 等均为 Json 中的逻辑 def main(): - detail = tasker.post_pipeline("识别并点击开始按钮").wait().get() + detail = tasker.post_task("识别并点击开始按钮").wait().get() if detail.completed: tasker.controller.post_click(100, 100).wait() @@ -95,7 +95,7 @@ def main(): save_to_file(image) tasker.resource.register_custom_action("MyAction", MyAction()) - tasker.post_pipeline("识别并点击确认图标").wait() + tasker.post_task("识别并点击确认图标").wait() image: np.ndarray = tasker.controller.post_screencap().wait().get() ``` @@ -169,7 +169,7 @@ my_resource - `logging`: 保存日志,会生成 `debug/maa.log`。默认 true 。 - `recording`: 保存录像功能,会保存运行期间所有的截图及操作数据,可使用 `DbgController` 进行复现调试。默认 false 。 - `save_draw`: 保存图像识别可视化结果,会保存运行期间所有图像识别可视化结果绘制图。默认 false 。 - - `show_hit_draw`: 显示任务命中弹窗,每次识别成功会弹窗显示识别结果。默认 false 。 + - `show_hit_draw`: 显示节点命中弹窗,每次识别成功会弹窗显示识别结果。默认 false 。 - `stdout_level`: 控制台显示日志等级。默认 2(Error),可设为 0 关闭全部控制台日志,或设为 7 打开全部控制台日志。 - 若自行集成,可通过 `Toolkit.init_option` / `MaaToolkitConfigInitOption` 接口开启调试选项。生成的 json 文件同上。 diff --git "a/docs/zh_cn/3.1-\344\273\273\345\212\241\346\265\201\346\260\264\347\272\277\345\215\217\350\256\256.md" "b/docs/zh_cn/3.1-\344\273\273\345\212\241\346\265\201\346\260\264\347\272\277\345\215\217\350\256\256.md" index c368acc2e..c32c3389d 100644 --- "a/docs/zh_cn/3.1-\344\273\273\345\212\241\346\265\201\346\260\264\347\272\277\345\215\217\350\256\256.md" +++ "b/docs/zh_cn/3.1-\344\273\273\345\212\241\346\265\201\346\260\264\347\272\277\345\215\217\350\256\256.md" @@ -4,22 +4,22 @@ ```jsonc { - "TaskA": { + "NodeA": { "next: [ - "TaskB", - "TaskC" + "NodeB", + "NodeC" ] // properties ... }, - "TaskB": { + "NodeB": { // properties ... }, - // other task ... + // other node ... } ``` -我们执行某个 Task 时( MaaTaskerPostPipeline 接口传入任务名),会对其 next 列表中的 Task **依次** 进行识别(根据每个 Task 的 recognition 相关设置) -且一旦匹配上了,则会退出 next 列表识别,转而去执行匹配上的任务。类似遍历比较,一旦找到了,就直接 break 转而去执行找到的那个 Task 。 +我们执行某个任务时( MaaTaskerPostTask 接口设置入口名),会对其 next 列表中的 Node **依次** 进行识别(根据每个 Node 的 recognition 相关设置) +且一旦匹配上了,则会退出 next 列表识别,转而去执行匹配上的 Node。类似遍历比较,一旦找到了,就直接 break 转而去执行找到的那个 Node。 ## 举例 @@ -55,14 +55,14 @@ ``` 假设现在画面中没有 Apple,但有 Orange 和 Banana 。 -在上述 JSON 中,若我们执行 "StartFruit"(即 MaaTaskerPostPipeline 接口传入 "StartFruit"),会先识别 Apple,画面中没有,所以继续识别 Orange,这次识别到了,则我们开始执行 Orange,不会再去识别 Banana 了。 +在上述 JSON 中,若我们执行 "StartFruit"(即 MaaTaskerPostTask 接口传入 "StartFruit"),会先识别 Apple,画面中没有,所以继续识别 Orange,这次识别到了,则我们开始执行 Orange,不会再去识别 Banana 了。 执行 Orange 就是根据其 action 去进行对应的操作,当执行完成后,我们会再去识别 Orange 的 next 。 Orange 的 next 中, 若识别到了 Cat,则不会继续去识别 Dog 了。这时同样会去执行 Cat 的 action,并在 action 完成后继续识别 Cat 的 next 。 若 Cat, Dog 都没有识别到,我们会再次尝试识别这两个,直至超时为止。 -如此循环,直至某个任务的 next 为空,即认为任务完成。 +如此循环,直至某个节点的 next 为空,即认为任务完成。 ## 属性字段 @@ -79,22 +79,22 @@ Orange 的 next 中, 详见 [动作类型](#动作类型)。 - `next` : *string* | *list* - 接下来要执行的任务列表。可选,默认空。 - 按顺序识别 next 中的每个任务,只执行第一个识别到的。 + 接下来要执行的节点列表。可选,默认空。 + 按顺序识别 next 中的每个节点,只执行第一个识别到的。 - `interrupt` : *string* | *list* - `next` 中全部未识别到时的候补任务列表,会执行类似中断操作。可选,默认空。 - 若 `next` 中的任务全部未识别到,则会按序识别该中断列表中的每个任务,并执行第一个识别到的。在后续任务全部执行完成后,重新跳转到该任务来再次尝试识别。 + `next` 中全部未识别到时的候补节点列表,会执行类似中断操作。可选,默认空。 + 若 `next` 中的节点全部未识别到,则会按序识别该中断列表中的每个节点,并执行第一个识别到的。在后续节点全部执行完成后,重新跳转到该节点来再次尝试识别。 例如: A: { next: [B, C], interrupt: [D, E] } - 当 B, C 未识别到而识别到 D 时,会去完整的执行 D 及 D.next。但当 D 的流水线完全执行完毕后。会再次回到任务 A,继续尝试识别 B, C, D, E 。 - 该字段多用于异常处理,例如 D 是识别 “网络断开提示框”,在点击确认并等待网络连接成功后,继续之前的任务流程。 + 当 B, C 未识别到而识别到 D 时,会去完整的执行 D 及 D.next。但当 D 的流水线完全执行完毕后。会再次回到节点 A,继续尝试识别 B, C, D, E 。 + 该字段多用于异常处理,例如 D 是识别 “网络断开提示框”,在点击确认并等待网络连接成功后,继续之前的节点流程。 - `is_sub`: *bool* **(已在 2.x 版本中废弃,但保留兼容性,推荐使用 `interrupt` 替代)** - 是否是子任务。可选,默认 false 。 - 如果是子任务,执行完本任务(及后续 next 等)后,会返回来再次识别本任务 **所在的** next 列表。 + 是否是子节点。可选,默认 false 。 + 如果是子节点,执行完本节点(及后续 next 等)后,会返回来再次识别本节点 **所在的** next 列表。 例如:A.next = [B, Sub_C, D],这里的 Sub_C.is_sub = true, - 若匹配上了 Sub_C,在完整执行完 Sub_C 及后续任务后,会返回来再次识别 [B, Sub_C, D] 并执行命中项及后续任务。 + 若匹配上了 Sub_C,在完整执行完 Sub_C 及后续节点后,会返回来再次识别 [B, Sub_C, D] 并执行命中项及后续节点。 - `rate_limit`: *uint* 识别速率限制,单位毫秒。可选,默认 1000 。 @@ -105,27 +105,27 @@ Orange 的 next 中, 具体逻辑为 `while(!timeout) { foreach(next + interrupt); sleep_until(rate_limit); }` 。 - `on_error` : *string* | *list* - 当识别超时,或动作执行失败后,接下来会执行该列表中的任务。可选,默认空。 + 当识别超时,或动作执行失败后,接下来会执行该列表中的节点。可选,默认空。 - `timeout_next`: *string* | *list* **(已在 2.x 版本中废弃,但保留兼容性,推荐使用 `on_error` 替代)** - 超时后执行的任务列表。可选,默认空。 + 超时后执行的节点列表。可选,默认空。 - `inverse`: *bool* 反转识别结果,识别到了当做没识别到,没识别到的当做识别到了。可选,默认 false 。 - 请注意由此识别出的任务,Click 等动作的点击自身将失效(因为实际并没有识别到东西),若有需求可单独设置 `target` 。 + 请注意由此识别出的节点,Click 等动作的点击自身将失效(因为实际并没有识别到东西),若有需求可单独设置 `target` 。 - `enabled`: *bool* - 是否启用该 task。可选,默认 true 。 - 若为 false,其他 task 的 next 列表中的该 task 会被跳过,既不会被识别也不会被执行。 + 是否启用该 node。可选,默认 true 。 + 若为 false,其他 node 的 next 列表中的该 node 会被跳过,既不会被识别也不会被执行。 - `pre_delay`: *uint* 识别到 到 执行动作前 的延迟,毫秒。可选,默认 200 。 - 推荐尽可能增加中间过程任务,少用延迟,不然既慢还不稳定。 + 推荐尽可能增加中间过程节点,少用延迟,不然既慢还不稳定。 - `post_delay`: *uint* 执行动作后 到 识别 next 的延迟,毫秒。可选,默认 200 。 - 推荐尽可能增加中间过程任务,少用延迟,不然既慢还不稳定。 + 推荐尽可能增加中间过程节点,少用延迟,不然既慢还不稳定。 - `pre_wait_freezes`: *uint* | *object* 识别到 到 执行动作前,等待画面不动了的时间,毫秒。可选,默认 0 ,即不等待。 @@ -138,8 +138,8 @@ Orange 的 next 中, 其余逻辑同 `pre_wait_freezes`。 - `focus`: *bool* - 是否关注任务,会额外产生部分回调消息。可选,默认 false ,即不产生。 - 详见 [任务通知](#任务通知)。 + 是否关注节点,会额外产生部分回调消息。可选,默认 false ,即不产生。 + 详见 [节点通知](#节点通知)。 ## 默认属性 @@ -161,7 +161,7 @@ Orange 的 next 中, - `roi`: *array* | *string* 识别区域坐标。可选,默认 [0, 0, 0, 0] ,即全屏。 - *array*: 识别区域坐标,[x, y, w, h],若希望全屏可设为 [0, 0, 0, 0] 。 - - *string*: 填写任务名,在之前执行过的某任务识别到的目标范围内识别。 + - *string*: 填写节点名,在之前执行过的某节点识别到的目标范围内识别。 - `roi_offset`: *array* 在 `roi` 的基础上额外移动再作为范围,四个值分别相加。可选,默认 [0, 0, 0, 0] 。 @@ -444,8 +444,8 @@ Orange 的 next 中, - `target`: *true* | *string* | *array* 点击的位置。可选,默认 true 。 - - *true*: 点击本任务中刚刚识别到的目标(即点击自身)。 - - *string*: 填写任务名,点击之前执行过的某任务识别到的目标。 + - *true*: 点击本节点中刚刚识别到的目标(即点击自身)。 + - *string*: 填写节点名,点击之前执行过的某节点识别到的目标。 - *array*: 点击固定坐标区域内随机一点,[x, y, w, h],若希望全屏可设为 [0, 0, 0, 0] 。 - `target_offset`: *array* @@ -561,7 +561,7 @@ Orange 的 next 中, ### `StopTask` -停止当前任务链(MaaTaskerPostPipeline 传入的单个任务链)。 +停止当前任务链(MaaTaskerPostTask 传入的单个任务链)。 ### `Command` @@ -577,20 +577,20 @@ Orange 的 next 中, 支持部分运行期参数替换: - `{ENTRY}`: 任务入口名。 - - `{NODE}`: 当前任务名。 + - `{NODE}`: 当前节点名。 - `{IMAGE}`: 截图保存到文件的路径。该文件在进程退出前删除,若要持久保存请自行复制。 - `{BOX}`: 识别命中的目标,格式为 `[x, y, w, h]`。 - `{RESOURCE_DIR}`: 最后一次加载的资源文件夹路径。 - `{LIBRARY_DIR}`: MaaFW 库所在的文件夹路径。 - `detach`: *bool* - 分离子进程,即不等待子进程执行完成,直接继续之后后面的任务。可选,默认 false。 + 分离子进程,即不等待子进程执行完成,直接继续之后后面的节点。可选,默认 false。 举例: ```jsonc { - "TaskA": { + "NodeA": { "action": "Command", "exec": "Python", "args": [ @@ -601,7 +601,7 @@ Orange 的 next 中, "{BOX}" ] }, - "TaskB": { + "NodeB": { "action": "Command", "exec": "{RESOURCE_DIR}/my_exec/my_exec.exe" } @@ -611,10 +611,10 @@ Orange 的 next 中, 实际将会执行命令 ```bash -# TaskA -Python C:/MaaXXX/resource/my_script/test.py Haha C:/temp/123.png TaskA [0,0,0,0] +# NodeA +Python C:/MaaXXX/resource/my_script/test.py Haha C:/temp/123.png NodeA [0,0,0,0] -# TaskB +# NodeB C:/MaaXXX/resource/my_exec/my_exec.exe ``` @@ -680,6 +680,6 @@ C:/MaaXXX/resource/my_exec/my_exec.exe - `timeout`: *uint* 识别超时时间,毫秒。可选,默认 20 * 1000 。 -## 任务通知 +## 节点通知 详见 [回调协议](2.2-回调协议.md)(还没写x diff --git "a/docs/zh_cn/NodeJS/J1.1-\345\277\253\351\200\237\345\274\200\345\247\213.md" "b/docs/zh_cn/NodeJS/J1.1-\345\277\253\351\200\237\345\274\200\345\247\213.md" index d6b498341..e9ee1bdfc 100644 --- "a/docs/zh_cn/NodeJS/J1.1-\345\277\253\351\200\237\345\274\200\345\247\213.md" +++ "b/docs/zh_cn/NodeJS/J1.1-\345\277\253\351\200\237\345\274\200\345\247\213.md" @@ -59,7 +59,7 @@ async function main() { console.log(msg, detail) } // 加载资源 - await res.post_path('./resource') + await res.post_bundle('./resource') // 创建实例 const tskr = new maa.Tasker() @@ -76,7 +76,7 @@ async function main() { // 执行任务, Task1定义在pipeline/Task.json if (await tskr - .post_pipeline('Task1') + .post_task('Task1') .wait().success) { console.log('success!') } @@ -87,7 +87,7 @@ main() ## 在JS侧影响资源行为 -注意执行任务的这段代码`await tskr.post_pipeline('task', 'Task1').wait()` +注意执行任务的这段代码`await tskr.post_task('task', 'Task1').wait()` `post`函数可以传入第三个参数, 该参数是一个对象, 其结构和`pipeline`下的json完全一致, 会覆盖在原有的`pipeline`之上. 因此, 可以通过在此处传入一个对象来实现控制任务(甚至创建新的任务). @@ -95,7 +95,7 @@ main() // 通过第三个参数, 创建了一个新的任务Task2, 然后执行它 // 此处创建的任务仅在当前执行中有效 await tskr - .post_pipeline('Task2', { + .post_task('Task2', { Task2: { next: [ 'Task1' diff --git a/include/MaaFramework/Instance/MaaContext.h b/include/MaaFramework/Instance/MaaContext.h index 5afa2c9fd..e51ba832b 100644 --- a/include/MaaFramework/Instance/MaaContext.h +++ b/include/MaaFramework/Instance/MaaContext.h @@ -19,7 +19,7 @@ extern "C" { #endif - MAA_FRAMEWORK_API MaaTaskId MaaContextRunPipeline(MaaContext* context, const char* entry, const char* pipeline_override); + MAA_FRAMEWORK_API MaaTaskId MaaContextRunTask(MaaContext* context, const char* entry, const char* pipeline_override); MAA_FRAMEWORK_API MaaRecoId MaaContextRunRecognition(MaaContext* context, const char* entry, const char* pipeline_override, const MaaImageBuffer* image); @@ -33,7 +33,7 @@ extern "C" MAA_FRAMEWORK_API MaaBool MaaContextOverridePipeline(MaaContext* context, const char* pipeline_override); - MAA_FRAMEWORK_API MaaBool MaaContextOverrideNext(MaaContext* context, const char* name, const MaaStringListBuffer* next_list); + MAA_FRAMEWORK_API MaaBool MaaContextOverrideNext(MaaContext* context, const char* node_name, const MaaStringListBuffer* next_list); MAA_FRAMEWORK_API MaaTaskId MaaContextGetTaskId(const MaaContext* context); diff --git a/include/MaaFramework/Instance/MaaResource.h b/include/MaaFramework/Instance/MaaResource.h index f35cf8f1a..54fee0033 100644 --- a/include/MaaFramework/Instance/MaaResource.h +++ b/include/MaaFramework/Instance/MaaResource.h @@ -37,7 +37,7 @@ extern "C" MAA_FRAMEWORK_API MaaBool MaaResourceClearCustomAction(MaaResource* res); - MAA_FRAMEWORK_API MaaResId MaaResourcePostPath(MaaResource* res, const char* path); + MAA_FRAMEWORK_API MaaResId MaaResourcePostBundle(MaaResource* res, const char* path); MAA_FRAMEWORK_API MaaBool MaaResourceClear(MaaResource* res); diff --git a/include/MaaFramework/Instance/MaaTasker.h b/include/MaaFramework/Instance/MaaTasker.h index 25a86cd24..9f55d93f0 100644 --- a/include/MaaFramework/Instance/MaaTasker.h +++ b/include/MaaFramework/Instance/MaaTasker.h @@ -38,7 +38,7 @@ extern "C" MAA_FRAMEWORK_API MaaBool MaaTaskerInited(const MaaTasker* tasker); - MAA_FRAMEWORK_API MaaTaskId MaaTaskerPostPipeline(MaaTasker* tasker, const char* entry, const char* pipeline_override); + MAA_FRAMEWORK_API MaaTaskId MaaTaskerPostTask(MaaTasker* tasker, const char* entry, const char* pipeline_override); MAA_FRAMEWORK_API MaaStatus MaaTaskerStatus(const MaaTasker* tasker, MaaTaskId id); @@ -60,7 +60,7 @@ extern "C" MAA_FRAMEWORK_API MaaBool MaaTaskerGetRecognitionDetail( const MaaTasker* tasker, MaaRecoId reco_id, - /* out */ MaaStringBuffer* name, + /* out */ MaaStringBuffer* node_name, /* out */ MaaStringBuffer* algorithm, /* out */ MaaBool* hit, /* out */ MaaRect* box, @@ -76,7 +76,7 @@ extern "C" MAA_FRAMEWORK_API MaaBool MaaTaskerGetNodeDetail( const MaaTasker* tasker, MaaNodeId node_id, - /* out */ MaaStringBuffer* name, + /* out */ MaaStringBuffer* node_name, /* out */ MaaRecoId* reco_id, /* out */ MaaBool* completed); @@ -98,7 +98,7 @@ extern "C" */ MAA_FRAMEWORK_API MaaBool MaaTaskerGetLatestNode( const MaaTasker* tasker, - const char* task_name, + const char* node_name, /* out */ MaaNodeId* latest_id); #ifdef __cplusplus diff --git a/include/MaaFramework/MaaDef.h b/include/MaaFramework/MaaDef.h index 96f1315a1..126d5fd4a 100644 --- a/include/MaaFramework/MaaDef.h +++ b/include/MaaFramework/MaaDef.h @@ -283,7 +283,7 @@ typedef void(MAA_CALL* MaaNotificationCallback)(const char* message, const char* typedef MaaBool(MAA_CALL* MaaCustomRecognitionCallback)( MaaContext* context, MaaTaskId task_id, - const char* current_task_name, + const char* node_name, const char* custom_recognition_name, const char* custom_recognition_param, const MaaImageBuffer* image, @@ -295,7 +295,7 @@ typedef MaaBool(MAA_CALL* MaaCustomRecognitionCallback)( typedef MaaBool(MAA_CALL* MaaCustomActionCallback)( MaaContext* context, MaaTaskId task_id, - const char* current_task_name, + const char* node_name, const char* custom_action_name, const char* custom_action_param, MaaRecoId reco_id, diff --git a/include/MaaFramework/MaaMsg.h b/include/MaaFramework/MaaMsg.h index 10772bad6..cfff82e5c 100644 --- a/include/MaaFramework/MaaMsg.h +++ b/include/MaaFramework/MaaMsg.h @@ -50,7 +50,7 @@ /** * @{ - * @brief Message for the tasks. + * @brief Message for the task. * * payload: { * task_id: number, @@ -66,7 +66,7 @@ /** * @{ - * @brief Message for the Recognition List. + * @brief Message for the next list of node. * * payload: { * task_id: number, @@ -74,14 +74,14 @@ * list: string[], * } */ -#define MaaMsg_Task_NextList_Starting ("Task.NextList.Starting") -#define MaaMsg_Task_NextList_Succeeded ("Task.NextList.Succeeded") -#define MaaMsg_Task_NextList_Failed ("Task.NextList.Failed") +#define MaaMsg_Node_NextList_Starting ("Node.NextList.Starting") +#define MaaMsg_Node_NextList_Succeeded ("Node.NextList.Succeeded") +#define MaaMsg_Node_NextList_Failed ("Node.NextList.Failed") /// @} /** * @{ - * @brief Message for the recognition list. + * @brief Message for the recognition list of node. * * payload: { * task_id: number, @@ -89,14 +89,14 @@ * name: string, * } */ -#define MaaMsg_Task_Recognition_Starting ("Task.Recognition.Starting") -#define MaaMsg_Task_Recognition_Succeeded ("Task.Recognition.Succeeded") -#define MaaMsg_Task_Recognition_Failed ("Task.Recognition.Failed") +#define MaaMsg_Node_Recognition_Starting ("Node.Recognition.Starting") +#define MaaMsg_Node_Recognition_Succeeded ("Node.Recognition.Succeeded") +#define MaaMsg_Node_Recognition_Failed ("Node.Recognition.Failed") /// @} /** * @{ - * @brief Message for the task action. + * @brief Message for the action of node. * * payload: { * task_id: number, @@ -104,9 +104,9 @@ * name: string, * } */ -#define MaaMsg_Task_Action_Starting ("Task.Action.Starting") -#define MaaMsg_Task_Action_Succeeded ("Task.Action.Succeeded") -#define MaaMsg_Task_Action_Failed ("Task.Action.Failed") +#define MaaMsg_Node_Action_Starting ("Node.Action.Starting") +#define MaaMsg_Node_Action_Succeeded ("Node.Action.Succeeded") +#define MaaMsg_Node_Action_Failed ("Node.Action.Failed") /// @} /** @} */ diff --git a/sample/cpp/main.cpp b/sample/cpp/main.cpp index 00d98f6eb..8d7585a92 100644 --- a/sample/cpp/main.cpp +++ b/sample/cpp/main.cpp @@ -28,7 +28,7 @@ MaaController* create_win32_controller(); MaaBool my_reco( MaaContext* context, MaaTaskId task_id, - const char* current_task_name, + const char* node_name, const char* custom_recognition_name, const char* custom_recognition_param, const MaaImageBuffer* image, @@ -48,7 +48,7 @@ int main([[maybe_unused]] int argc, char** argv) auto resource_handle = MaaResourceCreate(nullptr, nullptr); std::string resource_dir = R"(E:\Code\MaaFramework\sample\resource)"; - auto res_id = MaaResourcePostPath(resource_handle, resource_dir.c_str()); + auto res_id = MaaResourcePostBundle(resource_handle, resource_dir.c_str()); MaaControllerWait(controller_handle, ctrl_id); MaaResourceWait(resource_handle, res_id); @@ -72,7 +72,7 @@ int main([[maybe_unused]] int argc, char** argv) MaaResourceRegisterCustomRecognition(resource_handle, "MyReco", my_reco, nullptr); - auto task_id = MaaTaskerPostPipeline(tasker_handle, "MyTask", "{}"); + auto task_id = MaaTaskerPostTask(tasker_handle, "MyTask", "{}"); MaaTaskerWait(tasker_handle, task_id); destroy(); @@ -159,7 +159,7 @@ MaaController* create_win32_controller() MaaBool my_reco( MaaContext* context, MaaTaskId task_id, - const char* current_task_name, + const char* node_name, const char* custom_recognition_name, const char* custom_recognition_param, const MaaImageBuffer* image, diff --git a/sample/nodejs/main.ts b/sample/nodejs/main.ts index 82d8ec322..94e6070cb 100644 --- a/sample/nodejs/main.ts +++ b/sample/nodejs/main.ts @@ -48,7 +48,7 @@ async function main() { res.notify = (msg, detail) => { console.log(msg, detail) } - await res.post_path('sample/resource').wait() + await res.post_bundle('sample/resource').wait() const devices = await maa.AdbController.find() if (!devices || devices.length === 0) { @@ -76,7 +76,7 @@ async function main() { res.register_custom_recognizer('MyRec', my_reco) - let task_detail = await tskr.post_pipeline('StartUpAndClickButton').wait().get() + let task_detail = await tskr.post_task('StartUpAndClickButton').wait().get() tskr.destroy() ctrl.destroy() diff --git a/sample/python/__main__.py b/sample/python/__main__.py index 8bb8a68eb..5b2958ac0 100644 --- a/sample/python/__main__.py +++ b/sample/python/__main__.py @@ -14,7 +14,7 @@ def main(): Toolkit.init_option(user_path) resource = Resource() - res_job = resource.post_path("sample/resource") + res_job = resource.post_bundle("sample/resource") res_job.wait() adb_devices = Toolkit.find_adb_devices() @@ -43,7 +43,7 @@ def main(): resource.register_custom_recognition("MyRec", MyRecongition()) - task_detail = tasker.post_pipeline("StartUpAndClickButton").wait().get() + task_detail = tasker.post_task("StartUpAndClickButton").wait().get() # do something with task_detail @@ -72,7 +72,7 @@ def analyze( click_job = context.tasker.controller.post_click(10, 20) click_job.wait() - context.override_next(argv.current_task_name, ["TaskA", "TaskB"]) + context.override_next(argv.node_name, ["TaskA", "TaskB"]) return CustomRecognition.AnalyzeResult( box=(0, 0, 100, 100), detail="Hello World!" @@ -99,24 +99,24 @@ def on_tasker_task( ): print(f"on_tasker_task: {noti_type}, {detail}") - def on_task_next_list( + def on_node_next_list( self, noti_type: NotificationType, - detail: NotificationHandler.TaskNextListDetail, + detail: NotificationHandler.NodeNextListDetail, ): - print(f"on_task_next_list: {noti_type}, {detail}") + print(f"on_node_next_list: {noti_type}, {detail}") - def on_task_recognition( + def on_node_recognition( self, noti_type: NotificationType, - detail: NotificationHandler.TaskRecognitionDetail, + detail: NotificationHandler.NodeRecognitionDetail, ): - print(f"on_task_recognition: {noti_type}, {detail}") + print(f"on_node_recognition: {noti_type}, {detail}") - def on_task_action( - self, noti_type: NotificationType, detail: NotificationHandler.TaskActionDetail + def on_node_action( + self, noti_type: NotificationType, detail: NotificationHandler.NodeActionDetail ): - print(f"on_task_action: {noti_type}, {detail}") + print(f"on_node_action: {noti_type}, {detail}") if __name__ == "__main__": diff --git a/sample/python/pi_cli.py b/sample/python/pi_cli.py index 0ad72a652..0a23c74df 100644 --- a/sample/python/pi_cli.py +++ b/sample/python/pi_cli.py @@ -19,7 +19,7 @@ def run( print(f"on MyAction.run, context: {context}, argv: {argv}") - context.override_next(argv.current_task_name, ["TaskA", "TaskB"]) + context.override_next(argv.node_name, ["TaskA", "TaskB"]) image = context.tasker.controller.cached_image context.tasker.controller.post_click(100, 100).wait() diff --git a/source/MaaFramework/API/MaaContext.cpp b/source/MaaFramework/API/MaaContext.cpp index 309dc4c4b..49fb5bb98 100644 --- a/source/MaaFramework/API/MaaContext.cpp +++ b/source/MaaFramework/API/MaaContext.cpp @@ -5,7 +5,7 @@ #include "Utils/Buffer/StringBuffer.hpp" #include "Utils/Logger.h" -MaaTaskId MaaContextRunPipeline(MaaContext* context, const char* entry, const char* pipeline_override) +MaaTaskId MaaContextRunTask(MaaContext* context, const char* entry, const char* pipeline_override) { LogFunc << VAR_VOIDP(context) << VAR(entry) << VAR(pipeline_override); @@ -24,7 +24,7 @@ MaaTaskId MaaContextRunPipeline(MaaContext* context, const char* entry, const ch return MaaInvalidId; } - return context->run_pipeline(entry, ov_opt->as_object()); + return context->run_task(entry, ov_opt->as_object()); } MaaRecoId MaaContextRunRecognition(MaaContext* context, const char* entry, const char* pipeline_override, const MaaImageBuffer* image) diff --git a/source/MaaFramework/API/MaaResource.cpp b/source/MaaFramework/API/MaaResource.cpp index 682f2c98f..ff97e0a59 100644 --- a/source/MaaFramework/API/MaaResource.cpp +++ b/source/MaaFramework/API/MaaResource.cpp @@ -104,7 +104,7 @@ MaaBool MaaResourceClearCustomAction(MaaResource* res) return true; } -MaaResId MaaResourcePostPath(MaaResource* res, const char* path) +MaaResId MaaResourcePostBundle(MaaResource* res, const char* path) { LogFunc << VAR_VOIDP(res) << VAR(path); @@ -113,7 +113,7 @@ MaaResId MaaResourcePostPath(MaaResource* res, const char* path) return MaaInvalidId; } - return res->post_path(MAA_NS::path(path)); + return res->post_bundle(MAA_NS::path(path)); } MaaBool MaaResourceClear(MaaResource* res) diff --git a/source/MaaFramework/API/MaaTasker.cpp b/source/MaaFramework/API/MaaTasker.cpp index 155cadaea..3a21a9a12 100644 --- a/source/MaaFramework/API/MaaTasker.cpp +++ b/source/MaaFramework/API/MaaTasker.cpp @@ -70,7 +70,7 @@ MaaBool MaaTaskerInited(const MaaTasker* tasker) return tasker->inited(); } -MaaTaskId MaaTaskerPostPipeline(MaaTasker* tasker, const char* entry, const char* pipeline_override) +MaaTaskId MaaTaskerPostTask(MaaTasker* tasker, const char* entry, const char* pipeline_override) { LogFunc << VAR_VOIDP(tasker) << VAR(entry) << VAR(pipeline_override); @@ -89,7 +89,7 @@ MaaTaskId MaaTaskerPostPipeline(MaaTasker* tasker, const char* entry, const char return MaaInvalidId; } - return tasker->post_pipeline(entry, ov_opt->as_object()); + return tasker->post_task(entry, ov_opt->as_object()); } MaaStatus MaaTaskerStatus(const MaaTasker* tasker, MaaTaskId id) @@ -312,16 +312,16 @@ MaaBool MaaTaskerGetTaskDetail( return true; } -MaaBool MaaTaskerGetLatestNode(const MaaTasker* tasker, const char* task_name, MaaNodeId* latest_id) +MaaBool MaaTaskerGetLatestNode(const MaaTasker* tasker, const char* node_name, MaaNodeId* latest_id) { if (!tasker) { LogError << "handle is null"; return false; } - auto result_opt = tasker->get_latest_node(task_name); + auto result_opt = tasker->get_latest_node(node_name); if (!result_opt) { - LogError << "failed to get_latest_node" << VAR(task_name); + LogError << "failed to get_latest_node" << VAR(node_name); return false; } diff --git a/source/MaaFramework/API/MaaTypes.h b/source/MaaFramework/API/MaaTypes.h index 4c009916d..201cb91ec 100644 --- a/source/MaaFramework/API/MaaTypes.h +++ b/source/MaaFramework/API/MaaTypes.h @@ -18,7 +18,7 @@ struct MaaResource virtual bool set_option(MaaResOption key, MaaOptionValue value, MaaOptionValueSize val_size) = 0; - virtual MaaResId post_path(const std::filesystem::path& path) = 0; + virtual MaaResId post_bundle(const std::filesystem::path& path) = 0; virtual MaaStatus status(MaaResId res_id) const = 0; virtual MaaStatus wait(MaaResId res_id) const = 0; @@ -77,7 +77,7 @@ struct MaaTasker virtual bool set_option(MaaTaskerOption key, MaaOptionValue value, MaaOptionValueSize val_size) = 0; - virtual MaaTaskId post_pipeline(const std::string& entry, const json::object& pipeline_override) = 0; + virtual MaaTaskId post_task(const std::string& entry, const json::object& pipeline_override) = 0; virtual MaaStatus status(MaaTaskId task_id) const = 0; virtual MaaStatus wait(MaaTaskId task_id) const = 0; @@ -92,7 +92,7 @@ struct MaaTasker virtual std::optional get_task_detail(MaaTaskId task_id) const = 0; virtual std::optional get_node_detail(MaaNodeId node_id) const = 0; virtual std::optional get_reco_result(MaaRecoId reco_id) const = 0; - virtual std::optional get_latest_node(const std::string& task_name) const = 0; + virtual std::optional get_latest_node(const std::string& node_name) const = 0; }; struct MaaContext @@ -100,12 +100,12 @@ struct MaaContext public: virtual ~MaaContext() = default; - virtual MaaTaskId run_pipeline(const std::string& entry, const json::object& pipeline_override) = 0; + virtual MaaTaskId run_task(const std::string& entry, const json::object& pipeline_override) = 0; virtual MaaRecoId run_recognition(const std::string& entry, const json::object& pipeline_override, const cv::Mat& image) = 0; virtual MaaNodeId run_action(const std::string& entry, const json::object& pipeline_override, const cv::Rect& box, const std::string& reco_detail) = 0; virtual bool override_pipeline(const json::object& pipeline_override) = 0; - virtual bool override_next(const std::string& name, const std::vector& next) = 0; + virtual bool override_next(const std::string& node_name, const std::vector& next) = 0; virtual MaaContext* clone() const = 0; diff --git a/source/MaaFramework/Resource/PipelineResMgr.cpp b/source/MaaFramework/Resource/PipelineResMgr.cpp index 49d9cb27a..10891ab74 100644 --- a/source/MaaFramework/Resource/PipelineResMgr.cpp +++ b/source/MaaFramework/Resource/PipelineResMgr.cpp @@ -178,7 +178,7 @@ bool PipelineResMgr::check_next_list(const PipelineData::NextList& next_list, co { for (const auto& next : next_list) { if (!data_map.contains(next)) { - LogError << "Invalid next task name" << VAR(next); + LogError << "Invalid next node name" << VAR(next); return false; } } diff --git a/source/MaaFramework/Resource/ResourceMgr.cpp b/source/MaaFramework/Resource/ResourceMgr.cpp index f44915f1d..71639ffb9 100644 --- a/source/MaaFramework/Resource/ResourceMgr.cpp +++ b/source/MaaFramework/Resource/ResourceMgr.cpp @@ -45,7 +45,7 @@ bool ResourceMgr::set_option(MaaResOption key, MaaOptionValue value, MaaOptionVa } } -MaaResId ResourceMgr::post_path(const std::filesystem::path& path) +MaaResId ResourceMgr::post_bundle(const std::filesystem::path& path) { LogInfo << VAR(path); diff --git a/source/MaaFramework/Resource/ResourceMgr.h b/source/MaaFramework/Resource/ResourceMgr.h index 6cde4e308..9838ba322 100644 --- a/source/MaaFramework/Resource/ResourceMgr.h +++ b/source/MaaFramework/Resource/ResourceMgr.h @@ -35,7 +35,7 @@ class ResourceMgr : public MaaResource public: // MaaResource virtual bool set_option(MaaResOption key, MaaOptionValue value, MaaOptionValueSize val_size) override; - virtual MaaResId post_path(const std::filesystem::path& path) override; + virtual MaaResId post_bundle(const std::filesystem::path& path) override; virtual MaaStatus status(MaaResId res_id) const override; virtual MaaStatus wait(MaaResId res_id) const override; diff --git a/source/MaaFramework/Task/Component/CustomAction.cpp b/source/MaaFramework/Task/Component/CustomAction.cpp index 8ab3f4adf..ebdef51ec 100644 --- a/source/MaaFramework/Task/Component/CustomAction.cpp +++ b/source/MaaFramework/Task/Component/CustomAction.cpp @@ -6,17 +6,17 @@ MAA_TASK_NS_BEGIN bool CustomAction::run( Context& context, - std::string task_name, + std::string node_name, MAA_RES_NS::CustomActionSession session, const MAA_RES_NS::Action::CustomParam& param, MaaRecoId reco_id, const cv::Rect& rect) { - LogFunc << VAR(context.task_id()) << VAR(task_name) << VAR_VOIDP(session.action) << VAR_VOIDP(session.trans_arg) + LogFunc << VAR(context.task_id()) << VAR(node_name) << VAR_VOIDP(session.action) << VAR_VOIDP(session.trans_arg) << VAR(param.custom_param) << VAR(reco_id) << VAR(rect); if (!session.action) { - LogError << "Action is null" << VAR(task_name) << VAR(param.name); + LogError << "Action is null" << VAR(node_name) << VAR(param.name); return false; } @@ -26,14 +26,14 @@ bool CustomAction::run( bool ret = session.action( &context, context.task_id(), - task_name.c_str(), + node_name.c_str(), param.name.c_str(), custom_param_string.c_str(), reco_id, &crect, session.trans_arg); - LogDebug << VAR(task_name) << VAR_VOIDP(session.action) << VAR(session.trans_arg) << VAR(ret); + LogDebug << VAR(node_name) << VAR_VOIDP(session.action) << VAR(session.trans_arg) << VAR(ret); return ret; } diff --git a/source/MaaFramework/Task/Component/CustomAction.h b/source/MaaFramework/Task/Component/CustomAction.h index e60fa1b88..bf3e93dac 100644 --- a/source/MaaFramework/Task/Component/CustomAction.h +++ b/source/MaaFramework/Task/Component/CustomAction.h @@ -14,7 +14,7 @@ class CustomAction public: static bool run(Context& context, - std::string task_name, + std::string node_name, MAA_RES_NS::CustomActionSession session, const MAA_RES_NS::Action::CustomParam& param, MaaRecoId reco_id, diff --git a/source/MaaFramework/Task/Component/Recognizer.cpp b/source/MaaFramework/Task/Component/Recognizer.cpp index 0640f8d4b..174cf767d 100644 --- a/source/MaaFramework/Task/Component/Recognizer.cpp +++ b/source/MaaFramework/Task/Component/Recognizer.cpp @@ -301,7 +301,7 @@ RecoResult Recognizer::nn_detect(const MAA_VISION_NS::NeuralNetworkDetectorParam RecoResult Recognizer::custom_recognize(const MAA_VISION_NS::CustomRecognitionParam& param, const std::string& name) { using namespace MAA_VISION_NS; - std::ignore = name; // task name + std::ignore = name; // node name if (!tasker_) { LogError << "tasker_ is null"; @@ -366,7 +366,7 @@ cv::Rect Recognizer::get_roi(const MAA_VISION_NS::Target& roi) return cv::Rect { raw.x + roi.offset.x, raw.y + roi.offset.y, raw.width + roi.offset.width, raw.height + roi.offset.height }; } -void Recognizer::save_draws(const std::string& task_name, const RecoResult& result) const +void Recognizer::save_draws(const std::string& node_name, const RecoResult& result) const { const auto& option = GlobalOptionMgr::get_instance(); @@ -377,20 +377,20 @@ void Recognizer::save_draws(const std::string& task_name, const RecoResult& resu auto dir = option.log_dir() / "vision"; for (const auto& draw : result.draws) { - std::string filename = std::format("{}_{}_{}.png", task_name, result.reco_id, format_now_for_filename()); + std::string filename = std::format("{}_{}_{}.png", node_name, result.reco_id, format_now_for_filename()); auto filepath = dir / path(filename); imwrite(filepath, draw); LogDebug << "save draw to" << filepath; } } -void Recognizer::show_hit_draw(const cv::Rect& box, const std::string& task_name, MaaRecoId uid) const +void Recognizer::show_hit_draw(const cv::Rect& box, const std::string& node_name, MaaRecoId uid) const { if (!GlobalOptionMgr::get_instance().show_hit_draw()) { return; } - const std::string kWinName = std::format("Hit: {} {}", task_name, uid); + const std::string kWinName = std::format("Hit: {} {}", node_name, uid); cv::Mat draw = image_.clone(); diff --git a/source/MaaFramework/Task/Component/Recognizer.h b/source/MaaFramework/Task/Component/Recognizer.h index 79aaa67a4..267bb7a19 100644 --- a/source/MaaFramework/Task/Component/Recognizer.h +++ b/source/MaaFramework/Task/Component/Recognizer.h @@ -34,8 +34,8 @@ class Recognizer RecoResult custom_recognize(const MAA_VISION_NS::CustomRecognitionParam& param, const std::string& name); cv::Rect get_roi(const MAA_VISION_NS::Target& roi); - void save_draws(const std::string& task_name, const RecoResult& result) const; - void show_hit_draw(const cv::Rect& box, const std::string& task_name, MaaRecoId uid) const; + void save_draws(const std::string& node_name, const RecoResult& result) const; + void show_hit_draw(const cv::Rect& box, const std::string& node_name, MaaRecoId uid) const; private: bool debug_mode() const; diff --git a/source/MaaFramework/Task/Context.cpp b/source/MaaFramework/Task/Context.cpp index 523786e1a..61eea7b83 100644 --- a/source/MaaFramework/Task/Context.cpp +++ b/source/MaaFramework/Task/Context.cpp @@ -44,7 +44,7 @@ Context::Context(const Context& other) LogDebug << VAR(other.getptr()); } -MaaTaskId Context::run_pipeline(const std::string& entry, const json::object& pipeline_override) +MaaTaskId Context::run_task(const std::string& entry, const json::object& pipeline_override) { LogFunc << VAR(getptr()) << VAR(entry) << VAR(pipeline_override); @@ -175,11 +175,11 @@ Tasker* Context::tasker() const return tasker_; } -std::optional Context::get_pipeline_data(const std::string& task_name) +std::optional Context::get_pipeline_data(const std::string& node_name) { - auto override_it = pipeline_override_.find(task_name); + auto override_it = pipeline_override_.find(node_name); if (override_it != pipeline_override_.end()) { - LogDebug << "found in override" << VAR(task_name); + LogDebug << "found in override" << VAR(node_name); return override_it->second; } @@ -194,12 +194,12 @@ std::optional Context::get_pipeline_data(const std::strin } auto& raw_data_map = resource->pipeline_res().get_pipeline_data_map(); - auto raw_it = raw_data_map.find(task_name); + auto raw_it = raw_data_map.find(node_name); if (raw_it != raw_data_map.end()) { return raw_it->second; } - LogWarn << "task not found" << VAR(task_name); + LogWarn << "task not found" << VAR(node_name); return std::nullopt; } diff --git a/source/MaaFramework/Task/Context.h b/source/MaaFramework/Task/Context.h index 4e9975012..4fe083a11 100644 --- a/source/MaaFramework/Task/Context.h +++ b/source/MaaFramework/Task/Context.h @@ -35,7 +35,7 @@ class Context virtual ~Context() override = default; public: // from MaaContextAPI - virtual MaaTaskId run_pipeline(const std::string& entry, const json::object& pipeline_override) override; + virtual MaaTaskId run_task(const std::string& entry, const json::object& pipeline_override) override; virtual MaaRecoId run_recognition(const std::string& entry, const json::object& pipeline_override, const cv::Mat& image) override; virtual MaaNodeId run_action(const std::string& entry, const json::object& pipeline_override, const cv::Rect& box, const std::string& reco_detail) @@ -49,7 +49,7 @@ class Context virtual Tasker* tasker() const override; public: - std::optional get_pipeline_data(const std::string& task_name); + std::optional get_pipeline_data(const std::string& node_name); bool& need_to_stop(); private: diff --git a/source/MaaFramework/Task/PipelineTask.cpp b/source/MaaFramework/Task/PipelineTask.cpp index ca22bf946..cbd8bfe58 100644 --- a/source/MaaFramework/Task/PipelineTask.cpp +++ b/source/MaaFramework/Task/PipelineTask.cpp @@ -30,22 +30,22 @@ bool PipelineTask::run() return false; } - PipelineData current = std::move(*begin_opt); + PipelineData node = std::move(*begin_opt); PipelineData::NextList next = { entry_ }; PipelineData::NextList interrupt; bool error_handling = false; while (!next.empty() && !context_->need_to_stop()) { - cur_task_ = current.name; + cur_node_ = node.name; size_t next_size = next.size(); PipelineData::NextList list = std::move(next); list.insert(list.end(), std::make_move_iterator(interrupt.begin()), std::make_move_iterator(interrupt.end())); - auto node_detail = run_reco_and_action(list, current); + auto node_detail = run_reco_and_action(list, node); if (context_->need_to_stop()) { - LogWarn << "need_to_stop" << VAR(current.name); + LogWarn << "need_to_stop" << VAR(node.name); return true; } @@ -61,26 +61,26 @@ bool PipelineTask::run() LogError << "get_pipeline_data failed, task not exist" << VAR(node_detail.name); return false; } - PipelineData hit_task = std::move(*hit_opt); + PipelineData hit_node = std::move(*hit_opt); - if (is_interrupt || hit_task.is_sub) { // for compatibility with v1.x - LogInfo << "push task_stack:" << current.name; - task_stack.emplace(current.name); + if (is_interrupt || hit_node.is_sub) { // for compatibility with v1.x + LogInfo << "push task_stack:" << node.name; + task_stack.emplace(node.name); } - current = hit_task; - next = hit_task.next; - interrupt = hit_task.interrupt; + node = hit_node; + next = hit_node.next; + interrupt = hit_node.interrupt; } else if (error_handling) { - LogError << "error handling loop detected" << VAR(current.name); + LogError << "error handling loop detected" << VAR(node.name); next.clear(); interrupt.clear(); } else { - LogInfo << "handle error" << VAR(current.name); + LogInfo << "handle error" << VAR(node.name); error_handling = true; - next = current.on_error; + next = node.on_error; interrupt.clear(); } @@ -94,9 +94,9 @@ bool PipelineTask::run() LogError << "get_pipeline_data failed, task not exist" << VAR(top); return false; } - current = std::move(*top_opt); - next = current.next; - interrupt = current.interrupt; + node = std::move(*top_opt); + next = node.next; + interrupt = node.interrupt; } } @@ -117,7 +117,7 @@ NodeDetail PipelineTask::run_reco_and_action(const PipelineData::NextList& list, if (!tasker_) { LogError << "tasker is null"; return {}; - } + } if (!context_) { LogError << "context is null"; return {}; diff --git a/source/MaaFramework/Task/TaskBase.cpp b/source/MaaFramework/Task/TaskBase.cpp index 2041b7938..b17d04315 100644 --- a/source/MaaFramework/Task/TaskBase.cpp +++ b/source/MaaFramework/Task/TaskBase.cpp @@ -14,7 +14,7 @@ MAA_TASK_NS_BEGIN TaskBase::TaskBase(std::string entry, Tasker* tasker) : tasker_(tasker) , entry_(std::move(entry)) - , cur_task_(entry_) + , cur_node_(entry_) , context_(Context::create(task_id_, tasker)) { } @@ -22,7 +22,7 @@ TaskBase::TaskBase(std::string entry, Tasker* tasker) TaskBase::TaskBase(std::string entry, Tasker* tasker, std::shared_ptr context) : tasker_(tasker) , entry_(std::move(entry)) - , cur_task_(entry_) + , cur_node_(entry_) , context_(std::move(context)) { } @@ -59,7 +59,7 @@ MAA_CTRL_NS::ControllerAgent* TaskBase::controller() RecoResult TaskBase::run_recognition(const cv::Mat& image, const PipelineData::NextList& list) { - LogFunc << VAR(cur_task_) << VAR(list); + LogFunc << VAR(cur_node_) << VAR(list); if (!context_) { LogError << "context is null"; @@ -71,34 +71,34 @@ RecoResult TaskBase::run_recognition(const cv::Mat& image, const PipelineData::N return {}; } - auto cur_opt = context_->get_pipeline_data(cur_task_); - if (!cur_opt) { - LogError << "get_pipeline_data failed, task not exist" << VAR(cur_task_); + auto node_opt = context_->get_pipeline_data(cur_node_); + if (!node_opt) { + LogError << "get_pipeline_data failed, node not exist" << VAR(cur_node_); return {}; } - bool current_focus = cur_opt->focus; + bool focus = node_opt->focus; const json::value reco_list_cb_detail { { "task_id", task_id() }, - { "name", cur_task_ }, + { "name", cur_node_ }, { "list", json::array(list) }, }; - if (debug_mode() || current_focus) { - notify(MaaMsg_Task_NextList_Starting, reco_list_cb_detail); + if (debug_mode() || focus) { + notify(MaaMsg_Node_NextList_Starting, reco_list_cb_detail); } Recognizer recognizer(tasker_, *context_, image); - for (const auto& name : list) { - auto data_opt = context_->get_pipeline_data(name); + for (const auto& node : list) { + auto data_opt = context_->get_pipeline_data(node); if (!data_opt) { - LogError << "get_pipeline_data failed, task not exist" << VAR(name); + LogError << "get_pipeline_data failed, node not exist" << VAR(node); continue; } const auto& pipeline_data = *data_opt; if (!pipeline_data.enabled) { - LogDebug << "Task disabled" << name << VAR(pipeline_data.enabled); + LogDebug << "node disabled" << node << VAR(pipeline_data.enabled); continue; } @@ -106,9 +106,9 @@ RecoResult TaskBase::run_recognition(const cv::Mat& image, const PipelineData::N const json::value reco_cb_detail { { "task_id", task_id() }, { "reco_id", 0 }, - { "name", name }, + { "name", node }, }; - notify(MaaMsg_Task_Recognition_Starting, reco_cb_detail); + notify(MaaMsg_Node_Recognition_Starting, reco_cb_detail); } RecoResult result = recognizer.recognize(pipeline_data); @@ -117,26 +117,26 @@ RecoResult TaskBase::run_recognition(const cv::Mat& image, const PipelineData::N const json::value reco_cb_detail { { "task_id", task_id() }, { "reco_id", result.reco_id }, - { "name", name }, + { "name", node }, }; - notify(result.box ? MaaMsg_Task_Recognition_Succeeded : MaaMsg_Task_Recognition_Failed, reco_cb_detail); + notify(result.box ? MaaMsg_Node_Recognition_Succeeded : MaaMsg_Node_Recognition_Failed, reco_cb_detail); } if (!result.box) { continue; } - LogInfo << "Task hit" << VAR(result.name) << VAR(result.box); + LogInfo << "node hit" << VAR(result.name) << VAR(result.box); - if (debug_mode() || current_focus) { - notify(MaaMsg_Task_NextList_Succeeded, reco_list_cb_detail); + if (debug_mode() || focus) { + notify(MaaMsg_Node_NextList_Succeeded, reco_list_cb_detail); } return result; } - if (debug_mode() || current_focus) { - notify(MaaMsg_Task_NextList_Failed, reco_list_cb_detail); + if (debug_mode() || focus) { + notify(MaaMsg_Node_NextList_Failed, reco_list_cb_detail); } return {}; @@ -154,12 +154,12 @@ NodeDetail TaskBase::run_action(const RecoResult& reco) return {}; } - auto cur_opt = context_->get_pipeline_data(reco.name); - if (!cur_opt) { - LogError << "get_pipeline_data failed, task not exist" << VAR(reco.name); + auto node_opt = context_->get_pipeline_data(reco.name); + if (!node_opt) { + LogError << "get_pipeline_data failed, node not exist" << VAR(reco.name); return {}; } - const auto& pipeline_data = *cur_opt; + const auto& pipeline_data = *node_opt; if (debug_mode() || pipeline_data.focus) { const json::value cb_detail { @@ -167,7 +167,7 @@ NodeDetail TaskBase::run_action(const RecoResult& reco) { "node_id", 0 }, { "name", reco.name }, }; - notify(MaaMsg_Task_Action_Starting, cb_detail); + notify(MaaMsg_Node_Action_Starting, cb_detail); } Actuator actuator(tasker_, *context_); @@ -188,7 +188,7 @@ NodeDetail TaskBase::run_action(const RecoResult& reco) { "node_id", result.node_id }, { "name", reco.name }, }; - notify(result.completed ? MaaMsg_Task_Action_Succeeded : MaaMsg_Task_Action_Failed, cb_detail); + notify(result.completed ? MaaMsg_Node_Action_Succeeded : MaaMsg_Node_Action_Failed, cb_detail); } return result; diff --git a/source/MaaFramework/Task/TaskBase.h b/source/MaaFramework/Task/TaskBase.h index c6688d90f..96aa80470 100644 --- a/source/MaaFramework/Task/TaskBase.h +++ b/source/MaaFramework/Task/TaskBase.h @@ -53,7 +53,7 @@ class TaskBase Tasker* tasker_ = nullptr; const std::string entry_; - std::string cur_task_; + std::string cur_node_; std::shared_ptr context_ = nullptr; diff --git a/source/MaaFramework/Tasker/RuntimeCache.h b/source/MaaFramework/Tasker/RuntimeCache.h index 4f0919613..54a4de8c2 100644 --- a/source/MaaFramework/Tasker/RuntimeCache.h +++ b/source/MaaFramework/Tasker/RuntimeCache.h @@ -2,8 +2,9 @@ #include #include -#include #include +#include + #include "Task/TaskResultTypes.h" #include "Utils/NoWarningCVMat.hpp" diff --git a/source/MaaFramework/Tasker/Tasker.cpp b/source/MaaFramework/Tasker/Tasker.cpp index 3114422e5..df4100433 100644 --- a/source/MaaFramework/Tasker/Tasker.cpp +++ b/source/MaaFramework/Tasker/Tasker.cpp @@ -69,7 +69,7 @@ bool Tasker::set_option(MaaTaskerOption key, MaaOptionValue value, MaaOptionValu return false; } -MaaTaskId Tasker::post_pipeline(const std::string& entry, const json::object& pipeline_override) +MaaTaskId Tasker::post_task(const std::string& entry, const json::object& pipeline_override) { LogInfo << VAR(entry) << VAR(pipeline_override); @@ -168,9 +168,9 @@ std::optional Tasker::get_reco_result(MaaRecoId reco_id return runtime_cache().get_reco_result(reco_id); } -std::optional Tasker::get_latest_node(const std::string& task_name) const +std::optional Tasker::get_latest_node(const std::string& node_name) const { - return runtime_cache().get_latest_node(task_name); + return runtime_cache().get_latest_node(node_name); } RuntimeCache& Tasker::runtime_cache() diff --git a/source/MaaFramework/Tasker/Tasker.h b/source/MaaFramework/Tasker/Tasker.h index 33b950fc4..f47609ff1 100644 --- a/source/MaaFramework/Tasker/Tasker.h +++ b/source/MaaFramework/Tasker/Tasker.h @@ -30,7 +30,7 @@ class Tasker : public MaaTasker virtual bool set_option(MaaTaskerOption key, MaaOptionValue value, MaaOptionValueSize val_size) override; - virtual MaaTaskId post_pipeline(const std::string& entry, const json::object& pipeline_override) override; + virtual MaaTaskId post_task(const std::string& entry, const json::object& pipeline_override) override; virtual MaaStatus status(MaaTaskId task_id) const override; virtual MaaStatus wait(MaaTaskId task_id) const override; @@ -45,7 +45,7 @@ class Tasker : public MaaTasker virtual std::optional get_task_detail(MaaTaskId task_id) const override; virtual std::optional get_node_detail(MaaNodeId node_id) const override; virtual std::optional get_reco_result(MaaRecoId reco_id) const override; - virtual std::optional get_latest_node(const std::string& task_name) const override; + virtual std::optional get_latest_node(const std::string& node_name) const override; public: RuntimeCache& runtime_cache(); diff --git a/source/MaaProjectInterface/Impl/Runner.cpp b/source/MaaProjectInterface/Impl/Runner.cpp index 11aed6802..a8986044e 100644 --- a/source/MaaProjectInterface/Impl/Runner.cpp +++ b/source/MaaProjectInterface/Impl/Runner.cpp @@ -49,7 +49,7 @@ bool Runner::run( MaaId cid = MaaControllerPostConnection(controller_handle); MaaId rid = 0; for (const auto& path : param.resource_path) { - rid = MaaResourcePostPath(resource_handle, path.c_str()); + rid = MaaResourcePostBundle(resource_handle, path.c_str()); } for (const auto& [name, reco] : custom_recognitions) { MaaResourceRegisterCustomRecognition(resource_handle, name.c_str(), reco.recognition, reco.trans_arg); @@ -80,7 +80,7 @@ bool Runner::run( MaaId tid = 0; for (const auto& task : param.task) { std::string pp_override = task.pipeline_override.to_string(); - tid = MaaTaskerPostPipeline(tasker_handle, task.entry.c_str(), pp_override.c_str()); + tid = MaaTaskerPostTask(tasker_handle, task.entry.c_str(), pp_override.c_str()); } MaaTaskerWait(tasker_handle, tid); diff --git a/source/binding/NodeJS/release/maa-node/src/context.ts b/source/binding/NodeJS/release/maa-node/src/context.ts index f45115c38..fa6237c15 100644 --- a/source/binding/NodeJS/release/maa-node/src/context.ts +++ b/source/binding/NodeJS/release/maa-node/src/context.ts @@ -10,8 +10,8 @@ export class Context { this.#tasker = new TaskerBase(maa.context_get_tasker(this.handle)) } - async run_pipeline(entry: string, pipeline_override: Record = {}) { - const id = await maa.context_run_pipeline( + async run_task(entry: string, pipeline_override: Record = {}) { + const id = await maa.context_run_task( this.handle, entry, JSON.stringify(pipeline_override) diff --git a/source/binding/NodeJS/release/maa-node/src/maa.d.ts b/source/binding/NodeJS/release/maa-node/src/maa.d.ts index 68f88b244..82b18d9bb 100644 --- a/source/binding/NodeJS/release/maa-node/src/maa.d.ts +++ b/source/binding/NodeJS/release/maa-node/src/maa.d.ts @@ -36,7 +36,7 @@ export type NotificationCallback = (message: string, details_json: string) => Ma export type CustomRecognitionCallback = ( context: ContextHandle, task_id: TaskId, - current_task_name: string, + node_name: string, custom_recognition_name: string, custom_recognition_param: string, image: ImageData, @@ -45,7 +45,7 @@ export type CustomRecognitionCallback = ( export type CustomActionCallback = ( context: ContextHandle, task_id: TaskId, - current_task_name: string, + node_name: string, custom_action_name: string, custom_action_param: string, reco_id: RecoId, @@ -73,7 +73,7 @@ export type CustomControllerCallback = ( // context.cpp -export declare function context_run_pipeline( +export declare function context_run_task( context: ContextHandle, entry: string, pipeline_override: string @@ -223,7 +223,7 @@ export declare function resource_unregister_custom_action( name: string ): boolean export declare function resource_clear_custom_action(handle: ResourceHandle): boolean -export declare function resource_post_path(handle: ResourceHandle, path: string): ResId +export declare function resource_post_bundle(handle: ResourceHandle, path: string): ResId export declare function resource_clear(handle: ResourceHandle): boolean export declare function resource_status(handle: ResourceHandle, res_id: ResId): Status export declare function resource_wait(handle: ResourceHandle, res_id: ResId): Promise @@ -244,7 +244,7 @@ export declare function tasker_bind_controller( controller: ControllerHandle | null ): boolean export declare function tasker_inited(handle: TaskerHandle): boolean -export declare function tasker_post_pipeline( +export declare function tasker_post_task( handle: TaskerHandle, entry: string, pipeline_override: string @@ -280,7 +280,7 @@ export declare function tasker_get_task_detail( ): [entry: string, node_ids: NodeId[], status: Status] | null export declare function tasker_get_latest_node( handle: TaskerHandle, - task_name: string + node_name: string ): NodeId | null // config.cpp diff --git a/source/binding/NodeJS/release/maa-node/src/resource.ts b/source/binding/NodeJS/release/maa-node/src/resource.ts index 45d9684c0..9d0a2d390 100644 --- a/source/binding/NodeJS/release/maa-node/src/resource.ts +++ b/source/binding/NodeJS/release/maa-node/src/resource.ts @@ -135,8 +135,8 @@ export class ResourceBase { } } - post_path(path: string) { - return new Job(this.#source, maa.resource_post_path(this.handle, path)) + post_bundle(path: string) { + return new Job(this.#source, maa.resource_post_bundle(this.handle, path)) } clear() { diff --git a/source/binding/NodeJS/release/maa-node/src/tasker.ts b/source/binding/NodeJS/release/maa-node/src/tasker.ts index 9ed301fd1..e0f881e6b 100644 --- a/source/binding/NodeJS/release/maa-node/src/tasker.ts +++ b/source/binding/NodeJS/release/maa-node/src/tasker.ts @@ -117,11 +117,11 @@ export class TaskerBase { } } - post_pipeline(entry: string, param: Record = {}) { + post_task(entry: string, param: Record = {}) { return new TaskJob( this, this.#source, - maa.tasker_post_pipeline(this.handle, entry, JSON.stringify(param)) + maa.tasker_post_task(this.handle, entry, JSON.stringify(param)) ) } diff --git a/source/binding/NodeJS/src/include/cb.h b/source/binding/NodeJS/src/include/cb.h index cfee67022..1c42a713b 100644 --- a/source/binding/NodeJS/src/include/cb.h +++ b/source/binding/NodeJS/src/include/cb.h @@ -19,7 +19,7 @@ inline void NotificationCallback(const char* message, const char* details_json, inline MaaBool CustomRecognizerCallback( MaaContext* context, MaaTaskId task_id, - const char* current_task_name, + const char* node_name, const char* custom_recognition_name, const char* custom_recognition_param, const MaaImageBuffer* image, @@ -35,7 +35,7 @@ inline MaaBool CustomRecognizerCallback( return fn.Call({ Napi::External::New(env, context), JSConvert::to_value(env, task_id), - Napi::String::New(env, current_task_name), + Napi::String::New(env, node_name), Napi::String::New(env, custom_recognition_name), Napi::String::New(env, custom_recognition_param), ImageBufferRefer(image).data(env), @@ -65,7 +65,7 @@ inline MaaBool CustomRecognizerCallback( inline MaaBool CustomActionCallback( MaaContext* context, MaaTaskId task_id, - const char* current_task_name, + const char* node_name, const char* custom_action_name, const char* custom_action_param, MaaRecoId reco_id, @@ -79,7 +79,7 @@ inline MaaBool CustomActionCallback( return fn.Call({ Napi::External::New(env, context), JSConvert::to_value(env, task_id), - Napi::String::New(env, current_task_name), + Napi::String::New(env, node_name), Napi::String::New(env, custom_action_name), Napi::String::New(env, custom_action_param), JSConvert::to_value(env, reco_id), diff --git a/source/binding/NodeJS/src/instance/context.cpp b/source/binding/NodeJS/src/instance/context.cpp index b64cba1b5..653218e6a 100644 --- a/source/binding/NodeJS/src/instance/context.cpp +++ b/source/binding/NodeJS/src/instance/context.cpp @@ -6,17 +6,12 @@ #include #include -Napi::Promise context_run_pipeline( - Napi::Env env, - Napi::External info, - std::string entry, - std::string overr) +Napi::Promise context_run_task(Napi::Env env, Napi::External info, std::string entry, std::string overr) { auto handle = info.Data(); - auto worker = - new SimpleAsyncWork(env, [handle, entry, overr]() { - return MaaContextRunPipeline(handle, entry.c_str(), overr.c_str()); - }); + auto worker = new SimpleAsyncWork(env, [handle, entry, overr]() { + return MaaContextRunTask(handle, entry.c_str(), overr.c_str()); + }); worker->Queue(); return worker->Promise(); } @@ -107,7 +102,7 @@ void load_instance_context( Napi::Object& exports, Napi::External context) { - BIND(context_run_pipeline); + BIND(context_run_task); BIND(context_run_recognition); BIND(context_run_action); BIND(context_override_pipeline); diff --git a/source/binding/NodeJS/src/instance/resource.cpp b/source/binding/NodeJS/src/instance/resource.cpp index 16e7cd3f6..711d8ab88 100644 --- a/source/binding/NodeJS/src/instance/resource.cpp +++ b/source/binding/NodeJS/src/instance/resource.cpp @@ -123,9 +123,9 @@ bool resource_clear_custom_action(Napi::External info) } } -MaaResId resource_post_path(Napi::External info, std::string path) +MaaResId resource_post_bundle(Napi::External info, std::string path) { - return MaaResourcePostPath(info.Data()->handle, path.c_str()); + return MaaResourcePostBundle(info.Data()->handle, path.c_str()); } bool resource_clear(Napi::External info) @@ -187,7 +187,7 @@ void load_instance_resource(Napi::Env env, Napi::Object& exports, Napi::External BIND(resource_register_custom_action); BIND(resource_unregister_custom_action); BIND(resource_clear_custom_action); - BIND(resource_post_path); + BIND(resource_post_bundle); BIND(resource_clear); BIND(resource_status); BIND(resource_wait); diff --git a/source/binding/NodeJS/src/instance/tasker.cpp b/source/binding/NodeJS/src/instance/tasker.cpp index f91a592db..d4f543b84 100644 --- a/source/binding/NodeJS/src/instance/tasker.cpp +++ b/source/binding/NodeJS/src/instance/tasker.cpp @@ -85,9 +85,9 @@ bool tasker_inited(Napi::External info) return MaaTaskerInited(info.Data()->handle); } -MaaTaskId tasker_post_pipeline(Napi::External info, std::string entry, std::string overr) +MaaTaskId tasker_post_task(Napi::External info, std::string entry, std::string overr) { - return MaaTaskerPostPipeline(info.Data()->handle, entry.c_str(), overr.c_str()); + return MaaTaskerPostTask(info.Data()->handle, entry.c_str(), overr.c_str()); } MaaStatus tasker_status(Napi::External info, MaaTaskId id) @@ -208,7 +208,7 @@ void load_instance_tasker(Napi::Env env, Napi::Object& exports, Napi::External Optional[TaskDetail]: task_id = int( - Library.framework.MaaContextRunPipeline( + Library.framework.MaaContextRunTask( self._handle, *Context._gen_post_param(entry, pipeline_override) ) ) @@ -143,8 +143,8 @@ def _set_api_properties(): Context._api_properties_initialized = True - Library.framework.MaaContextRunPipeline.restype = MaaTaskId - Library.framework.MaaContextRunPipeline.argtypes = [ + Library.framework.MaaContextRunTask.restype = MaaTaskId + Library.framework.MaaContextRunTask.argtypes = [ MaaContextHandle, ctypes.c_char_p, ctypes.c_char_p, diff --git a/source/binding/Python/maa/custom_action.py b/source/binding/Python/maa/custom_action.py index 61b183a6b..399d44c91 100644 --- a/source/binding/Python/maa/custom_action.py +++ b/source/binding/Python/maa/custom_action.py @@ -16,7 +16,7 @@ def __init__(self): @dataclass class RunArg: task_detail: TaskDetail - current_task_name: str + node_name: str custom_action_name: str custom_action_param: str reco_detail: RecognitionDetail @@ -47,7 +47,7 @@ def c_arg(self) -> ctypes.c_void_p: def _c_run_agent( c_context: MaaContextHandle, c_task_id: MaaTaskId, - c_current_task_name: ctypes.c_char_p, + c_node_name: ctypes.c_char_p, c_custom_action_name: ctypes.c_char_p, c_custom_action_param: ctypes.c_char_p, c_reco_id: MaaRecoId, @@ -74,7 +74,7 @@ def _c_run_agent( context, CustomAction.RunArg( task_detail=task_detail, - current_task_name=c_current_task_name.decode(), + node_name=c_node_name.decode(), custom_action_name=c_custom_action_name.decode(), custom_action_param=c_custom_action_param.decode(), reco_detail=reco_detail, diff --git a/source/binding/Python/maa/custom_recognition.py b/source/binding/Python/maa/custom_recognition.py index 6ff540dac..7cd73cd4e 100644 --- a/source/binding/Python/maa/custom_recognition.py +++ b/source/binding/Python/maa/custom_recognition.py @@ -19,7 +19,7 @@ def __init__(self): @dataclass class AnalyzeArg: task_detail: TaskDetail - current_task_name: str + node_name: str custom_recognition_name: str custom_recognition_param: str image: numpy.ndarray @@ -51,7 +51,7 @@ def c_arg(self) -> ctypes.c_void_p: def _c_analyze_agent( c_context: MaaContextHandle, c_task_id: MaaTaskId, - c_current_task_name: ctypes.c_char_p, + c_node_name: ctypes.c_char_p, c_custom_reco_name: ctypes.c_char_p, c_custom_reco_param: ctypes.c_char_p, c_image: MaaImageBufferHandle, @@ -77,7 +77,7 @@ def _c_analyze_agent( context, CustomRecognition.AnalyzeArg( task_detail=task_detail, - current_task_name=c_current_task_name.decode(), + node_name=c_node_name.decode(), custom_recognition_name=c_custom_reco_name.decode(), custom_recognition_param=c_custom_reco_param.decode(), image=image, diff --git a/source/binding/Python/maa/define.py b/source/binding/Python/maa/define.py index f086fd62f..7d8e2c5bb 100644 --- a/source/binding/Python/maa/define.py +++ b/source/binding/Python/maa/define.py @@ -245,7 +245,7 @@ class MaaDbgControllerTypeEnum: MaaBool, # return value MaaContextHandle, # context MaaTaskId, # task_id - ctypes.c_char_p, # current_task_name + ctypes.c_char_p, # node_name ctypes.c_char_p, # custom_recognition_name ctypes.c_char_p, # custom_recognition_param MaaImageBufferHandle, # image @@ -259,7 +259,7 @@ class MaaDbgControllerTypeEnum: MaaBool, # return value MaaContextHandle, # context MaaTaskId, # task_id - ctypes.c_char_p, # current_task_name + ctypes.c_char_p, # node_name ctypes.c_char_p, # custom_action_name ctypes.c_char_p, # MaaRecoId, # reco_id @@ -372,18 +372,23 @@ def __init__(self, status: Union[MaaStatus, MaaStatusEnum, int]): else: self._status = MaaStatusEnum(status) + @property def done(self) -> bool: return self._status in [MaaStatusEnum.succeeded, MaaStatusEnum.failed] + @property def succeeded(self) -> bool: return self._status == MaaStatusEnum.succeeded + @property def failed(self) -> bool: return self._status == MaaStatusEnum.failed + @property def pending(self) -> bool: return self._status == MaaStatusEnum.pending + @property def running(self) -> bool: return self._status == MaaStatusEnum.running diff --git a/source/binding/Python/maa/job.py b/source/binding/Python/maa/job.py index 906490d7b..7b24d94ba 100644 --- a/source/binding/Python/maa/job.py +++ b/source/binding/Python/maa/job.py @@ -9,6 +9,7 @@ def __init__(self, job_id: MaaId, status_func, wait_func): self._status_func = status_func self._wait_func = wait_func + @property def job_id(self) -> int: return int(self._job_id) @@ -16,23 +17,29 @@ def wait(self) -> "Job": self._wait_func(self._job_id) return self + @property def status(self) -> Status: return Status(self._status_func(self._job_id)) + @property def done(self) -> bool: - return self.status().done() + return self.status.done + @property def succeeded(self) -> bool: - return self.status().succeeded() + return self.status.succeeded + @property def failed(self) -> bool: - return self.status().failed() + return self.status.failed + @property def pending(self) -> bool: - return self.status().pending() + return self.status.pending + @property def running(self) -> bool: - return self.status().running() + return self.status.running class JobWithResult(Job): diff --git a/source/binding/Python/maa/notification_handler.py b/source/binding/Python/maa/notification_handler.py index 7ae85fb17..6143aafd0 100644 --- a/source/binding/Python/maa/notification_handler.py +++ b/source/binding/Python/maa/notification_handler.py @@ -59,34 +59,34 @@ def on_tasker_task(self, noti_type: NotificationType, detail: TaskerTaskDetail): pass @dataclass - class TaskNextListDetail: + class NodeNextListDetail: task_id: int name: str next_list: list[str] - def on_task_next_list( - self, noti_type: NotificationType, detail: TaskNextListDetail + def on_node_next_list( + self, noti_type: NotificationType, detail: NodeNextListDetail ): pass @dataclass - class TaskRecognitionDetail: + class NodeRecognitionDetail: task_id: int reco_id: int name: str - def on_task_recognition( - self, noti_type: NotificationType, detail: TaskRecognitionDetail + def on_node_recognition( + self, noti_type: NotificationType, detail: NodeRecognitionDetail ): pass @dataclass - class TaskActionDetail: + class NodeActionDetail: task_id: int node_id: int name: str - def on_task_action(self, noti_type: NotificationType, detail: TaskActionDetail): + def on_node_action(self, noti_type: NotificationType, detail: NodeActionDetail): pass def on_unknown_notification(self, msg: str, details: dict): @@ -121,29 +121,29 @@ def on_raw_notification(self, msg: str, details: dict): ) self.on_tasker_task(noti_type, detail) - elif msg.startswith("Task.NextList"): - detail = self.TaskNextListDetail( + elif msg.startswith("Node.NextList"): + detail = self.NodeNextListDetail( task_id=details["task_id"], name=details["name"], next_list=details["list"], ) - self.on_task_next_list(noti_type, detail) + self.on_node_next_list(noti_type, detail) - elif msg.startswith("Task.Recognition"): - detail = self.TaskRecognitionDetail( + elif msg.startswith("Node.Recognition"): + detail = self.NodeRecognitionDetail( task_id=details["task_id"], reco_id=details["reco_id"], name=details["name"], ) - self.on_task_recognition(noti_type, detail) + self.on_node_recognition(noti_type, detail) - elif msg.startswith("Task.Action"): - detail = self.TaskActionDetail( + elif msg.startswith("Node.Action"): + detail = self.NodeActionDetail( task_id=details["task_id"], node_id=details["node_id"], name=details["name"], ) - self.on_task_action(noti_type, detail) + self.on_node_action(noti_type, detail) else: self.on_unknown_notification(msg, details) diff --git a/source/binding/Python/maa/resource.py b/source/binding/Python/maa/resource.py index ee73d57fb..96a363181 100644 --- a/source/binding/Python/maa/resource.py +++ b/source/binding/Python/maa/resource.py @@ -43,8 +43,10 @@ def __del__(self): if self._handle and self._own: Library.framework.MaaResourceDestroy(self._handle) - def post_path(self, path: Union[pathlib.Path, str]) -> Job: - resid = Library.framework.MaaResourcePostPath(self._handle, str(path).encode()) + def post_bundle(self, path: Union[pathlib.Path, str]) -> Job: + resid = Library.framework.MaaResourcePostBundle( + self._handle, str(path).encode() + ) return Job(resid, self._status, self._wait) @property @@ -212,8 +214,8 @@ def _set_api_properties(): Library.framework.MaaResourceDestroy.restype = None Library.framework.MaaResourceDestroy.argtypes = [MaaResourceHandle] - Library.framework.MaaResourcePostPath.restype = MaaResId - Library.framework.MaaResourcePostPath.argtypes = [ + Library.framework.MaaResourcePostBundle.restype = MaaResId + Library.framework.MaaResourcePostBundle.argtypes = [ MaaResourceHandle, ctypes.c_char_p, ] diff --git a/source/binding/Python/maa/tasker.py b/source/binding/Python/maa/tasker.py index fd9c7e4d2..fdf1ed634 100644 --- a/source/binding/Python/maa/tasker.py +++ b/source/binding/Python/maa/tasker.py @@ -74,8 +74,8 @@ def controller(self) -> Controller: def inited(self) -> bool: return bool(Library.framework.MaaTaskerInited(self._handle)) - def post_pipeline(self, entry: str, pipeline_override: Dict = {}) -> JobWithResult: - taskid = Library.framework.MaaTaskerPostPipeline( + def post_task(self, entry: str, pipeline_override: Dict = {}) -> JobWithResult: + taskid = Library.framework.MaaTaskerPostTask( self._handle, *Tasker._gen_post_param(entry, pipeline_override), ) @@ -363,8 +363,8 @@ def _set_api_properties(): Library.framework.MaaTaskerInited.restype = MaaBool Library.framework.MaaTaskerInited.argtypes = [MaaTaskerHandle] - Library.framework.MaaTaskerPostPipeline.restype = MaaId - Library.framework.MaaTaskerPostPipeline.argtypes = [ + Library.framework.MaaTaskerPostTask.restype = MaaId + Library.framework.MaaTaskerPostTask.argtypes = [ MaaTaskerHandle, ctypes.c_char_p, ctypes.c_char_p, diff --git a/test/nodejs/binding.ts b/test/nodejs/binding.ts index e3ff1ff68..4652092ec 100644 --- a/test/nodejs/binding.ts +++ b/test/nodejs/binding.ts @@ -18,7 +18,7 @@ const myReco: maa.CustomRecognizerCallback = async self => { } } - await self.context.run_pipeline(entry, ppover) + await self.context.run_task(entry, ppover) await self.context.run_action( entry, { @@ -93,7 +93,7 @@ async function api_test() { r2.inference_execution_provider = 'DirectML' r2.inference_device = 114514 r2.inference_execution_provider = 'CPU' - await r2.post_path('/path/to/resource').wait() + await r2.post_bundle('/path/to/resource').wait() r2.destroy() const resource = new maa.Resource() @@ -141,14 +141,14 @@ async function api_test() { } } - let detail = await tasker.post_pipeline('Entry', ppover).wait().get() + let detail = await tasker.post_task('Entry', ppover).wait().get() if (!detail) { console.log('pipeline failed') process.exit(1) } console.log('pipeline detail:', detail) - tasker.resource?.post_path('/path/to/resource') + tasker.resource?.post_bundle('/path/to/resource') tasker.clear_cache() const inited = tasker.inited const running = tasker.running diff --git a/test/pipeline/module/PipelineSmoking.cpp b/test/pipeline/module/PipelineSmoking.cpp index 9e86b031e..7ec65b5a1 100644 --- a/test/pipeline/module/PipelineSmoking.cpp +++ b/test/pipeline/module/PipelineSmoking.cpp @@ -19,7 +19,7 @@ bool pipeline_smoking(const std::filesystem::path& testset_dir) auto resource_handle = MaaResourceCreate(nullptr, nullptr); auto resource_dir = testset_dir / "PipelineSmoking" / "resource"; - auto res_id = MaaResourcePostPath(resource_handle, resource_dir.string().c_str()); + auto res_id = MaaResourcePostBundle(resource_handle, resource_dir.string().c_str()); MaaControllerWait(controller_handle, ctrl_id); MaaResourceWait(resource_handle, res_id); @@ -39,7 +39,7 @@ bool pipeline_smoking(const std::filesystem::path& testset_dir) return false; } - auto task_id = MaaTaskerPostPipeline(tasker_handle, "Wilderness", "{}"); + auto task_id = MaaTaskerPostTask(tasker_handle, "Wilderness", "{}"); auto status = MaaTaskerWait(tasker_handle, task_id); destroy(); diff --git a/test/pipeline/module/RunWithoutFile.cpp b/test/pipeline/module/RunWithoutFile.cpp index 7f92d1e40..9990c2dfc 100644 --- a/test/pipeline/module/RunWithoutFile.cpp +++ b/test/pipeline/module/RunWithoutFile.cpp @@ -20,7 +20,7 @@ MaaBool my_action( MaaContext* context, MaaTaskId task_id, - const char* current_task_name, + const char* node_name, const char* custom_action_name, const char* custom_action_param, MaaRecoId reco_id, @@ -49,7 +49,7 @@ bool run_without_file(const std::filesystem::path& testset_dir) MaaTaskerBindController(tasker_handle, controller_handle); { - auto failed_id = MaaTaskerPostPipeline(tasker_handle, "_NotExists_", "{}"); + auto failed_id = MaaTaskerPostTask(tasker_handle, "_NotExists_", "{}"); auto failed_status = MaaTaskerWait(tasker_handle, failed_id); if (failed_id == MaaInvalidId || failed_status != MaaStatus_Failed) { std::cout << "Failed to detect invalid task" << std::endl; @@ -64,7 +64,7 @@ bool run_without_file(const std::filesystem::path& testset_dir) }; std::string task_param_str = task_param.to_string(); - auto task_id = MaaTaskerPostPipeline(tasker_handle, "MyTask", task_param_str.c_str()); + auto task_id = MaaTaskerPostTask(tasker_handle, "MyTask", task_param_str.c_str()); auto status = MaaTaskerWait(tasker_handle, task_id); MaaTaskerDestroy(tasker_handle); @@ -77,7 +77,7 @@ bool run_without_file(const std::filesystem::path& testset_dir) MaaBool my_action( MaaContext* context, MaaTaskId task_id, - const char* current_task_name, + const char* node_name, const char* custom_action_name, const char* custom_action_param, MaaRecoId reco_id, diff --git a/test/python/binding_test.py b/test/python/binding_test.py index b11b3ec5d..3223f6795 100644 --- a/test/python/binding_test.py +++ b/test/python/binding_test.py @@ -52,14 +52,14 @@ def analyze( "action": "Click", } } - context.run_pipeline(entry, ppover) + context.run_task(entry, ppover) context.run_action(entry, [114, 514, 191, 810], "RunAction Detail", ppover) reco_detail = context.run_recognition(entry, argv.image, ppover) print(f"reco_detail: {reco_detail}") new_ctx = context.clone() new_ctx.override_pipeline({"TaskA": {}, "TaskB": {}}) - new_ctx.override_next(argv.current_task_name, ["TaskA", "TaskB"]) + new_ctx.override_next(argv.node_name, ["TaskA", "TaskB"]) node_detail = new_ctx.tasker.get_latest_node("ColorMatch") print(node_detail) @@ -119,10 +119,10 @@ def api_test(): r2.use_cpu() r2.use_directml(114514) r2.use_cpu() - r2.post_path("C:/_maafw_testing_/aaabbbccc").wait() + r2.post_bundle("C:/_maafw_testing_/aaabbbccc").wait() t1 = Tasker() t2 = Tasker() - t2.post_pipeline("Entry", {}).wait() + t2.post_task("Entry", {}).wait() resource = Resource(MyNotificationHandler()) print(f"resource: {resource}") @@ -158,19 +158,19 @@ def api_test(): }, } - detail = tasker.post_pipeline("Entry", ppover).wait().get() + detail = tasker.post_task("Entry", ppover).wait().get() if detail: print(f"pipeline detail: {detail}") else: print("pipeline failed") raise RuntimeError("pipeline failed") - tasker.post_pipeline("Entry", ppover) - stopped = tasker.post_stop().wait().succeeded() + tasker.post_task("Entry", ppover) + stopped = tasker.post_stop().wait().succeeded if not stopped: raise RuntimeError("post_stop failed") - tasker.resource.post_path("C:/_maafw_testing_/aaabbbccc") + tasker.resource.post_bundle("C:/_maafw_testing_/aaabbbccc") tasker.clear_cache() inited = tasker.inited running = tasker.running @@ -199,20 +199,20 @@ def custom_ctrl_test(): print("test_custom_controller") controller = MyController(MyNotificationHandler()) - ret = controller.post_connection().wait().succeeded() + ret = controller.post_connection().wait().succeeded uuid = controller.uuid - ret &= controller.post_start_app("custom_aaa").wait().succeeded() - ret &= controller.post_stop_app("custom_bbb").wait().succeeded() + ret &= controller.post_start_app("custom_aaa").wait().succeeded + ret &= controller.post_stop_app("custom_bbb").wait().succeeded image_job = controller.post_screencap().wait() - ret &= image_job.succeeded() + ret &= image_job.succeeded print(f"image: {image_job.get().shape}") - ret &= controller.post_click(100, 200).wait().succeeded() - ret &= controller.post_swipe(100, 200, 300, 400, 200).wait().succeeded() - ret &= controller.post_touch_down(1, 100, 100, 0).wait().succeeded() - ret &= controller.post_touch_move(1, 200, 200, 0).wait().succeeded() - ret &= controller.post_touch_up(1).wait().succeeded() - ret &= controller.post_press_key(32).wait().succeeded() - ret &= controller.post_input_text("Hello World!").wait().succeeded() + ret &= controller.post_click(100, 200).wait().succeeded + ret &= controller.post_swipe(100, 200, 300, 400, 200).wait().succeeded + ret &= controller.post_touch_down(1, 100, 100, 0).wait().succeeded + ret &= controller.post_touch_move(1, 200, 200, 0).wait().succeeded + ret &= controller.post_touch_up(1).wait().succeeded + ret &= controller.post_press_key(32).wait().succeeded + ret &= controller.post_input_text("Hello World!").wait().succeeded print(f"controller.count: {controller.count}, ret: {ret}") if controller.count != 11 or not ret: diff --git a/tools/ImageCropper/main.py b/tools/ImageCropper/main.py index afa6666ae..6c2f83f1b 100644 --- a/tools/ImageCropper/main.py +++ b/tools/ImageCropper/main.py @@ -111,7 +111,7 @@ def parse_args() -> Controller: controller = parse_args() if controller: set_screenshot_target_side(controller) - if controller.post_connection().failed(): + if controller.post_connection().failed: print(f"Failed to connect device({device_serial}).") # 初始化 Roi