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

📄 resourcesdlg.h

📁 BCAM 1394 Driver
💻 H
字号:
//-----------------------------------------------------------------------------
//  (c) 2002 by Basler Vision Technologies
//  Section:  Vision Components
//  Project:  BCAM
//  $Header: resourcesdlg.h, 8, 23.05.2006 10:02:53, Koschorreck, L.$
// Author: Margret Albrecht
// Date: 29.08.2002
//-----------------------------------------------------------------------------
/**
\file     resourcesdlg.h
*
\brief   Declaration and definition of a dialog showing the resources of an adapter
*
*/
//-----------------------------------------------------------------------------


#if !defined(AFX_RESOURCESDLG_H__D1547850_F457_4A5B_B249_3C7A9710984C__INCLUDED_)
#define AFX_RESOURCESDLG_H__D1547850_F457_4A5B_B249_3C7A9710984C__INCLUDED_
#include "BcamAdapter.h"
#include "Atlmisc.h"
#include <atlddx.h>

#define fromDialog TRUE 
#define toDialog FALSE


//------------------------------------------------------------------------------
// class CChannelsAvail
// Author: 
// Date: 06.09.2002
//------------------------------------------------------------------------------
/**
* \brief   shows the available channels
*
* the channels are displayed as a bar of 64 rectangles with different colors for 
* free DCAM channels, other free channels, occupied DCAM channels and occupied 
* other channels
* 
* 
*/
//------------------------------------------------------------------------------
class CChannelsAvail : public CWindowImpl< CChannelsAvail >
{
	BEGIN_MSG_MAP( CChannelsAvail )
		MESSAGE_HANDLER( WM_PAINT, OnPaint )
	END_MSG_MAP()
		
//------------------------------------------------------------------------------
// LRESULT OnPaint( UINT, WPARAM, LPARAM, BOOL& ) 
// Author: 
// Date: 06.09.2002
//------------------------------------------------------------------------------
/**
 * fill the rectangles with colors, distinguishing DCAM and non DCAM, free and occupied
 *
 * \return   0 
 *
 */
//------------------------------------------------------------------------------
	LRESULT OnPaint( UINT, WPARAM, LPARAM, BOOL& )
	{
		PAINTSTRUCT ps;
		HDC hDC = GetDC();
		BeginPaint( &ps );
		RECT client;
		GetClientRect(&client);
		
		RECT channelRect = client;
		channelRect.left = 1; channelRect.right = 3; 
		RECT rect = client; rect.top = 0;  rect.right = 3*64+1;
		
		CBrush freeDCAMbrush,occupiedDCAMbrush,occupiedbrush,freebrush,backgroundbrush;
		freeDCAMbrush.CreateSolidBrush(RGB(0x99,0xcc,0xff));
		occupiedDCAMbrush.CreateSolidBrush(RGB(0xff,0xcc,0x99));
		freebrush.CreateSolidBrush(RGB(0x00,0xff,0x00));
		occupiedbrush.CreateSolidBrush(RGB(0xff,0x00,0x00));
		backgroundbrush.CreateSolidBrush(RGB(0xee,0xee,0xee));
		::FillRect(hDC, &rect,(HBRUSH)backgroundbrush);
		
		for (long ch = 0; ch < 64; ch++)
		{
			if (ch < 48)
				if (m_CannelsAvail[ch])
					::FillRect(hDC, &channelRect,(HBRUSH)freebrush);
				else
					::FillRect(hDC, &channelRect,(HBRUSH)occupiedbrush);
			else
				if ((m_CannelsAvail[ch]))
					::FillRect(hDC,&channelRect,(HBRUSH)freeDCAMbrush);
				else
					::FillRect(hDC, &channelRect,(HBRUSH)occupiedDCAMbrush);
			channelRect.left +=3;
			channelRect.right +=3;
		}
		
		
		EndPaint( &ps );
		return 0;
	}
	
	CBcamAdapter::ISOCHANNELSET m_CannelsAvail;
	
};


//------------------------------------------------------------------------------
// class CResourcesDlg
// Author: 
// Date: 29.08.2002
//------------------------------------------------------------------------------
/**
* \brief   dialog showing the properties of a device node
*  
* 
* 
*/
//------------------------------------------------------------------------------
class CResourcesDlg : public CDialogImpl<CResourcesDlg>,
public CWinDataExchange<CResourcesDlg>
{
public:
	enum { IDD = IDD_RESOURCES};
	
	BEGIN_MSG_MAP(CResourcesDlg)
	MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
	COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
	COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
	COMMAND_HANDLER(IDC_SPEED_S100, BN_CLICKED, OnClickedRadio)
	COMMAND_HANDLER(IDC_SPEED_S200, BN_CLICKED, OnClickedRadio)
	COMMAND_HANDLER(IDC_SPEED_S400, BN_CLICKED, OnClickedRadio)
	COMMAND_HANDLER(IDC_SPEED_S800, BN_CLICKED, OnClickedRadio)
	COMMAND_HANDLER(IDC_RESOURCES_UPDATE, BN_CLICKED, OnClickedResources_update)
	END_MSG_MAP()
	//------------------------------------------------------------------------------
	// CResourcesDlg::CResourcesDlg(CBcamAdapter *adapter) 
	// Author: 
	// Date: 29.08.2002
	//------------------------------------------------------------------------------
	/**
	* retrieves the available resources from the adapter
	*
	* \param    adapter  IEEE1394 adapter card
	*/
	//------------------------------------------------------------------------------
	CResourcesDlg::CResourcesDlg(CBcamAdapter *adapter )
	{
		
		m_Adapter = adapter;
		
		m_Speed = TR_400;
		m_Adapter->Open(m_Adapter->GetDeviceName());
		m_BytesPerPacket = m_Adapter->ResourcesAvailable(m_Speed);
		CBcamAdapter::ISOCHANNELSET bits;
		m_NumChannelsAvailable = m_Adapter->NumChannelAvailable(bits );
		m_Adapter->Close();
		m_ChannelsAvailBitmap.m_CannelsAvail = bits;
		m_MaxBandwith[TR_100] = 1032;
		m_MaxBandwith[TR_200] = 2184;
		m_MaxBandwith[TR_400] = 4912;
		m_MaxBandwith[TR_800] = 9828;
	}
	
	//------------------------------------------------------------------------------
	// LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 
	// Author: 
	// Date: 03.09.2002
	//------------------------------------------------------------------------------
	/**
	* Let the controls show the available resources
	*
	*/
	//------------------------------------------------------------------------------
	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		m_BandwidthVailableCtrl.Attach( GetDlgItem( IDC_BANDWIDTH_AVAIL ) );
		//subclass the picture control so that CChannelsAvail gets first crack at the control's messages. 
		m_ChannelsAvailBitmap.SubclassWindow( GetDlgItem( IDC_AVAILABLECHANNELS ) );
		
		m_BandwidthVailableCtrl.SetStep( 1 );
		m_BandwidthVailableCtrl.SetRange( 0, m_MaxBandwith[m_Speed] );
		m_BandwidthVailableCtrl.SetBarColor(RGB(0x00,0xff,0x00));
		m_BandwidthVailableCtrl.SetPos( m_BytesPerPacket );
		CenterWindow(GetParent());
		DoDataExchange(toDialog);
		
		CClientDC aDC((HWND)m_ChannelsAvailBitmap);
		ShowWindow(SW_HIDE);
		
		return TRUE;
	}
	
	
	
	
	//------------------------------------------------------------------------------
	// LRESULT OnClickedRadio(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 
	// Author: 
	// Date: 03.09.2002
	//------------------------------------------------------------------------------
	/**
	* Set the selected speed and get the available Resources
	*
	* \return 0   
	*
	*/
	//------------------------------------------------------------------------------
	LRESULT OnClickedRadio(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		DoDataExchange(fromDialog);
		m_Adapter->Open(m_Adapter->GetDeviceName());
		m_BytesPerPacket = m_Adapter->ResourcesAvailable(m_Speed);
		m_Adapter->Close();
		m_BandwidthVailableCtrl.SetRange( 0, m_MaxBandwith[m_Speed] );
		m_BandwidthVailableCtrl.SetPos( m_BytesPerPacket );
		DoDataExchange(toDialog);
		return 0;
	}
	
	//------------------------------------------------------------------------------
	// LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 
	// Author: 
	// Date: 03.09.2002
	//------------------------------------------------------------------------------
	/**
	* End the Dialog
	*
	*/
	//------------------------------------------------------------------------------
	LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		ShowWindow(SW_HIDE);
		return 0;
	}
	
	//------------------------------------------------------------------------------
	// LRESULT OnClickedResources_update(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 
	// Author: 
	// Date: 04.09.2002
	//------------------------------------------------------------------------------
	/**
	* retrieve the available resources again 
	*
	* \return    0
	*
	*/
	//------------------------------------------------------------------------------
	LRESULT OnClickedResources_update(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		CBcamAdapter::ISOCHANNELSET bits;
		m_Adapter->Open(m_Adapter->GetDeviceName());
		m_NumChannelsAvailable = m_Adapter->NumChannelAvailable(bits);
		m_BytesPerPacket = m_Adapter->ResourcesAvailable(m_Speed);
		m_Adapter->Close();
		m_BandwidthVailableCtrl.SetRange( 0, m_MaxBandwith[m_Speed] );
		m_BandwidthVailableCtrl.SetPos( m_BytesPerPacket );
		m_ChannelsAvailBitmap.m_CannelsAvail = bits;
		DoDataExchange(toDialog);
		m_ChannelsAvailBitmap.Invalidate();
		return 0;
	}
	BEGIN_DDX_MAP(CResourcesDlg)
		DDX_RADIO(IDC_SPEED_S100, (int &) m_Speed)
		DDX_INT(IDC_BYTESPP, m_BytesPerPacket)
		DDX_INT(IDC_NUMCHANNELSAVAIL, m_NumChannelsAvailable)
	END_DDX_MAP()

	protected:
	long m_NumChannelsAvailable;
	long m_BytesPerPacket;
	TransferRate m_Speed;
	CBcamAdapter *m_Adapter;	
	CProgressBarCtrl m_BandwidthVailableCtrl;
	CChannelsAvail m_ChannelsAvailBitmap;
	long m_MaxBandwith[4];
};



#endif // !defined(AFX_RESOURCESDLG_H__D1547850_F457_4A5B_B249_3C7A9710984C__INCLUDED_)

⌨️ 快捷键说明

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