📄 clientstate.cpp
字号:
// lientState.cpp : implementation file
//
#include "stdafx.h"
#include "netsdkdemo.h"
#include "clientState.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CClientState dialog
CClientState::CClientState(CWnd* pParent /*=NULL*/)
: CDialog(CClientState::IDD, pParent)
{
m_dev = 0;
memset(&m_myState, 0, sizeof(NET_CLIENT_STATE));
//{{AFX_DATA_INIT(CClientState)
m_isNoMoreShow = FALSE;
//}}AFX_DATA_INIT
}
CClientState::~CClientState()
{
}
void CClientState::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CClientState)
DDX_Check(pDX, IDC_NOSHOW, m_isNoMoreShow);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CClientState, CDialog)
//{{AFX_MSG_MAP(CClientState)
ON_WM_TIMER()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// ClientState message handlers
void CClientState::UpdateState()
{
if (!m_dev)
{
return;
}
CDevMgr::GetDevMgr().GetAlarmInfo(m_dev->LoginID, &m_myState);
CString str;
str.Format("(%s [%s])",m_dev->Name, m_dev->IP);
CString strTmp;
CString strDiskError = MSG_CLIENTSTATE_DISKERR;
for (int i=0; i<32; i++)
{
if ((m_myState.dError >> i)%2)
{
strTmp.Format(" %d", i+1);
strDiskError += strTmp;
}
}
CString strDiskFull;
if (m_myState.dFull)
{
strDiskFull.Format("Disk Full: Yes");
}
else
{
strDiskFull.Format("Disk Full: No");
}
CString strShelter = "Shelter Alarm:";
for (i=0; i<16; i++)
{
if (m_myState.shelter[i])
{
strTmp.Format(" %d", i+1);
strShelter += strTmp;
}
}
CString strAlarm = MSG_CLIENTSTATE_ALARM;
for (i=0; i<m_myState.cState.alarminputcount; i++)
{
if (*(m_myState.cState.alarm + i))
{
strTmp.Format(" %d", i+1);
strAlarm += strTmp;
}
}
CString strMD = MSG_CLIENTSTATE_MOTION;
CString strVideoLost = MSG_CLIENTSTATE_VIDEOLOST;
for (i=0; i<m_myState.cState.channelcount; i++)
{
if (*(m_myState.cState.motiondection + i))
{
strTmp.Format(" %d", i+1);
strMD += strTmp;
}
if (*(m_myState.cState.videolost + i))
{
strTmp.Format(" %d", i+1);
strVideoLost += strTmp;
}
}
CString strSerial = "Serial No: ";
strTmp.Format("%s", m_dev->Info.sSerialNumber);
strSerial += strTmp;
str += MSG_CLIENTSTATE_CLIENTSTATE;
str = str +"\n" +"\n"+
strDiskError + "\n" +"\n"+
strDiskFull + "\n" +"\n"+
strShelter +"\n" + "\n"+
strAlarm + "\n" +"\n"+
strMD + "\n" +"\n"+
strVideoLost + "\n" +"\n"+
strSerial;
GetDlgItem(IDC_CLIENT_STATE)->SetWindowText(str);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CClientState message handlers
BOOL CClientState::OnInitDialog()
{
CDialog::OnInitDialog();
g_SetWndStaticText(this);
return TRUE;
}
void CClientState::StartRefresh()
{
SetTimer((UINT)this,200,0);
}
void CClientState::StopRefresh()
{
KillTimer((UINT)this);
}
void CClientState::OnTimer(UINT nIDEvent)
{
UpdateState();
CDialog::OnTimer(nIDEvent);
}
void CClientState::SetDevice(DeviceNode *dev)
{
m_dev = dev;
}
DeviceNode* CClientState::GetDevice()
{
return m_dev;
}
void CClientState::OnClose()
{
StopRefresh();
CDialog::OnClose();
}
void CClientState::OnOK()
{
StopRefresh();
CDialog::OnOK();
}
BOOL CClientState::PreTranslateMessage(MSG* pMsg)
{
if (WM_KEYDOWN == pMsg->message && (VK_ESCAPE == pMsg->wParam))
{
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -