LAPTOP-SNT8I5JK\Boounion
2025-06-19 be01318968aed5e55c511eedc6c1f72a961c3f13
SourceCode/Bond/Servo/CRobotTaskDlg.cpp
@@ -53,13 +53,42 @@
   }
   if (m_pRobotTask != nullptr) {
      SERVO::CEquipment* pEq1, * pEq2;
      pEq1 = theApp.m_model.getMaster().getEquipment(m_pRobotTask->getSrcPosition());
      pEq2 = theApp.m_model.getMaster().getEquipment(m_pRobotTask->getTarPosition());
      using namespace SERVO;
      CString strText;
      strText.Format(_T("%s --> %s"), pEq1->getName().c_str(), pEq2->getName().c_str());
      SetDlgItemText(IDC_LABEL_GET_PUT, strText);
      CEquipment* pSrcEq = theApp.m_model.getMaster().getEquipment(pRobotTask->getSrcPosition());
      CEquipment* pDstEq = theApp.m_model.getMaster().getEquipment(pRobotTask->getTarPosition());
      ROBOT_CMD_PARAM& param = pRobotTask->getRobotCmdParam(ACTION_TRANSFER);
      auto format_time = [](time_t t) -> CString {
         if (t == 0) {
            return _T("-");
         }
         CTime time(t);
         return time.Format(_T("%Y-%m-%d %H:%M:%S"));
      };
      CString strDetail;
      strDetail.Format(
         _T("任务 ID: %s\r\n源位置: %s (P%d)\r\n目标位置: %s (P%d)\r\n")
         _T("源槽位: Slot %d\r\n目标槽位: Slot %d\r\n手臂编号: Arm %d\r\n任务状态: %s\r\n")
         _T("创建时间: %s\r\n取片时间: %s\r\n放片时间: %s\r\n结束时间: %s"),
         pRobotTask->getId().c_str(),
         pSrcEq ? pSrcEq->getName().c_str() : _T("未知"),
         param.getPosition,
         pDstEq ? pDstEq->getName().c_str() : _T("未知"),
         param.putPosition,
         param.getSlotNo,
         param.putSlotNo,
         param.armNo,
         pRobotTask->getStateString(),
         format_time(pRobotTask->getCreateTime()),
         format_time(pRobotTask->getFetchoutTime()),
         format_time(pRobotTask->getStoredTime()),
         format_time(pRobotTask->getFinishTime())
      );
      SetDlgItemText(IDC_LABEL_GET_PUT, strDetail);
   }
}
@@ -76,6 +105,12 @@
      m_fontButton.CreatePointFont(110, _T("微软雅黑")); // 或 "Segoe UI"
   }
   m_btnAbortTask.SetFont(&m_fontButton);
   // 设置 LABEL 控件的字体
   if (m_fontDetail.GetSafeHandle() == nullptr) {
      m_fontDetail.CreatePointFont(100, _T("微软雅黑"));
   }
   GetDlgItem(IDC_LABEL_GET_PUT)->SetFont(&m_fontDetail);
   return TRUE;  // return TRUE unless you set the focus to a control
              // 异常: OCX 属性页应返回 FALSE
@@ -99,7 +134,11 @@
   // TODO: 在此处添加消息处理程序代码
   if (m_fontButton.GetSafeHandle()) {
      ::DeleteObject(m_fontButton.Detach());
      m_fontButton.DeleteObject();
   }
   if (m_fontDetail.GetSafeHandle()) {
      m_fontDetail.DeleteObject();
   }
}
@@ -131,9 +170,14 @@
      (rcClient.Height() - rcItem.Height()) / 2, rcItem.Width(), rcItem.Height());
   pItem = GetDlgItem(IDC_LABEL_GET_PUT);
   pItem->GetClientRect(&rcItem);
   pItem->MoveWindow(12,
      12, rcItem.Width(), rcItem.Height());
   if (pItem && pItem->m_hWnd) {
      const int nLabelX = 12;
      const int nLabelY = 12;
      const int nLabelWidth = rcClient.Width() - 24;
      const int nLabelHeight = rcClient.Height() - 24;
      pItem->MoveWindow(nLabelX, nLabelY, nLabelWidth, nLabelHeight);
   }
   // 设置“停止任务”按钮位置(右下角)
   if (m_btnAbortTask.m_hWnd != nullptr) {
@@ -150,8 +194,10 @@
void CRobotTaskDlg::OnBnClickedAbortTask()
{
   if (m_pRobotTask) {
      m_pRobotTask->abort();
      AfxMessageBox(_T("任务已停止。"));
   int ret = AfxMessageBox(_T("确认要终止当前搬送任务吗?除非发生了异常,否则请不要手动终止任务!"), MB_OKCANCEL | MB_ICONEXCLAMATION);
   if (ret != IDOK) {
      return;
   }
   theApp.m_model.getMaster().abortCurrentTask();
}