From 1a5dea8ff7bb724ecf652550df0642a291215f04 Mon Sep 17 00:00:00 2001 From: MistEO Date: Thu, 4 Nov 2021 22:43:35 +0800 Subject: [PATCH] =?UTF-8?q?perf.=E4=BC=98=E5=8C=96=E5=9F=BA=E5=BB=BA?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=E6=8C=89=E9=92=AE=E7=9A=84=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistance/InfrastAbstractTask.cpp | 6 ++++++ src/MeoAssistance/InfrastDormTask.cpp | 12 ++++++++++++ src/MeoAssistance/InfrastOfficeTask.cpp | 3 +++ src/MeoAssistance/InfrastPowerTask.cpp | 3 +++ src/MeoAssistance/InfrastProductionTask.cpp | 16 +++++++++++++++- src/MeoAssistance/InfrastReceptionTask.cpp | 9 +++++++++ 6 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/MeoAssistance/InfrastAbstractTask.cpp b/src/MeoAssistance/InfrastAbstractTask.cpp index 625431cf70..1f01d01ecf 100644 --- a/src/MeoAssistance/InfrastAbstractTask.cpp +++ b/src/MeoAssistance/InfrastAbstractTask.cpp @@ -114,6 +114,9 @@ bool asst::InfrastAbstractTask::click_confirm_button() OcrImageAnalyzer analyzer; analyzer.set_task_info(*task_ptr); for (int i = 0; i != m_retry_times; ++i) { + if (need_exit()) { + return false; + } const auto& image = ctrler.get_image(); analyzer.set_image(image); if (!analyzer.analyze()) { @@ -140,6 +143,9 @@ void asst::InfrastAbstractTask::swipe_to_the_left_of_operlist() static int loop_times = resource.task().task_ptr("InfrastOperListSwipeToTheLeftBegin")->max_times; for (int i = 0; i != loop_times; ++i) { + if (need_exit()) { + return; + } ctrler.swipe(end_rect, begin_rect, duration, true, 0, false); } sleep(extra_delay); diff --git a/src/MeoAssistance/InfrastDormTask.cpp b/src/MeoAssistance/InfrastDormTask.cpp index 5e40ca2965..b78ba23523 100644 --- a/src/MeoAssistance/InfrastDormTask.cpp +++ b/src/MeoAssistance/InfrastDormTask.cpp @@ -17,6 +17,9 @@ bool asst::InfrastDormTask::run() m_callback(AsstMsg::TaskStart, task_start_json, m_callback_arg); for (; m_cur_dorm_index < m_max_num_of_dorm; ++m_cur_dorm_index) { + if (need_exit()) { + return false; + } enter_facility(FacilityName, m_cur_dorm_index); if (!enter_oper_list_page()) { return false; @@ -26,6 +29,9 @@ bool asst::InfrastDormTask::run() int quantity_selected = 0; while (quantity_selected < MaxNumOfOpers) { + if (need_exit()) { + return false; + } const auto& image = ctrler.get_image(); InfrastMoodImageAnalyzer mood_analyzer(image); if (!mood_analyzer.analyze()) { @@ -36,6 +42,9 @@ bool asst::InfrastDormTask::run() int quantity_resting = 0; for (const auto& mood_info : mood_result) { + if (need_exit()) { + return false; + } if (quantity_selected >= MaxNumOfOpers) { break; } @@ -98,6 +107,9 @@ bool asst::InfrastDormTask::click_confirm_button() OcrImageAnalyzer analyzer; analyzer.set_task_info(*task_ptr); for (int i = 0; i != m_retry_times; ++i) { + if (need_exit()) { + return false; + } const auto& image = ctrler.get_image(); analyzer.set_image(image); if (!analyzer.analyze()) { diff --git a/src/MeoAssistance/InfrastOfficeTask.cpp b/src/MeoAssistance/InfrastOfficeTask.cpp index 8c6b21ca9e..69d4f4b66b 100644 --- a/src/MeoAssistance/InfrastOfficeTask.cpp +++ b/src/MeoAssistance/InfrastOfficeTask.cpp @@ -22,6 +22,9 @@ bool asst::InfrastOfficeTask::run() constexpr int retry_times = 1; for (int i = 0; i <= retry_times; ++i) { + if (need_exit()) { + return false; + } swipe_to_the_left_of_operlist(); opers_detect_with_swipe(); swipe_to_the_left_of_operlist(); diff --git a/src/MeoAssistance/InfrastPowerTask.cpp b/src/MeoAssistance/InfrastPowerTask.cpp index fe85c5295e..c76b3d13c2 100644 --- a/src/MeoAssistance/InfrastPowerTask.cpp +++ b/src/MeoAssistance/InfrastPowerTask.cpp @@ -17,6 +17,9 @@ bool asst::InfrastPowerTask::run() set_product("Drone"); for (int i = 0; i != MaxNumOfFacility; ++i) { + if (need_exit()) { + return false; + } swipe_to_the_left_of_main_ui(); enter_facility(FacilityName, i); diff --git a/src/MeoAssistance/InfrastProductionTask.cpp b/src/MeoAssistance/InfrastProductionTask.cpp index 1b432f2539..f367fe50f9 100644 --- a/src/MeoAssistance/InfrastProductionTask.cpp +++ b/src/MeoAssistance/InfrastProductionTask.cpp @@ -36,7 +36,9 @@ bool asst::InfrastProductionTask::shift_facility_list() { facility_list_detect(); - + if (need_exit()) { + return false; + } const auto tab_task_ptr = std::dynamic_pointer_cast( resource.task().task_ptr("InfrastFacilityListTab" + m_facility)); MatchImageAnalyzer add_analyzer; @@ -45,6 +47,9 @@ bool asst::InfrastProductionTask::shift_facility_list() add_analyzer.set_task_info(*add_task_ptr); for (const Rect& tab : m_facility_list_tabs) { + if (need_exit()) { + return false; + } ctrler.click(tab); sleep(tab_task_ptr->rear_delay); @@ -77,6 +82,9 @@ bool asst::InfrastProductionTask::shift_facility_list() constexpr int retry_times = 1; for (int i = 0; i <= retry_times; ++i) { + if (need_exit()) { + return false; + } click_clear_button(); swipe_to_the_left_of_operlist(); @@ -106,6 +114,9 @@ bool asst::InfrastProductionTask::opers_detect_with_swipe() int first_number = 0; while (true) { + if (need_exit()) { + return false; + } size_t num = opers_detect(); // 这里本来是判断不相等就可以退出循环。 @@ -324,6 +335,9 @@ bool asst::InfrastProductionTask::opers_choose() { bool has_error = false; while (true) { + if (need_exit()) { + return false; + } const auto& image = ctrler.get_image(); InfrastSkillsImageAnalyzer skills_analyzer(image); diff --git a/src/MeoAssistance/InfrastReceptionTask.cpp b/src/MeoAssistance/InfrastReceptionTask.cpp index 9630fa9a98..30978a150e 100644 --- a/src/MeoAssistance/InfrastReceptionTask.cpp +++ b/src/MeoAssistance/InfrastReceptionTask.cpp @@ -40,6 +40,9 @@ bool asst::InfrastReceptionTask::harvest_clue() { std::vector tasks_vec = { "InfrastClueNew" }; while (!tasks_vec.empty()) { + if (need_exit()) { + return false; + } ProcessTaskImageAnalyzer analyzer(ctrler.get_image(), tasks_vec); if (!analyzer.analyze()) { break; @@ -121,6 +124,9 @@ bool asst::InfrastReceptionTask::proc_vacancy() "No1", "No2", "No3", "No4", "No5", "No6", "No7" }; for (const std::string& clue : clue_suffix) { + if (need_exit()) { + return false; + } // 先识别线索的空位 cv::Mat image = ctrler.get_image(); InfrastClueVacancyImageAnalyzer vacancy_analyzer(image); @@ -164,6 +170,9 @@ bool asst::InfrastReceptionTask::shift() constexpr int retry_times = 1; for (int i = 0; i <= retry_times; ++i) { + if (need_exit()) { + return false; + } swipe_to_the_left_of_operlist(); click_clear_button();