chenluhua1980
2026-01-13 155cb7fe0dcb564729c6aecdb65815f3f0ed24e2
SourceCode/Bond/Servo/Model.cpp
@@ -10,6 +10,7 @@
#include "RecipeManager.h"
#include "GlassLogDb.h"
#include "CParam.h"
#include "CJobDataS.h"
#include <algorithm>
#include <iomanip>
#include <sstream>
@@ -167,18 +168,6 @@
         setControlState(ControlState::OnlineRemote);
      }
   };
   listener.onEQConstantRequest = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void {
      // 在此填充常量值,目前仅是加1后返回
      for (auto& item : eqcs) {
         sprintf_s(item.szValue, EQCONSTANT_VALUE_MAX, "Test%d", item.id + 1);
      }
   };
   listener.onEQConstantSend = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void {
      // 在此保存和设置机器常量值
      for (auto& item : eqcs) {
         LOGI("onEQConstantRequest: %d, %s", item.id, item.szValue);
      }
   };
   listener.onDatetimeSync = [&](void* pFrom, SYSTEMTIME& time) -> void {
      LOGI("onDatetimeSync: %d%02d%02d%02d%02d%02d", time.wYear,
         time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
@@ -310,6 +299,10 @@
   CString strVarialbleFile;
   strVarialbleFile.Format(_T("%s\\VariableList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir);
   m_hsmsPassive.loadVarialbles((LPTSTR)(LPCTSTR)strVarialbleFile);
   strVarialbleFile.Format(_T("%s\\DataVariableList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir);
   m_hsmsPassive.loadDataVarialbles((LPTSTR)(LPCTSTR)strVarialbleFile);
   strVarialbleFile.Format(_T("%s\\EquipmentConstantList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir);
   m_hsmsPassive.loadEquipmentConstants((LPTSTR)(LPCTSTR)strVarialbleFile);
   setControlState(m_currentControlState);
   refreshDerivedSVs();
   m_hsmsPassive.init(this, "APP", 7000);
@@ -510,6 +503,42 @@
      notifyPtrAndInt(RX_CODE_EQ_ROBOT_TASK, pTask, nullptr, code);
   };
   masterListener.onJobReceived = [&](void* pMaster, SERVO::CEquipment* pEquipment, int port, SERVO::CJobDataS* pJobDataS) {
      (void)pMaster;
      (void)port;
      if (pEquipment == nullptr || pJobDataS == nullptr) return;
      const int eqId = pEquipment->getID();
      const int recipeId = pJobDataS->getMasterRecipe();
      std::string recipe = RecipeManager::getInstance().getPPIDById(recipeId);
      if (recipe.empty()) {
         recipe = std::to_string(recipeId);
      }
      const std::string prev = pEquipment->getCurrentRecipe();
      if (recipe.empty() || recipe == prev) {
         pEquipment->setCurrentRecipe(recipe);
         return;
      }
      pEquipment->setCurrentRecipe(recipe);
      m_hsmsPassive.withVariableLock([&] {
         m_hsmsPassive.setVariableValue("Clock", CToolUnits::getCurrentTimeString().c_str());
         m_hsmsPassive.setVariableValue("EQPPExecName", recipe.c_str());
         m_hsmsPassive.setVariableValue("SubEqpName", pEquipment->getName().c_str());
         const char* recipeVid = nullptr;
         switch (eqId) {
         case EQ_ID_Bonder1: recipeVid = "Bonder1CurrentRecipe"; break;
         case EQ_ID_Bonder2: recipeVid = "Bonder2CurrentRecipe"; break;
         case EQ_ID_VACUUMBAKE: recipeVid = "VacuumBakeCurrentRecipe"; break;
         case EQ_ID_BAKE_COOLING: recipeVid = "BakeCoolingCurrentRecipe"; break;
         case EQ_ID_MEASUREMENT: recipeVid = "MeasurementCurrentRecipe"; break;
         case EQ_ID_EFEM: recipeVid = "EFEMCurrentRecipe"; break;
         default: break;
         }
         if (recipeVid != nullptr) {
            m_hsmsPassive.setVariableValue(recipeVid, recipe.c_str());
         }
         m_hsmsPassive.requestEventReportSend("RecipeChanged");
      });
   };
   masterListener.onLoadPortStatusChanged = [&] (void* pMaster, SERVO::CEquipment* pEquipment, short status, __int64 data) {
      LOGE("<CModel>onLoadPortStatusChanged. status = %d", status);
      static std::map<int, short> s_prevPortStatus;