diff --git a/docs/en_us/3.1-PipelineProtocol.md b/docs/en_us/3.1-PipelineProtocol.md index b62053317..51a0ac8fe 100644 --- a/docs/en_us/3.1-PipelineProtocol.md +++ b/docs/en_us/3.1-PipelineProtocol.md @@ -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 @@ -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. @@ -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` diff --git a/docs/en_us/NodeJS/J1.1-QuickStarted.md b/docs/en_us/NodeJS/J1.1-QuickStarted.md index a5aa68b42..45b29e0cb 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() 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 7615019ad..12fababc7 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" @@ -18,7 +18,7 @@ } ``` -我们执行某个 Task 时( MaaTaskerPostPipeline 接口传入任务名),会对其 next 列表中的 Task **依次** 进行识别(根据每个 Task 的 recognition 相关设置) +我们执行某个 Task 时( MaaTaskerPostTask 接口传入任务名),会对其 next 列表中的 Task **依次** 进行识别(根据每个 Task 的 recognition 相关设置) 且一旦匹配上了,则会退出 next 列表识别,转而去执行匹配上的任务。类似遍历比较,一旦找到了,就直接 break 转而去执行找到的那个 Task 。 ## 举例 @@ -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 中, @@ -561,7 +561,7 @@ Orange 的 next 中, ### `StopTask` -停止当前任务链(MaaTaskerPostPipeline 传入的单个任务链)。 +停止当前任务链(MaaTaskerPostTask 传入的单个任务链)。 ### `Custom` 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..f9edd3b02 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() 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/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..e16a7b624 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) { diff --git a/sample/python/__main__.py b/sample/python/__main__.py index 8bb8a68eb..3f97c1bd2 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() @@ -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!" 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..40ff39b32 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); @@ -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..6defb39a9 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; @@ -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/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 a0f78e5ac..47822f8d1 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/Context.cpp b/source/MaaFramework/Task/Context.cpp index a4e1b0070..8c89da57a 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); diff --git a/source/MaaFramework/Task/Context.h b/source/MaaFramework/Task/Context.h index 9599b030a..e4d9f0278 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) 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..64d75f3ae 100644 --- a/source/MaaFramework/Tasker/Tasker.cpp +++ b/source/MaaFramework/Tasker/Tasker.cpp @@ -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..5578e2568 100644 --- a/source/MaaFramework/Tasker/Tasker.h +++ b/source/MaaFramework/Tasker/Tasker.h @@ -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..1adbcfa61 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 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/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..8b0886a5d 100644 --- a/source/binding/NodeJS/src/instance/tasker.cpp +++ b/source/binding/NodeJS/src/instance/tasker.cpp @@ -87,7 +87,7 @@ bool tasker_inited(Napi::External info) MaaTaskId tasker_post_pipeline(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) diff --git a/source/binding/Python/maa/context.py b/source/binding/Python/maa/context.py index 6fb55934f..305821d8e 100644 --- a/source/binding/Python/maa/context.py +++ b/source/binding/Python/maa/context.py @@ -29,11 +29,11 @@ def __init__(self, handle: MaaContextHandle): def __del__(self): pass - def run_pipeline( + def run_task( self, entry: str, pipeline_override: Dict = {} ) -> 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..637b0c124 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 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..946ed00b0 100644 --- a/source/binding/Python/maa/tasker.py +++ b/source/binding/Python/maa/tasker.py @@ -75,7 +75,7 @@ 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( + 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..ef9720cd7 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() @@ -148,7 +148,7 @@ async function api_test() { } 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 8e7026fbb..805a47a10 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,7 +119,7 @@ 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() @@ -170,7 +170,7 @@ def api_test(): 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