Skip to content

Commit

Permalink
chore: rename for internal impl
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Dec 18, 2024
1 parent e55ae3b commit ef4c1df
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion 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 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 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.
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.
## 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 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.
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.
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 MaaTaskerPostTask).
Stops the current task chain (the individual task chain passed to MaaTaskerPostPipeline).

### `Custom`

Expand Down
2 changes: 1 addition & 1 deletion 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 Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Resource/PipelineResMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
10 changes: 5 additions & 5 deletions source/MaaFramework/Task/Component/CustomAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Task/Component/CustomAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions source/MaaFramework/Task/Component/Recognizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();

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

Expand Down
4 changes: 2 additions & 2 deletions source/MaaFramework/Task/Component/Recognizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions source/MaaFramework/Task/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ Tasker* Context::tasker() const
return tasker_;
}

std::optional<Context::PipelineData> Context::get_pipeline_data(const std::string& task_name)
std::optional<Context::PipelineData> 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;
}

Expand All @@ -194,12 +194,12 @@ std::optional<Context::PipelineData> 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;
}

Expand Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Task/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Context
virtual Tasker* tasker() const override;

public:
std::optional<PipelineData> get_pipeline_data(const std::string& task_name);
std::optional<PipelineData> get_pipeline_data(const std::string& node_name);

private:
bool check_pipeline() const;
Expand Down
2 changes: 1 addition & 1 deletion source/binding/NodeJS/release/maa-node/src/maa.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ef4c1df

Please sign in to comment.