Merge branch 'master' into dev

This commit is contained in:
MistEO
2022-05-09 00:09:24 +08:00
64 changed files with 58365 additions and 1376 deletions

View File

@@ -101,9 +101,14 @@ bool ProcessTask::_run()
Rect rect;
std::shared_ptr<TaskInfo> cur_task_ptr = nullptr;
auto front_task_ptr = Task.get(m_cur_tasks_name.front());
// 可能有配置错误,导致不存在对应的任务
if (front_task_ptr == nullptr) {
Log.error("Invalid task", m_cur_tasks_name.front());
return false;
}
// 如果第一个任务是JustReturn的那就没必要再截图并计算了
if (auto front_task_ptr = Task.get(m_cur_tasks_name.front());
front_task_ptr->algorithm == AlgorithmType::JustReturn) {
if (front_task_ptr->algorithm == AlgorithmType::JustReturn) {
cur_task_ptr = front_task_ptr;
}
else {
@@ -140,7 +145,12 @@ bool ProcessTask::_run()
}
if (exec_times >= max_times) {
Log.info("exec times exceeds the limit", info.to_string());
info["details"] = json::object{
{ "task", cur_name },
{ "exec_times", exec_times },
{ "max_times", max_times }
};
Log.info("exec times exceeded the limit", info.to_string());
m_cur_tasks_name = cur_task_ptr->exceeded_next;
sleep(m_task_delay);
continue;
@@ -181,6 +191,10 @@ bool ProcessTask::_run()
case ProcessTaskAction::SwipeToTheRight:
exec_swipe_task(cur_task_ptr->action);
break;
case ProcessTaskAction::SlowlySwipeToTheLeft:
case ProcessTaskAction::SlowlySwipeToTheRight:
exec_slowly_swipe_task(cur_task_ptr->action);
break;
case ProcessTaskAction::DoNothing:
break;
case ProcessTaskAction::Stop:
@@ -258,3 +272,23 @@ void asst::ProcessTask::exec_swipe_task(ProcessTaskAction action)
break;
}
}
void asst::ProcessTask::exec_slowly_swipe_task(ProcessTaskAction action)
{
LogTraceFunction;
static Rect right_rect = Task.get("ProcessTaskSlowlySwipeRightRect")->specific_rect;
static Rect left_rect = Task.get("ProcessTaskSlowlySwipeLeftRect")->specific_rect;
static int duration = Task.get("ProcessTaskSlowlySwipeRightRect")->pre_delay;
static int extra_delay = Task.get("ProcessTaskSlowlySwipeRightRect")->rear_delay;
switch (action) {
case asst::ProcessTaskAction::SlowlySwipeToTheLeft:
m_ctrler->swipe(left_rect, right_rect, duration, true, extra_delay, true);
break;
case asst::ProcessTaskAction::SlowlySwipeToTheRight:
m_ctrler->swipe(right_rect, left_rect, duration, true, extra_delay, true);
break;
default: // 走不到这里TODO 报个错
break;
}
}