LAPTOP-SNT8I5JK\Boounion
2025-05-27 e937700184e21d263b771921b269fbdda341dfc4
SourceCode/Bond/Servo/ServoDlg.cpp
@@ -169,6 +169,22 @@
               }
            }
         }
         else if (RX_CODE_MASTER_STATE_CHANGED == code) {
            SERVO::MASTERSTATE state = theApp.m_model.getMaster().getState();
            if (state == SERVO::MASTERSTATE::READY) {
               m_pMyStatusbar->setBackgroundColor(STATUSBAR_BK_NORMAL);
               m_pMyStatusbar->setForegroundColor(RGB(0, 0, 0));
               KillTimer(TIMER_ID_UPDATE_RUMTIME);
               CString strText;
               GetRuntimeFormatText(strText, "");
               m_pMyStatusbar->setRunTimeText((LPTSTR)(LPCTSTR)strText);
            }
            else if (state == SERVO::MASTERSTATE::RUNNING) {
               m_pMyStatusbar->setBackgroundColor(STATUSBAR_BK_RUNNING);
               m_pMyStatusbar->setForegroundColor(RGB(255, 255, 255));
               SetTimer(TIMER_ID_UPDATE_RUMTIME, 500, nullptr);
            }
         }
         pAny->release();
      }, [&]() -> void {
@@ -704,12 +720,8 @@
      if (index >= 4) index = 0;
      static char* status[] = {"|", "/", "--", "\\"};
      CTime time = CTime::GetCurrentTime();
      CString strText;
      strText.Format(_T("已运行:%d-%02d-%02d %02d:%02d:%02d   %s"),
         time.GetYear(), time.GetMonth(), time.GetDay(),
         time.GetHour(), time.GetMinute(), time.GetSecond(),
         status[index]);
      GetRuntimeFormatText(strText, status[index]);
      m_pMyStatusbar->setRunTimeText((LPTSTR)(LPCTSTR)strText);
   }
@@ -750,16 +762,11 @@
      theApp.m_model.getMaster().start();
      m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(FALSE);
      m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(TRUE);
      m_pMyStatusbar->setBkgnd(STATUSBAR_BK_RUNNING);
      SetTimer(TIMER_ID_UPDATE_RUMTIME, 1000, nullptr);
   }
   else if (id == IDC_BUTTON_STOP) {
      theApp.m_model.getMaster().stop();
      m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(TRUE);
      m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(FALSE);
      m_pMyStatusbar->setBkgnd(STATUSBAR_BK_ALARM);
      KillTimer(TIMER_ID_UPDATE_RUMTIME);
   }
   else if (id == IDC_BUTTON_ROBOT) {
      SERVO::CEFEM* pEFEM = (SERVO::CEFEM*)theApp.m_model.getMaster().getEquipment(EQ_ID_EFEM);
@@ -768,4 +775,23 @@
      dlg.DoModal();
   }
   return 0;
}
CString& CServoDlg::GetRuntimeFormatText(CString& strText, const char* pszSuffix)
{
   ULONGLONG ullRunTime = (ULONGLONG)(theApp.m_model.getMaster().getRunTime() * 0.001);
   int h, m, s;
   h = int(ullRunTime / 3600);
   m = int((ullRunTime % 3600) / 60);
   s = int(ullRunTime % 60);
   SERVO::MASTERSTATE state = theApp.m_model.getMaster().getState();
   if (state == SERVO::MASTERSTATE::RUNNING) {
      strText.Format(_T("正在运行:%02d:%02d:%02d   %s"), h, m, s, pszSuffix);
   }
   else {
      strText.Format(_T("已运行:%02d:%02d:%02d   %s"), h, m, s, pszSuffix);
   }
   return strText;
}