#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;
|
}
|