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

refactor: rename APIs to the term #472

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/en_us/1.1-QuickStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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()
```
Expand Down
6 changes: 3 additions & 3 deletions docs/en_us/3.1-PipelineProtocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
```

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 task (passing the task name to the MaaTaskerPostTask 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.

## Example

Expand Down Expand Up @@ -53,7 +53,7 @@ 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" 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.

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.

Expand Down Expand Up @@ -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).

### `Custom`

Expand Down
8 changes: 4 additions & 4 deletions docs/en_us/NodeJS/J1.1-QuickStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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!')
}
Expand All @@ -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).

Expand All @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions docs/zh_cn/1.1-快速开始.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
```

### 自行编写代码
Expand All @@ -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()
Expand All @@ -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()
```
Expand Down
6 changes: 3 additions & 3 deletions docs/zh_cn/3.1-任务流水线协议.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
```

我们执行某个 Task 时( MaaTaskerPostPipeline 接口传入任务名),会对其 next 列表中的 Task **依次** 进行识别(根据每个 Task 的 recognition 相关设置)
我们执行某个 Task 时( MaaTaskerPostTask 接口传入任务名),会对其 next 列表中的 Task **依次** 进行识别(根据每个 Task 的 recognition 相关设置)
且一旦匹配上了,则会退出 next 列表识别,转而去执行匹配上的任务。类似遍历比较,一旦找到了,就直接 break 转而去执行找到的那个 Task 。

## 举例
Expand Down Expand Up @@ -55,7 +55,7 @@
```

假设现在画面中没有 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 中,
Expand Down Expand Up @@ -561,7 +561,7 @@ Orange 的 next 中,

### `StopTask`

停止当前任务链(MaaTaskerPostPipeline 传入的单个任务链)。
停止当前任务链(MaaTaskerPostTask 传入的单个任务链)。

### `Custom`

Expand Down
8 changes: 4 additions & 4 deletions docs/zh_cn/NodeJS/J1.1-快速开始.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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!')
}
Expand All @@ -87,15 +87,15 @@ main()

## 在JS侧影响资源行为

注意执行任务的这段代码`await tskr.post_pipeline('task', 'Task1').wait()`
注意执行任务的这段代码`await tskr.post_task('task', 'Task1').wait()`

`post`函数可以传入第三个参数, 该参数是一个对象, 其结构和`pipeline`下的json完全一致, 会覆盖在原有的`pipeline`之上. 因此, 可以通过在此处传入一个对象来实现控制任务(甚至创建新的任务).

```javascript
// 通过第三个参数, 创建了一个新的任务Task2, 然后执行它
// 此处创建的任务仅在当前执行中有效
await tskr
.post_pipeline('Task2', {
.post_task('Task2', {
Task2: {
next: [
'Task1'
Expand Down
4 changes: 2 additions & 2 deletions include/MaaFramework/Instance/MaaContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion include/MaaFramework/Instance/MaaResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions include/MaaFramework/Instance/MaaTasker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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,
Expand All @@ -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);

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions include/MaaFramework/MaaDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions sample/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions sample/nodejs/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions sample/python/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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!"
Expand Down
2 changes: 1 addition & 1 deletion sample/python/pi_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions source/MaaFramework/API/MaaContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions source/MaaFramework/API/MaaResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)
Expand Down
Loading
Loading