mrDarker
2025-06-12 6d71f1d8264b929ca71bf133246b894ed955c079
SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp
@@ -14,7 +14,7 @@
#define LOG_COLOR_TIME     RGB(0, 0, 255)       // 时间戳:蓝色
// 快捷命令映射表
std::map<CString, QuickCmdFieldMask> g_quickCmdMap = {
std::map<CString, QuickCmdFieldMask> g_mapQuickCmd = {
   {_T("SendHome"),             {false, false, false, false, false}},
   {_T("SendTransfer"),         {true,  true,  true,  true,  true }},
   {_T("SendMoveToGet"),        {true,  true,  true,  false, false}},
@@ -76,14 +76,14 @@
   // TODO:  在此添加额外的初始化
   // 初始化命令组合列表
   for (const auto& pair : g_quickCmdMap) {
   for (const auto& pair : g_mapQuickCmd) {
      m_comboCmdType.AddString(pair.first);
   }
   m_comboCmdType.SetCurSel(0);
   // 初始化命令输入控件
   if (!g_quickCmdMap.empty()) {
      UpdateCommandInputUI(g_quickCmdMap.begin()->first);
   if (!g_mapQuickCmd.empty()) {
      UpdateCommandInputUI(g_mapQuickCmd.begin()->first);
   }
   // 初始化 Arm No(1:Arm#1,2:Arm#2)
@@ -93,19 +93,25 @@
   // 示例设备名称列表
   CStringList eqNameList;
   eqNameList.AddTail(_T("PORT 1"));            // 1 1 UNIT
   eqNameList.AddTail(_T("PORT 2"));            // 2 1 UNIT
   eqNameList.AddTail(_T("PORT 3"));            // 3 1 UNIT
   eqNameList.AddTail(_T("PORT 4"));            // 4 1 UNIT
   eqNameList.AddTail(_T("RB1"));               // 5 1 UNIT
   eqNameList.AddTail(_T("RB2"));               // 6 1 UNIT
   eqNameList.AddTail(_T("ALIGN"));            // 7 1 UNIT
   eqNameList.AddTail(_T("FLIP"));               // 8 1 UNIT
   eqNameList.AddTail(_T("VAC BAKE"));            // 9 2 UNIT
   eqNameList.AddTail(_T("BONDER1"));            // 10 2 UNIT
   eqNameList.AddTail(_T("BONDER2"));            // 11 2 UNIT
   eqNameList.AddTail(_T("POST BAKE(COOLING)"));   // 12 4 UNIT
   eqNameList.AddTail(_T("MEASUREMENT"));         // 13 1 UNIT
   eqNameList.AddTail(_T("Port1"));
   eqNameList.AddTail(_T("Port2"));
   eqNameList.AddTail(_T("Port3"));
   eqNameList.AddTail(_T("Port4"));
   eqNameList.AddTail(_T("RB1"));
   eqNameList.AddTail(_T("RB2"));
   eqNameList.AddTail(_T("AL"));
   eqNameList.AddTail(_T("FLIP"));
   eqNameList.AddTail(_T("Bonder1-上产品"));
   eqNameList.AddTail(_T("Bonder1-下产品"));
   eqNameList.AddTail(_T("Bonder2-上产品"));
   eqNameList.AddTail(_T("Bonder2-下产品"));
   eqNameList.AddTail(_T("VacBakeA腔"));
   eqNameList.AddTail(_T("VacBakeB腔"));
   eqNameList.AddTail(_T("BakecCoolingA烘烤"));
   eqNameList.AddTail(_T("BakecCoolingA冷却"));
   eqNameList.AddTail(_T("BakecCoolingB烘烤"));
   eqNameList.AddTail(_T("BakecCoolingB冷却"));
   eqNameList.AddTail(_T("Measurement"));
   for (POSITION pos = eqNameList.GetHeadPosition(); pos != NULL;) {
      CString item = eqNameList.GetNext(pos);
@@ -127,64 +133,64 @@
   // 快捷命令执行映射表
   m_mapCmdExec = {
      {_T("SendHome"), [this](int seq, int, int, int, int, int) {
         return m_pEFEM->SendHome(seq);
      {_T("SendHome"), [this](int seq, int, int, int, int, int, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendHome(seq, onWritedBlock);
      }},
      {_T("SendTransfer"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot) {
         return m_pEFEM->SendTransfer(seq, armNo, getPos, putPos, getSlot, putSlot);
      {_T("SendTransfer"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendTransfer(seq, armNo, getPos, putPos, getSlot, putSlot, onWritedBlock);
      }},
      {_T("SendMoveToGet"), [this](int seq, int armNo, int pos, int, int slot, int) {
         return m_pEFEM->SendMoveToGet(seq, armNo, pos, slot);
      {_T("SendMoveToGet"), [this](int seq, int armNo, int pos, int, int slot, int, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendMoveToGet(seq, armNo, pos, slot, onWritedBlock);
      }},
      {_T("SendMoveToPut"), [this](int seq, int armNo, int, int pos, int, int slot) {
         return m_pEFEM->SendMoveToPut(seq, armNo, pos, slot);
      {_T("SendMoveToPut"), [this](int seq, int armNo, int, int pos, int, int slot, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendMoveToPut(seq, armNo, pos, slot, onWritedBlock);
      }},
      {_T("SendGet"), [this](int seq, int armNo, int pos, int, int slot, int) {
         return m_pEFEM->SendGet(seq, armNo, pos, slot);
      {_T("SendGet"), [this](int seq, int armNo, int pos, int, int slot, int, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendGet(seq, armNo, pos, slot, onWritedBlock);
      }},
      {_T("SendPut"), [this](int seq, int armNo, int, int pos, int, int slot) {
         return m_pEFEM->SendPut(seq, armNo, pos, slot);
      {_T("SendPut"), [this](int seq, int armNo, int, int pos, int, int slot, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendPut(seq, armNo, pos, slot, onWritedBlock);
      }},
      {_T("SendExchange"), [this](int seq, int armNo, int pos, int, int getSlot, int putSlot) {
         return m_pEFEM->SendExchange(seq, armNo, pos, getSlot, putSlot);
      {_T("SendExchange"), [this](int seq, int armNo, int pos, int, int getSlot, int putSlot, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendExchange(seq, armNo, pos, getSlot, putSlot, onWritedBlock);
      }},
      {_T("SendCommandClear"), [this](int seq, int, int, int, int, int) {
         return m_pEFEM->SendCommandClear(seq);
      {_T("SendCommandClear"), [this](int seq, int, int, int, int, int, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendCommandClear(seq, onWritedBlock);
      }},
      {_T("SendBatchGet"), [this](int seq, int armNo, int pos, int, int slot, int) {
         return m_pEFEM->SendBatchGet(seq, pos, slot);
      {_T("SendBatchGet"), [this](int seq, int armNo, int pos, int, int slot, int, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendBatchGet(seq, pos, slot, onWritedBlock);
      }},
      {_T("SendBatchPut"), [this](int seq, int armNo, int, int pos, int, int slot) {
         return m_pEFEM->SendBatchPut(seq, pos, slot);
      {_T("SendBatchPut"), [this](int seq, int armNo, int, int pos, int, int slot, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendBatchPut(seq, pos, slot, onWritedBlock);
      }},
      {_T("SendMoveToGetAndHome"), [this](int seq, int armNo, int pos, int, int slot, int) {
         return m_pEFEM->SendMoveToGetAndHome(seq, armNo, pos, slot);
      {_T("SendMoveToGetAndHome"), [this](int seq, int armNo, int pos, int, int slot, int, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendMoveToGetAndHome(seq, armNo, pos, slot, onWritedBlock);
      }},
      {_T("SendMoveToPutAndHome"), [this](int seq, int armNo, int, int pos, int, int slot) {
         return m_pEFEM->SendMoveToPutAndHome(seq, armNo, pos, slot);
      {_T("SendMoveToPutAndHome"), [this](int seq, int armNo, int, int pos, int, int slot, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendMoveToPutAndHome(seq, armNo, pos, slot, onWritedBlock);
      }},
      {_T("SendTransferAndHome"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot) {
         return m_pEFEM->SendTransferAndHome(seq, armNo, getPos, putPos, getSlot, putSlot);
      {_T("SendTransferAndHome"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendTransferAndHome(seq, armNo, getPos, putPos, getSlot, putSlot, onWritedBlock);
      }},
      {_T("SendGetAndPut"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot) {
         return m_pEFEM->SendGetAndPut(seq, armNo, getPos, putPos, getSlot, putSlot);
      {_T("SendGetAndPut"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendGetAndPut(seq, armNo, getPos, putPos, getSlot, putSlot, onWritedBlock);
      }},
      {_T("SendPutAndHome"), [this](int seq, int armNo, int, int pos, int, int slot) {
         return m_pEFEM->SendPutAndHome(seq, armNo, pos, slot);
      {_T("SendPutAndHome"), [this](int seq, int armNo, int, int pos, int, int slot, SERVO::ONWRITED onWritedBlock) {
         return m_pEFEM->robotSendPutAndHome(seq, armNo, pos, slot, onWritedBlock);
      }}
   };
@@ -197,8 +203,9 @@
void CRobotCmdTestDlg::UpdateCommandInputUI(const CString& cmdName)
{
   auto it = g_quickCmdMap.find(cmdName);
   if (it == g_quickCmdMap.end()) {
   auto it = g_mapQuickCmd.find(cmdName);
   if (it == g_mapQuickCmd.end()) {
      AppendLogLineRichStyled(_T("未知的命令类型"), LOG_COLOR_ERROR);
      return;
   }
@@ -274,7 +281,6 @@
   long nStart = 0;
   long nEnd = m_editLog.GetTextLength();
   CHARRANGE cr;
   FINDTEXTEX ft = { 0 };
   ft.chrg.cpMin = 0;
   ft.chrg.cpMax = nEnd;
@@ -333,7 +339,16 @@
   // 查找函数并执行
   auto it = m_mapCmdExec.find(cmdName);
   if (it != m_mapCmdExec.end() && nullptr != m_pEFEM) {
      int ret = it->second(1, armNo, getPos, getSlot, putPos, putSlot);
      int ret = it->second(1, armNo, getPos, getSlot, putPos, putSlot, [&](int code) -> int {
         if (code == WOK) {
            AppendLogLineRichStyled(_T("已收到Robot回应!"), LOG_COLOR_SUCCESS);
         }
         else {
            AppendLogLineRichStyled(_T("未收到Robot回应!"), LOG_COLOR_ERROR);
         }
         return 0;
      });
      CString log;
      if (ret == 0) {