From bc7f1c4e028e69be51079b59dae4ae5c4d43f5bb Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期六, 31 一月 2026 21:54:56 +0800
Subject: [PATCH] 1.状态指示图,目前灰色表示掉线,绿色表示在线。增加Slot的小点表示有没有料,及加工状态 。 2.增加图示

---
 SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp |   46 ++++++++++++++++++++++++++++------------------
 1 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp b/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
index a3f8234..8e45bb2 100644
--- a/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
+++ b/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
@@ -247,7 +247,7 @@
 	strFullLogLine.Format(_T("%s %s"), strLevel, strContent);
 
 	// 鍐欏叆鏃ュ織鏂囦欢
-	// LOG_LINE(strFullLogLine);
+	LOG_LINE(strFullLogLine);
 }
 
 void CSGMeasurementDlg::HighlightAllMatches(const CString& strSearch, COLORREF clrHighlight/* = RGB(255, 165, 0)*/)
@@ -639,7 +639,8 @@
 
 	fAvg1 = CalcAverage(vecGlass1);
 	fAvg2 = CalcAverage(vecGlass2);
-	fOffset = std::fabs(fAvg2 - fAvg1);  // 绗簩鐗� - 绗竴鐗�
+	fOffset = fAvg2 - fAvg1;				// 绗簩鐗� - 绗竴鐗�
+	//fOffset = std::fabs(fAvg2 - fAvg1);	// 绗簩鐗� - 绗竴鐗�
 
 	CString strLog;
 	strLog.Format(_T("绗竴鐗囩幓鐠冨钩鍧囧��: %.3f锛岀浜岀墖鐜荤拑骞冲潎鍊�: %.3f锛屽亸绉婚噺: %.3f"), fAvg1, fAvg2, fOffset);
@@ -723,27 +724,27 @@
 	if (m_nUseTrigger) {
 		UpdateControlStatus(m_bConnected, m_bSaving);
 		AfxMessageBox(_T("褰撳墠鏄‖瑙﹀彂妯″紡锛岃妫�鏌ヨЕ鍙戝櫒鐘舵�併��"), MB_ICONINFORMATION);
-		return -1.0f;
+		return 0xFF;
 	}
 
 	if (!m_bConnected) {
 		AppendLogLineRichStyled(_T("璁惧鏈繛鎺ワ紝璇峰厛杩炴帴璁惧銆�"), LOG_COLOR_WARNING);
-		return -1.0f;
+		return 0xFF;
 	}
 
 	if (m_bSaving) {
 		AppendLogLineRichStyled(_T("鏁版嵁瀛樺偍姝e湪杩涜涓紝璇峰厛鍋滄瀛樺偍銆�"), LOG_COLOR_WARNING);
-		return -1.0f;
+		return 0xFF;
 	}
 
 	if (nOutNo < 1 || nOutNo > 4) {
 		AppendLogLineRichStyled(_T("杈撳嚭绔彛缂栧彿鏃犳晥锛屽繀椤诲湪 1 鍒� 4 涔嬮棿銆�"), LOG_COLOR_ERROR);
-		return -1.0f;
+		return 0xFF;
 	}
 
 	if (m_nSavePointCount < 0) {
 		AppendLogLineRichStyled(_T("鏁版嵁鐐规暟蹇呴』澶т簬 0銆�"), LOG_COLOR_ERROR);
-		return -1.0f;
+		return 0xFF;
 	}
 
 	std::vector<float> vecBuffer(m_nSavePointCount, 0.0f);
@@ -754,7 +755,7 @@
 		CString strError;
 		strError.Format(_T("璇诲彇 OUT%d 鏁版嵁澶辫触锛岄敊璇爜锛�%#X"), nOutNo, nRet);
 		AppendLogLineRichStyled(strError, LOG_COLOR_ERROR);
-		return -1.0f;
+		return 0xFF;
 	}
 
 	vecBuffer.resize(nReceived);
@@ -763,7 +764,7 @@
 	std::vector<float> vecGlass1, vecGlass2;
 	if (!SplitGlassSegments(nOutNo, vecBuffer, vecGlass1, vecGlass2, m_fJumpThreshold, m_nJumpWindow, m_nValleyMargin, m_nMinGlass1Count)) {
 		AppendLogLineRichStyled(_T("鏈兘璇嗗埆鍑轰袱鐗囩幓鐠冪殑鏁版嵁銆�"), LOG_COLOR_WARNING);
-		return -1.0f;
+		return 0xFF;
 	}
 
 	std::vector<float> vecGlass1Filtered, vecGlass2Filtered;
@@ -923,7 +924,7 @@
 	m_plcListener.SetAnalyzeCallback([this]() {
 		if (!m_bConnected) {
 			AppendLogLineRichStyled(_T("璁惧鏈繛鎺ワ紝璇峰厛杩炴帴璁惧銆�"), LOG_COLOR_WARNING);
-			return std::array<double, 4>{ -1.0, -1.0, -1.0, -1.0 };
+			return std::array<double, 4>{ 0xFF, 0xFF, 0xFF, 0xFF };
 		}
 
 		std::array<double, 4> result;
@@ -931,10 +932,9 @@
 			result[i] = AnalyzeStoredData(i + 1); // OUT1 ~ OUT4
 		}
 
-		if (std::any_of(result.begin(), result.end(), [](double v) { return v < 0; })) {
-			AppendLogLineRichStyled(_T("鍒嗘瀽澶辫触锛屾煇浜涜緭鍑虹鍙f暟鎹棤鏁堛��"), LOG_COLOR_ERROR);
-			return std::array<double, 4>{ -1.0, -1.0, -1.0, -1.0 };
-		}
+		std::string strProductID;
+		m_plcListener.ReadProductID(strProductID);
+		m_resultStorage.SaveAnalyzeResult(CString(strProductID.c_str()), result);
 
 		CString strLog;
 		strLog.Format(_T("鍒嗘瀽缁撴灉锛歄UT1: %.3f, OUT2: %.3f, OUT3: %.3f, OUT4: %.3f"), result[0], result[1], result[2], result[3]);
@@ -998,11 +998,21 @@
 		RC nRet = SGIF_GetCalcDataALL(DeviceID, value);
 		if (nRet == RC_OK) {
 			for (int i = 0; i < 4; ++i) {
-				m_dOutValues[i] = value[i].Value;
-			}
+				double dNew = value[i].Value;
+				if (fabs(m_dOutValues[i] - dNew) > 1e-6) {
+					m_dOutValues[i] = dNew;
 
-			// 鏇存柊缁戝畾鎺т欢
-			UpdateData(FALSE);
+					CString str;
+					str.Format(_T("%.3f"), dNew);
+
+					switch (i) {
+					case 0: GetDlgItem(IDC_EDIT_OUT1)->SetWindowText(str); break;
+					case 1: GetDlgItem(IDC_EDIT_OUT2)->SetWindowText(str); break;
+					case 2: GetDlgItem(IDC_EDIT_OUT3)->SetWindowText(str); break;
+					case 3: GetDlgItem(IDC_EDIT_OUT4)->SetWindowText(str); break;
+					}
+				}
+			}
 		}
 		else {
 			CString strError;

--
Gitblit v1.9.3