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

📄 dlg_ch.cpp

📁 一个在Linux下开发的IP摄像头的驱动程序及控制软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// DLG_CH.cpp : implementation file
//

#include "stdafx.h"
#include "MP_AP.h"
#include "DLG_CH.h"
#include "SrvDepResource.h"
#include "ServerUtl.h"
// DLG_CH dialog

IMPLEMENT_DYNAMIC(DLG_CH, CDialog)
DLG_CH::DLG_CH(CWnd* pParent /*=NULL*/)
	: CDialog(DLG_CH::IDD, pParent)
	, m_nMediaType(FALSE)
{
}

DLG_CH::~DLG_CH()
{
}

void DLG_CH::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_IPADDRESS1, m_HOSTIP);
	DDX_Control(pDX, IDC_EDIT1, m_Port);
	DDX_Control(pDX, IDC_EDIT2, m_UserName);
	DDX_Control(pDX, IDC_EDIT3, m_Password);
	DDX_Control(pDX, IDC_COMBO2, m_ServerModel);
	DDX_Radio(pDX,IDC_RADIO1,m_Protocol);
	DDX_Radio(pDX,IDC_RADIO4,m_Camera);
	DDX_Radio(pDX, IDC_RADIO_VO, m_nMediaType);
}


BEGIN_MESSAGE_MAP(DLG_CH, CDialog)
	ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
	ON_BN_CLICKED(IDOK, OnBnClickedOk)
	ON_CBN_SELENDOK(IDC_COMBO2, OnCbnSelendokCombo2)
	ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
	ON_BN_CLICKED(IDC_RADIO1, OnBnClickedRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio2)
	ON_BN_CLICKED(IDC_RADIO3, OnBnClickedRadio3)
END_MESSAGE_MAP()


// DLG_CH message handlers

BOOL DLG_CH::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
    CenterWindow();
	char csTemp[32];
	sprintf(csTemp,"Channel_%d Setting",m_index + 1);
	SetWindowText(csTemp);
	m_HOSTIP.SetWindowText(m_Ch_Info.chHostIP);
	m_UserName.SetWindowText(m_Ch_Info.chUserName);
	m_nMediaType = ((m_Ch_Info.dwWantMedia & 3) - 1);
	if (m_nMediaType == -1)
		m_nMediaType = 3;

	UpdateData(FALSE);

	char chTemp[8];
	sprintf(chTemp,"%d",m_Ch_Info.dwHTTPPort);
	m_Port.SetWindowText(chTemp);
	m_Password.SetWindowText(m_Ch_Info.chPassword);
	size_t s=strlen(m_Ch_Info.chServer_Type);

	// List support Server_Model Name
	char **pFriendlyNameList;
	DWORD dwSrv_Model_Num;
	SrvDepResource_EnumerateSupportingMode(&pFriendlyNameList,&dwSrv_Model_Num);
	//EnumerateSupportingMode(&pFriendlyNameList);
	for ( int i=0; i < (int) dwSrv_Model_Num ; i++)
	{
		m_ServerModel.AddString(pFriendlyNameList[i]);
	}
	SrvDepResource_FreeFriendlyNameList(&pFriendlyNameList);

	//---------------------------------------------
	//char FriendlyName[64];
	//GetMappingFriendlyName(m_Ch_Info.chServer_Type,FriendlyName);
	//strcpy(m_Ch_Info.chServer_Type,FriendlyName);
	//-----------------------------------------------------------
	m_ServerModel.SetWindowText(m_Ch_Info.chServer_Type);
	if ( strlen(m_Ch_Info.chServer_Type) > 0 )
	{
		for (int i=0; i < (int) dwSrv_Model_Num ; i++)
		{
			CString s2;
			m_ServerModel.GetLBText(i,s2);
			if ( s2.Find(m_Ch_Info.chServer_Type,0) > -1 )
			{
				m_ServerModel.SetCurSel(i);
				break;
			}
		}
		
	}
	CheckServerModel();
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void DLG_CH::ChannelSetting(int index,TCHANNEL_INFO Ch_Info)
{
	m_index=index;
	m_Ch_Info=Ch_Info;
}

void DLG_CH::OnEnChangeEdit1()
{
	// TODO:  If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO:  Add your control notification handler code here
}

void DLG_CH::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	UpdateData();
	m_HOSTIP.GetWindowText(m_Ch_Info.chHostIP,sizeof(m_Ch_Info.chHostIP));
	m_UserName.GetWindowText(m_Ch_Info.chUserName,sizeof(m_Ch_Info.chUserName));
	m_Password.GetWindowText(m_Ch_Info.chPassword,sizeof(m_Ch_Info.chPassword));
	m_ServerModel.GetWindowText(m_Ch_Info.chServer_Type,sizeof(m_Ch_Info.chServer_Type));
	m_Ch_Info.dwProtocol=m_Protocol+1;
	m_Ch_Info.dwCamera=m_Camera+1;
	m_Ch_Info.dwWantMedia = m_nMediaType + 1;
	char szBuf[MAX_PATH];
	this->m_Port.GetWindowText(szBuf, MAX_PATH);
	m_Ch_Info.dwHTTPPort = atoi(szBuf);

	// chek setting
	HANDLE hObject,hDevice;
	TSERVERUTL_DEV_PROPERTY tDevProperty;
	char lpszModelName[64]; 

	CWaitCursor wc;
	char chHost[64];
	char chPassword[64];
	char chUserName[64];
	ZeroMemory(&tDevProperty, sizeof(tDevProperty));
	m_HOSTIP.GetWindowText(chHost,sizeof(chHost));
	tDevProperty.lpszHost=chHost;
	m_Password.GetWindowText(chPassword,sizeof(chPassword));
	tDevProperty.lpszPassword=chPassword;
	m_UserName.GetWindowText(chUserName,sizeof(chUserName));
	tDevProperty.lpszUserName=chUserName;
	tDevProperty.dwHttpPort = m_Ch_Info.dwHTTPPort;

	if ( NULL == *m_phSrvUtl )
	{
		ServerUtl_Initial(m_phSrvUtl,SERVERUTL_VERSION);
		
	}

	hObject = *m_phSrvUtl;

	ServerUtl_CreateDevice(hObject,&hDevice);
	ServerUtl_SetDeviceProperty(hDevice,tDevProperty, FALSE);
	ServerUtl_GetDeviceModel(hDevice,lpszModelName);

	//strcpy(m_Ch_Info.chServer_Type,lpszModelName); // test 
	ServerUtl_DeleteDevice(hDevice);	
	//ServerUtl_Release(&hObject);
	
	char FriendlyName[64];
	SrvDepResource_GetMappingFriendlyName(lpszModelName,FriendlyName);

	CString s2;
	
	m_ServerModel.GetLBText(m_ServerModel.GetCurSel(),s2);
	BOOL bError = FALSE;

	if ( s2.Find(FriendlyName,0) == -1 )
	{
		bError = TRUE;
		if (strlen(FriendlyName) > 6)
		{
			char szTemp[256];

			strcpy(szTemp, FriendlyName);
			szTemp[6] = 0;

			if (s2.Find(szTemp,0) != -1)
			{
				bError = FALSE;
			}
		}

		if (bError)
		{
			char s3[128];
			sprintf(s3,"Server Model is error!");
			MessageBox(s3,NULL,MB_ICONWARNING);
		}
	}

	if (!bError)
	{
		OnOK();
	}
}

void DLG_CH::OnCbnSelendokCombo2()
{
	// TODO: Add your control notification handler code here
	CheckServerModel();
}

void DLG_CH::CheckServerModel(void)
{
	CString s;
	CButton *pButton;
	int i;

	int index=m_ServerModel.GetCurSel();
	for ( i=0 ; i < 10 ; i++ )
	{
		pButton=(CButton *)GetDlgItem(IDC_RADIO1+i);
		pButton->EnableWindow(FALSE);
		pButton->SetCheck(BST_UNCHECKED);
	}

	if ( index != CB_ERR )
	{
		m_ServerModel.GetLBText(index,s);
		TSrvDepResource_ServerInfo tServerInfo;
		SCODE scRet = SrvDepResource_GetParamForServerByFriendlyName(s.GetBuffer(128),&tServerInfo);
		if (scRet == S_OK)
		{
			if (m_Ch_Info.dwProtocol == 0)
				m_Ch_Info.dwProtocol = 1;
			if (m_Ch_Info.dwWantMedia == 0)
				m_Ch_Info.dwWantMedia = 3;

			if (tServerInfo.zServerName[2] == '3')// 3000
			{
				pButton=(CButton *)GetDlgItem(IDC_RADIO4);
				pButton->SetCheck(BST_CHECKED);
				if ( strlen(tServerInfo.zServerName) > 0 )
				{
					for ( i=0 ; i < 3 ; i ++)
					{
						pButton=(CButton *)GetDlgItem(IDC_RADIO1+i);
						pButton->EnableWindow(TRUE);
					}


					pButton=(CButton *)GetDlgItem(IDC_RADIO1+m_Ch_Info.dwProtocol-1);
					pButton->SetCheck(BST_CHECKED);

					pButton=(CButton *)GetDlgItem(IDC_RADIO_VO + m_Ch_Info.dwWantMedia - 1);
					pButton->SetCheck(BST_CHECKED);
				}
				else
				{
					for ( i=0 ; i < 3 ; i ++)
					{
						pButton=(CButton *)GetDlgItem(IDC_RADIO1+i);
						pButton->EnableWindow(TRUE);
					}
					pButton=(CButton *)GetDlgItem(IDC_RADIO1);
					pButton->SetCheck(BST_CHECKED);
				}
			}
			else if ( tServerInfo.zServerName[2] == '2' ) // 2000 series
			{
				if (tServerInfo.dwCamNum > 1)
				{
					pButton=(CButton *)GetDlgItem(IDC_RADIO3);
					pButton->SetCheck(BST_CHECKED);
					
					//if ( strlen(m_Ch_Info.chServer_Type) > 0 )
					if ( strlen(tServerInfo.zServerName) > 0 )
					{
						for ( i=0 ; i < 4 ; i ++)
						{
							pButton=(CButton *)GetDlgItem(IDC_RADIO4+i);
							pButton->EnableWindow(TRUE);
						}

						pButton=(CButton *)GetDlgItem(IDC_RADIO4+m_Ch_Info.dwCamera-1);
						pButton->SetCheck(BST_CHECKED);
					}
					else
					{
						for ( i=0 ; i < 4 ; i ++)
						{
							pButton=(CButton *)GetDlgItem(IDC_RADIO4+i);
							pButton->EnableWindow(TRUE);
						}

						pButton=(CButton *)GetDlgItem(IDC_RADIO4);
						pButton->SetCheck(BST_CHECKED);
					}
				}
			}
			else if ( tServerInfo.zServerName[2] >= '4' && tServerInfo.zServerName[2] <= '7' ) // 4/5/6K servers
			{
				pButton=(CButton *)GetDlgItem(IDC_RADIO4);
				pButton->SetCheck(BST_CHECKED);
				if (m_Ch_Info.dwProtocol == 1)
					m_Ch_Info.dwProtocol = 3;
				if ( strlen(tServerInfo.zServerName) > 0 )
				//if ( strlen(m_Ch_Info.chServer_Type) > 0 )
				{
					for ( i=1 ; i < 3 ; i ++)
					{
						pButton=(CButton *)GetDlgItem(IDC_RADIO1+i);
						pButton->EnableWindow(TRUE);
					}

					pButton=(CButton *)GetDlgItem(IDC_RADIO1+m_Ch_Info.dwProtocol-1);
					pButton->SetCheck(BST_CHECKED);

					for ( i=0 ; i < 3 ; i ++)
					{
						pButton=(CButton *)GetDlgItem(IDC_RADIO_VO + i);
						pButton->EnableWindow(TRUE);
					}

					pButton=(CButton *)GetDlgItem(IDC_RADIO_VO+m_Ch_Info.dwWantMedia-1);
					pButton->SetCheck(BST_CHECKED);
				}
				else
				{
					for ( i=1 ; i < 3 ; i ++)
					{
						pButton=(CButton *)GetDlgItem(IDC_RADIO1+i);
						pButton->EnableWindow(TRUE);
					}

⌨️ 快捷键说明

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