From ebf96874b6a994e3b09b69f272416cb482cf25bb Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 30 五月 2025 18:49:43 +0800
Subject: [PATCH] 1.Fliper(G2) -> Aligner VacuumBake(G1) -> Aligner搬送逻辑和模拟测试; 2.在状态栏增加当前搬送状态显示(按钮,下一步用于实现点击按钮展开搬送任务详情,中断操作等)
---
SourceCode/Bond/Servo/CMyStatusbar.h | 5 +
SourceCode/Bond/Servo/CRobotTask.h | 1
SourceCode/Bond/Servo/resource.h | 0
SourceCode/Bond/Servo/CEquipmentPage2.cpp | 17 +++--
SourceCode/Bond/Servo/CRobotTask.cpp | 19 ++++++
SourceCode/Bond/Servo/Servo.rc | 0
SourceCode/Bond/Servo/CMaster.cpp | 75 +++++++++++++++++++-----
SourceCode/Bond/Servo/CMyStatusbar.cpp | 39 ++++++++++++
SourceCode/Bond/Servo/CMaster.h | 2
SourceCode/Bond/Servo/Model.cpp | 3 +
SourceCode/Bond/Servo/ServoDlg.cpp | 16 +++++
SourceCode/Bond/Servo/Common.h | 1
12 files changed, 150 insertions(+), 28 deletions(-)
diff --git a/SourceCode/Bond/Servo/CEquipmentPage2.cpp b/SourceCode/Bond/Servo/CEquipmentPage2.cpp
index e28bc78..f566568 100644
--- a/SourceCode/Bond/Servo/CEquipmentPage2.cpp
+++ b/SourceCode/Bond/Servo/CEquipmentPage2.cpp
@@ -82,14 +82,15 @@
ASSERT(m_pEquipment);
for (int i = 0; i < SLOT_MAX; i++) {
SERVO::CGlass* pGlass = m_pEquipment->getGlassFromSlot(i+1);
- pGlass->addRef();
-
- SERVO::CGlass* pBuddy = pGlass->getBuddy();
- int index = m_listCtrl.InsertItem(m_listCtrl.GetItemCount(), _T(""));
- m_listCtrl.SetItemData(index, (DWORD_PTR)pGlass);
- m_listCtrl.SetItemText(index, 1, pGlass->getID().c_str());
- if (pBuddy != nullptr) {
- m_listCtrl.SetItemText(index, 2, pBuddy->getID().c_str());
+ if (pGlass != nullptr) {
+ pGlass->addRef();
+ SERVO::CGlass* pBuddy = pGlass->getBuddy();
+ int index = m_listCtrl.InsertItem(m_listCtrl.GetItemCount(), _T(""));
+ m_listCtrl.SetItemData(index, (DWORD_PTR)pGlass);
+ m_listCtrl.SetItemText(index, 1, pGlass->getID().c_str());
+ if (pBuddy != nullptr) {
+ m_listCtrl.SetItemText(index, 2, pBuddy->getID().c_str());
+ }
}
}
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index d536f7c..7a30bfa 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -279,6 +279,19 @@
unsigned CMaster::DispatchProc()
{
+ // 各种机器
+ CLoadPort* pLoadPort1 = (CLoadPort*)getEquipment(EQ_ID_LOADPORT1);
+ CLoadPort* pLoadPort2 = (CLoadPort*)getEquipment(EQ_ID_LOADPORT2);
+ CFliper* pFliper = (CFliper*)getEquipment(EQ_ID_FLIPER);
+ CVacuumBake* pVacuumBack = (CVacuumBake*)getEquipment(EQ_ID_VACUUMBAKE);
+ CAligner* pAligner = (CAligner*)getEquipment(EQ_ID_ALIGNER);
+
+ ASSERT(pLoadPort1);
+ ASSERT(pLoadPort2);
+ ASSERT(pFliper);
+ ASSERT(pVacuumBack);
+ ASSERT(pAligner);
+
while (1) {
// 待退出信号或时间到
HANDLE hEvents[] = { m_hEventDispatchThreadExit[0], m_hDispatchEvent };
@@ -310,30 +323,24 @@
// 调度逻辑处理
else if (m_state == MASTERSTATE::RUNNING) {
unlock();
- LOGI("调度处理中...");
+ // LOGI("调度处理中...");
lock();
if (m_pActiveRobotTask != nullptr) {
unlock();
// 检测到当前有正在下午的任务,确保当前任务完成或中止后继续
- LOGI("检测到当前有正在下午的任务,确保当前任务完成或中止后继续...");
+ // LOGI("检测到当前有正在下午的任务,确保当前任务完成或中止后继续...");
continue;
}
// LoadPort -> Fliper(G2)
- CLoadPort* pLoadPort1 = (CLoadPort*)getEquipment(EQ_ID_LOADPORT1);
- CLoadPort* pLoadPort2 = (CLoadPort*)getEquipment(EQ_ID_LOADPORT2);
- CFliper* pFliper = (CFliper*)getEquipment(EQ_ID_FLIPER);
- CVacuumBake* pVacuumBack = (CVacuumBake*)getEquipment(EQ_ID_VACUUMBAKE);
- ASSERT(pLoadPort1);
- ASSERT(pLoadPort2);
- ASSERT(pFliper);
- ASSERT(pVacuumBack);
-
m_pActiveRobotTask = createTransferTask(pLoadPort1, pFliper);
if (m_pActiveRobotTask != nullptr) {
std::string strDescription = m_pActiveRobotTask->getDescription();
unlock();
+ if (m_listener.onRobotTaskEvent != nullptr) {
+ m_listener.onRobotTaskEvent(this, m_pActiveRobotTask, 0);
+ }
LOGI("创建新任务<%s>...", strDescription.c_str());
continue;
}
@@ -342,6 +349,9 @@
if (m_pActiveRobotTask != nullptr) {
std::string strDescription = m_pActiveRobotTask->getDescription();
unlock();
+ if (m_listener.onRobotTaskEvent != nullptr) {
+ m_listener.onRobotTaskEvent(this, m_pActiveRobotTask, 0);
+ }
LOGI("创建新任务<%s>...", strDescription.c_str());
continue;
}
@@ -353,7 +363,10 @@
if (m_pActiveRobotTask != nullptr) {
std::string strDescription = m_pActiveRobotTask->getDescription();
unlock();
- LOGI("创建新任务1<%s>...", strDescription.c_str());
+ if (m_listener.onRobotTaskEvent != nullptr) {
+ m_listener.onRobotTaskEvent(this, m_pActiveRobotTask, 0);
+ }
+ LOGI("创建新任务<%s>...", strDescription.c_str());
continue;
}
@@ -361,16 +374,40 @@
if (m_pActiveRobotTask != nullptr) {
std::string strDescription = m_pActiveRobotTask->getDescription();
unlock();
- LOGI("创建新任务2<%s>...", strDescription.c_str());
+ if (m_listener.onRobotTaskEvent != nullptr) {
+ m_listener.onRobotTaskEvent(this, m_pActiveRobotTask, 0);
+ }
+ LOGI("创建新任务<%s>...", strDescription.c_str());
+ continue;
+ }
+
+
+ // Fliper(G2) -> Aligner
+ // VacuumBake(G1) -> Aligner
+ m_pActiveRobotTask = createTransferTask(pFliper, pAligner);
+ if (m_pActiveRobotTask != nullptr) {
+ std::string strDescription = m_pActiveRobotTask->getDescription();
+ unlock();
+ if (m_listener.onRobotTaskEvent != nullptr) {
+ m_listener.onRobotTaskEvent(this, m_pActiveRobotTask, 0);
+ }
+ LOGI("创建新任务<%s>...", strDescription.c_str());
+ continue;
+ }
+
+ m_pActiveRobotTask = createTransferTask(pVacuumBack, pAligner);
+ if (m_pActiveRobotTask != nullptr) {
+ std::string strDescription = m_pActiveRobotTask->getDescription();
+ unlock();
+ if (m_listener.onRobotTaskEvent != nullptr) {
+ m_listener.onRobotTaskEvent(this, m_pActiveRobotTask, 0);
+ }
+ LOGI("创建新任务<%s>...", strDescription.c_str());
continue;
}
- // Fliper(G2) -> Aligner
-
-
- // VacuumBake(G1) -> Aligner
// Aligner -> Bonder
@@ -554,6 +591,10 @@
lock();
delete m_pActiveRobotTask;
m_pActiveRobotTask = nullptr;
+
+ if (m_listener.onRobotTaskEvent != nullptr) {
+ m_listener.onRobotTaskEvent(this, m_pActiveRobotTask, 0);
+ }
}
unlock();
}
diff --git a/SourceCode/Bond/Servo/CMaster.h b/SourceCode/Bond/Servo/CMaster.h
index 93ff6cc..ba4fd04 100644
--- a/SourceCode/Bond/Servo/CMaster.h
+++ b/SourceCode/Bond/Servo/CMaster.h
@@ -29,6 +29,7 @@
typedef std::function<void(void* pMaster, CEquipment* pEquipment, int state, int alarmId, int unitId, int level)> ONEQALARM;
typedef std::function<void(void* pMaster, CEquipment* pEquipment, CVcrEventReport* pReport)> ONEQVCREVENTREPORT;
typedef std::function<void(void* pMaster, CEquipment* pEquipment, int code)> ONEQDATACHANGED;
+ typedef std::function<void(void* pMaster, CRobotTask* pTask, int code)> ONROBOTTASKEVENT;
typedef struct _MasterListener
{
ONMASTERSTATECHANGED onMasterStateChanged;
@@ -37,6 +38,7 @@
ONEQALARM onEqAlarm;
ONEQVCREVENTREPORT onEqVcrEventReport;
ONEQDATACHANGED onEqDataChanged;
+ ONROBOTTASKEVENT onRobotTaskEvent;
} MasterListener;
class CMaster
diff --git a/SourceCode/Bond/Servo/CMyStatusbar.cpp b/SourceCode/Bond/Servo/CMyStatusbar.cpp
index d85b341..3432829 100644
--- a/SourceCode/Bond/Servo/CMyStatusbar.cpp
+++ b/SourceCode/Bond/Servo/CMyStatusbar.cpp
@@ -43,7 +43,15 @@
m_brBkgnd.DeleteObject();
}
+ m_crBkgnd = color;
m_brBkgnd.CreateSolidBrush(color);
+ m_btnCurTask.SetFaceColor(m_crBkgnd);
+ m_btnCurTask.SetFrameColor(m_crBkgnd);
+ m_btnCurTask.SetFrameColor(BS_HOVER, CColorTransfer::ApproximateColor(m_crBkgnd, 0.05));
+ m_btnCurTask.SetFrameColor(BS_PRESS, CColorTransfer::ApproximateColor(m_crBkgnd, 0.12));
+ m_btnCurTask.SetBkgndColor(BS_HOVER, CColorTransfer::ApproximateColor(m_crBkgnd, 0.05));
+ m_btnCurTask.SetBkgndColor(BS_PRESS, CColorTransfer::ApproximateColor(m_crBkgnd, 0.12));
+
Invalidate();
UpdateWindow();
}
@@ -51,6 +59,8 @@
void CMyStatusbar::setForegroundColor(COLORREF cr)
{
m_crForeground = cr;
+ m_btnCurTask.SetTextColor(m_crForeground);
+
Invalidate();
UpdateWindow();
}
@@ -60,11 +70,23 @@
SetDlgItemText(IDC_LABEL_RUNTIME, pszText);
}
+void CMyStatusbar::setCurTaskBtnText(const char* pszText)
+{
+ SetDlgItemText(IDC_BUTTON_ROBOTTASK, pszText);
+}
+
BOOL CMyStatusbar::OnInitDialog()
{
CDialogEx::OnInitDialog();
- // TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
+
+ m_btnCurTask.SubclassDlgItem(IDC_BUTTON_ROBOTTASK, this);
+ // m_btnCurTask.SetIcon(hIcon1, hIcon1, 24);
+ m_btnCurTask.SetFaceColor(m_crBkgnd);
+ m_btnCurTask.SetFrameColor(m_crBkgnd);
+ m_btnCurTask.SetFrameColor(BS_HOVER, RGB(218, 218, 218));
+ m_btnCurTask.SetFrameColor(BS_PRESS, RGB(168, 168, 168));
+
return TRUE; // return TRUE unless you set the focus to a control
// 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
@@ -110,8 +132,21 @@
int x;
GetClientRect(&rcClient);
- x = 120;
+ x = 20;
pItem = GetDlgItem(IDC_LABEL_RUNTIME);
pItem->GetClientRect(rcItem);
pItem->MoveWindow(x, (rcClient.Height() - rcItem.Height()) / 2, rcItem.Width(), rcItem.Height());
+ x += rcItem.Width();
+
+ x += 8;
+ pItem = GetDlgItem(IDC_LABEL_CUR_TASK_L);
+ pItem->GetClientRect(rcItem);
+ pItem->MoveWindow(x, (rcClient.Height() - rcItem.Height()) / 2, rcItem.Width(), rcItem.Height());
+ x += rcItem.Width();
+
+ x += 8;
+ pItem = GetDlgItem(IDC_BUTTON_ROBOTTASK);
+ pItem->GetClientRect(rcItem);
+ pItem->MoveWindow(x, (rcClient.Height() - rcItem.Height()) / 2, rcItem.Width(), rcItem.Height());
+ x += rcItem.Width();
}
diff --git a/SourceCode/Bond/Servo/CMyStatusbar.h b/SourceCode/Bond/Servo/CMyStatusbar.h
index 3ac6fee..ed1d4e2 100644
--- a/SourceCode/Bond/Servo/CMyStatusbar.h
+++ b/SourceCode/Bond/Servo/CMyStatusbar.h
@@ -1,4 +1,6 @@
锘�#pragma once
+#include "BlButton.h"
+#include "ColorTransfer.h"
// CMyStatusbar 瀵硅瘽妗�
@@ -16,6 +18,7 @@
void setBackgroundColor(COLORREF color);
void setForegroundColor(COLORREF cr);
void setRunTimeText(const char* pszText);
+ void setCurTaskBtnText(const char* pszText);
private:
void Resize();
@@ -24,7 +27,7 @@
COLORREF m_crForeground;
COLORREF m_crBkgnd;
CBrush m_brBkgnd;
-
+ CBlButton m_btnCurTask;
// 瀵硅瘽妗嗘暟鎹�
#ifdef AFX_DESIGN_TIME
diff --git a/SourceCode/Bond/Servo/CRobotTask.cpp b/SourceCode/Bond/Servo/CRobotTask.cpp
index 3b19a24..6a223de 100644
--- a/SourceCode/Bond/Servo/CRobotTask.cpp
+++ b/SourceCode/Bond/Servo/CRobotTask.cpp
@@ -42,6 +42,25 @@
return strOut;
}
+ std::string CRobotTask::getSimpleDescription() const
+ {
+ std::string strOut = "CRobotTask<ID:";
+ strOut = strOut + std::to_string(m_robotCmdParam.sequenceNo);
+ strOut = strOut + ",Arm:";
+ strOut = strOut + std::to_string(m_robotCmdParam.armNo);
+ strOut = strOut + ",GetPossion:";
+ strOut = strOut + std::to_string(m_robotCmdParam.getPosition);
+ strOut = strOut + ",GetSlot:";
+ strOut = strOut + std::to_string(m_robotCmdParam.getSlotNo);
+ strOut = strOut + ",PutPossion:";
+ strOut = strOut + std::to_string(m_robotCmdParam.putPosition);
+ strOut = strOut + ",PutSlot:";
+ strOut = strOut + std::to_string(m_robotCmdParam.putSlotNo);
+ strOut = strOut + ">";
+
+ return strOut;
+ }
+
void CRobotTask::setContext(CContext* pContext)
{
if (pContext != nullptr) {
diff --git a/SourceCode/Bond/Servo/CRobotTask.h b/SourceCode/Bond/Servo/CRobotTask.h
index 1fee5f2..f02d1ff 100644
--- a/SourceCode/Bond/Servo/CRobotTask.h
+++ b/SourceCode/Bond/Servo/CRobotTask.h
@@ -13,6 +13,7 @@
public:
std::string& getId();
std::string getDescription() const;
+ std::string getSimpleDescription() const;
void setContext(CContext* pContext);
CContext* getContext();
void setRobotTransferParam(int seq, int armNo, int fromPos, int toPos, int fromSlot, int toSlot);
diff --git a/SourceCode/Bond/Servo/Common.h b/SourceCode/Bond/Servo/Common.h
index f0e5917..590226c 100644
--- a/SourceCode/Bond/Servo/Common.h
+++ b/SourceCode/Bond/Servo/Common.h
@@ -17,6 +17,7 @@
#define RX_CODE_ALARM_CLEAR 1009
#define RX_CODE_EQ_DATA_CHANGED 1010
#define RX_CODE_MASTER_STATE_CHANGED 1011
+#define RX_CODE_EQ_ROBOT_TASK 1012
/* Channel Name */
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index c991c64..8e32798 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -170,6 +170,9 @@
LOGE("<CModel>onEqDataChanged.");
notifyPtr(RX_CODE_EQ_DATA_CHANGED, pEquipment);
};
+ masterListener.onRobotTaskEvent = [&](void* pMaster, SERVO::CRobotTask* pTask, int code) {
+ notifyPtr(RX_CODE_EQ_ROBOT_TASK, pTask);
+ };
m_master.setListener(masterListener);
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index dd5c0e4..65d8222 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index 6ce2bf0..1921443 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -185,6 +185,22 @@
SetTimer(TIMER_ID_UPDATE_RUMTIME, 500, nullptr);
}
}
+ else if (RX_CODE_EQ_ROBOT_TASK == code) {
+ SERVO::CRobotTask* pTask = theApp.m_model.getMaster().getActiveRobotTask();
+ if (pTask == nullptr) {
+ m_pMyStatusbar->setCurTaskBtnText("无");
+ }
+ else {
+ SERVO::CEquipment* pEq1, * pEq2;
+ pEq1 = theApp.m_model.getMaster().getEquipment(pTask->getSrcPosition());
+ pEq2 = theApp.m_model.getMaster().getEquipment(pTask->getTarPosition());
+ if (pEq1 != nullptr && pEq2 != nullptr) {
+ CString strText;
+ strText.Format(_T("%s --> %s"), pEq1->getName().c_str(), pEq2->getName().c_str());
+ m_pMyStatusbar->setCurTaskBtnText((LPTSTR)(LPCTSTR)strText);
+ }
+ }
+ }
pAny->release();
}, [&]() -> void {
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index 59bd598..b3b41cc 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ
--
Gitblit v1.9.3