#include "stdafx.h"
|
#include "CornerRcutProcess.h"
|
#include "VisionRecipe.h"
|
#include "FileRecipe.h"
|
|
CCornerRcutProcess::CCornerRcutProcess(){
|
/* code */
|
for (int i = 0; i < 2; i++) {
|
m_dots[i] = NULL;
|
}
|
m_eDir = DIMENSION_NONE;
|
init();
|
}
|
|
CCornerRcutProcess::CCornerRcutProcess(DimensionDir eDir) {
|
/* code */
|
for (int i = 0; i < 2; i++) {
|
m_dots[i] = NULL;
|
}
|
m_eDir = eDir;
|
init();
|
}
|
|
CCornerRcutProcess::~CCornerRcutProcess(){
|
/* code */
|
release();
|
}
|
|
int CCornerRcutProcess::init(void) {
|
/* code */
|
release();
|
|
for (int i = 0; i < 2; i++) {
|
m_dots[i] = new CRcutDotProcess(m_eDir, i + 1);
|
}
|
|
return 0;
|
}
|
|
void CCornerRcutProcess::release(void) {
|
/* code */
|
int nCount = 2;
|
for (int i = 0; i < nCount; i++) {
|
CRcutDotProcess *dot = m_dots[i];
|
if (NULL == dot) continue;
|
delete dot;
|
dot = NULL;
|
m_dots[i] = NULL;
|
}
|
}
|
|
int CCornerRcutProcess::execute(DimensionDir eDir) {
|
/* code */
|
if (m_eDir != eDir) return -1;
|
|
int nCount = 2;
|
Point2I offset;
|
for (int i = 0; i < nCount; i++) {
|
CRcutDotProcess *dot = m_dots[i];
|
if (NULL == dot) continue;
|
if (1 != dot->m_nUse) continue;
|
|
offset.x = i;
|
offset.y = i;
|
dot->Execute(m_eDir, offset);
|
}
|
|
return 0;
|
}
|
|
Json::Value CCornerRcutProcess::WriteToJson(void) {
|
/* code */
|
Json::Value jsValue;
|
jsValue["type"] = RCUT_VISION_PROCESS;
|
jsValue["side"] = (int)(m_eDir);
|
|
for (int i = 0; i < 2; i++) {
|
std::string name = ClsVision::FormatString("Dot%d", i);
|
jsValue[name.c_str()] = m_dots[i]->WriteToJson();
|
}
|
|
return jsValue;
|
}
|
|
void CCornerRcutProcess::DecodeJson(Json::Value &jsValue) {
|
/* 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 < 2; 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(jsData);
|
}
|
}
|
}
|