LAPTOP-SNT8I5JK\Boounion
2025-05-13 4d9ee1abb3290f468fe30e048be211bb7fa8cf84
SourceCode/Bond/Servo/CPageGraph2.cpp
@@ -5,6 +5,11 @@
#include "Servo.h"
#include "CPageGraph2.h"
#include "afxdialogex.h"
#include "CHMPropertyDlg.h"
#include "CEquipmentPage1.h"
#include "CEquipmentPage2.h"
#include "CPagePortProperty.h"
#include "CPageCassetteCtrlCmd.h"
// CPageGraph2 对话框
@@ -17,6 +22,7 @@
   m_pEqsGraphWnd = nullptr;
   m_crBkgnd = PAGE_GRPAH2_BACKGROUND_COLOR;
   m_hbrBkgnd = nullptr;
   m_pObserver = nullptr;
}
CPageGraph2::~CPageGraph2()
@@ -40,9 +46,44 @@
// CPageGraph2 消息处理程序
void CPageGraph2::InitRxWindows()
{
   /* code */
   // 订阅数据
   IRxWindows* pRxWindows = RX_GetRxWindows();
   pRxWindows->enableLog(5);
   if (m_pObserver == NULL) {
      m_pObserver = pRxWindows->allocObserver([&](IAny* pAny) -> void {
         // onNext
         pAny->addRef();
         int code = pAny->getCode();
         if (RX_CODE_EQ_DATA_CHANGED == code) {
            // 通知设备状态
            SERVO::CEquipment* pEquipment = nullptr;
            if (pAny->getPtrValue("ptr", (void*&)pEquipment)) {
               if (pEquipment != nullptr) {
                  m_pEqsGraphWnd->ShowItemIndicator((DWORD_PTR)pEquipment, !pEquipment->isGlassListEmpty());
               }
            }
         }
         pAny->release();
         }, [&]() -> void {
            // onComplete
         }, [&](IThrowable* pThrowable) -> void {
            // onErrorm
            pThrowable->printf();
         });
      theApp.m_model.getObservable()->observeOn(pRxWindows->mainThread())
         ->subscribe(m_pObserver);
   }
}
BOOL CPageGraph2::OnInitDialog()
{
   CDialogEx::OnInitDialog();
   InitRxWindows();
   SetTimer(1, 2000, nullptr);
@@ -80,6 +121,31 @@
   };
   listener.onDblckEqItem = [&](EQITEM* pItem) -> bool {
      ASSERT(pItem);
      SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
      CHMPropertyDlg dlg(pEquipment->getName().c_str(), 600, 680);
      if (_strcmpi(pEquipment->getClassName(), "CLoadPort") == 0) {
         CPagePortProperty* pPage1 = new CPagePortProperty();
         pPage1->setLoadPort((SERVO::CLoadPort*)pEquipment);
         pPage1->Create(IDD_PAGE_PORT_PROPERTY);
         dlg.addPage(pPage1, "属性");
      }
      CEquipmentPage2* pPage2 = new CEquipmentPage2();
      pPage2->setEquipment(pEquipment);
      pPage2->Create(IDD_PAGE_EQUIPMENT2);
      dlg.addPage(pPage2, "Glass");
      if (pEquipment->getID() == EQ_ID_LOADPORT1
         || pEquipment->getID() == EQ_ID_LOADPORT2) {
         CPageCassetteCtrlCmd* pPage = new CPageCassetteCtrlCmd();
         pPage->setEquipment(pEquipment);
         pPage->Create(IDD_PAGE_CASSETTE_CTRL_CMD);
         dlg.addPage(pPage, "Cassette control command");
      }
      dlg.DoModal();
      return true;
   };
   listener.onRclickEqItem = [&](EQITEM* pItem) -> bool {
@@ -124,14 +190,80 @@
      // 测试
      else if (nCmd == ID_EQSGRAPHITEM_TEST1) {
         SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
         pEquipment->outputGlass(0);
         if (pEquipment->getID() == EQ_ID_LOADPORT1) {
            pEquipment->outputGlass(1);
         }
         pEquipment->fetchedOutJob("P20250320A1A2");
      }
      else if (nCmd == ID_EQSGRAPHITEM_TEST2) {
         SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
         pEquipment->outputGlass(1);
         pEquipment->storedJob("P20250320A1A2");
      }
      else if (nCmd == ID_EQSGRAPHITEM_TEST3) {
         SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
         // 测试下发Cim Message
         /*
         if (pEquipment->getID() == EQ_ID_Bonder1
            || pEquipment->getID() == EQ_ID_Bonder2) {
            static int msgId = 0; msgId++;
            if (msgId % 2 == 0) {
               pEquipment->setCimMessage("Hello!", msgId, 1);
            }
            else {
               pEquipment->setCimMessage("ABC0123456789", msgId, 2);
            }
         }
         */
         // 测试清除Cim Message
         /*
         if (pEquipment->getID() == EQ_ID_Bonder1
            || pEquipment->getID() == EQ_ID_Bonder2) {
            static int msgId = 0; msgId++;
            if (msgId % 2 == 0) {
               pEquipment->clearCimMessage(msgId, 1);
            }
            else {
               pEquipment->clearCimMessage(msgId, 2);
            }
         }
         */
         // 测试设置时间
         /*
         if (pEquipment->getID() == EQ_ID_Bonder1
            || pEquipment->getID() == EQ_ID_Bonder2) {
            CTime time = CTime::GetCurrentTime();
            pEquipment->setDateTime((short)time.GetYear(),
               (short)time.GetMonth(),
               (short)time.GetDay(),
               (short)time.GetHour(),
               (short)time.GetMinute(),
               (short)time.GetSecond());
         }
         */
         // 测试设置cim mode
         /*
         if (pEquipment->getID() == EQ_ID_Bonder1
            || pEquipment->getID() == EQ_ID_Bonder2) {
            static int ii = 0; ii++;
            pEquipment->setCimMode(ii % 2 == 0);
         }
         */
         if (pEquipment->getID() == EQ_ID_Bonder1
            || pEquipment->getID() == EQ_ID_Bonder2) {
            static int ii = 0; ii++;
            pEquipment->setEqMode((ii % 5) + 1);
         }
         /*
         SERVO::CGlass* pGlass = pEquipment->getFrontGlass();
         if (pGlass != nullptr) {
            std::string strDescription;
@@ -142,6 +274,13 @@
               pPath = pPath->getNext();
            }
         }
         */
         // 请求主配方列表
         if (pEquipment != nullptr) {
            pEquipment->masterRecipeListRequest(0);
         }
      }
@@ -190,6 +329,11 @@
   if (m_hbrBkgnd != nullptr) {
      ::DeleteObject(m_hbrBkgnd);
   }
   if (m_pObserver != nullptr) {
      m_pObserver->unsubscribe();
      m_pObserver = NULL;
   }
}
@@ -225,6 +369,8 @@
   for (auto outPin : outPins) {
      m_pEqsGraphWnd->AddPin(pItem, OUTPIN, outPin->getName().c_str(), (DWORD_PTR)outPin);
   }
   m_pEqsGraphWnd->ShowItemIndicator((DWORD_PTR)pEquipment, !pEquipment->isGlassListEmpty());
}
void CPageGraph2::OnTimer(UINT_PTR nIDEvent)
@@ -258,6 +404,9 @@
   std::list<SERVO::CEquipment*>& eqs = theApp.m_model.m_master.getEquipmentList();
   for (auto item : eqs) {
      EQITEM* pEqItem = m_pEqsGraphWnd->GetItem((DWORD_PTR)item);
      if (nullptr == pEqItem) {
         continue;
      }
      strValue.Format(_T("%d"), pEqItem->rect.left);
      WritePrivateProfileString(item->getName().c_str(), _T("Left"),