chenluhua1980
23 小时以前 2b87741f1a372c6da84d6ae3839ff2cf6297b71f
SourceCode/Bond/Servo/CPageGraph1.cpp
@@ -229,9 +229,7 @@
      m_slotTable.SetTitleHeight(m_slotTableTitleHeight);
      m_slotTable.SetLineColor(lineColor);
      m_slotTable.SetHeaderBgColor(headerBgColor);
      LOGI("[Graph1] SlotTable create ret=%d hwnd=%p err=%lu rc=(%d,%d)-(%d,%d)",
         created, m_slotTable.GetSafeHwnd(), GetLastError(),
         rcTable.left, rcTable.top, rcTable.right, rcTable.bottom);
      (void)created;
   }
   else {
      m_slotTable.MoveWindow(&rcTable);
@@ -241,20 +239,16 @@
      m_slotTable.SetTitleHeight(m_slotTableTitleHeight);
      m_slotTable.SetLineColor(lineColor);
      m_slotTable.SetHeaderBgColor(headerBgColor);
      LOGI("[Graph1] SlotTable moved rc=(%d,%d)-(%d,%d)", rcTable.left, rcTable.top, rcTable.right, rcTable.bottom);
   }
   // 如果超出可视区域,强制移到左上角作为兜底
   CRect rcWnd;
   m_slotTable.GetWindowRect(&rcWnd);
   ScreenToClient(&rcWnd);
   LOGI("[Graph1] SlotTable wnd rc=(%d,%d)-(%d,%d) client=(%d,%d)",
      rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, rcClient.right, rcClient.bottom);
   if (rcWnd.right <= 0 || rcWnd.bottom <= 0 ||
      rcWnd.left >= rcClient.right || rcWnd.top >= rcClient.bottom) {
      CRect rcFallback(10, 10, 10 + cfgW, 10 + cfgH);
      m_slotTable.MoveWindow(&rcFallback);
      LOGI("[Graph1] SlotTable fallback rc=(%d,%d)-(%d,%d)", rcFallback.left, rcFallback.top, rcFallback.right, rcFallback.bottom);
   }
   m_slotTable.SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
@@ -270,7 +264,6 @@
   std::vector<CSlotTableCtrl::Row> rows;
   if (pEquipment != nullptr) {
      LOGI("[Graph1] UpdateSlotTable eq=%s(%p)", pEquipment->getName().c_str(), pEquipment);
      for (int i = 0; i < SLOT_MAX && rows.size() < 8; ++i) {
         SERVO::CSlot* pSlot = pEquipment->getSlot(i);
         if (pSlot == nullptr || !pSlot->isEnable()) continue;
@@ -291,7 +284,6 @@
         rows.push_back(row);
      }
   }
   LOGI("[Graph1] SlotTable rows=%zu", rows.size());
   m_slotTableRowCount = static_cast<int>(rows.size());
   if (m_slotTableRowCount < 1) m_slotTableRowCount = 1;
@@ -359,6 +351,14 @@
               }
            }
         }
         else if (RX_CODE_EQ_DATA_CHANGED == code
            || RX_CODE_LOADPORT_STATUS_CHANGED == code) {
            // 设备数据变化时,及时刷新格子与右侧Slot表,避免只在点击时更新一次
            UpdateSlotBars();
            if (m_pSelectedEquipment != nullptr) {
               UpdateSlotTable(m_pSelectedEquipment);
            }
         }
         pAny->release();
         }, [&]() -> void {
@@ -386,8 +386,39 @@
   if (auto* pGraphWnd = GetDlgItem(IDC_SERVO_GRAPH1)) {
      pGraphWnd->ModifyStyle(0, WS_CLIPSIBLINGS);
   }
   std::string iniPath = GetConfigPath();
   CString strPath;
   strPath.Format(_T("%s\\res\\Servo001.bmp"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
   auto resolveGraphImagePath = [&](const char* iniKey, const char* defaultName) -> CString {
      char value[MAX_PATH] = { 0 };
      GetPrivateProfileStringA("Graph1", iniKey, defaultName, value, (DWORD)sizeof(value), iniPath.c_str());
      std::string file = value;
      auto trim = [](std::string& s) {
         while (!s.empty() && (s.front() == ' ' || s.front() == '\t' || s.front() == '\r' || s.front() == '\n')) s.erase(s.begin());
         while (!s.empty() && (s.back() == ' ' || s.back() == '\t' || s.back() == '\r' || s.back() == '\n')) s.pop_back();
      };
      trim(file);
      if (file.empty()) file = defaultName;
      CString path;
      const bool isAbs = (file.size() > 1 && file[1] == ':') || (!file.empty() && (file[0] == '\\' || file[0] == '/'));
      if (isAbs) {
         path = file.c_str();
      }
      else if (file.rfind("res\\", 0) == 0 || file.rfind("res/", 0) == 0) {
         path.Format(_T("%s\\%s"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, CString(file.c_str()));
      }
      else {
         path.Format(_T("%s\\res\\%s"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, CString(file.c_str()));
      }
      DWORD attr = GetFileAttributes(path);
      if (attr == INVALID_FILE_ATTRIBUTES || (attr & FILE_ATTRIBUTE_DIRECTORY)) {
         path.Format(_T("%s\\res\\%s"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, CString(defaultName));
      }
      return path;
   };
   strPath = resolveGraphImagePath("BackgroundBmp", "Servo001.bmp");
   m_pGraph->AddImage(1, (LPTSTR)(LPCTSTR)strPath, 0, 0);
   strPath.Format(_T("%s\\res\\Robot001.bmp"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
@@ -403,14 +434,17 @@
   // 添加指示器
   // Bonder
   // size config
   std::string iniPath = GetConfigPath();
   int boxSize = GetPrivateProfileIntA("Graph1", "BoxSize", 56, iniPath.c_str());
   if (boxSize < 40) boxSize = 40;
   if (boxSize > 80) boxSize = 80;
   int slotSize = GetPrivateProfileIntA("Graph1", "SlotSize", 6, iniPath.c_str());
   if (slotSize < 2) slotSize = 2;
   if (slotSize > 12) slotSize = 12;
   m_pGraph->SetSlotBarSize(slotSize);
   int slotSizeDefault = GetPrivateProfileIntA("Graph1", "SlotSize", 6, iniPath.c_str());
   int slotSize8 = GetPrivateProfileIntA("Graph1", "SlotSize8", slotSizeDefault, iniPath.c_str());
   int slotSizeOther = GetPrivateProfileIntA("Graph1", "SlotSizeOther", slotSizeDefault, iniPath.c_str());
   if (slotSize8 < 2) slotSize8 = 2;
   if (slotSize8 > 12) slotSize8 = 12;
   if (slotSizeOther < 2) slotSizeOther = 2;
   if (slotSizeOther > 12) slotSizeOther = 12;
   m_pGraph->SetSlotBarSizeByCount(slotSize8, slotSizeOther);
   int armBoxSize = GetPrivateProfileIntA("Graph1", "ArmBoxSize", boxSize, iniPath.c_str());
   if (armBoxSize < 30) armBoxSize = 30;
   if (armBoxSize > 80) armBoxSize = 80;
@@ -442,73 +476,96 @@
      arm2X = baseMid + half;
   }
   m_pGraph->AddIndicateBox(INDICATE_BONDER1, 220, 172, boxSize, RGB(22, 22, 22),
   auto readGraphPoint = [&](const char* keyPrefix, int defaultX, int defaultY) -> POINT {
      std::string keyX = std::string(keyPrefix) + "_X";
      std::string keyY = std::string(keyPrefix) + "_Y";
      POINT pt = { 0 };
      pt.x = GetPrivateProfileIntA("Graph1", keyX.c_str(), defaultX, iniPath.c_str());
      pt.y = GetPrivateProfileIntA("Graph1", keyY.c_str(), defaultY, iniPath.c_str());
      return pt;
   };
   const POINT ptBonder1 = readGraphPoint("Bonder1", 220, 172);
   const POINT ptBonder2 = readGraphPoint("Bonder2", 220, 516);
   const POINT ptFliper = readGraphPoint("Fliper", 338, 172);
   const POINT ptAligner = readGraphPoint("Aligner", 428, 172);
   const POINT ptLoadPort4 = readGraphPoint("LoadPort4", 518, 172);
   const POINT ptLoadPort3 = readGraphPoint("LoadPort3", 606, 172);
   const POINT ptLoadPort2 = readGraphPoint("LoadPort2", 690, 172);
   const POINT ptLoadPort1 = readGraphPoint("LoadPort1", 774, 172);
   const POINT ptRobotArm1 = readGraphPoint("RobotArm1", arm1X, armY);
   const POINT ptRobotArm2 = readGraphPoint("RobotArm2", arm2X, armY);
   const POINT ptVacuumBake = readGraphPoint("VacuumBake", 396, 516);
   const POINT ptBakeCooling = readGraphPoint("BakeCooling", 566, 516);
   const POINT ptMeasurement = readGraphPoint("Measurement", 737, 516);
   m_pGraph->AddIndicateBox(INDICATE_BONDER1, ptBonder1.x, ptBonder1.y, boxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_BONDER1, "", "Bonder 1");
   m_pGraph->AddIndicateBox(INDICATE_BONDER2, 220, 516, boxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_BONDER2, ptBonder2.x, ptBonder2.y, boxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_BONDER2, "", "Bonder 2");
   // 翻转
   m_pGraph->AddIndicateBox(INDICATE_FLIPER, 338, 172, boxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_FLIPER, ptFliper.x, ptFliper.y, boxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_FLIPER, "", "Fliper");
   // 对位
   m_pGraph->AddIndicateBox(INDICATE_ALIGNER, 428, 172, boxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_ALIGNER, ptAligner.x, ptAligner.y, boxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_ALIGNER, "", "Aligner");
   // Load port 4
   m_pGraph->AddIndicateBox(INDICATE_LPORT4, 518, 172, boxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_LPORT4, ptLoadPort4.x, ptLoadPort4.y, boxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_LPORT4, "", "LPort4");
   // Load port 3
   m_pGraph->AddIndicateBox(INDICATE_LPORT3, 606, 172, boxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_LPORT3, ptLoadPort3.x, ptLoadPort3.y, boxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_LPORT3, "", "LPort3");
   // Load port 2
   m_pGraph->AddIndicateBox(INDICATE_LPORT2, 690, 172, boxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_LPORT2, ptLoadPort2.x, ptLoadPort2.y, boxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_LPORT2, "", "LPort2");
   // Load port 1
   m_pGraph->AddIndicateBox(INDICATE_LPORT1, 774, 172, boxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_LPORT1, ptLoadPort1.x, ptLoadPort1.y, boxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_LPORT1, "", "LPort1");
   // Robot
   m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM1, arm1X, armY, armBoxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM1, ptRobotArm1.x, ptRobotArm1.y, armBoxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_ROBOT_ARM1, "", "Robot");
   m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM2, arm2X, armY, armBoxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM2, ptRobotArm2.x, ptRobotArm2.y, armBoxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_ROBOT_ARM2, "", "Robot");
   // Vacuum bake
   m_pGraph->AddIndicateBox(INDICATE_VACUUM_BAKE, 396, 516, boxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_VACUUM_BAKE, ptVacuumBake.x, ptVacuumBake.y, boxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_VACUUM_BAKE, "", "Vacuum bake");
   // Bake cooling
   m_pGraph->AddIndicateBox(INDICATE_BAKE_COOLING, 566, 516, boxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_BAKE_COOLING, ptBakeCooling.x, ptBakeCooling.y, boxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_BAKE_COOLING, "", "Bake cooling");
   // 精度检
   m_pGraph->AddIndicateBox(INDICATE_MEASUREMENT, 737, 516, boxSize, RGB(22, 22, 22),
   m_pGraph->AddIndicateBox(INDICATE_MEASUREMENT, ptMeasurement.x, ptMeasurement.y, boxSize, RGB(22, 22, 22),
      RGB(255, 127, 39), EQ_BOX_OFFLINE);
   m_pGraph->SetBoxText(INDICATE_MEASUREMENT, "", "Measurement");
@@ -1016,6 +1073,9 @@
      SERVO::CEFEM* pEFEM = (SERVO::CEFEM*)theApp.m_model.m_master.getEquipment(EQ_ID_EFEM);
      if (!pEFEM || !pEFEM->isAlive()) {
         UpdateSlotBars();
         if (m_pSelectedEquipment != nullptr) {
            UpdateSlotTable(m_pSelectedEquipment);
         }
         return;
      }
@@ -1041,6 +1101,10 @@
      }
      UpdateSlotBars();
      if (m_pSelectedEquipment != nullptr) {
         // 定时兜底:即使漏掉事件通知,也确保右侧Slot表持续刷新
         UpdateSlotTable(m_pSelectedEquipment);
      }
   }
   else if (nIDEvent == TIMER_ID_ROBOT_ANIMATION) {
      if (!m_bIsRobotMoving) {