完善容错机制,添加出错后清缓存并重试的逻辑

This commit is contained in:
MistEO
2021-08-09 00:27:11 +08:00
parent 9124bde59c
commit 2281ca72d1
4 changed files with 76 additions and 10 deletions

View File

@@ -43,7 +43,7 @@ namespace asst {
bool set_param(const std::string& type, const std::string& param, const std::string& value);
static constexpr int MatchTaskRetryTimesDefault = 60;
static constexpr int MatchTaskRetryTimesDefault = 20;
static constexpr int OpenRecruitTaskRetyrTimesDefault = 5;
private:

View File

@@ -159,7 +159,7 @@ void Assistance::start_match_task(const std::string& task, int retry_times, bool
if (block)
{
lock = std::unique_lock<std::mutex>(m_mutex);
clear_exec_times();
//clear_exec_times();
m_identify_ptr->clear_cache();
}
@@ -218,10 +218,10 @@ void Assistance::stop(bool block)
if (block)
{ // 外部调用
lock = std::unique_lock<std::mutex>(m_mutex);
clear_exec_times();
}
decltype(m_tasks_queue) empty;
m_tasks_queue.swap(empty);
clear_exec_times();
m_identify_ptr->clear_cache();
}

View File

@@ -42,6 +42,9 @@ namespace MeoAsstGui
private IntPtr p_asst;
private RecruitWindow recruitWindow;
private int retry_times = 0;
private int retry_limits = 2;
public enum AsstMsg
{
/* Error Msg */
@@ -85,6 +88,7 @@ namespace MeoAsstGui
{
case AsstMsg.TaskCompleted:
{
retry_times = 0;
string task_name = detail["name"].ToString();
if (task_name == "StartButton2")
{
@@ -136,9 +140,29 @@ namespace MeoAsstGui
case AsstMsg.TaskError:
{
string task_chain = detail["task_chain"].ToString();
if (task_chain == "SanityBegin" || task_chain == "VisitBegin")
if (task_chain == "SanityBegin")
{
label_status.Content = "出现错误,已停止运行";
// 出错了会重试两次,再不行就算了
if (retry_times >= retry_limits)
{
retry_times = 0;
label_status.Content = "出现错误,已停止运行";
break;
}
++retry_times;
button_Click_startSanity(null, null);
}
else if (task_chain == "VisitBegin")
{
// 出错了会重试两次,再不行就算了
if (retry_times >= retry_limits)
{
retry_times = 0;
label_status.Content = "出现错误,已停止运行";
break;
}
++retry_times;
button_Click_visit(null, null);
}
}
break;

View File

@@ -242,7 +242,8 @@
"StartButton2",
"PRTS",
"UseMedicine",
"UseStone"
"UseStone",
"ClickCorner"
]
},
"UsePrts": {
@@ -287,12 +288,34 @@
"templThreshold": 0,
"type": "printWindow",
"next": [
"Random"
"ClickCorner"
]
},
"Random": {
"ClickCorner": {
"ClickCorner_Doc": "点击右下角既不会点到掉落物品又能点到蓝色开始按钮的一块位置。1、2是一样的3的next没有ClickCorner了之所以分三个就是为了最多点三次而不是循环跑起来一直命中ClickCorner",
"template": "",
"templThreshold": 0,
"preDelay": 2000,
"type": "clickRect",
"specificArea": [
1100,
700,
150,
30
],
"next": [
"Loading",
"StartButton1",
"StartButton2",
"UseMedicine",
"UseStone",
"ClickCorner2"
]
},
"ClickCorner2": {
"template": "",
"preDelay": 2000,
"templThreshold": 0,
"type": "clickRect",
"specificArea": [
1100,
@@ -306,7 +329,26 @@
"StartButton2",
"UseMedicine",
"UseStone",
"Random"
"ClickCorner3"
]
},
"ClickCorner3": {
"template": "",
"preDelay": 2000,
"templThreshold": 0,
"type": "clickRect",
"specificArea": [
1100,
700,
150,
30
],
"next": [
"Loading",
"StartButton1",
"StartButton2",
"UseMedicine",
"UseStone"
]
},
"Loading": {
@@ -368,7 +410,7 @@
"Loading"
],
"next": [
"Random"
"ClickCorner"
]
},
"VisitBegin": {