示例#1
0
void CMainFrame::on_video_play()
{
	//if(theApp.m_CCD.m_runstatus==RUNMODE_STOP)
	if(!theApp.m_CCD.m_isinit)
	{
		MessageBox(_T("CCD设备未初始化."),_T("错误"),MB_ICONSTOP);
		return;
	}
	if(theApp.m_CCD.m_runstatus==RUNMODE_PLAY)
		return;
	
	CameraPlay();
	CameraSetLongExpPower(FALSE);
	theApp.m_CCD.m_runstatus=RUNMODE_PLAY;
	CameraSetVideoMessage(WM_CCDVIDEOMSG);
	CameraDisplayEnable(TRUE);
}
示例#2
0
void CMainFrame::on_dev_open_ccd()
{
	BOOL isccdinit=theApp.m_CCD.m_isinit;
	DS_RUNMODE ccd_status=theApp.m_CCD.m_runstatus;
	DS_CAMERA_STATUS ds_err=STATUS_OK;

	//if(ccd_status==RUNMODE_STOP)
	if(!isccdinit)
	{
		if ( STATUS_OK != (ds_err=CameraInit(SnapThreadCallback, theApp.m_CCD.m_resolution, 
			((CMainFrame*)AfxGetMainWnd())->GetActiveView()->m_hWnd, this->m_hWnd)))
		{
			string strret("Init Camera failed!\tError: ");

			switch(ds_err)
			{
				case STATUS_NO_DEVICE_FIND:
					strret+="No device found.";
					break;
				case STATUS_NOT_ENOUGH_SYSTEM_MEMORY:
					strret+="Not enough memory.";
					break;
				case STATUS_PARAMETER_INVALID:
					strret+="Invalid parameter.";
					break;
				default:
					strret+="Other error.";
					break;
			}
			
			MessageBox(strret.c_str(), "Error", MB_OK | MB_ICONSTOP);
			return;
			
		}

		//theApp.m_CCD.m_runstatus=RUNMODE_PLAY;
		theApp.m_CCD.m_isinit=TRUE;
		CameraPlay();
		CameraSetLongExpPower(FALSE);
		theApp.m_CCD.m_runstatus=RUNMODE_PLAY;
		CameraSetVideoMessage(WM_CCDVIDEOMSG);
		CameraDisplayEnable(TRUE);
	}
}
void CDialog3::OnBnClickedPlay()
{
	// TODO: 在此添加控件通知处理程序代码
	if(m_RunMode == RUNMODE_PLAY)
	{
		CameraStop(); //fp in dll
		CameraUnInit();
		this->SetDlgItemTextA(IDC_PLAY,"&Play");
		this->GetDlgItem(IDC_PLAY)->SetFocus();
		this->GetDlgItem(IDC_SAVEFILE)->EnableWindow(FALSE);
		this->GetDlgItem(IDC_SETUP)->EnableWindow(FALSE);
		this->GetDlgItem(IDC_RESOLUTION)->EnableWindow(FALSE);
		this->GetDlgItem(IDC_SAVEIMG)->EnableWindow(FALSE);
		m_RunMode =RUNMODE_STOP;
		return ;
	}
	else
	{
		BYTE CamNum = this->m_MultiCamList.GetCurSel();//取得组合框当前选中项的下标
		if(this->m_MultiCamList.GetCount() == 0)
		{
			CamNum = 0;
		}
		if(R_ROI == m_Resolution)
		{
			CameraSetROI(m_HOff, m_VOff, m_Width, m_Height); //fp in dll ,to set the resolution
		}
		if(STATUS_OK != CameraInit(SnapThreadCallback, 
			                       m_Resolution,
								   m_pDlg->GetDlgItem(IDC_PICTURE)->m_hWnd, //NULL
								   CamNum+1,
								   m_pDlg))
		 { 
			 MessageBox("Init Camera failed","Error",MB_OK|MB_ICONSTOP);
			 return ;
		}

#ifdef ENABLE_READ_SN_DEBUG
		char SN[32];
		CameraReadSN(SN, 32);
		CString sSN;
		sSN = SN;
		
		CString sUserSN = "WWW.D-IMAGE.NET 0755-61860636";
		if (sSN == sUserSN)
		{
		//	MessageBox(x, "SN is OK!", MB_OK | MB_ICONSTOP);
		}
		else //检查不对,重写一次,写之前请确保EEPROM处于可写状态。
		{
			char* pAddr = sUserSN.GetBuffer(32);
			
			CameraWriteSN(pAddr, 32);

			char cNewSn[32];
			CameraReadSN(cNewSn, 32);
			CString sNewSN = cNewSn;

			if (sNewSN == sUserSN )
			{		
				MessageBox("SN Rewrite Ok!", "SN Error", MB_OK | MB_ICONSTOP);
			}
			else
			{
				MessageBox("SN Rewrite Error!", "SN Error", MB_OK | MB_ICONSTOP);
			}
			CameraUnInit();
			return;
		}
#endif
		// Set AWB Window
		{
			INT width = 0;
			INT hight = 0;
			CameraGetImageSize(&width, &hight);
			CameraSetWBWindow(width>>2, hight>>2, width>>1, hight>>1);
		}
		this->SetDlgItemText(IDC_PLAY, "Sto&p");
		this->GetDlgItem(IDC_SAVEFILE)->EnableWindow(TRUE);
		this->GetDlgItem(IDC_SETUP)->EnableWindow(TRUE);
		this->GetDlgItem(IDC_RESOLUTION)->EnableWindow(TRUE);
		this->GetDlgItem(IDC_SAVEIMG)->EnableWindow(TRUE);
		
		/*WM_USERDEFMSG 用户自定义信息,通过CameraSetMessage()函数得到相机
		Message ID;该Message ID含有Wparam和Lparam信息,将它们传递到信息
		响应函数OnVideoMsg()当中进行判断和处理*/
		CameraSetMessage(this->m_hWnd, WM_USERDEFMSG);
		CameraPlay();
		m_iVideoCnt = 0;
		m_iErrorFrames = 0;
		m_RunMode = RUNMODE_PLAY;
		return;
	}
}