From 7ddca21fdb798123239eab9daa390e2702afdff7 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 10 十月 2025 18:02:19 +0800
Subject: [PATCH] 1.ProcessStart和ProcessEnd加调上层时加上SlotNo, 状态也关联到SlotNo, 因为多腔可能 并行工作。 2.加入曲线采集服务端到项目中。
---
SourceCode/Bond/Servo/CMaster.cpp | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 174 insertions(+), 1 deletions(-)
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 960294c..037d0f5 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -9,6 +9,11 @@
namespace SERVO {
+ static inline int64_t now_ms_epoch() {
+ using namespace std::chrono;
+ return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
+ }
+
CMaster* g_pMaster = NULL;
unsigned __stdcall DispatchThreadFunction(LPVOID lpParam)
@@ -262,6 +267,12 @@
}
m_listEquipment.clear();
+
+ if (m_pCollector != nullptr) {
+ m_pCollector->stopLoop();
+ delete m_pCollector;
+ m_pCollector = nullptr;
+ }
return 0;
}
@@ -1520,8 +1531,20 @@
unlock();
}
};
- listener.onProcessStateChanged = [&](void* pEquipment, PROCESS_STATE state) -> void {
+ listener.onProcessStateChanged = [&](void* pEquipment, int slotNo, PROCESS_STATE state) -> void {
+ ASSERT(1 <= slotNo && slotNo <= 8);
+ int eqid = ((CEquipment*)pEquipment)->getID();
+ CGlass* pGlass = ((CEquipment*)pEquipment)->getGlassFromSlot(slotNo);
LOGI("<Master>onProcessStateChanged<%d>", (int)state);
+ if (state == PROCESS_STATE::Processing) {
+ if (pGlass != nullptr) {
+ m_pCollector->batchStart(eqid,
+ pGlass->getID().c_str(), 10 * 60 * 1000ULL);
+ }
+ }
+ else if (state == PROCESS_STATE::Complete) {
+ m_pCollector->batchStop(eqid);
+ }
};
listener.onMapMismatch = [&](void* pEquipment, short scanMap, short downMap) {
LOGE("<Master-%s>Port InUse, map(%d!=%d)不一致,请检查。",
@@ -1599,6 +1622,61 @@
std::vector<CParam> params;
((CEquipment*)pEquipment)->parsingSVData((const char*)rawData.data(), rawData.size(), params);
+
+ // 以下加入到曲线数据中
+ const int64_t ts = now_ms_epoch();
+ int eqid = ((CEquipment*)pEquipment)->getID();
+ if (eqid == EQ_ID_Bonder1 || eqid == EQ_ID_Bonder2) {
+ m_pCollector->buffersPush(eqid, 1, ts, params.at(1).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 2, ts, params.at(2).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 3, ts, params.at(3).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 4, ts, params.at(4).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 5, ts, params.at(5).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 6, ts, params.at(6).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 7, ts, params.at(7).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 8, ts, params.at(8).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 9, ts, params.at(9).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 10, ts, params.at(10).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 11, ts, params.at(11).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 12, ts, params.at(12).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 13, ts, params.at(13).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 14, ts, params.at(14).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 15, ts, params.at(15).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 16, ts, params.at(16).getDoubleValue());
+ }
+ else if (eqid == EQ_ID_VACUUMBAKE) {
+ m_pCollector->buffersPush(eqid, 1, ts, params.at(1).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 2, ts, params.at(2).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 3, ts, params.at(3).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 4, ts, params.at(4).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 5, ts, params.at(5).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 6, ts, params.at(6).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 7, ts, params.at(7).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 8, ts, params.at(10).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 9, ts, params.at(11).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 10, ts, params.at(12).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 11, ts, params.at(13).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 12, ts, params.at(14).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 13, ts, params.at(15).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 14, ts, params.at(16).getDoubleValue());
+ }
+ else if (eqid == EQ_ID_BAKE_COOLING) {
+ m_pCollector->buffersPush(eqid, 1, ts, params.at(1).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 2, ts, params.at(2).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 3, ts, params.at(3).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 4, ts, params.at(4).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 5, ts, params.at(5).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 6, ts, params.at(6).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 7, ts, params.at(11).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 8, ts, params.at(12).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 9, ts, params.at(13).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 10, ts, params.at(14).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 11, ts, params.at(15).getDoubleValue());
+ m_pCollector->buffersPush(eqid, 12, ts, params.at(16).getDoubleValue());
+ }
+
+
+ // 以下是输出测试
std::string strOut;
char szBuffer[256];
for (auto p : params) {
@@ -3008,4 +3086,99 @@
return nullptr;
}
+
+ void CMaster::CreateDAQBridgeServer()
+ {
+ auto connectionStatusCallback = [&](int code, const std::string& status) {
+ LOGI("<DAQBridge>status:", status.c_str());
+ };
+ auto rawDataCallback = [](const std::vector<uint8_t>& bytes) {
+
+ };
+
+ // 事件:有人连入/断开就上日志
+ auto clieintEventCallback = [](const std::string& ip, uint16_t port, bool connected) {
+ LOGI("<DAQBridge>[Client %s] %s:%u", connected ? _T("JOIN") : _T("LEAVE"), ip.c_str(), port);
+ };
+
+ if (m_pCollector == nullptr) {
+ m_pCollector = new Collector();
+ m_pCollector->setConnectionStatusCallback(connectionStatusCallback);
+ m_pCollector->setRawDataCallback(rawDataCallback);
+ m_pCollector->setClientEventCallback(clieintEventCallback);
+ m_pCollector->createServer(8081);
+ m_pCollector->startLoop(10);
+
+ // 1) 注册机台(推荐:先注册 id + 机器名称)
+ RetentionPolicy defP; defP.mode = RetainMode::ByCount; defP.maxSamples = 200;
+ m_pCollector->registryAddMachine(EQ_ID_Bonder1, "Bonder1", defP);
+ m_pCollector->registryAddMachine(EQ_ID_Bonder2, "Bonder2", defP);
+ m_pCollector->registryAddMachine(EQ_ID_VACUUMBAKE, "前烘烤", defP);
+ m_pCollector->registryAddMachine(EQ_ID_BAKE_COOLING, "烘烤冷却", defP);
+
+
+ // 2) 为通道设置“曲线名称”
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 1, "气囊压力");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 2, "上腔压力");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 3, "管道真空规值");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 4, "腔体真空规值");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 5, "上腔温度1");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 6, "上腔温度2");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 7, "上腔温度3");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 8, "上腔温度4");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 9, "上腔温度5");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 10, "上腔温度6");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 11, "下腔温度1");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 12, "下腔温度2");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 13, "下腔温度3");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 14, "下腔温度4");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 15, "下腔温度5");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder1, 16, "下腔温度6");
+
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 1, "气囊压力");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 2, "上腔压力");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 3, "管道真空规值");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 4, "腔体真空规值");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 5, "上腔温度1");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 6, "上腔温度2");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 7, "上腔温度3");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 8, "上腔温度4");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 9, "上腔温度5");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 10, "上腔温度6");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 11, "下腔温度1");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 12, "下腔温度2");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 13, "下腔温度3");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 14, "下腔温度4");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 15, "下腔温度5");
+ m_pCollector->buffersSetChannelName(EQ_ID_Bonder2, 16, "下腔温度6");
+
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 1, "A腔真空规值");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 2, "A腔温控1");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 3, "A腔温控2");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 4, "A腔温控4");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 5, "A腔温控5");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 6, "A腔温控6");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 7, "A腔温控7");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 8, "B腔真空规值");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 9, "B腔温控1");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 10, "B腔温控2");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 11, "B腔温控4");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 12, "B腔温控5");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 13, "B腔温控6");
+ m_pCollector->buffersSetChannelName(EQ_ID_VACUUMBAKE, 14, "B腔温控7");
+
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 1, "A烘烤温控1");
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 2, "A烘烤温控2");
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 3, "A烘烤温控4");
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 4, "A烘烤温控5");
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 5, "A烘烤温控6");
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 6, "A烘烤温控7");
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 7, "B烘烤温控1");
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 8, "B烘烤温控2");
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 9, "B烘烤温控4");
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 10, "B烘烤温控5");
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 11, "B烘烤温控6");
+ m_pCollector->buffersSetChannelName(EQ_ID_BAKE_COOLING, 12, "B烘烤温控7");
+ }
+ }
}
--
Gitblit v1.9.3