LAPTOP-SNT8I5JK\Boounion
2025-03-10 19261d011387ec57d646decc945aadaf8913eeab
SourceCode/Bond/Servo/ServoDlg.cpp
@@ -88,9 +88,12 @@
   m_bShowAlarmWnd = FALSE;
   m_bIsRobotMoving = FALSE;
   m_pLogDlg = nullptr;
   m_pAlarmDlg = nullptr;
   m_pTerminalDisplayDlg = nullptr;
   m_pObserver = nullptr;
   m_pPanelMaster = nullptr;
   m_pPanelEquipment = nullptr;
   m_pPanelAttributes = nullptr;
}
void CServoDlg::DoDataExchange(CDataExchange* pDX)
@@ -112,6 +115,7 @@
   ON_WM_SIZE()
   ON_WM_CLOSE()
   ON_MESSAGE(ID_MSG_LOGDLG_HIDE, &CServoDlg::OnLogDlgHide)
   ON_MESSAGE(ID_MSG_ALARMDLG_HIDE, &CServoDlg::OnAlarmDlgHide)
   ON_WM_MOVING()
   ON_WM_MOVE()
   ON_COMMAND(ID_MENU_FILE_EXIT, &CServoDlg::OnMenuFileExit)
@@ -167,12 +171,32 @@
               }
            }
         }
         else if (RX_CODE_SELECT_EQUIPMENT == code) {
            SERVO::CEquipment* pEquipment = nullptr;
            if (pAny->getPtrValue("ptr", (void*&)pEquipment)) {
               ASSERT(pEquipment);
               ASSERT(m_pPanelEquipment);
               ASSERT(m_pPanelAttributes);
               m_pPanelEquipment->SetEquipment(pEquipment);
               m_pPanelAttributes->ShowWindow(SW_HIDE);
               if (!m_pPanelEquipment->IsWindowVisible()) {
                  m_pPanelEquipment->ShowWindow(SW_SHOW);
                  Resize();
               }
            }
         }
         else if (RX_CODE_SELECT_STEP == code) {
            SERVO::CStep* pStep = nullptr;
            if (pAny->getPtrValue("ptr", (void*&)pStep)) {
               ASSERT(pStep);
               ASSERT(m_pPanelEquipment);
               ASSERT(m_pPanelAttributes);
               m_pPanelEquipment->ShowWindow(SW_HIDE);
               m_pPanelAttributes->loadDataFromStep(pStep);
               if (!m_pPanelAttributes->IsWindowVisible()) {
                  m_pPanelAttributes->ShowWindow(SW_SHOW);
                  Resize();
               }
            }
         }
@@ -314,10 +338,11 @@
   m_pPanelMaster = new CPanelMaster();
   m_pPanelMaster->Create(IDD_PANEL_MASTER, this);
   m_pPanelMaster->ShowWindow(SW_SHOW);
   m_pPanelEquipment = new CPanelEquipment();
   m_pPanelEquipment->Create(IDD_PANEL_EQUIPMENT, this);
   m_pPanelAttributes = new CPanelAttributes();
   m_pPanelAttributes->Create(IDD_PANEL_ATTRIBUTES, this);
   m_pPanelAttributes->ShowWindow(SW_SHOW);
   // 调整初始窗口位置
@@ -559,6 +584,13 @@
      delete m_pLogDlg;
      m_pLogDlg = nullptr;
   }
   if (m_pAlarmDlg != nullptr) {
      m_pAlarmDlg->DestroyWindow();
      delete m_pAlarmDlg;
      m_pAlarmDlg = nullptr;
   }
   if (m_pTerminalDisplayDlg != nullptr) {
      m_pTerminalDisplayDlg->DestroyWindow();
      delete m_pTerminalDisplayDlg;
@@ -569,6 +601,12 @@
      m_pPanelMaster->DestroyWindow();
      delete m_pPanelMaster;
      m_pPanelMaster = nullptr;
   }
   if (m_pPanelEquipment != nullptr) {
      m_pPanelEquipment->DestroyWindow();
      delete m_pPanelEquipment;
      m_pPanelEquipment = nullptr;
   }
   if (m_pPanelAttributes != nullptr) {
@@ -591,6 +629,16 @@
void CServoDlg::OnBnClickedButtonLog()
{
   m_bShowLogWnd = !m_bShowLogWnd;
   // 如果要显示日志窗口,则隐藏报警窗口
   if (m_bShowLogWnd) {
      m_bShowAlarmWnd = false;
      if (m_pAlarmDlg != nullptr) {
         m_pAlarmDlg->ShowWindow(SW_HIDE);
         UpdateAlarmBtn();
      }
   }
   if (m_pLogDlg == nullptr) {
      m_pLogDlg = new CLogDlg();
      m_pLogDlg->Create(IDD_DIALOG_LOG, this);
@@ -782,7 +830,13 @@
      x += nPanelWidth;
   }
   if (m_pPanelAttributes != nullptr) {
   if (m_pPanelEquipment != nullptr && m_pPanelEquipment->IsWindowVisible()) {
      nPanelWidth = m_pPanelEquipment->getPanelWidth();
      m_pPanelEquipment->MoveWindow(x, y, nPanelWidth, rcClient.Height());
      x += nPanelWidth;
   }
   if (m_pPanelAttributes != nullptr && m_pPanelAttributes->IsWindowVisible()) {
      nPanelWidth = m_pPanelAttributes->getPanelWidth();
      m_pPanelAttributes->MoveWindow(x, y, nPanelWidth, rcClient.Height());
      x += nPanelWidth;
@@ -829,6 +883,15 @@
   return 0;
}
LRESULT CServoDlg::OnAlarmDlgHide(WPARAM wParam, LPARAM lParam)
{
   m_bShowAlarmWnd = FALSE;
   UpdateAlarmBtn();
   LOGE("OnAlarmDlgHide");
   return 0;
}
void CServoDlg::OnMoving(UINT fwSide, LPRECT pRect)
{
   CDialogEx::OnMoving(fwSide, pRect);
@@ -842,6 +905,12 @@
      m_pLogDlg->MoveWindow(rcWnd.left, rcWnd.bottom - 8, rcWnd.Width(), 200);
   }
   if (m_pAlarmDlg != nullptr && !m_pAlarmDlg->IsZoomed()) {
      CRect rcWnd;
      GetWindowRect(&rcWnd);
      m_pAlarmDlg->MoveWindow(rcWnd.left, rcWnd.bottom - 8, rcWnd.Width(), 200);
   }
   CDialogEx::OnMove(x, y);
}