⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myworkview.cpp

📁 VC6开发的用于进行色谱分析的示例
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	// TODO: Add your command handler code here
		if (!nTime)
	{
	CMenu *pMenu,*SubMenu;
	pMenu=AfxGetMainWnd()->GetMenu();
	SubMenu=pMenu->GetSubMenu(2);
	SubMenu->CheckMenuItem(IDB_TIME,MF_CHECKED);
	nTime=true;
	Invalidate();

	}
	else 
	{
    CMenu *pMenu,*SubMenu;
	pMenu=AfxGetMainWnd()->GetMenu();
	SubMenu=pMenu->GetSubMenu(2);
	SubMenu->CheckMenuItem(IDB_TIME,MF_UNCHECKED);
	nTime=false;
	Invalidate();
	}


	
  }

void CMyWorkView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	switch (nIDEvent)
	{
	
//	case 1: Invalidate(); break;
	case 2: Invalidate(); break;
//	case 3: ADcollect(); break;
	default: break;
	}

	CView::OnTimer(nIDEvent);
}

void CMyWorkView::OnSezi() 
{
	// TODO: Add your command handler code here
	
	CADSetup dlg;
    if (dlg.DoModal()==IDOK)
	{ 
	  //使采集菜单初始状态
	CMenu *pMenu1,*SubMenu1;
	pMenu1=AfxGetMainWnd()->GetMenu();
	SubMenu1=pMenu1->GetSubMenu(6);
	SubMenu1->CheckMenuItem(IDB_START,MF_UNCHECKED);
	 
	CMenu *pMenu2,*SubMenu2;
	pMenu2=AfxGetMainWnd()->GetMenu();
	SubMenu2=pMenu2->GetSubMenu(6);
	SubMenu2->CheckMenuItem(IDB_PAUSE,MF_UNCHECKED);

		Invalidate();
	   stoping=false;
	   starting=false;
	// 获得在设置对话框中的数据;	
	 m_main_spz=dlg.m_view_cpz;
	 m_main_ldx=dlg.m_view_ldx;
	 m_main_gdx=dlg.m_view_gdx;
	 m_main_jcq=dlg.m_view_jcq;
	 m_main_jyl=dlg.m_view_jyl;
	 m_main_cybc=dlg.m_view_cybc;
	 m_main_cname=dlg.m_view_cname;
	 m_main_gain=dlg.m_view_gain;
	 m_main_time=dlg.m_cytime;
	 m_main_channel=dlg.m_view_channel;
	 m_main_ratio=dlg.m_view_ratio;
	
  //获取数据库中的信息,在主界面上显示;
	CDatabase m_db;
	m_Set= new Set1(&m_db);
    m_Set->m_strFilter="name_c='"+m_main_cname+"' ";
	if (!m_Set->IsOpen())
	{
	m_Set->Open();
	m_Set->MoveFirst();	
	}
	GetDocument()->m_cname=m_Set->m_name_c;
	GetDocument()->m_ename=m_Set->m_name_e;
	GetDocument()->m_gnzz=m_Set->m_herbal_gnzz;
	GetDocument()->m_zwxt=m_Set->m_herbal_zwxt;
	GetDocument()->m_picpath=m_Set->m_herbal_pathname;
	GetDocument()->UpdateAllViews(NULL);
	}

}

void CMyWorkView::OnStart() 
{
	// TODO: Add your command handler code here
	//色谱采集开始,获取中药材名使主视图显示属性信息和图片信息;
    GetDocument()->open_flag=false ;
	if(!starting&&!stoping)
	{
	stoping=false;
	CMenu *pMenu1,*SubMenu1;
	pMenu1=AfxGetMainWnd()->GetMenu();
	SubMenu1=pMenu1->GetSubMenu(6);
	SubMenu1->CheckMenuItem(IDB_START,MF_CHECKED);
	 
	CMenu *pMenu2,*SubMenu2;
	pMenu2=AfxGetMainWnd()->GetMenu();
	SubMenu2=pMenu2->GetSubMenu(6);
	SubMenu2->CheckMenuItem(IDB_PAUSE,MF_UNCHECKED);

	ADCollect();
//	Invalidate();
	}
	else if (!starting&&stoping)
	{
    MessageBox("请重新设置A/D采集卡,再进行采集!","重新设置!",MB_ICONINFORMATION);
    CMenu *pMenu1,*SubMenu1;
	pMenu1=AfxGetMainWnd()->GetMenu();
	SubMenu1=pMenu1->GetSubMenu(6);
	SubMenu1->CheckMenuItem(IDB_START,MF_CHECKED);
	 
	CMenu *pMenu2,*SubMenu2;
	pMenu2=AfxGetMainWnd()->GetMenu();
	SubMenu2=pMenu2->GetSubMenu(6);
	SubMenu2->CheckMenuItem(IDB_PAUSE,MF_UNCHECKED);
	}
}



void CMyWorkView::ADCollect()
{
	//TODO: Add your command handler code here
	
  	if( W_711B_Initial( CARD_1 , 0x300) != ERR_NoError ) 
        printf( "PCL-711B Initialization Error !!\n" );
	
	//参数声明部分:
//	int status=2;
	int ad_ch_no,irq_no;//中断和通道
	int ad_count;//计数器采集的总点数
	int c1,c2;//8253两个初值
    
	//确定电压增益:
	if (m_main_gain=="-5(V)--5(V)")
		ad_gain=0;
    else	if (m_main_gain=="-2.5(V)--2.5(V)")
		ad_gain=1;
    else if (m_main_gain=="-1.25(V)--1.25(V)")
		ad_gain=2;
    else	if (m_main_gain=="-0.625(V)--0.625(V)")
		ad_gain=3;
    else if (m_main_gain=="-0.3125(V)--0.3125(V)")
		ad_gain=4;
    else { 
	      MessageBox("A/D采集卡初始化设置不正确,请重新设置!","设置失败!",MB_ICONINFORMATION);
          return;
   }
    
	//参数初始化:
	
	//采集画曲线;
//	starting=true;
	
	//初始化chunnal;
	ad_ch_no=m_main_channel;
	
	//初始化中断
	irq_no=7;

	//初始化采集频率
	int real_ratio;
	real_ratio=m_main_ratio*10;
    
	//初始化采集总点数:
	ad_count=real_ratio*m_main_time*60;
	
	//初始化计数器
    
	c2=100;
	c1=int(2*1000000/(c2*real_ratio));
	
	div_t div_count;
	div_count=div(2*1000000,c2*real_ratio);
	if (div_count.rem>0)
		div_label=true;
   
	/////////////////////////////////////////////////////////

	if(!stoping)
	 {
   //   if  (m_con<=(m_main_ratio*10*60*m_main_time)/100)
	//初始化采集次数,频率,中断等
//	{   	
		if( W_711B_Initial( CARD_1 , 0x300) != ERR_NoError ) 
        printf( "PCL-711B Initialization Error !!\n" );
		 
		 if( W_711B_AD_INT_Start( ad_ch_no,ad_gain,irq_no,ad_count,ad_buffer1,c1,c2) != ERR_NoError)
	   MessageBox("时钟中断设置出错!","设置失败!",MB_ICONINFORMATION);
         starting=true;		
		 Invalidate();
	}
    else
	{	
        W_711B_AD_INT_Stop( &real_count );
	
	}

}



void CMyWorkView::OnPause() 
{
	// TODO: Add your command handler code here
    //////////////如果曾经采集过
	if (starting)
	{
	finishing=true;	  
	stoping=true;
	starting=false;
	doc_m=m;/////////////////////////
	m=0;
    W_711B_AD_INT_Stop( &real_count );
	KillTimer(2);
    CMenu *pMenu2,*SubMenu2;
	pMenu2=AfxGetMainWnd()->GetMenu();
	SubMenu2=pMenu2->GetSubMenu(6);
	SubMenu2->CheckMenuItem(IDB_PAUSE,MF_CHECKED);
	 
	CMenu *pMenu1,*SubMenu1;
	pMenu1=AfxGetMainWnd()->GetMenu();
	SubMenu1=pMenu1->GetSubMenu(6);
	SubMenu1->CheckMenuItem(IDB_START,MF_UNCHECKED);

	KillTimer(2);
	///////后增添
	MessageBox("你已中途停止采集!","停止采集!",MB_ICONINFORMATION);
	}  	///////////
   }



void CMyWorkView::OnSavedata() 
{
	// TODO: Add your command handler code here
		  if (finishing)
	{
      	//获取系统时间:
	    CTime datetime;
		datetime=CTime::GetCurrentTime();
		CString number;
		number=datetime.Format("%y%m%d-%H%M%S");
        CString strn;
		strn=m_main_cname+number;
		m_main_num=strn;  
		CString m_path;
		m_path=strn+".txt";
	    CString Bmpname1;
	    CFileDialog dlg(FALSE,_T("TXT"),_T(m_path),OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,_T("文本文件(*.TXT)|*.TXT|"));
	  if(IDOK==dlg.DoModal()) 
		{
	     Bmpname1.Format("%s",dlg.GetFileName());
	     CFile file(Bmpname1,CFile::modeCreate|CFile::modeWrite);

	     CArchive ar(&file,CArchive::store);
	  //  CFile *fp=ar.GetFile();
        if (ar.IsStoring())
		{
		// TODO: add storing code here
		//写入色谱数据
	    ar<<doc_m;
	//	GetDocument()->doc_number=doc_m;
		for (int sn_doc=0;sn_doc<doc_m;sn_doc++)
		{
			ar<< ad_data[sn_doc];
		//	GetDocument()->doc_data[sn_doc]=ad_data[sn_doc];
		}
		finishing=false;
		
		}
		}
        CDatabase db1;
		m_set3=new Set2(&db1);
		
		if(!m_set3->IsOpen())
			m_set3->Open();
		
		m_set3->AddNew();
		
		m_set3->m_herbal_cname=m_main_cname;
		m_set3->m_herbal_cybc=m_main_cybc;
		m_set3->m_herbal_gdx=m_main_gdx;
		m_set3->m_herbal_ldx=m_main_ldx;
		m_set3->m_herbal_jyl=m_main_jyl;
		m_set3->m_herbal_jcq=m_main_jcq;
		m_set3->m_herbal_spz=m_main_spz;
		
		m_set3->m_herbal_datetime=datetime;
		m_main_num=strn;
		m_set3->m_herbal_number=m_main_num;// 存序列号
		m_set3->Update();
		m_set3->Requery();
  
		MessageBox("你已成功添加到数据库中","成功!",MB_ICONINFORMATION);
	    CDataSaveDialog dlg_D;
	    dlg_D.m_view_num=strn;
		dlg_D.DoModal();
	   }
	   else 
		   MessageBox("数据已经存储或没有数据!","存储数据失败!",MB_ICONINFORMATION);


}





void CMyWorkView::OnPicEmplify() 
{
	// TODO: Add your command handler code here
    mask=true;
	circle_num=circle_num+1;
	if (circle_num<=4)
	{
	switch (circle_num)
	{
	case 0: 
		{
			advance=1;
			Invalidate();
			break;
		}
	case 1:
		{  advance=2; 
		   Invalidate();
		   break;
		}
	case 2:
		{
			advance=4; 
			Invalidate();
			break;
		}
	case 3: 
		{
			advance=8; 
			Invalidate();
			break;
		}
	case 4: 
		{
			advance=16; 
			Invalidate();
			break;
		}

		}
	}
	else 
	{
		circle_num=4;
		advance=16;
		Invalidate();
	}
}

void CMyWorkView::OnPicShrink() 
{
	// TODO: Add your command handler code here
	mask=true;
	circle_num=circle_num-1;
	if (circle_num>=1)
	{
	switch (circle_num)
	{
	  case 0: 
		  {
			  advance=1; 
			  Invalidate();
			  break;
		  }
	  case 1:
		  {
			  advance=2; 
			  Invalidate();
			  break;
		  }
	  case 2: 
		  {
			  advance=4; 
			  Invalidate();
			  break;
		  }
	  case 3:  
		  {
			  advance=8; 
			  Invalidate();
			  break;
		  }
	  case 4:  
		  {
			  advance=16; 
			  Invalidate();
			  break;
		  }
	}
	}
	else 
	{
		circle_num=0;
		advance=1;
		Invalidate();
	}
}

void CMyWorkView::OnFour() 
{
	// TODO: Add your command handler code here
	advance=4;
	CMenu *pMenu2,*SubMenu2;
	pMenu2=AfxGetMainWnd()->GetMenu();
	SubMenu2=pMenu2->GetSubMenu(8);
    SubMenu2->CheckMenuItem(ID_ONE,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_TWO,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_FOUR,MF_CHECKED);
	SubMenu2->CheckMenuItem(ID_EIGHT,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_SIXTTEEN,MF_UNCHECKED);
	Invalidate();
}

void CMyWorkView::OnOne() 
{
	// TODO: Add your command handler code here
	advance=1;
	CMenu *pMenu2,*SubMenu2;
	pMenu2=AfxGetMainWnd()->GetMenu();
	SubMenu2=pMenu2->GetSubMenu(8);
	SubMenu2->CheckMenuItem(ID_ONE,MF_CHECKED);
	SubMenu2->CheckMenuItem(ID_TWO,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_FOUR,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_EIGHT,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_SIXTTEEN,MF_UNCHECKED);
	Invalidate();
}

void CMyWorkView::OnSixtteen() 
{
	// TODO: Add your command handler code here
	advance=16;
	 CMenu *pMenu2,*SubMenu2;
	pMenu2=AfxGetMainWnd()->GetMenu();
	SubMenu2=pMenu2->GetSubMenu(8);
	SubMenu2->CheckMenuItem(ID_ONE,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_TWO,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_FOUR,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_EIGHT,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_SIXTTEEN,MF_CHECKED);
	Invalidate();
}

void CMyWorkView::OnTwo() 
{
	// TODO: Add your command handler code here
	advance=2;
	CMenu *pMenu2,*SubMenu2;
	pMenu2=AfxGetMainWnd()->GetMenu();
	SubMenu2=pMenu2->GetSubMenu(8);
    SubMenu2->CheckMenuItem(ID_ONE,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_TWO,MF_CHECKED);
	SubMenu2->CheckMenuItem(ID_FOUR,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_EIGHT,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_SIXTTEEN,MF_UNCHECKED);
	Invalidate();
}

void CMyWorkView::OnEight() 
{
	// TODO: Add your command handler code here
	advance=8;
	CMenu *pMenu2,*SubMenu2;
	pMenu2=AfxGetMainWnd()->GetMenu();
	SubMenu2=pMenu2->GetSubMenu(8);
    SubMenu2->CheckMenuItem(ID_ONE,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_TWO,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_FOUR,MF_UNCHECKED);
	SubMenu2->CheckMenuItem(ID_EIGHT,MF_CHECKED);
	SubMenu2->CheckMenuItem(ID_SIXTTEEN,MF_UNCHECKED);
	Invalidate();
}

void CMyWorkView::OnYTwo() 
{
	// TODO: Add your command handler code here
	y_emply=2;
	Invalidate();
}

void CMyWorkView::OnYEight() 
{
	// TODO: Add your command handler code here
	y_emply=8;
	Invalidate();
}

void CMyWorkView::OnYFour() 
{
	// TODO: Add your command handler code here
    y_emply=4;
	Invalidate();	
}

void CMyWorkView::OnYOne() 
{
	// TODO: Add your command handler code here
	y_emply=1;
	Invalidate();
}

void CMyWorkView::OnFileSave() 
{
	// TODO: Add your command handler code here
    OnSavedata();

  }

void CMyWorkView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	// TODO: Add your specialized code here and/or call the base class
   	int gigi;
	gigi=GetDocument()->doc_number;
	for (int nn=0; nn< gigi;nn++)
	ad_buffer2[nn]=GetDocument()->doc_data[nn];
	Invalidate();
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -