From c62dbec7328a8b44e6ec61758e7b8463f2e502dd Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 12 九月 2025 11:58:15 +0800
Subject: [PATCH] Merge branch 'liuyang'
---
SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp | 46 ++++++++++++++++++++++++++--------------------
1 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp b/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
index a3f8234..a2afe06 100644
--- a/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
+++ b/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
@@ -1,4 +1,4 @@
-锘�
+
// 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,17 +924,12 @@
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;
for (int i = 0; i < 4; ++i) {
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 };
}
CString strLog;
@@ -998,11 +994,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