| | |
| | | m_ullStartTime = 0; |
| | | m_ullRunTime = 0; |
| | | m_state = MASTERSTATE::READY; |
| | | m_curveMode = CurveMode::Production; |
| | | m_pActiveRobotTask = nullptr; |
| | | m_nLastError = ER_CODE_NOERROR; |
| | | m_isCompareMapsBeforeProceeding = FALSE; |
| | |
| | | m_hEventDispatchThreadExit[1] = nullptr; |
| | | } |
| | | |
| | | |
| | | DeleteCriticalSection(&m_criticalSection); |
| | | } |
| | | |
| | |
| | | |
| | | int CMaster::init() |
| | | { |
| | | const ULONGLONG boot_master_begin = GetTickCount64(); |
| | | LOGI("<Master>正在初始化..."); |
| | | LOGI("[BOOT][MASTER] init begin"); |
| | | |
| | | |
| | | // cclink |
| | | if (m_cclink.Connect(CC_LINK_IE_CONTROL_CHANNEL(1)) != 0) { |
| | | const ULONGLONG boot_cclink_begin = GetTickCount64(); |
| | | const int cc_ret = m_cclink.Connect(CC_LINK_IE_CONTROL_CHANNEL(1)); |
| | | LOGI("[BOOT][MASTER] CC-Link connect ret=%d, cost=%llu ms", |
| | | cc_ret, |
| | | (unsigned long long)(GetTickCount64() - boot_cclink_begin)); |
| | | if (cc_ret != 0) { |
| | | LOGE("连接CC-Link失败."); |
| | | } |
| | | else { |
| | |
| | | |
| | | |
| | | // 读缓存数据 |
| | | const ULONGLONG boot_cache_begin = GetTickCount64(); |
| | | const ULONGLONG boot_read_begin = GetTickCount64(); |
| | | readCache(); |
| | | LOGI("[BOOT][MASTER] readCache finished, cost=%llu ms", (unsigned long long)(GetTickCount64() - boot_read_begin)); |
| | | |
| | | const ULONGLONG boot_state_begin = GetTickCount64(); |
| | | loadState(); |
| | | LOGI("[BOOT][MASTER] loadState finished, cost=%llu ms", (unsigned long long)(GetTickCount64() - boot_state_begin)); |
| | | if (m_listener.onControlJobChanged) { |
| | | m_listener.onControlJobChanged(this); |
| | | notifyControlJobChanged(); |
| | | } |
| | | |
| | | LOGI("[BOOT][MASTER] cache/state loaded, cost=%llu ms (since init %llu ms)", |
| | | (unsigned long long)(GetTickCount64() - boot_cache_begin), |
| | | (unsigned long long)(GetTickCount64() - boot_master_begin)); |
| | | |
| | | |
| | | // 定时器 |
| | |
| | | |
| | | |
| | | LOGI("<Master>初始化完成."); |
| | | LOGI("[BOOT][MASTER] init finished, total cost=%llu ms", |
| | | (unsigned long long)(GetTickCount64() - boot_master_begin)); |
| | | return 0; |
| | | } |
| | | |
| | | void CMaster::setCurveMode(CurveMode mode) |
| | | { |
| | | if (m_curveMode == mode) { |
| | | return; |
| | | } |
| | | m_curveMode = mode; |
| | | if (m_pCollector != nullptr) { |
| | | const uint32_t mids[] = { |
| | | MID_Bonder1, MID_Bonder2, |
| | | MID_VacuumBakeA, MID_VacuumBakeB, |
| | | MID_BakeCoolingA, MID_BakeCoolingB |
| | | }; |
| | | for (uint32_t mid : mids) { |
| | | if (mode == CurveMode::EmptyChamber) { |
| | | m_pCollector->batchStart(mid, "EMPTY_CHAMBER", 30 * 60 * 1000ULL); // 空腔模式:启动采样批次 |
| | | } |
| | | else { |
| | | m_pCollector->batchStop(mid); |
| | | m_pCollector->buffersClear(mid); // 切回生产模式,清掉空腔数据 |
| | | } |
| | | } |
| | | } |
| | | LOGI("<Master>CurveMode=%s", mode == CurveMode::EmptyChamber ? "EmptyChamber" : "Production"); |
| | | } |
| | | |
| | | CurveMode CMaster::getCurveMode() const |
| | | { |
| | | return m_curveMode; |
| | | } |
| | | |
| | | int CMaster::term() |
| | |
| | | } |
| | | m_listEquipment.clear(); |
| | | |
| | | // release manual-remove buffer before glass pool is torn down |
| | | for (auto* pGlass : m_bufGlass) { |
| | | if (pGlass != nullptr) { |
| | | pGlass->release(); |
| | | } |
| | | } |
| | | m_bufGlass.clear(); |
| | | |
| | | if (m_pCollector != nullptr) { |
| | | m_pCollector->stopLoop(); |
| | |
| | | } |
| | | }; |
| | | listener.onSVDataReport = [&](void* pEquipment, void* pData) { |
| | | const bool allowSvLog = |
| | | (m_state == MASTERSTATE::RUNNING || |
| | | m_state == MASTERSTATE::RUNNING_CONTINUOUS_TRANSFER || |
| | | m_state == MASTERSTATE::RUNNING_BATCH || |
| | | m_state == MASTERSTATE::STARTING); |
| | | const bool allowCurve = allowSvLog || (m_curveMode == CurveMode::EmptyChamber); |
| | | if (!allowCurve) { |
| | | return; |
| | | } |
| | | CSVData* pSVData = (CSVData*)pData; |
| | | auto rawData = pSVData->getSVRawData(); |
| | | std::vector<CParam> params; |
| | |
| | | int paramIndex = mapping.first; |
| | | int channel = mapping.second; |
| | | |
| | | if (paramIndex < params.size() && channel - 1 < vacuumbakeTypes.size()) { |
| | | if (paramIndex < params.size()) { |
| | | auto& param = params.at(paramIndex); |
| | | double value = param.getDoubleValue(); |
| | | const std::string& dataType = vacuumbakeTypes[channel - 1]; |
| | | const std::string& paramName = param.getName(); |
| | | const char slotTag = !paramName.empty() ? paramName[0] : '\0'; |
| | | const int typeIndex = (slotTag == 'B') ? (channel - 8) : (channel - 1); |
| | | if (typeIndex < 0 || typeIndex >= (int)vacuumbakeTypes.size()) { |
| | | continue; |
| | | } |
| | | const int pushChannel = typeIndex + 1; |
| | | const std::string& dataType = vacuumbakeTypes[typeIndex]; |
| | | |
| | | if (m_pCollector != nullptr) { |
| | | if (slotTag == 'A') |
| | | m_pCollector->buffersPush(SlotToMid(eqid, 1), channel, ts, value); |
| | | m_pCollector->buffersPush(SlotToMid(eqid, 1), pushChannel, ts, value); |
| | | else if (slotTag == 'B') |
| | | m_pCollector->buffersPush(SlotToMid(eqid, 2), channel, ts, value); |
| | | m_pCollector->buffersPush(SlotToMid(eqid, 2), pushChannel, ts, value); |
| | | } |
| | | |
| | | // 根据腔体前缀写入对应 Slot 的玻璃 |
| | |
| | | int paramIndex = mapping.first; |
| | | int channel = mapping.second; |
| | | |
| | | if (paramIndex < params.size() && channel - 1 < coolingTypes.size()) { |
| | | if (paramIndex < params.size()) { |
| | | auto& param = params.at(paramIndex); |
| | | double value = param.getDoubleValue(); |
| | | const std::string& dataType = coolingTypes[channel - 1]; |
| | | const std::string& paramName = param.getName(); |
| | | const char slotTag = !paramName.empty() ? paramName[0] : '\0'; |
| | | const bool paramIsBake = paramName.find("烘烤") != std::string::npos; |
| | | const bool paramIsCooling = paramName.find("冷却") != std::string::npos; |
| | | const int typeIndex = (slotTag == 'B') ? (channel - 7) : (channel - 1); |
| | | if (typeIndex < 0 || typeIndex >= (int)coolingTypes.size()) { |
| | | continue; |
| | | } |
| | | const int pushChannel = typeIndex + 1; |
| | | const std::string& dataType = coolingTypes[typeIndex]; |
| | | |
| | | if (m_pCollector != nullptr && paramIsBake) { |
| | | if (slotTag == 'A') |
| | | m_pCollector->buffersPush(SlotToMid(eqid, 1), channel, ts, value); |
| | | m_pCollector->buffersPush(SlotToMid(eqid, 1), pushChannel, ts, value); |
| | | else if (slotTag == 'B') |
| | | m_pCollector->buffersPush(SlotToMid(eqid, 3), channel, ts, value); |
| | | m_pCollector->buffersPush(SlotToMid(eqid, 3), pushChannel, ts, value); |
| | | } |
| | | |
| | | if (!dataType.empty()) { |
| | |
| | | |
| | | this->saveState(); |
| | | if (m_listener.onControlJobChanged) { |
| | | m_listener.onControlJobChanged(this); |
| | | notifyControlJobChanged(); |
| | | } |
| | | |
| | | return (int)m_processJobs.size(); |
| | |
| | | m_pControlJob->setPJs(temps); |
| | | this->saveState(); |
| | | if (m_listener.onControlJobChanged) { |
| | | m_listener.onControlJobChanged(this); |
| | | notifyControlJobChanged(); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | if (pausedAny && m_listener.onControlJobChanged) { |
| | | // 通知应用层刷新 UI/按钮状态 |
| | | m_listener.onControlJobChanged(this); |
| | | notifyControlJobChanged(); |
| | | } |
| | | if (pausedAny && !m_bPauseAlarmRaised) { |
| | | std::string desc = CToolUnits::formatString("<PauseEvent CEID=%u>", ceid); |
| | |
| | | |
| | | saveState(); |
| | | if (m_listener.onControlJobChanged) { |
| | | m_listener.onControlJobChanged(this); |
| | | notifyControlJobChanged(); |
| | | } |
| | | |
| | | return true; |
| | |
| | | |
| | | saveState(); |
| | | if (m_listener.onControlJobChanged) { |
| | | m_listener.onControlJobChanged(this); |
| | | notifyControlJobChanged(); |
| | | } |
| | | |
| | | return true; |
| | |
| | | if (pSlot == nullptr) return false; |
| | | |
| | | CGlass* pGlass = (CGlass*)pSlot->getContext(); |
| | | if (pGlass == nullptr) return false; |
| | | |
| | | // Buffer 上限为 1:新搬出时丢弃旧的 |
| | | if (!m_bufGlass.empty()) { |
| | | for (auto* oldGlass : m_bufGlass) { |
| | | if (oldGlass != nullptr) oldGlass->release(); |
| | | } |
| | | m_bufGlass.clear(); |
| | | } |
| | | m_bufGlass.push_back(pGlass); |
| | | pGlass->addRef(); |
| | | pSlot->setContext(nullptr); |
| | |
| | | auto& dataTypes = CServoUtilsTool::getEqDataTypes(); |
| | | auto& bonderTypes = dataTypes[MID_Bonder1]; |
| | | for (size_t i = 0; i < bonderTypes.size(); ++i) { |
| | | m_pCollector->buffersSetChannelName(MID_Bonder1, i + 1, bonderTypes[i].c_str()); |
| | | m_pCollector->buffersSetChannelName(MID_Bonder2, i + 1, bonderTypes[i].c_str()); |
| | | m_pCollector->buffersSetChannelName(MID_Bonder1, (UINT)i + 1, bonderTypes[(UINT)i].c_str()); |
| | | m_pCollector->buffersSetChannelName(MID_Bonder2, (UINT)i + 1, bonderTypes[(UINT)i].c_str()); |
| | | } |
| | | |
| | | auto& vacuumbakeTypes = dataTypes[MID_VacuumBakeA]; |
| | | for (size_t i = 0; i < vacuumbakeTypes.size(); ++i) { |
| | | m_pCollector->buffersSetChannelName(MID_VacuumBakeA, i + 1, vacuumbakeTypes[i].c_str()); |
| | | m_pCollector->buffersSetChannelName(MID_VacuumBakeB, i + 1, vacuumbakeTypes[i].c_str()); |
| | | m_pCollector->buffersSetChannelName(MID_VacuumBakeA, (UINT)i + 1, vacuumbakeTypes[(UINT)i].c_str()); |
| | | m_pCollector->buffersSetChannelName(MID_VacuumBakeB, (UINT)i + 1, vacuumbakeTypes[(UINT)i].c_str()); |
| | | } |
| | | |
| | | auto& coolingTypes = dataTypes[MID_BakeCoolingA]; |
| | |
| | | m_pCollector->buffersSetChannelName(MID_BakeCoolingA, i + 1, coolingTypes[i].c_str()); |
| | | m_pCollector->buffersSetChannelName(MID_BakeCoolingB, i + 1, coolingTypes[i].c_str()); |
| | | } |
| | | |
| | | if (m_curveMode == CurveMode::EmptyChamber) { |
| | | const uint32_t mids[] = { |
| | | MID_Bonder1, MID_Bonder2, |
| | | MID_VacuumBakeA, MID_VacuumBakeB, |
| | | MID_BakeCoolingA, MID_BakeCoolingB |
| | | }; |
| | | for (uint32_t mid : mids) { |
| | | m_pCollector->batchStart(mid, "EMPTY_CHAMBER", 10 * 60 * 1000ULL); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |