You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
5.4 KiB
C++

#include "RecipeAttrObj.h"
RecipeAttrObj::RecipeAttrObj()
{
}
RecipeAttrObj::~RecipeAttrObj()
{
}
void RecipeAttrObj::GenerateWaferIdContent(int autoGenWay, int cassSlot)
{
char buffer[10];
sprintf(buffer, "%02d", cassSlot); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32>ʾ<EFBFBD><CABE>С<EFBFBD><D0A1><EFBFBD><EFBFBD>Ϊ2<CEAA><32><EFBFBD><EFBFBD><EFBFBD>㲿<EFBFBD><E3B2BF><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD>
QString formattedNum = QString::fromLatin1(buffer);
QString waferIdNoCrc = m_charContent + "-" + formattedNum + "-";
std::string waferID = waferIdNoCrc.toStdString(); // ʾ<><CABE>WaferID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λУ<CEBB><D0A3>λ
std::vector<unsigned char> data = stringToBytes(waferID); // <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
unsigned char checksum = crc82(data);
int checkSumNum = static_cast<int>(checksum);
std::stringstream ss;
ss << std::hex << checkSumNum;
std::string waferIdhex= ss.str();
// ʹ<><CAB9> std::transform <20><> std::toupper <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA>д
std::transform(waferIdhex.begin(), waferIdhex.end(), waferIdhex.begin(),
[](unsigned char c) { return std::toupper(c); });
if (autoGenWay == 0)
{
m_markCharContent = m_charContent;
}
else if(autoGenWay == 1)
{
m_markCharContent = m_charContent + "-" + formattedNum;
}
else if (autoGenWay == 2)
{
m_markCharContent = m_charContent + "-" + formattedNum + "-" + QString::fromStdString(waferIdhex);
}
}
int RecipeAttrObj::JudgeWaferSize()
{
if (m_waferDie - 300 <= 20)
{
return 12;
}
if (m_waferDie - 200 <= 20)
{
return 8;
}
return 0;
}
std::vector<unsigned char> RecipeAttrObj::stringToBytes(const std::string& str)
{
std::vector<unsigned char> bytes;
for (char c : str) {
bytes.push_back(c);
}
return bytes;
}
uint8_t RecipeAttrObj::crc82(const std::vector<unsigned char>& data)
{
uint8_t crc = 0x00; // <20><>ʼֵ
uint8_t polynomial = 0x07; // <20><><EFBFBD><EFBFBD>ʽ
for (size_t i = 0; i < data.size(); ++i) {
crc ^= data[i]; // <20>뵱ǰ<EBB5B1>ֽڽ<D6BD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (int j = 0; j < 8; ++j) { // <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
if (crc & 0x80) { // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λΪ1
crc = (crc << 1) ^ polynomial; // <20><><EFBFBD><EFBFBD>һλ<D2BB><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
}
else {
crc <<= 1; // <20><><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>һλ
}
}
}
return crc; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>CRCֵ
}
RecipeAttrObj& RecipeAttrObj::operator=(const RecipeAttrObj& other)
{
this->m_PPID = other.m_PPID;
this->m_dieMarkFlag = other.m_dieMarkFlag;
this->m_waferIDMarkFlag = other.m_waferIDMarkFlag;
this->m_lotID = other.m_lotID;
this->m_waferDie = other.m_waferDie;
this->m_waferThick = other.m_waferThick;
this->m_dieWidth = other.m_dieWidth;
this->m_dieHeight = other.m_dieHeight;
this->m_baseDieCoordX = other.m_baseDieCoordX;
this->m_baseDIeCoordY = other.m_baseDIeCoordY;
this->m_mark1CoordX = other.m_mark1CoordX;
this->m_mark1CoordY = other.m_mark1CoordY;
this->m_mark2CoordX = other.m_mark2CoordX;
this->m_mark2CoordY = other.m_mark2CoordY;
this->m_watchDie1X = other.m_watchDie1X;
this->m_watchDie1Y = other.m_watchDie1Y;
this->m_watchDie2X = other.m_watchDie2X;
this->m_watchDie2Y = other.m_watchDie2Y;
this->m_mark1ToAxisCoordX = other.m_mark1ToAxisCoordX;
this->m_mark1ToAxisCoordY = other.m_mark1ToAxisCoordY;
this->m_mark2ToAxisCoordX = other.m_mark2ToAxisCoordX;
this->m_mark2ToAxisCoordY = other.m_mark2ToAxisCoordY;
this->m_norchToAxisCoordX = other.m_norchToAxisCoordX;
this->m_norchToAxisCoordY = other.m_norchToAxisCoordY;
this->m_cameraModuleID = other.m_cameraModuleID;
this->m_cameraMark1ModuleID = other.m_cameraMark1ModuleID;
this->m_cameraMark2ModuleID = other.m_cameraMark2ModuleID;
this->m_cameraZFocus = other.m_cameraZFocus;
this->m_workSpeed = other.m_workSpeed;
this->m_emptySpeed = other.m_emptySpeed;
this->m_openFrontDelay = other.m_openFrontDelay;
this->m_openBackDelay = other.m_openBackDelay;
this->m_closeFrontDelay = other.m_closeFrontDelay;
this->m_closeBackDelay = other.m_closeBackDelay;
this->m_drTime = other.m_drTime;
this->m_laserFreq = other.m_laserFreq;
this->m_laserPower = other.m_laserPower;
this->m_laserRealPower = other.m_laserRealPower;
this->m_markZFocus = other.m_markZFocus;
this->m_charContent = other.m_charContent;
this->m_charSpacing = other.m_charSpacing;
this->m_offsetNorchX = other.m_offsetNorchX;
this->m_offsetNorchY = other.m_offsetNorchY;
this->m_semiWidth = other.m_semiWidth;
this->m_semiHeight = other.m_semiHeight;
this->m_isAutoGenerrate = other.m_isAutoGenerrate;
this->m_isMarkChar = other.m_isMarkChar;
this->m_markFocal = other.m_markFocal;
this->m_markType = other.m_markType;
this->m_circleMarkAngle = other.m_circleMarkAngle;
this->m_fontType = other.m_fontType;
this->m_markCharVec.clear();
for (auto& iter : other.m_markCharVec)
{
this->m_markCharVec.push_back(iter);
}
this->m_InputMarkCharVec.clear();
for (auto& iter : other.m_InputMarkCharVec)
{
this->m_InputMarkCharVec.push_back(iter);
}
this->m_markGraphicsVec.clear();
for (auto& iter : other.m_markGraphicsVec)
{
this->m_markGraphicsVec.push_back(iter);
}
this->m_addSerialFlag = other.m_addSerialFlag;
this->m_serialStartStr = other.m_serialStartStr;
//this->m_serialCharWidth = other.m_serialCharWidth;
//this->m_serialCharHeight = other.m_serialCharHeight;
//this->m_serialCharSpacing = other.m_serialCharSpacing;
//this->m_serialCharCoordX = other.m_serialCharCoordX;
//this->m_serialCharCoordY = other.m_serialCharCoordY;
this->m_areaOffsetStr = other.m_areaOffsetStr;
this->m_waferOffsetX = other.m_waferOffsetX;
this->m_waferOffsetY = other.m_waferOffsetY;
this->m_yDirectionOffsetUseXFlag = other.m_yDirectionOffsetUseXFlag;
this->m_yDirectionOneOffset = other.m_yDirectionOneOffset;
this->m_xDirectionAutoOffsetFlag = other.m_xDirectionAutoOffsetFlag;
return *this;
}