LAPTOP-SNT8I5JK\Boounion
2025-05-30 ebf96874b6a994e3b09b69f272416cb482cf25bb
SourceCode/Bond/Servo/ServoDlg.cpp
@@ -169,6 +169,38 @@
               }
            }
         }
         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);
            }
         }
         else if (RX_CODE_EQ_ROBOT_TASK == code) {
            SERVO::CRobotTask* pTask = theApp.m_model.getMaster().getActiveRobotTask();
            if (pTask == nullptr) {
               m_pMyStatusbar->setCurTaskBtnText("无");
            }
            else {
               SERVO::CEquipment* pEq1, * pEq2;
               pEq1 = theApp.m_model.getMaster().getEquipment(pTask->getSrcPosition());
               pEq2 = theApp.m_model.getMaster().getEquipment(pTask->getTarPosition());
               if (pEq1 != nullptr && pEq2 != nullptr) {
                  CString strText;
                  strText.Format(_T("%s --> %s"), pEq1->getName().c_str(), pEq2->getName().c_str());
                  m_pMyStatusbar->setCurTaskBtnText((LPTSTR)(LPCTSTR)strText);
               }
            }
         }
         pAny->release();
      }, [&]() -> void {
@@ -704,12 +736,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 +778,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 +791,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;
}