LAPTOP-SNT8I5JK\Boounion
2025-07-08 f0f942498d6b0c9a92ee2d7b9ea62a592b8f4cce
SourceCode/Bond/Servo/Model.cpp
@@ -121,13 +121,13 @@
      notify(RX_CODE_MASTER_STATE_CHANGED);
   };
   masterListener.onEqAlive = [&](void* pMaster, SERVO::CEquipment* pEquipment, BOOL bAlive) -> void {
      LOGI("<CModel>Equipment onAlive:%s(%s).\n", pEquipment->getName().c_str(),
      LOGI("<CModel>Equipment onAlive:%s(%s).", pEquipment->getName().c_str(),
         bAlive ? _T("ON") : _T("OFF"));
      notifyPtr(RX_CODE_EQ_ALIVE, pEquipment);
   };
   masterListener.onEqCimStateChanged = [&](void* pMaster, SERVO::CEquipment* pEquipment, BOOL bOn) -> void {
      LOGI("<CModel>Equipment Cim State:%s(%s).\n", pEquipment->getName().c_str(),
      LOGI("<CModel>Equipment Cim State:%s(%s).", pEquipment->getName().c_str(),
         bOn ? _T("ON") : _T("OFF"));
      notifyPtr(RX_CODE_EQ_ALIVE, pEquipment);
@@ -190,8 +190,16 @@
      }
      // 任务描述与 ID 用于日志
      SERVO::CGlass* pGlass = (SERVO::CGlass*)pTask->getContext();
      const std::string& strDesc = pTask->getDescription();
      const std::string& strClassID = pTask->getId();
      std::string strClassID;
      if (pGlass != nullptr) {
         strClassID = pGlass->getID();
         if (pGlass->getBuddy() != nullptr) {
            strClassID += "/";
            strClassID += pGlass->getBuddy()->getID();
         }
      }
      // 日志输出与状态处理
      switch (code) {
@@ -245,23 +253,26 @@
      // 状态映射
      static const char* STATUS_STR[] = {
         "Unknown", "Ready", "Running", "Picking", "Placing", "Restoring", "Error", "Abort", "Completed"
         "Ready", "Running", "Picking", "Picked", "Placing", "Restoring", "Error", "Abort", "Restored", "Completed"
      };
      auto state = pTask->getState();
      int index = static_cast<int>(state);
      if (index > 0 && index < static_cast<int>(std::size(STATUS_STR))) {
      if (index >= 0 && index < static_cast<int>(std::size(STATUS_STR))) {
         data.strStatus = STATUS_STR[index];
      }
      else {
         data.strStatus = STATUS_STR[0];
         data.strStatus = "Unknown";
      }
      // 写入数据库
      int nRecordId = 0;
      TransferManager::getInstance().addTransferRecord(data, nRecordId);
      if (code == ROBOT_EVENT_FINISH || code == ROBOT_EVENT_ERROR
         || code == ROBOT_EVENT_ABORT || code == ROBOT_EVENT_RESTORE) {
         int nRecordId = 0;
         TransferManager::getInstance().addTransferRecord(data, nRecordId);
         LOGI("<CModel>onRobotTaskEvent: 任务记录已保存,RecordID=%d", nRecordId);
      }
      notifyPtrAndInt(RX_CODE_EQ_ROBOT_TASK, pTask, nullptr, code);
      LOGI("<CModel>onRobotTaskEvent: 任务记录已保存,RecordID=%d", nRecordId);
   };
   m_master.setListener(masterListener);