📄 mainfrm.cpp
字号:
lsUpdate[15]=true;
m_wndToolBar.m_wndZoom.SetCurSel(8);
//下面这段代码通过曲线调用文档实现对整个显示的刷新
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
}
void CMainFrame::OnUpdateMenuRange64k(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(nNumInfo[15]=="64K");
}
void CMainFrame::OnMenuRange8k()
{
// TODO: Add your command handler code here
nNumInfo[16]="手动";
nNumInfo[15]="8K";
lsUpdate[15]=true;
m_wndToolBar.m_wndZoom.SetCurSel(5);
//下面这段代码通过曲线调用文档实现对整个显示的刷新
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
}
void CMainFrame::OnUpdateMenuRange8k(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(nNumInfo[15]=="8K");
}
void CMainFrame::OnMenuSetrangeauto()
{
// TODO: Add your command handler code here
if(nNumInfo[16]=="自动"){
nNumInfo[16]="手动";
}
else if(nNumInfo[16]=="手动"){
nNumInfo[16]="自动";
nNumInfo[15]=AutoSetRange();
lsUpdate[15]=true;
}
lsUpdate[16]=true;
//下面这段代码通过曲线调用文档实现对整个显示的刷新
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
}
void CMainFrame::OnUpdateMenuSetrangeauto(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(nNumInfo[16]=="自动");
}
void CMainFrame::OnButtonWhetherauto()
{
// TODO: Add your command handler code here
if(nNumInfo[16]=="自动"){
nNumInfo[16]="手动";
}
else if(nNumInfo[16]=="手动"){
nNumInfo[16]="自动";
nNumInfo[15]=AutoSetRange();
lsUpdate[15]=true;
}
lsUpdate[16]=true;
//下面这段代码通过曲线调用文档实现对整个显示的刷新
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
}
void CMainFrame::OnUpdateButtonWhetherauto(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(nNumInfo[16]=="自动");
}
void CMainFrame::OnMenuSetroileft()
{
// TODO: Add your command handler code here
lsSetROILeft=true;
lsSetROIRight=false;
}
void CMainFrame::OnMenuClearroi()
{
// TODO: Add your command handler code here
lsSetROILeft=false;
lsSetROIRight=false;
lsUpdate[20]=true;
lsUpdate[21]=true;
lsUpdate[22]=true;
nNumInfo[20]="0";
nNumInfo[21]="255";
nNumInfo[22]="256";
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
}
void CMainFrame::OnUpdateMenuClearroi(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(nNumInfo[20]=="0"&&nNumInfo[21]=="255")
{
pCmdUI->Enable(FALSE);
}
else pCmdUI->Enable(TRUE);
}
void CMainFrame::OnButtonRoiset()
{
// TODO: Add your command handler code here
if(!(lsSetROILeft||lsSetROIRight))
{
lsSetROILeft=true;
lsSetROIRight=false;
}
}
void CMainFrame::OnUpdateButtonRoiset(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(lsSetROILeft||lsSetROIRight);
}
int CMainFrame::PickMaxChannel()
{
unsigned int temp=0;
int che=0;
for(int i=atoi(nNumInfo[20]);i<=atoi(nNumInfo[21]);i++)
{
if(temp<m_data[i])
{
che=i;
temp=m_data[i];
}
}
return che;
}
CString CMainFrame::AutoSetRange()
{
CString ret;
unsigned int a=m_data[PickMaxChannel()];
if(a<=256)ret="256";
else if(256<a&&a<=512)ret="512";
else if(512<a&&a<=1024)ret="1K";
else if(1024<a&&a<=2048)ret="2K";
else if(2048<a&&a<=4096)ret="4K";
else if(4096<a&&a<=8192)ret="8K";
else if(8192<a&&a<=16384)ret="16K";
else if(16384<a&&a<=32768)ret="32K";
else if(32768<a&&a<=65536)ret="64K";
return ret;
}
void CMainFrame::OnMenuCursorleft()
{
// TODO: Add your command handler code here
char temp[15];
int c=atoi(nNumInfo[12])-1;
if(c<atoi(nNumInfo[20]))c=atoi(nNumInfo[20]);
_itoa(c,temp,10);
nNumInfo[12]=temp;
lsUpdate[12]=true;
_itoa(m_data[c],temp,10);
nNumInfo[13]=temp;
lsUpdate[13]=true;
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
}
void CMainFrame::OnMenuCursorright()
{
// TODO: Add your command handler code here
char temp[15];
int c=atoi(nNumInfo[12])+1;
if(c>atoi(nNumInfo[21]))c=atoi(nNumInfo[21]);
_itoa(c,temp,10);
nNumInfo[12]=temp;
lsUpdate[12]=true;
_itoa(m_data[c],temp,10);
nNumInfo[13]=temp;
lsUpdate[13]=true;
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
}
void CMainFrame::OnMenuStartcollect()
{
// TODO: Add your command handler code here
cs.Lock();
nNumInfo[10]="开";
cs.Unlock();
lsUpdate[10]=true;
SetTimer(1,1000,NULL);
CMenu *pMenu=AfxGetApp()->m_pMainWnd->GetSystemMenu(FALSE);
int x=pMenu->GetMenuItemCount( );
UINT pID=pMenu->GetMenuItemID(x-1);
pMenu->EnableMenuItem(pID, MF_DISABLED|MF_GRAYED);
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
StartTime = CTime::GetCurrentTime();
CWinThread* pThread=AfxBeginThread(RUNTIME_CLASS(CIOThread),THREAD_PRIORITY_ABOVE_NORMAL,0,0,NULL);
}
void CMainFrame::OnMenuStopcollect()
{
// TODO: Add your command handler code here
cs.Lock();
nNumInfo[10]="关";
cs.Unlock();
lsUpdate[10]=true;
KillTimer(1);//删除计时器
CMenu *pMenu=AfxGetApp()->m_pMainWnd->GetSystemMenu(FALSE);
int x=pMenu->GetMenuItemCount( );
UINT pID=pMenu->GetMenuItemID(x-1);
pMenu->EnableMenuItem(pID, MF_ENABLED);
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
}
void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(!(lsSetROILeft||lsSetROIRight)) //为了数据显示这里开辟了一个缓冲区
//在设置roi区的时候不进行更新
{
for(int i=0;i<=255;i++)
{
cs.Lock();
m_data[i]=data[i]; //这里读取数据
cs.Unlock();
}
}
if(nNumInfo[16]=="自动")
{
nNumInfo[15]=AutoSetRange();
lsUpdate[15]=true;
}
int m=PickMaxChannel();//最大道数显示
char temp[15];
_itoa(m,temp,10);
nNumInfo[18]=temp;
_itoa(m_data[m],temp,10);
nNumInfo[17]=temp;
_itoa(m_data[atoi(nNumInfo[12])],temp,10);//刷新当前光标的计数
nNumInfo[13]=temp;
lsUpdate[18]=true;
lsUpdate[17]=true;
lsUpdate[13]=true;
CurrentTime=CTime::GetCurrentTime();
CTimeSpan elapsedTime = CurrentTime - StartTime;
nNumInfo[8]=_itoa(elapsedTime.GetTotalSeconds(),temp,10);
lsUpdate[8]=true;
cs.Lock();
if((nNumInfo[2]=="时间"&&elapsedTime.GetTotalSeconds()>=atoi(nNumInfo[7]))//预置时间
||(nNumInfo[2]=="计数"&&atoi(nNumInfo[13])>=atoi(nNumInfo[9])))//预置计数
{
nNumInfo[10]="关";
}
if(nNumInfo[10]=="关")
{
lsUpdate[10]=true;
KillTimer(1);//删除计时器
CMenu *pMenu=AfxGetApp()->m_pMainWnd->GetSystemMenu(FALSE);
int x=pMenu->GetMenuItemCount( );
UINT pID=pMenu->GetMenuItemID(x-1);
pMenu->EnableMenuItem(pID, MF_ENABLED);
}
cs.Unlock();
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
CFrameWnd::OnTimer(nIDEvent);
}
void CMainFrame::OnUpdateMenuStartcollect(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
cs.Lock();
pCmdUI->Enable(nNumInfo[10]=="关");
cs.Unlock();
}
void CMainFrame::OnUpdateMenuStopcollect(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
cs.Lock();
pCmdUI->Enable(nNumInfo[10]=="开");
cs.Unlock();
}
void CMainFrame::OnButtonRangedown()
{
// TODO: Add your command handler code here
cs.Lock();
lsUpdate[15]=true;
m_wndToolBar.m_wndZoom.SetCurSel(m_wndToolBar.m_wndZoom.GetCurSel()+1);
CString strTemp;
m_wndToolBar.m_wndZoom.GetWindowText(strTemp);
nNumInfo[15]=strTemp;
lsUpdate[15]=true;
//下面这段代码通过曲线调用文档实现对整个显示的刷新
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
cs.Unlock();
}
void CMainFrame::OnUpdateButtonRangedown(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
cs.Lock();
pCmdUI->Enable(nNumInfo[16]=="手动"&&nNumInfo[15]!="64K");
cs.Unlock();
}
void CMainFrame::OnButtonRangeup()
{
// TODO: Add your command handler code here
cs.Lock();
lsUpdate[15]=true;
m_wndToolBar.m_wndZoom.SetCurSel(m_wndToolBar.m_wndZoom.GetCurSel()-1);
CString strTemp;
m_wndToolBar.m_wndZoom.GetWindowText(strTemp);
nNumInfo[15]=strTemp;
lsUpdate[15]=true;
//下面这段代码通过曲线调用文档实现对整个显示的刷新
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
cs.Unlock();
}
void CMainFrame::OnUpdateButtonRangeup(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
cs.Lock();
pCmdUI->Enable(nNumInfo[16]=="手动"&&nNumInfo[15]!="256");
cs.Unlock();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -