#include "RecipeAttrObj.h" RecipeAttrObj::RecipeAttrObj() { } RecipeAttrObj::~RecipeAttrObj() { } void RecipeAttrObj::GenerateWaferIdContent(int autoGenWay, int cassSlot) { char buffer[10]; sprintf(buffer, "%02d", cassSlot); // 这里的2表示最小宽度为2,不足部分用0填充 QString formattedNum = QString::fromLatin1(buffer); QString waferIdNoCrc = m_charContent + "-" + formattedNum + "-"; std::string waferID = waferIdNoCrc.toStdString(); // 示例WaferID,不包含最后两位校验位 std::vector data = stringToBytes(waferID); // 将字符串转换为字节向量 unsigned char checksum = crc82(data); int checkSumNum = static_cast(checksum); std::stringstream ss; ss << std::hex << checkSumNum; std::string waferIdhex= ss.str(); // 使用 std::transform 和 std::toupper 将所有字符转换为大写 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 RecipeAttrObj::stringToBytes(const std::string& str) { std::vector bytes; for (char c : str) { bytes.push_back(c); } return bytes; } uint8_t RecipeAttrObj::crc82(const std::vector& data) { uint8_t crc = 0x00; // 初始值 uint8_t polynomial = 0x07; // 多项式 for (size_t i = 0; i < data.size(); ++i) { crc ^= data[i]; // 与当前字节进行异或 for (int j = 0; j < 8; ++j) { // 逐位处理 if (crc & 0x80) { // 如果最高位为1 crc = (crc << 1) ^ polynomial; // 左移一位并异或多项式 } else { crc <<= 1; // 否则只左移一位 } } } return crc; // 返回最终的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; }