www.pudn.com > DVBPlayer.rar > DlgScanTransponder.cpp, change:2004-07-15,size:7854b


// DlgScanTransponder.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "app.h" 
#include "DlgScanTransponder.h" 
#include "dsm.h" 
#include "misc.h" 
#include "mainfrm.h" 
 
#include "tunerevent.h" 
#include "misc.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CDlgScanTransponder dialog 
 
 
CDlgScanTransponder::CDlgScanTransponder(CWnd* pParent /*=NULL*/) 
	: CDialog(CDlgScanTransponder::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CDlgScanTransponder) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
 
void CDlgScanTransponder::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CDlgScanTransponder) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CDlgScanTransponder, CDialog) 
	//{{AFX_MSG_MAP(CDlgScanTransponder) 
	ON_WM_DESTROY() 
	ON_CBN_SELCHANGE(IDR_COMBO_LNB, OnSelchangeComboLnb) 
	ON_CBN_SELCHANGE(IDR_COMBO_TRANSPOND, OnSelchangeComboTranspond) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CDlgScanTransponder message handlers 
 
void CDlgScanTransponder::OnOK()  
{ 
	// TODO: Add extra validation here 
	 
	CDialog::OnOK(); 
} 
 
void CDlgScanTransponder::OnCancel()  
{ 
	// TODO: Add extra cleanup here 
	 
	ToggleYouself(); 
 
	 
	//CDialog::OnCancel(); 
} 
 
BOOL CDlgScanTransponder::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
	CComboBox* p_combo_lnb = (CComboBox*) GetDlgItem (IDR_COMBO_LNB) ;  
 
	BYTE n ;  
	BYTE n_disqec_num ;  
	DaGetSwitchNum ( &n_disqec_num ) ;  
	for ( n  = 0 ; n < n_disqec_num ;  n ++ ) 
	{ 
		WORD sat_id ;  
		DaGetSwitchSatelID ( n , &sat_id )  ;  
 
		if ( sat_id != NO_CONNECT_ID ) 
		{ 
			char name  [MAX_PARAM_LENGTH] ;  
			DaGetSatelName ( sat_id, (BYTE*)name ) ;  
			int index = p_combo_lnb ->AddString(name) ;  
			p_combo_lnb ->SetItemData ( index, DWORD(sat_id) ) ;  
		} 
	} 
 
	p_combo_lnb ->SetCurSel(0) ;  
 
 
	CEdit* p_edit_freq = (CEdit*)  GetDlgItem ( IDR_EIDT_FREQUENCY ) ;  
	p_edit_freq ->SetReadOnly(TRUE) ;  
 
 
#if 0 
	CEdit* p_edit_polar = (CEdit*) ( GetDlgItem(IDR_COMBO_POLARISATION) ->GetWindow(GW_CHILD) ) ;  
	p_edit_polar ->EnableWindow(TRUE) ;  
	p_edit_polar ->SetReadOnly(TRUE) ;  
 
	CEdit* p_edit_symbol = (CEdit*) ( GetDlgItem(IDR_COMBO_SYMBOL) ->GetWindow(GW_CHILD) ) ;  
	p_edit_symbol ->EnableWindow(TRUE) ;  
	p_edit_symbol ->SetReadOnly(TRUE) ;  
 
#else 
	GetDlgItem(IDR_COMBO_POLARISATION) ->EnableWindow(FALSE) ;  
 
	CEdit* p_edit_symbol = (CEdit*) ( GetDlgItem(IDR_COMBO_SYMBOL) ->GetWindow(GW_CHILD) ) ;  
	p_edit_symbol ->EnableWindow(TRUE) ;  
	p_edit_symbol ->SetReadOnly(TRUE) ;  
	 
#endif 
	 
 
	 
	OnSelchangeComboLnb () ;  
 
	 
 
	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void CDlgScanTransponder::OnDestroy()  
{ 
 
 
	CDialog::OnDestroy(); 
	 
	// TODO: Add your message handler code here 
	 
} 
 
void CDlgScanTransponder::OnSelchangeComboLnb()  
{ 
	// TODO: Add your control notification handler code here 
 
	CComboBox* p_combo_lnb = (CComboBox*) GetDlgItem (IDR_COMBO_LNB) ;  
 
	WORD sat_id  = p_combo_lnb ->GetItemData( p_combo_lnb ->GetCurSel() ) ;  
 
 
	CComboBox* p_combo_transponder = (CComboBox*) GetDlgItem (IDR_COMBO_TRANSPOND) ;  
	while (p_combo_transponder ->DeleteString(0) != CB_ERR ) ;  
 
 
	if ( sat_id != NO_CONNECT_ID ) 
	{ 
		 
		UINT n ;  
		for ( n  =0 ; n < DaGetTransponderCount(sat_id) ; n ++ ) 
		{ 
			CString s ;  
			TransParams tp ;  
			DaGetTransBaseParams   ( sat_id, n, &tp ) ; 
			s .Format ( "%d  --%c-- %d", tp .dwFrequency, (tp .bVorH == VERTICAL )? 'V': 'H', tp .dwSymbolRate ) ;  
			int index = p_combo_transponder ->AddString(s) ;  
			p_combo_transponder ->SetItemData( index, n ) ;  
		} 
		 
		p_combo_transponder ->SetCurSel(0) ;  
		OnSelchangeComboTranspond ()  ;  
	} 
	 
	 
	 
} 
 
void CDlgScanTransponder::OnSelchangeComboTranspond()  
{ 
	// TODO: Add your control notification handler code here 
	CComboBox* p_combo_lnb = (CComboBox*) GetDlgItem (IDR_COMBO_LNB) ;  
	UINT n_lnb_id = p_combo_lnb ->GetItemData( p_combo_lnb ->GetCurSel()  ) ;  
 
	CComboBox* p_combo_transponder = (CComboBox*) GetDlgItem (IDR_COMBO_TRANSPOND) ;  
	UINT n_trans_id = p_combo_transponder ->GetItemData( p_combo_transponder ->GetCurSel() ) ;  
 
	TransParams tp ;  
	DaGetTransBaseParams   ( n_lnb_id, n_trans_id, &tp ) ; 
 
	SetDlgItemInt( IDR_EIDT_FREQUENCY, tp .dwFrequency ) ;  
 
	((CComboBox*) GetDlgItem( IDR_COMBO_POLARISATION )) ->SetCurSel( tp .bVorH == VERTICAL ? 1 : 0 ) ;  
	 
	SetDlgItemInt( IDR_COMBO_SYMBOL, tp .dwSymbolRate ) ;  
 
 
	//send tuner command 
#if 0 
	CWnd* pwnd = GetParent () ;  
	ASSERT(pwnd!= NULL) ;  
	ASSERT(pwnd ->GetSafeHwnd () != NULL) ;  
	ASSERT( pwnd ->IsKindOf ( RUNTIME_CLASS( CMainFrame ) ) ) ;  
	CMainFrame* p_main_wnd = (CMainFrame*) pwnd ;  
#endif 
 
	TunerAttr tu ;  
	memset (  &tu, 0, sizeof (tu)) ;  
 
	SatelParams ts ;  
	DaGetSatelAttr ( n_lnb_id, &ts ) ;  
 
 
	UINT u_disqec_type = DaGetSwitchMode () ;  
	tu .b22K = (u_disqec_type == SWITCH_22k && n_lnb_id ==1) ? TRUE : FALSE ; 
	if ( u_disqec_type == SWITCH_DISQEC10 ) 
	{ 
		tu .bDisEqc = n_lnb_id + 1;  
	} 
 
	tu .bDual_LNB_Flag = ts .bDual_LNB_Flag ;  
	tu .bToneBurst = (u_disqec_type == SWITCH_TONEBURST && n_lnb_id ==1) ? TRUE : FALSE ;  
	tu .bVOrH = tp .bVorH ;  
	tu .dwFreLOF = ts .dwFreLOF ;  
	tu .dwFreLOF1 = ts .dwFreLOF1 ;  
	tu .dwFrequency = tp .dwFrequency ;  
	tu .dwSymbolRate = tp .dwSymbolRate ;  
 
//	if ( p_main_wnd ->m_target ) p_main_wnd ->m_target ->AcceptEvent( new CTunerEvent( &tu ) ) ;  
//	if ( p_main_wnd ->m_target ) p_main_wnd ->m_target ->AcceptEvent( new CTunerEvent( &tu ) ) ;  
	m_target ->AcceptEvent(new CTunerEvent(&tu) ) ;  
 
 
} 
 
BOOL CDlgScanTransponder::init() 
{ 
	return TRUE ;  
} 
 
CWnd* CDlgScanTransponder::GetMainWnd() 
{ 
	return this ;  
} 
 
void CDlgScanTransponder::ToggleYouself() 
{ 
	if ( IsWindowVisible () ) 
	{ 
		CDialog::OnCancel() ;  
	} 
	else 
	{ 
		ShowWindow ( SW_NORMAL ) ;  
		SetForegroundWindow() ;  
	} 
} 
 
void CDlgScanTransponder::ReinitData() 
{ 
	CComboBox* p_combo_lnb = (CComboBox*) GetDlgItem (IDR_COMBO_LNB) ;  
	while ( p_combo_lnb ->DeleteString(0) != CB_ERR ) ;  
	 
	BYTE n ;  
	BYTE n_disqec_num ;  
	DaGetSwitchNum ( &n_disqec_num ) ;  
	for ( n  = 0 ; n < n_disqec_num ;  n ++ ) 
	{ 
		WORD sat_id ;  
		DaGetSwitchSatelID ( n , &sat_id )  ;  
		 
		if ( sat_id != NO_CONNECT_ID ) 
		{ 
			char name  [MAX_PARAM_LENGTH] ;  
			DaGetSatelName ( sat_id, (BYTE*)name ) ;  
			int index = p_combo_lnb ->AddString(name) ;  
			p_combo_lnb ->SetItemData ( index, DWORD(sat_id) ) ;  
		} 
	} 
	 
	p_combo_lnb ->SetCurSel(0) ;  
	 
	 
	CEdit* p_edit_freq = (CEdit*)  GetDlgItem ( IDR_EIDT_FREQUENCY ) ;  
	p_edit_freq ->SetReadOnly(TRUE) ;  
	 
	 
#if 0 
	CEdit* p_edit_polar = (CEdit*) ( GetDlgItem(IDR_COMBO_POLARISATION) ->GetWindow(GW_CHILD) ) ;  
	p_edit_polar ->EnableWindow(TRUE) ;  
	p_edit_polar ->SetReadOnly(TRUE) ;  
	 
	CEdit* p_edit_symbol = (CEdit*) ( GetDlgItem(IDR_COMBO_SYMBOL) ->GetWindow(GW_CHILD) ) ;  
	p_edit_symbol ->EnableWindow(TRUE) ;  
	p_edit_symbol ->SetReadOnly(TRUE) ;  
	 
#else 
	GetDlgItem(IDR_COMBO_POLARISATION) ->EnableWindow(FALSE) ;  
	 
	CEdit* p_edit_symbol = (CEdit*) ( GetDlgItem(IDR_COMBO_SYMBOL) ->GetWindow(GW_CHILD) ) ;  
	p_edit_symbol ->EnableWindow(TRUE) ;  
	p_edit_symbol ->SetReadOnly(TRUE) ;  
	 
#endif 
	 
	 
	 
	OnSelchangeComboLnb () ;  
	 
	 
} 
 
DWORD CDlgScanTransponder::AcceptEvent(Event *) 
{ 
	return 1 ;  
}