fix: end judgment

This commit is contained in:
liuyihui 2022-06-03 12:14:48 +08:00
parent 2e03506916
commit 15e3d30cdb

View File

@ -263,33 +263,24 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent)
if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView)); if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
pDoc->SetModifiedFlag(TRUE); pDoc->SetModifiedFlag(TRUE);
// 生成随机信号
int n = rand() % 50 + 25;
pDoc->RandomPeak(pView->m_sSource, n);
// 更新
UpdateValue();
// 判断终止 // 判断终止
CString tmp; CString tmp;
pView->m_ComboMode.GetWindowText(tmp); pView->m_ComboMode.GetWindowText(tmp);
if (tmp == "时间" && pView->m_nTime >= pView->m_nCond) OnStaStop(); if ((tmp == "时间" && pView->m_nTime >= pView->m_nCond) || (tmp == "计数" && pView->m_nTotalCount >= pView->m_nCond))
if (tmp == "计数" && pView->m_nTotalCount >= pView->m_nCond) OnStaStop(); OnStaStop();
else {
// 生成随机信号
int n = rand() % 10 + 5;
pDoc->RandomPeak(pView->m_sSource, n);
// 更新
UpdateValue();
}
// 修改坐标轴 // 修改坐标轴
pView->m_ComboAxis.GetWindowText(tmp); pView->m_ComboAxis.GetWindowText(tmp);
if (tmp == "对数") { if (tmp == "对数") OnAxisLog();
m_bAutoFlag = FALSE; else OnAxisLinear();
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;
}
pDoc->UpdateAllViews(NULL); pDoc->UpdateAllViews(NULL);
CFrameWnd::OnTimer(nIDEvent); CFrameWnd::OnTimer(nIDEvent);
@ -324,29 +315,6 @@ BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
return CFrameWnd::PreTranslateMessage(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() void CMainFrame::OnOptOpen()
{ {
if (pDoc == nullptr) pDoc = (CMCADoc*)GetActiveDocument(); if (pDoc == nullptr) pDoc = (CMCADoc*)GetActiveDocument();
@ -366,11 +334,19 @@ void CMainFrame::OnOptOpen()
try try
{ {
// 获取时间
std::getline(ifs, line); std::getline(ifs, line);
pView->m_nTime = 0; pView->m_nTime = 0;
pView->m_nT0 = GetMilliTime() - std::stof(line); pView->m_nT0 = GetMilliTime() - std::stof(line);
// 获取源
std::getline(ifs, line); std::getline(ifs, line);
pView->m_sSource = line.c_str(); 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)) while (std::getline(ifs, line))
{ {
std::stringstream ss(line); std::stringstream ss(line);
@ -381,8 +357,11 @@ void CMainFrame::OnOptOpen()
cnt += 1; cnt += 1;
} }
for (int i = 1; i < 1024; i++) pDoc->m_nChannelCount[i] = count[i]; for (int i = 1; i < 1024; i++) pDoc->m_nChannelCount[i] = count[i];
// 其他设置
m_bClearFlag = TRUE; m_bClearFlag = TRUE;
pView->m_sRangeMode = "Auto"; pView->m_sRangeMode = "Auto";
pView->m_sSmoothType = "Origin";
UpdateValue(); UpdateValue();
pDoc->UpdateAllViews(NULL); pDoc->UpdateAllViews(NULL);
} }
@ -414,6 +393,29 @@ void CMainFrame::OnOptSave()
pDoc->SetModifiedFlag(FALSE); 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() void CMainFrame::OnStaStop()
{ {
// 设置状态 // 设置状态
@ -532,6 +534,8 @@ void CMainFrame::OnAxisLog()
if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView)); if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
pView->m_sAxisMode = (CString)"Log"; pView->m_sAxisMode = (CString)"Log";
pView->m_sRangeMode = "Auto";
m_bAutoFlag = FALSE;
m_bLinearFlag = TRUE; m_bLinearFlag = TRUE;
m_bLogFlag = FALSE; m_bLogFlag = FALSE;
} }