mrDarker
2025-06-16 817d91396abc1cca6f1ef5abb1fd5fbfd3511268
SourceCode/Bond/Servo/CLoadPort.cpp
@@ -17,7 +17,7 @@
   {
      m_nIndex = 0;
      m_portType = PortType::Loading;
      m_portMode = PortMode::InService;
      m_portMode = PortMode::ReadyToLoad;
      m_cassetteType = CassetteType::G1;
      m_transferMode = TransferMode::AGVMode;
      m_bEnable = FALSE;
@@ -111,7 +111,7 @@
         // Type
         static char* pszName[] = { STEP_EQ_PORT1_TYPE, STEP_EQ_PORT2_TYPE, STEP_EQ_PORT3_TYPE, STEP_EQ_PORT4_TYPE };
         static int dev[] = { 0x6010 , 0x6020, 0x6030, 0x6040 };
         static int writeSignalDev[] = { 0xa0, 0xa1, 0xa2, 0xa3 };
         static int writeSignalDev[] = { 0x90, 0x91, 0x92, 0x93 };
         static int addr[] = { STEP_ID_PORT1_TYPE_CHANGE, STEP_ID_PORT2_TYPE_CHANGE, STEP_ID_PORT3_TYPE_CHANGE, STEP_ID_PORT4_TYPE_CHANGE };
         CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
@@ -132,7 +132,7 @@
         // Mode
         static char* pszName[] = { STEP_EQ_PORT1_MODE, STEP_EQ_PORT2_MODE, STEP_EQ_PORT3_MODE, STEP_EQ_PORT4_MODE };
         static int dev[] = { 0x6011, 0x6021, 0x6031, 0x6041 };
         static int writeSignalDev[] = { 0xa8, 0xa9, 0xaa, 0xab };
         static int writeSignalDev[] = { 0x98, 0x99, 0x9a, 0x9b };
         static int addr[] = { STEP_ID_PORT1_MODE_CHANGE, STEP_ID_PORT2_MODE_CHANGE, STEP_ID_PORT3_MODE_CHANGE, STEP_ID_PORT4_MODE_CHANGE };
         CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
@@ -153,7 +153,7 @@
         // Cassette type
         static char* pszName[] = { STEP_EQ_PORT1_CASSETTE_TYPE, STEP_EQ_PORT2_CASSETTE_TYPE, STEP_EQ_PORT3_CASSETTE_TYPE, STEP_EQ_PORT4_CASSETTE_TYPE };
         static int dev[] = { 0x6012, 0x6022, 0x6032, 0x6042 };
         static int writeSignalDev[] = { 0xb0, 0xb1, 0xb2, 0xb3 };
         static int writeSignalDev[] = { 0xa0, 0xa1, 0xa2, 0xa3 };
         static int addr[] = { STEP_ID_PORT1_CASSETTE_TYPE_CHANGE, STEP_ID_PORT2_CASSETTE_TYPE_CHANGE, STEP_ID_PORT3_CASSETTE_TYPE_CHANGE, STEP_ID_PORT4_CASSETTE_TYPE_CHANGE };
         CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
@@ -174,7 +174,7 @@
         // Transfer type
         static char* pszName[] = { STEP_EQ_PORT1_TRANSFER_MODE, STEP_EQ_PORT2_TRANSFER_MODE, STEP_EQ_PORT3_TRANSFER_MODE, STEP_EQ_PORT4_TRANSFER_MODE };
         static int dev[] = { 0x6014, 0x6024, 0x6034, 0x6044 };
         static int writeSignalDev[] = { 0xb8, 0xb9, 0xba, 0xbb };
         static int writeSignalDev[] = { 0xa8, 0xa9, 0xaa, 0xab };
         static int addr[] = { STEP_ID_PORT1_TRANSFER_MODE_CHANGE, STEP_ID_PORT2_TRANSFER_MODE_CHANGE, STEP_ID_PORT3_TRANSFER_MODE_CHANGE, STEP_ID_PORT4_TRANSFER_MODE_CHANGE };
         CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
@@ -195,7 +195,7 @@
         // Port enable
         static char* pszName[] = { STEP_EQ_PORT1_ENABLE, STEP_EQ_PORT2_ENABLE, STEP_EQ_PORT3_ENABLE, STEP_EQ_PORT4_ENABLE };
         static int dev[] = { 0x6015, 0x6025, 0x6035, 0x6045 };
         static int writeSignalDev[] = { 0xc0, 0xc1, 0xc2, 0xc3 };
         static int writeSignalDev[] = { 0xb0, 0xb1, 0xb2, 0xb3 };
         static int addr[] = { STEP_ID_PORT1_ENABLE_MODE_CHANGE, STEP_ID_PORT2_ENABLE_MODE_CHANGE, STEP_ID_PORT3_ENABLE_MODE_CHANGE, STEP_ID_PORT4_ENABLE_MODE_CHANGE };
         CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
@@ -376,6 +376,28 @@
   void CLoadPort::serialize(CArchive& ar)
   {
      CEquipment::serialize(ar);
      if (ar.IsStoring()) {
         ar << m_nIndex;
         ar << (int)m_portType;
         ar << (int)m_portMode;
         ar << (int)m_cassetteType;
         ar << (int)m_transferMode;
         ar << m_bEnable;
         ar << m_bAutoChangeEnable;
         m_portStatusReport.serialize(ar);
      }
      else {
         int temp;
         ar >> m_nIndex;
         ar >> temp; m_portType = (PortType)temp;
         ar >> temp; m_portMode = (PortMode)temp;
         ar >> temp; m_cassetteType = (CassetteType)temp;
         ar >> temp; m_transferMode = (TransferMode)temp;
         ar >> m_bEnable;
         ar >> m_bAutoChangeEnable;
         m_portStatusReport.serialize(ar);
      }
   }
   void CLoadPort::getAttributeVector(CAttributeVector& attrubutes)
@@ -891,21 +913,22 @@
      LOGI("<CLoadPort-%d>准备设置Port type<%d>", m_nIndex, (int)type);
      short value = (short)type;
      if (onWritedBlock != nullptr) {
         pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
      }
      else {
         pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
            if (code == WOK) {
               LOGI("<CLoadPort-%d>设置Port type成功.", m_nIndex);
            }
            else {
               LOGI("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code);
            }
      pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
         // test
         code = WOK;
         if (code == WOK) {
            m_portType = type;
            LOGI("<CLoadPort-%d>设置Port type成功.", m_nIndex);
         }
         else {
            LOGI("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
         }
            return 0;
            });
      }
         return 0;
         });
      return 0;
   }
@@ -920,21 +943,21 @@
      LOGI("<CLoadPort-%d>准备%s Port", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
      short value = bEnable ? 1 : 2;
      if (onWritedBlock != nullptr) {
         pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
      }
      else {
         pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
            if (code == WOK) {
               LOGI("<CLoadPort-%d>%s Port成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
            }
            else {
               LOGI("<CLoadPort-%d>%s  Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
            }
            return 0;
            });
      }
      pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
         // test
         code = WOK;
         if (code == WOK) {
            m_bEnable = bEnable;
            LOGI("<CLoadPort-%d>%s Port成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
         }
         else {
            LOGI("<CLoadPort-%d>%s  Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
         }
         return 0;
         });
      return 0;
   }
@@ -949,21 +972,21 @@
      LOGI("<CLoadPort-%d>准备设置Port mode<%d>", m_nIndex, (int)mode);
      short value = (short)mode;
      if (onWritedBlock != nullptr) {
         pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
      }
      else {
         pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
            if (code == WOK) {
               LOGI("<CLoadPort-%d>设置Port mode成功.", m_nIndex);
            }
            else {
               LOGI("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code);
            }
            return 0;
            });
      }
      pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
         // test
         code = WOK;
         if (code == WOK) {
            m_portMode = mode;
            LOGI("<CLoadPort-%d>设置Port mode成功.", m_nIndex);
         }
         else {
            LOGI("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
         }
         return 0;
         });
      return 0;
   }
@@ -978,21 +1001,21 @@
      LOGI("<CLoadPort-%d>准备设置Cassette Type<%d>", m_nIndex, (int)type);
      short value = (short)type;
      if (onWritedBlock != nullptr) {
         pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
      }
      else {
         pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
            if (code == WOK) {
               LOGI("<CLoadPort-%d>设置Cassette Type成功.", m_nIndex);
            }
            else {
               LOGI("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code);
            }
            return 0;
            });
      }
      pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
         // test
         code = WOK;
         if (code == WOK) {
            m_cassetteType = type;
            LOGI("<CLoadPort-%d>设置Cassette Type成功.", m_nIndex);
         }
         else {
            LOGI("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
         }
         return 0;
         });
      return 0;
   }
@@ -1007,21 +1030,21 @@
      LOGI("<CLoadPort-%d>准备设置Transfer mode<%d>", m_nIndex, (int)mode);
      short value = (short)mode;
      if (onWritedBlock != nullptr) {
         pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
      }
      else {
         pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
            if (code == WOK) {
               LOGI("<CLoadPort-%d>设置Transfer mode成功.", m_nIndex + 1);
            }
            else {
               LOGI("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code);
            }
            return 0;
            });
      }
      pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
         // test
         code = WOK;
         if (code == WOK) {
            m_transferMode = mode;
            LOGI("<CLoadPort-%d>设置Transfer mode成功.", m_nIndex + 1);
         }
         else {
            LOGI("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
         }
         return 0;
         });
      return 0;
   }
@@ -1036,21 +1059,21 @@
      LOGI("<CLoadPort-%d>准备%s Auto Change", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
      short value = bEnable ? 1 : 2;
      if (onWritedBlock != nullptr) {
         pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
      }
      else {
         pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
            if (code == WOK) {
               LOGI("<CLoadPort-%d>%s Auto Change成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
            }
            else {
               LOGI("<CLoadPort-%d>%s  Auto Change失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
            }
            return 0;
            });
      }
      pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
         // test
         code = WOK;
         if (code == WOK) {
            m_bAutoChangeEnable = bEnable;
            LOGI("<CLoadPort-%d>%s Auto Change成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
         }
         else {
            LOGI("<CLoadPort-%d>%s  Auto Change失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
         }
         return 0;
         });
      return 0;
   }
@@ -1097,13 +1120,12 @@
         }
         CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
         pGlass->addPath(m_nID);
         pGlass->processEnd(m_nID);
         pGlass->addPath(m_nID, 0);
         pGlass->processEnd(m_nID, 0);
         pGlass->setID(szBuffer);
         pGlass->setJobDataB(&jb);
         pGlass->setType(type);
         pGlass->setJobDataS(&js);
         pGlass->addRef();
         m_slot[i].setContext(pGlass);
      }