Skip to content

Commit

Permalink
chore: rename context var: task -> subtask
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Dec 3, 2024
1 parent 5c07bfa commit 186f00f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions source/MaaFramework/Task/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ MaaTaskId Context::run_pipeline(const std::string& entry, const json::value& pip
return MaaInvalidId;
}

PipelineTask task(entry, tasker_, getptr());
bool ov = task.override_pipeline(pipeline_override);
PipelineTask subtask(entry, tasker_, getptr());
bool ov = subtask.override_pipeline(pipeline_override);
if (!ov) {
LogError << "failed to override_pipeline" << VAR(entry) << VAR(pipeline_override);
return MaaInvalidId;
Expand All @@ -64,47 +64,47 @@ MaaTaskId Context::run_pipeline(const std::string& entry, const json::value& pip

// context 的子任务没有 Pending 状态,直接就是 Running
runtime_cache.set_task_detail(
task.task_id(),
MAA_TASK_NS::TaskDetail { .task_id = task.task_id(), .entry = task.entry(), .status = MaaStatus_Running });
subtask.task_id(),
MAA_TASK_NS::TaskDetail { .task_id = subtask.task_id(), .entry = subtask.entry(), .status = MaaStatus_Running });

bool ret = task.run();
bool ret = subtask.run();

{
auto task_detail =
runtime_cache.get_task_detail(task.task_id()).value_or(MAA_TASK_NS::TaskDetail { .task_id = task.task_id(), .entry = entry });
runtime_cache.get_task_detail(subtask.task_id()).value_or(MAA_TASK_NS::TaskDetail { .task_id = subtask.task_id(), .entry = entry });
task_detail.status = ret ? MaaStatus_Succeeded : MaaStatus_Failed;
runtime_cache.set_task_detail(task.task_id(), std::move(task_detail));
runtime_cache.set_task_detail(subtask.task_id(), std::move(task_detail));
}

return task.task_id();
return subtask.task_id();
}

MaaRecoId Context::run_recognition(const std::string& entry, const json::value& pipeline_override, const cv::Mat& image)
{
LogFunc << VAR(getptr()) << VAR(entry) << VAR(pipeline_override);

RecognitionTask task(entry, tasker_, getptr());
bool ov = task.override_pipeline(pipeline_override);
RecognitionTask subtask(entry, tasker_, getptr());
bool ov = subtask.override_pipeline(pipeline_override);
if (!ov) {
LogError << "failed to override_pipeline" << VAR(entry) << VAR(pipeline_override);
return MaaInvalidId;
}
return task.run_with_param(image);
return subtask.run_with_param(image);
}

MaaNodeId
Context::run_action(const std::string& entry, const json::value& pipeline_override, const cv::Rect& box, const std::string& reco_detail)
{
LogFunc << VAR(getptr()) << VAR(entry) << VAR(pipeline_override) << VAR(box) << VAR(reco_detail);

ActionTask task(entry, tasker_, getptr());
bool ov = task.override_pipeline(pipeline_override);
ActionTask subtask(entry, tasker_, getptr());
bool ov = subtask.override_pipeline(pipeline_override);
if (!ov) {
LogError << "failed to override_pipeline" << VAR(entry) << VAR(pipeline_override);
return MaaInvalidId;
}
json::value j_detail = json::parse(reco_detail).value_or(reco_detail);
return task.run_with_param(box, j_detail);
return subtask.run_with_param(box, j_detail);
}

bool Context::override_pipeline(const json::value& pipeline_override)
Expand Down

0 comments on commit 186f00f

Please sign in to comment.