From 15e3d30cdb863752c68ede00b8170a99192046c7 Mon Sep 17 00:00:00 2001 From: YiHui Liu Date: Fri, 3 Jun 2022 12:14:48 +0800 Subject: [PATCH] fix: end judgment --- MCA/MainFrm.cpp | 92 ++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/MCA/MainFrm.cpp b/MCA/MainFrm.cpp index 16ad0b6..2c6776a 100644 --- a/MCA/MainFrm.cpp +++ b/MCA/MainFrm.cpp @@ -263,33 +263,24 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent) if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView)); pDoc->SetModifiedFlag(TRUE); - // 生成随机信号 - int n = rand() % 50 + 25; - pDoc->RandomPeak(pView->m_sSource, n); - - // 更新 - UpdateValue(); - // 判断终止 CString tmp; pView->m_ComboMode.GetWindowText(tmp); - if (tmp == "时间" && pView->m_nTime >= pView->m_nCond) OnStaStop(); - if (tmp == "计数" && pView->m_nTotalCount >= pView->m_nCond) OnStaStop(); + if ((tmp == "时间" && pView->m_nTime >= pView->m_nCond) || (tmp == "计数" && pView->m_nTotalCount >= pView->m_nCond)) + OnStaStop(); + else { + // 生成随机信号 + int n = rand() % 10 + 5; + pDoc->RandomPeak(pView->m_sSource, n); + + // 更新 + UpdateValue(); + } // 修改坐标轴 pView->m_ComboAxis.GetWindowText(tmp); - if (tmp == "对数") { - m_bAutoFlag = FALSE; - pView->m_sAxisMode = "Log"; - pView->m_sRangeMode = "Auto"; - m_bLinearFlag = TRUE; - m_bLogFlag = FALSE; - } - else { - pView->m_sAxisMode = "Linear"; - m_bLinearFlag = FALSE; - m_bLogFlag = TRUE; - } + if (tmp == "对数") OnAxisLog(); + else OnAxisLinear(); pDoc->UpdateAllViews(NULL); CFrameWnd::OnTimer(nIDEvent); @@ -324,29 +315,6 @@ BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) return CFrameWnd::PreTranslateMessage(pMsg); } -void CMainFrame::OnStaStart() -{ - if (pDoc == nullptr) pDoc = (CMCADoc*)GetActiveDocument(); - if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView)); - - // 重置结束条件 - pView->m_nT0 = GetMilliTime(); - // 设置状态 - m_bStartFlag = FALSE; - m_bStopFlag = TRUE; - m_bClearFlag = FALSE; - pView->SetCond(FALSE); - // 获取屏幕值至变量 - pView->UpdateData(TRUE); - // 设置更新 - SetTimer(1, 100, NULL); -} - -void CMainFrame::OnUpdateStaStart(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(m_bStartFlag); -} - void CMainFrame::OnOptOpen() { if (pDoc == nullptr) pDoc = (CMCADoc*)GetActiveDocument(); @@ -366,11 +334,19 @@ void CMainFrame::OnOptOpen() try { + // 获取时间 std::getline(ifs, line); pView->m_nTime = 0; pView->m_nT0 = GetMilliTime() - std::stof(line); + + // 获取源 std::getline(ifs, line); pView->m_sSource = line.c_str(); + if (pView->m_sSource == "Cs137") OnSimuCs(); + else if (pView->m_sSource == "Co60") OnSimuCo(); + else OnSimuNa(); + + // 获取计数 while (std::getline(ifs, line)) { std::stringstream ss(line); @@ -381,8 +357,11 @@ void CMainFrame::OnOptOpen() cnt += 1; } for (int i = 1; i < 1024; i++) pDoc->m_nChannelCount[i] = count[i]; + + // 其他设置 m_bClearFlag = TRUE; pView->m_sRangeMode = "Auto"; + pView->m_sSmoothType = "Origin"; UpdateValue(); pDoc->UpdateAllViews(NULL); } @@ -414,6 +393,29 @@ void CMainFrame::OnOptSave() pDoc->SetModifiedFlag(FALSE); } +void CMainFrame::OnStaStart() +{ + if (pDoc == nullptr) pDoc = (CMCADoc*)GetActiveDocument(); + if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView)); + + // 重置结束条件 + pView->m_nT0 = GetMilliTime(); + // 设置状态 + m_bStartFlag = FALSE; + m_bStopFlag = TRUE; + m_bClearFlag = FALSE; + pView->SetCond(FALSE); + // 获取屏幕值至变量 + pView->UpdateData(TRUE); + // 设置更新 + SetTimer(1, 20, NULL); +} + +void CMainFrame::OnUpdateStaStart(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(m_bStartFlag); +} + void CMainFrame::OnStaStop() { // 设置状态 @@ -532,6 +534,8 @@ void CMainFrame::OnAxisLog() if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView)); pView->m_sAxisMode = (CString)"Log"; + pView->m_sRangeMode = "Auto"; + m_bAutoFlag = FALSE; m_bLinearFlag = TRUE; m_bLogFlag = FALSE; }