#include "InfrastAbstractTask.h" #include #include #include "WinMacro.h" #include "Identify.h" #include "Configer.h" #include "InfrastConfiger.h" #include "Logger.hpp" using namespace asst; asst::InfrastAbstractTask::InfrastAbstractTask(AsstCallback callback, void* callback_arg) : OcrAbstractTask(callback, callback_arg), m_swipe_begin(Configer::WindowWidthDefault * 0.9, Configer::WindowHeightDefault * 0.5, 0, 0), m_swipe_end(Configer::WindowWidthDefault * 0.5, Configer::WindowHeightDefault * 0.5, 0, 0) { } bool asst::InfrastAbstractTask::swipe_to_the_left() { DebugTraceFunction; constexpr int SwipeTimes = 5; m_swipe_duration = 100; m_swipe_extra_delay = 0; // 往左使劲滑几下 bool ret = false; for (int i = 0; i != SwipeTimes; ++i) { ret = swipe(true); if (!ret) { break; } } m_swipe_duration = SwipeDurationDefault; m_swipe_extra_delay = SwipeExtraDelayDefault; if (!ret) { return false; } return sleep(SwipeExtraDelayDefault); } bool asst::InfrastAbstractTask::click_clear_button() { DebugTraceFunction; const static Rect ClearButtonRect(430, 655, 150, 40); return m_controller_ptr->click(ClearButtonRect); } bool asst::InfrastAbstractTask::click_confirm_button() { DebugTraceFunction; const static Rect ConfirmButtonRect(1105, 655, 150, 40); return m_controller_ptr->click(ConfirmButtonRect); } bool asst::InfrastAbstractTask::swipe(bool reverse) { DebugTraceFunction; //#ifndef LOG_TRACE if (!reverse) { m_controller_ptr->swipe(m_swipe_begin, m_swipe_end, m_swipe_duration); ++m_swipe_times; } else { m_controller_ptr->swipe(m_swipe_end, m_swipe_begin, m_swipe_duration); --m_swipe_times; } return sleep(m_swipe_extra_delay); //#else // return sleep(SwipeExtraDelay); //#endif } bool asst::InfrastAbstractTask::swipe_left() { DebugTraceFunction; const static Rect right_rect(Configer::WindowWidthDefault * 0.8, Configer::WindowHeightDefault * 0.4, Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.2); const static Rect left_rect(Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.4, Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.2); m_controller_ptr->swipe(left_rect, right_rect); return true; } bool asst::InfrastAbstractTask::swipe_right() { DebugTraceFunction; const static Rect right_rect(Configer::WindowWidthDefault * 0.8, Configer::WindowHeightDefault * 0.4, Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.2); const static Rect left_rect(Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.4, Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.2); m_controller_ptr->swipe(right_rect, left_rect); return true; } bool asst::InfrastAbstractTask::append_task_to_back_to_infrast_home() { const static json::value append_json = json::object{ { "task", "InfrastBegin" }, { "task_chain", m_task_chain } }; m_callback(AsstMsg::AppendProcessTask, append_json, m_callback_arg); return true; } std::vector