From 92dee0d8070594c351008d02fd9645c9e5de80a7 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 11 四月 2025 09:01:04 +0800
Subject: [PATCH] 1.车间测试部分功能; 2.警告测试,修复未能显示警告到报表中的问题。
---
SourceCode/Bond/Servo/CPageGraph2.cpp | 17 ++++
SourceCode/Bond/Servo/AlarmManager.cpp | 11 ++
SourceCode/Bond/Servo/LogDlg.cpp | 2
SourceCode/Bond/Servo/CEquipment.cpp | 35 +++++++-
SourceCode/Bond/Servo/CEFEM.cpp | 3
SourceCode/Bond/Servo/CMaster.cpp | 82 ++++++++++++++++++-
SourceCode/Bond/Servo/CMaster.h | 6 +
SourceCode/Bond/Servo/CEquipment.h | 3
SourceCode/Bond/Servo/CPageGraph1.cpp | 33 +++++++
9 files changed, 177 insertions(+), 15 deletions(-)
diff --git a/SourceCode/Bond/Servo/AlarmManager.cpp b/SourceCode/Bond/Servo/AlarmManager.cpp
index 3283979..440178d 100644
--- a/SourceCode/Bond/Servo/AlarmManager.cpp
+++ b/SourceCode/Bond/Servo/AlarmManager.cpp
@@ -221,6 +221,17 @@
return result;
#else
+ for (AlarmDataMap::const_iterator it = m_mapCache.begin(); it != m_mapCache.end(); ++it) {
+ const AlarmData& alarm = it->second;
+ if (alarm.nId == alarmData.nId &&
+ alarm.nDeviceId == alarmData.nDeviceId &&
+ alarm.nUnitId == alarmData.nUnitId) {
+
+ alarmEventId = it->first;
+ return false;
+ }
+ }
+
// 构建插入查询并使用 RETURNING 获取插入后的 alarm_event_id
std::ostringstream query;
query << "INSERT INTO alarms (id, severity_level, device_id, unit_id, description, start_time, end_time) "
diff --git a/SourceCode/Bond/Servo/CEFEM.cpp b/SourceCode/Bond/Servo/CEFEM.cpp
index b77ed4a..3e2ab9d 100644
--- a/SourceCode/Bond/Servo/CEFEM.cpp
+++ b/SourceCode/Bond/Servo/CEFEM.cpp
@@ -38,6 +38,9 @@
int CEFEM::onStepEvent(CStep* pStep, int code)
{
+ int nRet = CEquipment::onStepEvent(pStep, code);
+ if (nRet > 0) return nRet;
+
if (code == STEP_EVENT_READDATA) {
if (isCassetteTransferStateStep(pStep)) {
SERVO::CEqCassetteTransferStateStep* pEqCassetteStep = (SERVO::CEqCassetteTransferStateStep*)pStep;
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index e61b4b3..93d8455 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -24,7 +24,7 @@
CEquipment::CEquipment() : m_nID(0), m_strName(""), m_strDescription(""), m_station(0, 255)
{
m_listener = { nullptr, nullptr, nullptr, nullptr };
- m_alive = {FALSE, 0, FALSE};
+ m_alive = { FALSE, 0, FALSE };
m_bCimState = FALSE;
m_bUpstreamInline = FALSE;
m_bDownstreamInline = FALSE;
@@ -328,7 +328,7 @@
}
}
}
-
+
// CIM State
bFlag = isBitOn(pszData, size, ++index);
if (!equalBool(m_bCimState, bFlag)) {
@@ -383,6 +383,8 @@
// CIM Mode
CHECK_WRITE_STEP_SIGNAL(0x350, pszData, size);
+ // EQ Mode
+ CHECK_WRITE_STEP_SIGNAL(0x355, pszData, size);
// Port1 ~ Port4
CHECK_READ_STEP_SIGNAL(0x3e0, pszData, size);
@@ -495,11 +497,13 @@
int state = pEqAlarmStep->getAlarmState();
ASSERT(state == 0 || state == 1);
if (m_listener.onAlarm != nullptr) {
- m_listener.onAlarm(this, state,
+ m_listener.onAlarm(this, state,
pEqAlarmStep->getAlarmId(),
pEqAlarmStep->getUnitId(),
pEqAlarmStep->getAlarmLevel());
}
+
+ return 1;
}
}
@@ -748,4 +752,27 @@
return CToolUnits::startsWith(pStep->getName(), "EQPort")
&& pStep->getName().find("Cassette") != std::string::npos;
}
-}
+
+ int CEquipment::setEqMode(short mode)
+ {
+ SERVO::CEqModeChangeStep* pStep = (SERVO::CEqModeChangeStep*)getStepWithName(STEP_EQ_MODE_CHANGE);
+ if (pStep == nullptr) {
+ return -1;
+ }
+
+ return pStep->setEqMode(mode);
+ }
+
+ int CEquipment::setCimMode(BOOL bOn)
+ {
+ SERVO::CEqCimModeChangeStep* pStep = (SERVO::CEqCimModeChangeStep*)getStepWithName(STEP_CIM_MODE_CHANGE);
+ if (pStep == nullptr) {
+ return -1;
+ }
+
+ if (bOn)
+ return pStep->cimOn();
+ else
+ return pStep->cimOff();
+ }
+}
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index 7dd0501..3837e39 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -106,7 +106,8 @@
BOOL removeClass(CGlass* pGlass);
bool isAlarmStep(SERVO::CStep* pStep);
bool isCassetteTransferStateStep(SERVO::CStep* pStep);
-
+ int setEqMode(short mode);
+ int setCimMode(BOOL bOn);
// 以下为从CC-Link读取到的Bit标志位检测函数
public:
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 6e00a3a..e3ea729 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -15,6 +15,16 @@
namespace SERVO {
CMaster* g_pMaster = NULL;
+
+ unsigned __stdcall ReadBitsThreadFunction(LPVOID lpParam)
+ {
+ if (g_pMaster != NULL) {
+ return g_pMaster->ReadBitsProc();
+ }
+
+ return 0;
+ }
+
void CALLBACK MasterTimerProc(HWND hWnd, UINT nMsg, UINT nTimerid, DWORD dwTime)
{
if (g_pMaster != NULL) {
@@ -26,6 +36,10 @@
{
m_listener = {nullptr, nullptr, nullptr};
m_bDataModify = FALSE;
+ m_hEventReadBitsThreadExit[0] = ::CreateEvent(NULL, TRUE, FALSE, NULL);
+ m_hEventReadBitsThreadExit[1] = ::CreateEvent(NULL, TRUE, FALSE, NULL);
+ m_hReadBitsThreadHandle = nullptr;
+ m_nReadBitsThreadAddr = 0;
}
CMaster::~CMaster()
@@ -34,6 +48,16 @@
delete item;
}
m_listEquipment.clear();
+
+ if (m_hEventReadBitsThreadExit[0] != nullptr) {
+ ::CloseHandle(m_hEventReadBitsThreadExit[0]);
+ m_hEventReadBitsThreadExit[0] = nullptr;
+ }
+
+ if (m_hEventReadBitsThreadExit[1] != nullptr) {
+ ::CloseHandle(m_hEventReadBitsThreadExit[1]);
+ m_hEventReadBitsThreadExit[1] = nullptr;
+ }
}
void CMaster::setListener(MasterListener listener)
@@ -98,12 +122,19 @@
SetTimer(NULL, 1, 250, (TIMERPROC)MasterTimerProc);
+ m_hReadBitsThreadHandle = (HANDLE)_beginthreadex(NULL, 0, SERVO::ReadBitsThreadFunction, this,
+ 0, &m_nReadBitsThreadAddr);
+
+
LOGI("<Master>初始化完成.");
return 0;
}
int CMaster::term()
{
+ SetEvent(m_hEventReadBitsThreadExit[0]);
+ ::WaitForSingleObject(m_hEventReadBitsThreadExit[1], INFINITE);
+
LOGI("<Master>正在结束程序.");
for (auto item : m_listEquipment) {
item->term();
@@ -111,6 +142,38 @@
saveCache();
+
+ return 0;
+ }
+
+ unsigned CMaster::ReadBitsProc()
+ {
+ while (1) {
+ // 待退出信号或时间到
+ int nRet = ::WaitForSingleObject(m_hEventReadBitsThreadExit[0], 1000);
+ if (nRet == WAIT_OBJECT_0) {
+ break;
+ }
+
+ for (auto item : m_listEquipment) {
+ if (item->getID() == EQ_ID_Bonder1) {
+ const StationIdentifier& station = item->getStation();
+ MemoryBlock& block = item->getReadBitBlock();
+
+ int nRet = m_cclink.ReadData2(station, (DeviceType)block.type,
+ block.start, block.size, block.buffer);
+ if (0 == nRet) {
+ item->onReceiveLBData(block.buffer, block.size);
+ }
+ }
+ }
+ }
+
+ SetEvent(m_hEventReadBitsThreadExit[1]);
+
+
+ // _endthreadex(0);
+ TRACE("CMaster::ReadBitsProc 线程退出\n");
return 0;
}
@@ -663,7 +726,8 @@
pEquipment->setID(EQ_ID_Bonder1 + index);
pEquipment->setName(index == 0 ? "Bonder 1" : "Bonder 2");
pEquipment->setDescription(index == 0 ? "Bonder 1." : "Bonder 2.");
- pEquipment->setStation(1, index == 0 ? 3 : 4);
+ // pEquipment->setStation(1, index == 0 ? 3 : 4);
+ pEquipment->setStation(0, 255);
pEquipment->setReadBitBlock(index == 0 ? 0x4600 : 0x4c00,
index == 0 ? 0x4c00 : 0x5200);
addToEquipmentList(pEquipment);
@@ -823,19 +887,23 @@
// 按一定频率扫描LB数据
static int i = 0;
i++;
+ /*
if (i % (4 * 1) == 0) {
for (auto item : m_listEquipment) {
- const StationIdentifier& station = item->getStation();
- MemoryBlock& block = item->getReadBitBlock();
+ if (item->getID() == EQ_ID_Bonder1) {
+ const StationIdentifier& station = item->getStation();
+ MemoryBlock& block = item->getReadBitBlock();
- int nRet = m_cclink.ReadData2(station, (DeviceType)block.type,
- block.start, block.size, block.buffer);
- if (0 == nRet) {
- item->onReceiveLBData(block.buffer, block.size);
+ int nRet = m_cclink.ReadData2(station, (DeviceType)block.type,
+ block.start, block.size, block.buffer);
+ if (0 == nRet) {
+ item->onReceiveLBData(block.buffer, block.size);
+ }
}
}
}
+ */
// 自动保存缓存
diff --git a/SourceCode/Bond/Servo/CMaster.h b/SourceCode/Bond/Servo/CMaster.h
index c6180cc..fa79fce 100644
--- a/SourceCode/Bond/Servo/CMaster.h
+++ b/SourceCode/Bond/Servo/CMaster.h
@@ -33,6 +33,7 @@
void setListener(MasterListener listener);
int init();
int term();
+ unsigned ReadBitsProc();
void onTimer(UINT nTimerid);
std::list<CEquipment*>& getEquipmentList();
CEquipment* getEquipment(int id);
@@ -59,6 +60,11 @@
std::list<CEquipment*> m_listEquipment;
std::string m_strFilepath;
BOOL m_bDataModify;
+
+ private:
+ HANDLE m_hEventReadBitsThreadExit[2];
+ HANDLE m_hReadBitsThreadHandle;
+ unsigned m_nReadBitsThreadAddr;
};
}
diff --git a/SourceCode/Bond/Servo/CPageGraph1.cpp b/SourceCode/Bond/Servo/CPageGraph1.cpp
index be12698..243dea1 100644
--- a/SourceCode/Bond/Servo/CPageGraph1.cpp
+++ b/SourceCode/Bond/Servo/CPageGraph1.cpp
@@ -86,6 +86,14 @@
UpdateDeviceStatus(INDICATE_ROBOT_ARM1, status);
UpdateDeviceStatus(INDICATE_ROBOT_ARM2, status);
}
+ else if(EQ_ID_Bonder1 == nID) {
+ DeviceStatus status = bAlive ? DeviceStatus::ONLINE : DeviceStatus::OFFLINE;
+ UpdateDeviceStatus(INDICATE_BONDER1, status);
+ }
+ else if (EQ_ID_Bonder2 == nID) {
+ DeviceStatus status = bAlive ? DeviceStatus::ONLINE : DeviceStatus::OFFLINE;
+ UpdateDeviceStatus(INDICATE_BONDER2, status);
+ }
}
}
}
@@ -171,8 +179,6 @@
m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM2, 243, 294, 48, RGB(22, 22, 22),
RGB(255, 127, 39), EQ_BOX_OFFLINE);
m_pGraph->SetBoxText(INDICATE_ROBOT_ARM2, "6", "Robot");
-
-
// Vacuum bake
@@ -400,6 +406,29 @@
if (1 == nIDEvent) {
KillTimer(1);
InitRxWindows();
+
+ // 鏇存柊鐘舵��
+ {
+ SERVO::CEquipment* pEquipment = (SERVO::CEFEM*)theApp.m_model.m_master.getEquipment(EQ_ID_EFEM);
+ ASSERT(pEquipment);
+ DeviceStatus status = pEquipment->isAlive() ? DeviceStatus::ONLINE : DeviceStatus::OFFLINE;
+ UpdateDeviceStatus(INDICATE_ROBOT_ARM1, status);
+ UpdateDeviceStatus(INDICATE_ROBOT_ARM2, status);
+ }
+
+ {
+ SERVO::CEquipment* pEquipment = theApp.m_model.m_master.getEquipment(EQ_ID_Bonder1);
+ ASSERT(pEquipment);
+ DeviceStatus status = pEquipment->isAlive() ? DeviceStatus::ONLINE : DeviceStatus::OFFLINE;
+ UpdateDeviceStatus(INDICATE_BONDER1, status);
+ }
+
+ {
+ SERVO::CEquipment* pEquipment = theApp.m_model.m_master.getEquipment(EQ_ID_Bonder2);
+ ASSERT(pEquipment);
+ DeviceStatus status = pEquipment->isAlive() ? DeviceStatus::ONLINE : DeviceStatus::OFFLINE;
+ UpdateDeviceStatus(INDICATE_BONDER2, status);
+ }
}
CDialogEx::OnTimer(nIDEvent);
diff --git a/SourceCode/Bond/Servo/CPageGraph2.cpp b/SourceCode/Bond/Servo/CPageGraph2.cpp
index 082667e..bdc4da1 100644
--- a/SourceCode/Bond/Servo/CPageGraph2.cpp
+++ b/SourceCode/Bond/Servo/CPageGraph2.cpp
@@ -158,6 +158,22 @@
}
else if (nCmd == ID_EQSGRAPHITEM_TEST3) {
SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
+ if (pEquipment->getID() == EQ_ID_Bonder1
+ || pEquipment->getID() == EQ_ID_Bonder2) {
+ static int ii = 0; ii++;
+ pEquipment->setCimMode(ii % 2 == 0);
+ }
+
+ /*
+ SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
+ if (pEquipment->getID() == EQ_ID_Bonder1
+ || pEquipment->getID() == EQ_ID_Bonder2) {
+ static int ii = 0; ii++;
+ pEquipment->setEqMode((ii % 5) + 1);
+ }
+ */
+ /*
+ SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
SERVO::CGlass* pGlass = pEquipment->getFrontGlass();
if (pGlass != nullptr) {
std::string strDescription;
@@ -168,6 +184,7 @@
pPath = pPath->getNext();
}
}
+ */
}
diff --git a/SourceCode/Bond/Servo/LogDlg.cpp b/SourceCode/Bond/Servo/LogDlg.cpp
index 560b5cc..f8fa9b8 100644
--- a/SourceCode/Bond/Servo/LogDlg.cpp
+++ b/SourceCode/Bond/Servo/LogDlg.cpp
@@ -154,7 +154,7 @@
// 内容
- m_logEdit.SetMaxLineCount(20);
+ m_logEdit.SetMaxLineCount(500);
m_logEdit.SetLimitText(-1);
--
Gitblit v1.9.3