完成办公室换班任务流程

This commit is contained in:
MistEO
2021-09-11 15:19:23 +08:00
parent 9c3df883ef
commit bce5fa0740
9 changed files with 117 additions and 3 deletions

View File

@@ -234,7 +234,7 @@ bool Assistance::start_debug_task()
//}
{
constexpr static const char* InfrastTaskCahin = "Debug";
auto shift_task_ptr = std::make_shared<InfrastPowerTask>(task_callback, (void*)this);
auto shift_task_ptr = std::make_shared<InfrastOfficeTask>(task_callback, (void*)this);
shift_task_ptr->set_task_chain(InfrastTaskCahin);
m_tasks_deque.emplace_back(shift_task_ptr);
}
@@ -365,6 +365,13 @@ bool asst::Assistance::start_infrast()
power_task_ptr->set_task_chain(InfrastTaskCahin);
m_tasks_deque.emplace_back(std::move(power_task_ptr));
// 返回基建的主界面
append_match_task(InfrastTaskCahin, { "InfrastBegin" });
auto office_task_ptr = std::make_shared<InfrastOfficeTask>(task_callback, (void*)this);
office_task_ptr->set_task_chain(InfrastTaskCahin);
m_tasks_deque.emplace_back(std::move(office_task_ptr));
// 全操作完之后,再返回基建的主界面
append_match_task(InfrastTaskCahin, { "InfrastBegin" });

View File

@@ -86,6 +86,36 @@ bool asst::InfrastAbstractTask::swipe(bool reverse)
//#endif
}
bool asst::InfrastAbstractTask::swipe_left()
{
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);
return m_controller_ptr->swipe(left_rect, right_rect);
}
bool asst::InfrastAbstractTask::swipe_right()
{
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);
return m_controller_ptr->swipe(right_rect, left_rect);
}
std::vector<TextArea> asst::InfrastAbstractTask::detect_operators_name(
const cv::Mat& image,
std::unordered_map<std::string,

View File

@@ -11,11 +11,13 @@ namespace asst {
virtual ~InfrastAbstractTask() = default;
virtual bool run() = 0;
protected:
virtual bool swipe_to_the_left();
virtual bool swipe_to_the_left(); // 滑动到最左侧
virtual bool click_clear_button();
virtual bool click_confirm_button();
virtual bool click_return_button();
virtual bool swipe(bool reverse = false);
virtual bool swipe_left(); // 往左划(只滑一下)
virtual bool swipe_right(); // 往右划(只滑一下)
// 检测干员名
virtual std::vector<TextArea> detect_operators_name(const cv::Mat& image,

View File

@@ -0,0 +1,47 @@
#include "InfrastOfficeTask.h"
#include "Configer.h"
#include "Identify.h"
#include "WinMacro.h"
bool asst::InfrastOfficeTask::run()
{
if (m_controller_ptr == nullptr
|| m_identify_ptr == nullptr)
{
m_callback(AsstMsg::PtrIsNull, json::value(), m_callback_arg);
return false;
}
swipe_right();
enter_station({ "Office", "OfficeMin" }, 0);
if (enter_operator_selection()) {
select_operators(true);
}
return true;
}
bool asst::InfrastOfficeTask::enter_operator_selection()
{
auto suspended_result = m_identify_ptr->find_image(m_controller_ptr->get_image(), "ContactSuspended");
if (suspended_result.score > Configer::TemplThresholdDefault) {
m_controller_ptr->click(suspended_result.rect);
sleep(1000);
return true;
}
else {
return false;
}
}
int asst::InfrastOfficeTask::select_operators(bool need_to_the_left)
{
if (need_to_the_left) {
swipe_to_the_left();
}
// 办公室干员不用做识别,直接选择第一个即可
click_first_operator();
click_confirm_button();
return 1;
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include "InfrastAbstractTask.h"
namespace asst {
class InfrastOfficeTask : public InfrastAbstractTask
{
public:
using InfrastAbstractTask::InfrastAbstractTask;
virtual ~InfrastOfficeTask() = default;
virtual bool run() override;
protected:
// 进入干员选择界面
bool enter_operator_selection();
// 选择干员返回本次选择了几个干员DuckType办公室固定返回 1
int select_operators(bool need_to_the_left = false);
};
}

View File

@@ -25,6 +25,7 @@
<ClInclude Include="InfrastAbstractTask.h" />
<ClInclude Include="InfrastConfiger.h" />
<ClInclude Include="InfrastDormTask.h" />
<ClInclude Include="InfrastOfficeTask.h" />
<ClInclude Include="InfrastPowerTask.h" />
<ClInclude Include="InfrastProductionTask.h" />
<ClInclude Include="Logger.hpp" />
@@ -48,6 +49,7 @@
<ClCompile Include="Configer.cpp" />
<ClCompile Include="Identify.cpp" />
<ClCompile Include="InfrastDormTask.cpp" />
<ClCompile Include="InfrastOfficeTask.cpp" />
<ClCompile Include="InfrastPowerTask.cpp" />
<ClCompile Include="InfrastProductionTask.cpp" />
<ClCompile Include="OcrAbstractTask.cpp" />

View File

@@ -117,6 +117,9 @@
<ClInclude Include="InfrastPowerTask.h">
<Filter>头文件\Task</Filter>
</ClInclude>
<ClInclude Include="InfrastOfficeTask.h">
<Filter>头文件\Task</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="WinMacro.cpp">
@@ -173,6 +176,9 @@
<ClCompile Include="InfrastPowerTask.cpp">
<Filter>源文件\Task</Filter>
</ClCompile>
<ClCompile Include="InfrastOfficeTask.cpp">
<Filter>源文件\Task</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\resource\config.json">

View File

@@ -5,4 +5,5 @@
#include "IdentifyOperTask.h"
#include "InfrastProductionTask.h"
#include "InfrastDormTask.h"
#include "InfrastPowerTask.h"
#include "InfrastPowerTask.h"
#include "InfrastOfficeTask.h"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB