SourceCode/Bond/Servo/CBonder.cpp
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "CBonder.h"
@@ -29,10 +29,10 @@
      CEquipment::term();
   }
   // 必须要实现的虚函数,在此初始化Pin列表
   // 必须要实现的虚函数,在此初始化Pin列表
   void CBonder::initPins()
   {
      // 加入Pin初始化代码
      // 加入Pin初始化代码
      LOGI("<CBonder>initPins");
      addPin(SERVO::PinType::INPUT, _T("In1"));
      addPin(SERVO::PinType::INPUT, _T("In2"));
@@ -137,8 +137,8 @@
      {
         // CIM Message Confirm
         // 要将int32的值拆分为两个short, 分别为msg id和panel id
         // 65538, 2Ϊmsg id, 1Ϊpanel id
         // 要将int32的值拆分为两个short, 分别为msg id和panel id
         // 65538, 2为msg id, 1为panel id
         CEqReadIntStep* pStep = new CEqReadIntStep(__INT32, m_nIndex == 0 ? 0x9d80 : 0xdd80);
         pStep->setName(STEP_EQ_CIM_MESSAGE_CONFIRM);
         pStep->setWriteSignalDev(m_nIndex == 0 ? 0x349 : 0x649);
@@ -156,7 +156,6 @@
            delete pStep;
         }
      }
      {
         CEqDateTimeSetCmdStep* pStep = new CEqDateTimeSetCmdStep();
@@ -179,7 +178,7 @@
      }
      {
         // 请求主配方列表的step
         // 请求主配方列表的step
         CEqWriteStep* pStep = new CEqWriteStep();
         pStep->setName(STEP_EQ_MASTER_RECIPE_LIST_REQ);
         pStep->setWriteSignalDev(m_nIndex == 0 ? 0x366 : 0x666);
@@ -196,7 +195,7 @@
               CEqReadStep* pTmpStep = (CEqReadStep*)pFrom;
               short ret = MRLRC_OK;
               if (code == ROK && pszData != nullptr && size > 0) {
                  // 此处解释配方数据
                  // 此处解释配方数据
                  ret = decodeRecipeListReport(pszData, size);
               }
               pTmpStep->setReturnCode(ret);
@@ -211,7 +210,7 @@
      }
      {
         // 请求配方参数
         // 请求配方参数
         CEqWriteStep* pStep = new CEqWriteStep();
         pStep->setName(STEP_EQ_RECIPE_PARAMETER_REQ);
         pStep->setWriteSignalDev(m_nIndex == 0 ? 0x367 : 0x667);
@@ -228,7 +227,7 @@
               CEqReadStep* pTmpStep = (CEqReadStep*)pFrom;
               short ret = MRLRC_OK;
               if (code == ROK && pszData != nullptr && size > 0) {
                  // 此处解释配方数据
                  // 此处解释配方数据
                  ret = decodeRecipeParameterReport(pszData, size);
               }
               pTmpStep->setReturnCode(ret);
@@ -242,7 +241,7 @@
         }
      }
      // 使用CEqReadStep替换CEqJobEventStep
      // 使用CEqReadStep替换CEqJobEventStep
      {
         // Received Job Report Upstream #1~9
         char szBuffer[256];
@@ -266,6 +265,7 @@
            }
         }
      }
      {
         // Sent Out Job Report Downstream #1~9
         char szBuffer[256];
@@ -350,9 +350,12 @@
         }
      }
      // FAC Data Report
      addFacDataReportStep(m_nIndex == 0 ? 0xA589 : 0xE589,
         m_nIndex == 0 ? 0x34d : 0x64d, 1);
      /*
      {
         // FAC Data Report
         CEqReadStep* pStep = new CEqReadStep(m_nIndex == 0 ? 0xA60E : 0xE60E, 108 * 2,
         CEqReadStep* pStep = new CEqReadStep(m_nIndex == 0 ? 0xA589 : 0xE589, 133 * 2,
            [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
               if (code == ROK && pszData != nullptr && size > 0) {
                  decodeFacDataReport((CStep*)pFrom, pszData, size);
@@ -366,6 +369,7 @@
            delete pStep;
         }
      }
      */
      // process start/end report
      {
@@ -400,7 +404,7 @@
      }
   }
   // 必须要实现的虚函数,在此初始化Slot信息
   // 必须要实现的虚函数,在此初始化Slot信息
   void CBonder::initSlots()
   {
      m_slot[0].enable();
@@ -483,35 +487,35 @@
      return 0;
   }
   int CBonder::onProcessStateChanged(PROCESS_STATE state)
   int CBonder::onProcessStateChanged(int slotNo, PROCESS_STATE prevState, PROCESS_STATE state)
   {
      CEquipment::onProcessStateChanged(state);
      CEquipment::onProcessStateChanged(slotNo, prevState, state);
      if (state == PROCESS_STATE::Complete) {
         // 检查数据,当前两片玻璃,一片为G1, 一片为G2, 且pProcessData中的id能匹配G1或G2
         // 检查数据,当前两片玻璃,一片为G1, 一片为G2, 且pProcessData中的id能匹配G1或G2
         Lock();
         CGlass* pGlass2 = getGlassFromSlot(1);
         CGlass* pGlass1 = getGlassFromSlot(2);
         if (pGlass1 == nullptr || pGlass2 == nullptr) {
            LOGE("<CBonder-%s>onProcessData,错误!不满足两片玻璃且分别为G1与G2的条件,请检查数据是否正确!", m_strName.c_str());
            LOGE("<CBonder-%s>onProcessData,错误!不满足两片玻璃且分别为G1与G2的条件,请检查数据是否正确!", m_strName.c_str());
            Unlock();
            return -1;
         }
         if (pGlass1->getBuddy() != nullptr) {
            LOGE("<CBonder-%s>onProcessData,错误!玻璃较早前已被绑定,请检查数据是否正确!", m_strName.c_str());
            LOGE("<CBonder-%s>onProcessData,错误!玻璃较早前已被绑定,请检查数据是否正确!", m_strName.c_str());
            Unlock();
            return -1;
         }
         if (pGlass1->getType() != MaterialsType::G1 || pGlass2->getType() != MaterialsType::G2) {
            LOGE("<CBonder-%s>onProcessData,错误!两片玻璃未匹配,必须分别为G1和G2类型,请检查数据是否正确!", m_strName.c_str());
            LOGE("<CBonder-%s>onProcessData,错误!两片玻璃未匹配,必须分别为G1和G2类型,请检查数据是否正确!", m_strName.c_str());
            Unlock();
            return -1;
         }
         pGlass1->setBuddy(pGlass2);
         getSlot(0)->setContext(nullptr);
         LOGE("<CBonder-%s>onProcessStateChanged,%s和%s已贴合!", m_strName.c_str(),
         LOGE("<CBonder-%s>onProcessStateChanged,%s和%s已贴合!", m_strName.c_str(),
            pGlass1->getID().c_str(), pGlass2->getID().c_str());
         Unlock();
      }
@@ -531,115 +535,245 @@
      int i = 0, v;
      // 1.校正对位延时
      // 1.校正对位延时
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("校正对位延时", "", this->getName().c_str(), v * 0.01f));
      params.push_back(CParam("校正对位延时", "", this->getName().c_str(), v * 0.01f));
      i += 2;
      // 2.保压时间
      // 2.保压时间
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("保压时间", "", this->getName().c_str(), v * 0.01f));
      params.push_back(CParam("保压时间", "", this->getName().c_str(), v * 0.01f));
      i += 2;
      // 3.腔体破真空延时
      // 3.腔体破真空延时
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("腔体破真空延时", "", this->getName().c_str(), v * 0.01f));
      params.push_back(CParam("腔体破真空延时", "", this->getName().c_str(), v * 0.01f));
      i += 2;
      // 4.腔体分子泵启动延时
      // 4.腔体分子泵启动延时
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("腔体分子泵启动延时", "", this->getName().c_str(), v * 0.1f));
      params.push_back(CParam("腔体分子泵启动延时", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 5.腔体贴附抽真空延时
      // 5.腔体贴附抽真空延时
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("腔体贴附抽真空延时", "", this->getName().c_str(), v * 0.1f));
      params.push_back(CParam("腔体贴附抽真空延时", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 6.加热等待延时
      // 6.加热等待延时
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("加热等待延时", "", this->getName().c_str(), v * 0.1f));
      params.push_back(CParam("加热等待延时", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 7.气囊压力设定
      // 7.气囊压力设定
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("气囊压力设定", "", this->getName().c_str(), v * 0.001f));
      params.push_back(CParam("气囊压力设定", "", this->getName().c_str(), v * 0.001f));
      i += 4;
      // 8.气囊加压速率
      // 8.气囊加压速率
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("气囊加压速率", "", this->getName().c_str(), v * 0.001f));
      params.push_back(CParam("气囊加压速率", "", this->getName().c_str(), v * 0.001f));
      i += 4;
      // 9.气囊泄压速率
      // 9.气囊泄压速率
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("气囊泄压速率", "", this->getName().c_str(), v * 0.001f));
      params.push_back(CParam("气囊泄压速率", "", this->getName().c_str(), v * 0.001f));
      i += 4;
      // 10.贴附压力上限
      // 10.贴附压力上限
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("贴附压力上限", "", this->getName().c_str(), v * 0.1f));
      params.push_back(CParam("贴附压力上限", "", this->getName().c_str(), v * 0.1f));
      i += 4;
      // 11.Z轴转矩速度设定
      // 11.Z轴转矩速度设定
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("上腔Z轴转矩速度设定", "", this->getName().c_str(), v * 0.001f));
      params.push_back(CParam("上腔Z轴转矩速度设定", "", this->getName().c_str(), v * 0.001f));
      i += 4;
      // 12.上腔温度设定
      // 12.上腔温度设定
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("上腔温度设定", "", this->getName().c_str(), v * 0.1f));
      params.push_back(CParam("上腔温度设定", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 13.下腔温度设定
      // 13.下腔温度设定
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("下腔温度设定", "", this->getName().c_str(), v * 0.1f));
      params.push_back(CParam("下腔温度设定", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 14.上腔Z轴预贴合位速度
      // 14.上腔Z轴预贴合位速度
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("上腔Z轴预贴合位速度", "", this->getName().c_str(), v * 0.001f));
      params.push_back(CParam("上腔Z轴预贴合位速度", "", this->getName().c_str(), v * 0.001f));
      i += 4;
      // 15.上腔Z轴贴附位速度
      // 15.上腔Z轴贴附位速度
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("上腔Z轴贴附位速度", "", this->getName().c_str(), v * 0.001f));
      params.push_back(CParam("上腔Z轴贴附位速度", "", this->getName().c_str(), v * 0.001f));
      i += 4;
      // 16.上腔Z上腔加热位间距
      // 16.上腔Z上腔加热位间距
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("上腔Z上腔加热位间距", "", this->getName().c_str(), v * 0.001f));
      params.push_back(CParam("上腔Z上腔加热位间距", "", this->getName().c_str(), v * 0.001f));
      i += 4;
      // 17.上腔贴附位压入量
      // 17.上腔贴附位压入量
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("上腔贴附位压入量", "", this->getName().c_str(), v * 0.001f));
      params.push_back(CParam("上腔贴附位压入量", "", this->getName().c_str(), v * 0.001f));
      i += 4;
      // 18.上腔Z轴破真空距离
      // 18.上腔Z轴破真空距离
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("上腔Z轴破真空距离", "", this->getName().c_str(), v * 0.001f));
      params.push_back(CParam("上腔Z轴破真空距离", "", this->getName().c_str(), v * 0.001f));
      i += 4;
      // 19.下顶Pin破真空距离
      // 19.下顶Pin破真空距离
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("下顶Pin破真空距离", "", this->getName().c_str(), v * 0.001f));
      params.push_back(CParam("下顶Pin破真空距离", "", this->getName().c_str(), v * 0.001f));
      i += 4;
      // 20.下顶Pin加热位间距
      // 20.下顶Pin加热位间距
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("下顶Pin加热位间距", "", this->getName().c_str(), v * 0.001f));
      params.push_back(CParam("下顶Pin加热位间距", "", this->getName().c_str(), v * 0.001f));
      i += 4;
      // 21.腔体真空泵真空规设定值
      params.push_back(CParam("腔体真空泵真空规设定值", "", this->getName().c_str(), (double)toFloat(&pszData[i])));
      // 21.腔体真空泵真空规设定值
      params.push_back(CParam("腔体真空泵真空规设定值", "", this->getName().c_str(), (double)toFloat(&pszData[i])));
      i += 4;
      // 22.腔体分子泵到达设定值
      params.push_back(CParam("腔体分子泵到达设定值", "", this->getName().c_str(), (double)toFloat(&pszData[i])));
      // 22.腔体分子泵到达设定值
      params.push_back(CParam("腔体分子泵到达设定值", "", this->getName().c_str(), (double)toFloat(&pszData[i])));
      i += 4;
      return (int)params.size();
   }
   int CBonder::parsingProcessData(const char* pszData, size_t size, std::vector<CParam>& params)
   {
      return parsingParams(pszData, size, params);
   }
   int CBonder::parsingSVData(const char* pszData, size_t size, std::vector<CParam>& params)
   {
      /*
      1   工艺运行步骤   1Word   123456
         2   气囊压力当前   2Word   12345.6
         3   上腔压力合计   1Word   1234.56
         4   管道真空规值   FLOAT   123.456
         5   腔体真空规值   FLOAT   123.456
         6   上腔温度1   1Word   12345.6
         7   上腔温度2   1Word   12345.6
         8   上腔温度3   1Word   12345.6
         9   上腔温度4   1Word   12345.6
         10   上腔温度5   1Word   12345.6
         11   上腔温度6   1Word   12345.6
         12   下腔温度1   1Word   12345.6
         13   下腔温度2   1Word   12345.6
         14   下腔温度3   1Word   12345.6
         15   下腔温度4   1Word   12345.6
         16   下腔温度5   1Word   12345.6
         17   下腔温度6   1Word   12345.6
         18   压合剩余时间   1Word   1234.56
*/
      ASSERT(pszData);
      if (size < 125) return 0;
      int i = 0, v;
      // 1.工艺运行步骤
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("工艺运行步骤", "", this->getName().c_str(), v));
      i += 2;
      // 2.气囊压力当前
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
      params.push_back(CParam("气囊压力当前", "", this->getName().c_str(), v * 0.1f));
      i += 4;
      // 3.上腔压力合计
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("上腔压力合计", "", this->getName().c_str(), ((short)v) * 0.01f));
      i += 2;
      // 4.管道真空规值
      params.push_back(CParam("管道真空规值", "", this->getName().c_str(), (double)toFloat(&pszData[i])));
      i += 4;
      // 5.腔体真空规值
      params.push_back(CParam("腔体真空规值", "", this->getName().c_str(), (double)toFloat(&pszData[i])));
      i += 4;
      // 6.上腔温度1
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("上腔温度1", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 7.上腔温度2
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("上腔温度2", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 8.上腔温度3
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("上腔温度3", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 9.上腔温度4
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("上腔温度4", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 10.上腔温度5
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("上腔温度5", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 11.上腔温度6
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("上腔温度6", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 12.下腔温度1
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("下腔温度1", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 13.下腔温度2
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("下腔温度2", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 14.下腔温度3
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("下腔温度3", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 15.下腔温度4
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("下腔温度4", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 16.下腔温度5
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("下腔温度5", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 17.下腔温度6
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("下腔温度6", "", this->getName().c_str(), v * 0.1f));
      i += 2;
      // 18.加热剩余时间
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("加热剩余时间", "", this->getName().c_str(), v * 0.01f));
      i += 2;
      // 19.压合剩余时间
      v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
      params.push_back(CParam("压合剩余时间", "", this->getName().c_str(), v * 0.01f));
      i += 2;
      return (int)params.size();
   }
}