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

📄 newclientdlg.cpp

📁 监控开发资料,提供二次开发源码和使用说明书
💻 CPP
📖 第 1 页 / 共 5 页
字号:
{
	int itemp,i;

	if(numberpos <= WINDOWNUM)
		return;

	for(i = 0; i < MAXVIEWNUM; i++)
	{
		if( (myoutput[i].m_iPlayhandle >= 0) || (myoutput[i].m_bFileSave) )
			F_StopClientRecord(i);
	}
	if( (hikClientParam.m_bEnlarged) || (hikClientParam.m_bFullScreen) )
	{
		ArrayWindow(0, WINDOWNUM);	//窗口放大状态时,循环到下一画面,恢复原窗口数;					
		MoveCurWin(WINDOWNUM,0);
		hikClientParam.m_bEnlarged = FALSE;
		hikClientParam.m_bFullScreen = FALSE;
	}

	if(numberpos > WINDOWNUM)
	{
		if(numberpos < 2*WINDOWNUM)
		{
			itemp = 0;
		}
		else
		{
			i = numberpos % WINDOWNUM;
			if (i == 0)
				itemp = numberpos - 2*WINDOWNUM ;
			else
				itemp = numberpos - WINDOWNUM -i;

		}
		if(!hikClientParam.m_bUseCard)
		{
			if(!g_bShareSound)
				NET_DVR_CloseSound();
		}
//itemp:确定上一页要播放监控点的起始编号;
		for(i=0;i<WINDOWNUM;i++)
		{
			if(g_bShareSound)
				NET_DVR_CloseSoundShare(myoutput[i].m_iPlayhandle);
			myoutput[i].StopNet();
		}

		for(i=0;i<WINDOWNUM;i++)
		{
			if(itemp+i < MAXNUMBER)
			{
				if(hikClientParam.m_bUseCard)
					myoutput[i].StartCard(&selipinfo[i+itemp]);
				else
				{
					myoutput[i].StartNet(&selipinfo[i+itemp]);
					if(g_bShareSound && (myoutput[i].m_iPlayhandle >= 0))
					{
						hikClientParam.m_bPlaySound[i] = TRUE;
					}
				}
				Sleep(100);
			}
		}

		if (numberpos <= 2*WINDOWNUM)
		{
			numberpos = WINDOWNUM;
			hikClientParam.m_bFrontPage = FALSE;		//没有上一页
		}
		else
		{
			i = numberpos % WINDOWNUM;
			if(i == 0)
				numberpos -= WINDOWNUM;
			else
				numberpos -= i;
		}
	}
	
	hikClientParam.m_bNextPage = TRUE;
	UpdateData(FALSE);
}

void CNewclientDlg::F_CyclePause()
{
	if(!hikClientParam.m_bPaused)
	{	
		hikClientParam.m_bPaused = TRUE;
		if(cycletimer)
		{
			KillTimer(CYCLE_TIMER);
			cycletimer = 0;
		}
	}
	else
	{
		m_bChangePage = TRUE;
		F_CyclePlay();
		if(cycletimer == 0)
			cycletimer = SetTimer(CYCLE_TIMER,hikClientParam.m_iCycleTime*1000+3000,NULL);
		hikClientParam.m_bPaused = FALSE;
	}
}

void CNewclientDlg::F_CyclePlay()
{
	int itemp,i,j;
	TRACE("F_CyclePlay");
	if (iSurveillanceNumber <= WINDOWNUM)
		return;	
	m_bChangePage = FALSE; 
	
	if( (hikClientParam.m_bEnlarged) || (hikClientParam.m_bFullScreen) )
	{
		if(hikClientParam.m_bFullScreen) 
		{
			F_EndFullScreen();
		}		
		ArrayWindow(0, WINDOWNUM);	//窗口放大状态时,循环到下一画面,恢复原窗口数;					
		MoveCurWin(WINDOWNUM,0);
		hikClientParam.m_bEnlarged = FALSE;
		hikClientParam.m_bFullScreen = FALSE;
	}
	if (iSurveillanceNumber == numberpos)		//循环已到了最后一页,又开始第一页;
		itemp = WINDOWNUM;
	else
	{
		itemp = iSurveillanceNumber - numberpos;
		
		if (itemp > WINDOWNUM)
			itemp = WINDOWNUM;
	}
	
	if (iSurveillanceNumber == numberpos)
		j = 0;
	else
		j = numberpos;
	
	if(!hikClientParam.m_bUseCard)
	{
		if(!g_bShareSound)
			NET_DVR_CloseSound();
	}
	//如果一个循环结束,可能不是从9->9,或许是9->i,所以需要对对(9-i)做ClientStop
	//循环到最后一个画面,要播放的窗口数可能小于WINDOWNUM,所以在播放最后一个画面时,关闭多余的播放窗口;
	for(i=0;i<WINDOWNUM;i++)
	{
//		TRACE("cycle stopplay %d", myoutput[i].m_iPlayhandle);
		if(g_bShareSound)
			NET_DVR_CloseSoundShare(myoutput[i].m_iPlayhandle);
		myoutput[i].StopNet();
//		TRACE("StopNet");
	}
	
	for(i=0;i<itemp;i++)
	{
		if (i+j < MAXNUMBER)
		{	
//			TRACE("play sel = %d", i+j);
			if(hikClientParam.m_bUseCard)
				myoutput[i].StartCard(&selipinfo[i+j]);
			else
			{
				myoutput[i].StartNet(&selipinfo[i+j]);
				if(g_bShareSound && (myoutput[i].m_iPlayhandle >= 0))
				{
					hikClientParam.m_bPlaySound[i] = TRUE;
				}
			}
			Sleep(100);
//			TRACE("cycle startplay %d", myoutput[i].m_iPlayhandle);
		}
	}
	
	//	MyInvalidate();
	itemp = iSurveillanceNumber - numberpos;
	if(itemp ==0)
	{
		numberpos = WINDOWNUM;
	}
	else if(itemp <= WINDOWNUM)
	{
		numberpos = iSurveillanceNumber;
	}	
	else
	{
		numberpos += WINDOWNUM;
	}
	
	m_bChangePage = TRUE;
	
	UpdateData(FALSE);
}

void CNewclientDlg::OnGetpicture() 
{
	// TODO: Add your control notification handler code here
	int i;
	char cFilename[256];
	
	i = iActiveWndNumber;
	CTime time = CTime::GetCurrentTime();
	if(myoutput[i].m_iPlayhandle >= 0)
	{
		sprintf(cFilename, "%s\\Picture_%s_%02d_%4d%02d%02d_%02d%02d%02d_%d.bmp", hikClientParam.m_csPictureSavePath, myoutput[i].m_csIP, myoutput[i].m_iChannel,	\
			time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond(), GetTickCount());
		TRACE("Picture save file name : %s", cFilename);
		if(hikClientParam.m_bUseCard)
		{
			//新SDK中暂时无此接口
		//	MP4_ClientCapPicFile_Card(myoutput[i].m_iPlayhandle, cFilename);
		}
		else
		{
			if(NET_DVR_CapturePicture(myoutput[i].m_iPlayhandle, cFilename))
			{
				CString sTemp;	
				sTemp.Format("抓图成功 %s!",cFilename);
				AfxMessageBox(sTemp);
				return;
			}
			else
			{
				AfxMessageBox("抓图失败!");
			}
		}
	}
}

void CNewclientDlg::OnRecord() 
{
	// TODO: Add your control notification handler code here
	int i;
	
	if(hikClientParam.m_bAutoRecord)
		return;
	i = iActiveWndNumber;
	if( (myoutput[i].m_iPlayhandle >= 0) && (!myoutput[i].m_bFileSave) )
	{
		//AfxMessageBox("111");
		if(F_MakeDir())
			F_StartClientRecord(i);	
	}
	else if(myoutput[i].m_bFileSave)
		F_StopClientRecord(i);
}

BOOL CNewclientDlg::F_MakeDir()
{
	CString sTemp;
	DWORD dirattr;
	CTime time;
	
	time = CTime::GetCurrentTime();
	sTemp.Format("%c:\\mpeg4record\\", m_cCurrentRecordDriver);
	dirattr = GetFileAttributes(sTemp);
	if(dirattr == FILE_ATTRIBUTE_DIRECTORY)
	{
		sTemp.Format("%c:\\mpeg4record\\%4d-%02d-%02d\\", m_cCurrentRecordDriver, time.GetYear(), time.GetMonth(), time.GetDay());
		dirattr=GetFileAttributes(sTemp);
		if(dirattr == FILE_ATTRIBUTE_DIRECTORY)
		{
			hikClientParam.m_csClientRecordPath.Format("%s",sTemp);
			TRACE("已经创建了目录%s", sTemp);
			return TRUE;
		}
		else
		{
			if(!CreateDirectory(sTemp, NULL))
			{
				AfxMessageBox("创建年月日目录失败!");
				return FALSE;
			}
			else
			{
				hikClientParam.m_csClientRecordPath.Format("%s",sTemp);
				TRACE("在已有的目录%c:\\mpeg4record下创建子目录%4d-%02d-%02d", m_cCurrentRecordDriver, time.GetYear(), time.GetMonth(), time.GetDay());
				return TRUE;
			}
		}	
	}
	if(!CreateDirectory(sTemp, NULL))
	{
		TRACE("创建mpeg4record目录失败!");
		return FALSE;
	}
	sTemp.Format("%c:\\mpeg4record\\%4d-%02d-%02d\\",m_cCurrentRecordDriver, time.GetYear(), time.GetMonth(), time.GetDay());
	if(!CreateDirectory(sTemp, NULL))
	{
		return FALSE;
	}
	hikClientParam.m_csClientRecordPath.Format("%s",sTemp);
	TRACE("先创建%c:\\mpeg4record目录,再创建子目录%4d-%02d-%02d", m_cCurrentRecordDriver, time.GetYear(), time.GetMonth(), time.GetDay());
	return TRUE;
}

void CNewclientDlg::F_StartClientRecord(int iRecordWndIndex)
{
	int i;
	char cFilename[256];
	
	i = iRecordWndIndex;
	TRACE("Start myoutput[%d] Client Record", i);
	CTime time = CTime::GetCurrentTime();
	sprintf(cFilename, "%s%s_%02d_%4d%02d%02d_%02d%02d%02d.mp4", hikClientParam.m_csClientRecordPath, myoutput[i].m_csIP, myoutput[i].m_iChannel,		\
		time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond() );
	if(!NET_DVR_SaveRealData(myoutput[i].m_iPlayhandle, cFilename))
	{
		AfxMessageBox("录像失败!");
		return;
	}
	TRACE("Client Record Filename = %s", cFilename);
	myoutput[i].m_lChangeFileNameTime = time.GetTime() + hikClientParam.m_iRecordFileInterval * 60;
	myoutput[i].m_bFileSave = TRUE;
	m_pCapLed[i]->SetLed(CLed::LED_COLOR_RED,CLed::LED_ON,CLed::LED_ROUND);	
}

void CNewclientDlg::F_StopClientRecord(int iRecordWndIndex)
{
	int i;
	
	i = iRecordWndIndex;
	TRACE("Stop myoutput[%d] Client Record", i);
	NET_DVR_StopSaveRealData(myoutput[i].m_iPlayhandle);
	myoutput[i].m_bFileSave = FALSE;
	m_pCapLed[i]->SetLed(CLed::LED_COLOR_RED,CLed::LED_DISABLED,CLed::LED_ROUND);
}
/*
void CNewclientDlg::OnHide() 
{
	// TODO: Add your control notification handler code here
	ShowWindow(SW_MINIMIZE);
}
*/

void CNewclientDlg::OnEventlist() 
{
	// TODO: Add your control notification handler code here
	int i;
	CEventLog	EventLogDlg;
	EventLogDlg.DoModal();
	SetEvent(hVideoBeeper);	
	for(i = 0; i < MAXVIEWNUM; i++)
	{
		if(hikClientParam.m_iAlarmHandle[i] >= 0)
		{
			m_pAlarmLed[i]->SetLed(CLed::LED_COLOR_GREEN,CLed::LED_ON,CLed::LED_ROUND);
		}
		else
			m_pAlarmLed[i]->SetLed(CLed::LED_COLOR_RED,CLed::LED_DISABLED,CLed::LED_ROUND);
	}
	for(i = 0; i < MAXALARMIN; i++)
	{
		alarminfo[i].m_csIP.Format(_T(""));
		alarminfo[i].m_csUsername.Format(_T(""));
		alarminfo[i].m_csPassword.Format(_T(""));
		alarminfo[i].m_iChannel = -1;
		alarminfo[i].m_iAlarmLevel = -1;
		alarminfo[i].m_iAlarmType = -1;
		alarminfo[i].m_iPortIndex = -1;
		alarminfo[i].m_wServerPort = 8000;
	}
	m_iAlarmNumber = 0;
}

void CNewclientDlg::OnButtonalarmset() 
{
	// TODO: Add your control notification handler code here
	int i;
	
	CSetAlarm	SetAlarmDlg;
	SetAlarmDlg.DoModal();
	if(SetAlarmDlg.m_bOK)
	{
		for(i = 0; i < MAXVIEWNUM; i++)
		{
			if(hikClientParam.m_iAlarmHandle[i] >= 0)
			{
				m_pAlarmLed[i]->SetLed(CLed::LED_COLOR_GREEN,CLed::LED_ON,CLed::LED_ROUND);
			}
			else
			{
				m_pAlarmLed[i]->SetLed(CLed::LED_COLOR_RED,CLed::LED_DISABLED,CLed::LED_ROUND);
			}
		}
	}
}

void CNewclientDlg::OnVideofileplay() 
{
	// TODO: Add your control notification handler code here
	CPlayBack	PlayBackDlg;
	PlayBackDlg.DoModal();
}

BOOL CNewclientDlg::F_JudgeDiskFull()
{
	int i;
	ULARGE_INTEGER FreeSpace,CallerSpace,TotalSpace;
	CString csRootPath;	
	
	for(i = hikClientParam.m_iStartRecordDriver; i < hikClientParam.m_iEndRecordDriver + 1; i++)
	{	
		csRootPath.Format("%c%s",m_cHardDriver[i],":\\");	//从录像起始驱动器开始	
		GetDiskFreeSpaceEx(csRootPath,&CallerSpace,&TotalSpace,&FreeSpace);
		if(CallerSpace.QuadPart > MINSPACE)
		{
			m_cCurrentRecordDriver = m_cHardDriver[i];
//			TRACE("m_cCurrentRecordDriver = %c:\\", m_cCurrentRecordDriver);
			hikClientParam.m_bAllDiskFull = FALSE;
			return	TRUE;
		}
	}
	hikClientParam.m_bAllDiskFull = TRUE;
	return FALSE;
}

void CNewclientDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	time_t	lCurrentTime;
	CString	csRootPath;
	CString csTemp;
	int i,j;
	CTime time1 = CTime::GetCurrentTime();
	int iWeekday = time1.GetDayOfWeek() - 1;
	WORD	iNowTime = time1.GetHour() * 100 + time1.GetMinute();
	NET_DVR_TIME CurTime;
	CurTime.dwYear = time1.GetYear();
	CurTime.dwMonth = time1.GetMonth();
	CurTime.dwDay = time1.GetDay();
	CurTime.dwHour = time1.GetHour();
	CurTime.dwMinute = time1.GetMinute();
	CurTime.dwSecond = time1.GetSecond();
	switch(nIDEvent)
	{
	case CYCLE_TIMER:
		if(m_bChangePage)
			F_CyclePlay();
		break;
	case FREESPACE_TIMER:
		csRootPath.Format("%c:\\", m_cCurrentRecordDriver);	
		ULARGE_INTEGER FreeSpace,CallerSpace,TotalSpace;
		GetDiskFreeSpaceEx(csRootPath,&CallerSpace,&TotalSpace,&FreeSpace);
		hikClientParam.m_bAllDiskFull = FALSE;
		if(CallerSpace.QuadPart < MINSPACE)
		{
			csTemp.Format("%4d-%02d-%02d %02d:%02d:%02d 硬盘驱动器%c已满", CurTime.dwYear, CurTime.dwMonth, CurTime.dwDay, CurTime.dwHour, CurTime.dwMinute, CurTime.dwSecond, m_cCurrentRecordDriver);
			TRACE(csTemp);
			//AfxMessageBox(csTemp);
			if(!F_JudgeDiskFull())		//所有硬盘都满,删除8个最早的录像文件
			{
				if(hikClientParam.m_bCycleRecord)
					F_DeleteClientRecordFile();
				else
				{
					for(i = 0; i < MAXVIEWNUM; i++)
					{
						if( 

⌨️ 快捷键说明

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