1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "stdafx.h"
#include "HoleProcess.h"
#include "BlSideData.h"
#include "VisionRecipe.h"
#include "FileRecipe.h"
 
CHoleProcess::CHoleProcess(){
    /* code */
    m_eDir = DIMENSION_NONE;
    for (int i = 0; i < 4; i++) {
        m_dots[i] = new CHoleDotProcess(m_eDir, i + 1);
    }
}
 
CHoleProcess::CHoleProcess(DimensionDir eDir) {
    /* code */
    m_eDir = eDir;
    for (int i = 0; i < 4; i++) {
        m_dots[i] = new CHoleDotProcess(m_eDir, i + 1);
    }
}
 
CHoleProcess::~CHoleProcess(){
    /* code */
    for (int i = 0; i < 4; i++) {
        CHoleDotProcess* dot = m_dots[i];
        if (NULL == dot) continue;
 
        delete dot;
        dot = NULL;
        m_dots[i] = NULL;
    }
}
 
void CHoleProcess::Execute(DimensionDir eDir) {
    /* code */
    Point2I offset;
    for (int i = 0; i < 4; i++) {
        CHoleDotProcess* dot = m_dots[i];
        if (NULL == dot) continue;
        if (1 != dot->m_nUse) continue;
 
        offset.x = i;
        offset.y = i;
        dot->Execute(eDir, offset);
    }
}
 
Json::Value CHoleProcess::WriteToJson(std::string& strDir) {
    /* code */
    Json::Value jsValue;
    jsValue["type"] = HOLE_VISION_PROCESS;
    jsValue["side"] = (int)(m_eDir);
 
    for (int i = 0; i < 4; i++) {
        std::string name = ClsVision::FormatString("Dot%d", i);
        jsValue[name.c_str()] = m_dots[i]->WriteToJson(strDir);
    }
    return jsValue;
}
 
void CHoleProcess::DecodeJson(Json::Value& jsValue, std::string& strDir) {
    /* code */
    int num = (int)jsValue.size();
    if (num < 1) return;
 
    //1. Side
    std::string strName = "side";
    if (jsValue.isMember(strName.c_str()) && jsValue[strName.c_str()].isInt()) {
        m_eDir = (DimensionDir)(jsValue[strName.c_str()].asInt());
    }
 
    for (int i = 0; i < 4; i++) {
        std::string name = ClsVision::FormatString("Dot%d", i);
        if (jsValue.isMember(name.c_str()) && jsValue[name.c_str()].isObject()) {
            Json::Value jsData = jsValue[name.c_str()];
            m_dots[i]->DecodeJson(strDir, jsData);
        }
    }
 
    return;
}