?? newclientdlg.cpp
字號(hào):
{
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); //窗口放大狀態(tài)時(shí),循環(huán)到下一畫面,恢復(fù)原窗口數(shù);
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:確定上一頁要播放監(jiān)控點(diǎn)的起始編號(hào);
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); //窗口放大狀態(tài)時(shí),循環(huán)到下一畫面,恢復(fù)原窗口數(shù);
MoveCurWin(WINDOWNUM,0);
hikClientParam.m_bEnlarged = FALSE;
hikClientParam.m_bFullScreen = FALSE;
}
if (iSurveillanceNumber == numberpos) //循環(huán)已到了最后一頁,又開始第一頁;
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();
}
//如果一個(gè)循環(huán)結(jié)束,可能不是從9->9,或許是9->i,所以需要對(duì)對(duì)(9-i)做ClientStop
//循環(huán)到最后一個(gè)畫面,要播放的窗口數(shù)可能小于WINDOWNUM,所以在播放最后一個(gè)畫面時(shí),關(guān)閉多余的播放窗口;
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中暫時(shí)無此接口
// 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("已經(jīng)創(chuàng)建了目錄%s", sTemp);
return TRUE;
}
else
{
if(!CreateDirectory(sTemp, NULL))
{
AfxMessageBox("創(chuàng)建年月日目錄失敗!");
return FALSE;
}
else
{
hikClientParam.m_csClientRecordPath.Format("%s",sTemp);
TRACE("在已有的目錄%c:\\mpeg4record下創(chuàng)建子目錄%4d-%02d-%02d", m_cCurrentRecordDriver, time.GetYear(), time.GetMonth(), time.GetDay());
return TRUE;
}
}
}
if(!CreateDirectory(sTemp, NULL))
{
TRACE("創(chuàng)建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("先創(chuàng)建%c:\\mpeg4record目錄,再創(chuàng)建子目錄%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],":\\"); //從錄像起始驅(qū)動(dòng)器開始
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 硬盤驅(qū)動(dòng)器%c已滿", CurTime.dwYear, CurTime.dwMonth, CurTime.dwDay, CurTime.dwHour, CurTime.dwMinute, CurTime.dwSecond, m_cCurrentRecordDriver);
TRACE(csTemp);
//AfxMessageBox(csTemp);
if(!F_JudgeDiskFull()) //所有硬盤都滿,刪除8個(gè)最早的錄像文件
{
if(hikClientParam.m_bCycleRecord)
F_DeleteClientRecordFile();
else
{
for(i = 0; i < MAXVIEWNUM; i++)
{
if(
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -