From d256f84735b75529a640ca61384c3c55b557fce9 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期一, 12 五月 2025 16:22:57 +0800
Subject: [PATCH] 1. 修复日志时顺问题 2. 解决远程路径不存在编译报错的问题
---
SourceCode/Bond/Servo/Servo.vcxproj | 6 ++++--
SourceCode/Bond/Servo/LogDlg.cpp | 30 +++++++++++++++++++-----------
SourceCode/Bond/Servo/LogDlg.h | 1 -
SourceCode/Bond/Servo/ServoDlg.cpp | 2 +-
4 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/SourceCode/Bond/Servo/LogDlg.cpp b/SourceCode/Bond/Servo/LogDlg.cpp
index 04a2781..74fe0f2 100644
--- a/SourceCode/Bond/Servo/LogDlg.cpp
+++ b/SourceCode/Bond/Servo/LogDlg.cpp
@@ -40,7 +40,6 @@
BEGIN_MESSAGE_MAP(CLogDlg, CDialogEx)
ON_WM_CTLCOLOR()
ON_WM_SIZE()
- ON_WM_TIMER()
ON_WM_DESTROY()
ON_WM_CLOSE()
ON_NOTIFY(BLBUTTON_MENU_ITEM_CLICKED, IDC_BUTTON_LEVEL, &CLogDlg::OnButtonLevelMenuClicked)
@@ -106,7 +105,6 @@
BOOL CLogDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
- SetTimer(1, 3000, nullptr);
// 缓存
@@ -160,7 +158,25 @@
m_logEdit.SetLimitText(-1);
- //InitRxWindow();
+ std::thread([this]() {
+ constexpr int nMaxWaitMs = 3000; // 最多等待 3 秒
+ constexpr int nStepMs = 1; // 每次等待 1ms
+ int nElapsed = 0;
+
+ while (nElapsed < nMaxWaitMs) {
+ if (theApp.m_model.getObservable() != nullptr) {
+ InitRxWindow();
+ return;
+ }
+ std::this_thread::sleep_for(std::chrono::milliseconds(nStepMs));
+ nElapsed += nStepMs;
+ }
+
+ // 超时也可以发消息记录下日志
+ TRACE(_T("InitRxWindow 超时,未执行\n"));
+ }).detach();
+
+
Resize();
@@ -173,14 +189,6 @@
CDialogEx::OnSize(nType, cx, cy);
if (GetDlgItem(IDC_EDIT_LOG) == nullptr) return;
Resize();
-}
-
-void CLogDlg::OnTimer(UINT_PTR nIDEvent)
-{
- if (1 == nIDEvent) {
- KillTimer(1);
- InitRxWindow();
- }
}
void CLogDlg::Resize()
diff --git a/SourceCode/Bond/Servo/LogDlg.h b/SourceCode/Bond/Servo/LogDlg.h
index ba35903..29acf5a 100644
--- a/SourceCode/Bond/Servo/LogDlg.h
+++ b/SourceCode/Bond/Servo/LogDlg.h
@@ -51,7 +51,6 @@
public:
virtual BOOL OnInitDialog();
afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg void OnDestroy();
afx_msg void OnClose();
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj b/SourceCode/Bond/Servo/Servo.vcxproj
index 421d42a..648de13 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj
+++ b/SourceCode/Bond/Servo/Servo.vcxproj
@@ -133,8 +133,10 @@
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
- <Command>
- </Command>
+ <Command>if exist "\\DESKTOP-IODBVIQ\Servo\Debug\" (
+ xcopy /Y /D "$(OutDir)*.exe" "\\DESKTOP-IODBVIQ\Servo\Debug\"
+ xcopy /Y /D "$(OutDir)*.pdb" "\\DESKTOP-IODBVIQ\Servo\Debug\"
+)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index b0fb6cd..0a15903 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -840,7 +840,7 @@
{
ASSERT(0 <= index && index < 4);
static CWnd* pPages[] = { m_pPageGraph1, m_pPageGraph2, m_pPageGraph3, m_pPageGraph4 };
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < 4; i++) {
pPages[i]->ShowWindow(i == index ? SW_SHOW : SW_HIDE);
}
}
--
Gitblit v1.9.3