📄 deviceinfoview.cpp
字号:
// DeviceInfoView.cpp : implementation file
//
#include "stdafx.h"
#include "mbpc.h"
#include "DeviceInfoView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDeviceInfoView
IMPLEMENT_DYNCREATE(CDeviceInfoView, CFormView)
CDeviceInfoView::CDeviceInfoView()
: CFormView(CDeviceInfoView::IDD)
{
//{{AFX_DATA_INIT(CDeviceInfoView)
m_nTimerFlag = 0;
//}}AFX_DATA_INIT
}
CDeviceInfoView::~CDeviceInfoView()
{
}
void CDeviceInfoView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDeviceInfoView)
DDX_Control(pDX, IDC_TIMEMODE, m_szTimeMode);
DDX_Control(pDX, IDC_ALARMCOUNT, m_szAlarmCntr);
DDX_Control(pDX, IDC_ACTCOUNT, m_szActCntr);
DDX_Control(pDX, IDC_USEDSECCNTR, m_EditUsedSecCntr);
DDX_Control(pDX, IDC_DEVICENAME, m_szDeviceName);
DDX_Control(pDX, IDC_STATIONNAME, m_szStationName);
DDX_Control(pDX, IDC_DEVICETYPE, m_szDeviceType);
DDX_Control(pDX, IDC_DESIGNER, m_szDesigner);
DDX_Control(pDX, IDC_DEVICETYPEID, m_szDeviceTypeId);
DDX_Control(pDX, IDC_DEVICEADDR, m_szDeviceAddr);
DDX_Control(pDX, IDC_REVISION, m_szRevision);
DDX_Control(pDX, IDC_REVISIONDATE, m_szRevDate);
DDX_Control(pDX, IDC_ANALOGCNTR, m_szAnalogCntr);
DDX_Control(pDX, IDC_ENERGYCNTR, m_szEnergyCntr);
DDX_Control(pDX, IDC_DICNTR, m_szDiCntr);
DDX_Control(pDX, IDC_ENABLECNTR, m_szEnableCntr);
DDX_Control(pDX, IDC_DOCNTR, m_szDoCntr);
DDX_Control(pDX, IDC_SETSECCNTR, m_szSetSecCntr);
DDX_Control(pDX, IDC_CURSEC, m_szCurrentSec);
DDX_Control(pDX, IDC_ITEMINSEC, m_szItemInSec);
DDX_Control(pDX, IDC_MMIREV, m_szMMIRev);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDeviceInfoView, CFormView)
//{{AFX_MSG_MAP(CDeviceInfoView)
ON_WM_CREATE()
ON_WM_TIMER()
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_TEST, OnTest)
ON_BN_CLICKED(IDC_TEST2, OnTest2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDeviceInfoView diagnostics
#ifdef _DEBUG
void CDeviceInfoView::AssertValid() const
{
CFormView::AssertValid();
}
void CDeviceInfoView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDeviceInfoView message handlers
int CDeviceInfoView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFormView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
SetTimer(1,500,NULL);
return 0;
}
CMbpcDoc* CDeviceInfoView::GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMbpcDoc)));
return (CMbpcDoc*)m_pDocument;
}
void CDeviceInfoView::OnTimer(UINT nIDEvent)
{
char szBuf[1024],szBuf1[1024],szBuf2[1024],szBuf3[1024];
memset(szBuf,0,sizeof(szBuf));
memset(szBuf1,0,sizeof(szBuf1));
memset(szBuf2,0,sizeof(szBuf2));
memset(szBuf3,0,sizeof(szBuf3));
// TODO: Add your message handler code here and/or call default
DEVICE_INFO* pDevice = &GetDocument()->m_device_info;
if(1 == nIDEvent)
{
m_nTimerFlag++;
if(m_nTimerFlag > 1)
{
m_nTimerFlag --;
}
else
{
if(GetDocument()->m_bSetuped)
{
m_szStationName.SetWindowText((CString)pDevice->station_name);
this->m_szDeviceName.SetWindowText((CString)pDevice->device_name);
this->m_szDeviceType.SetWindowText((CString)pDevice->device_type);
this->m_szDesigner.SetWindowText((CString)pDevice->designer);
itoa((int)pDevice->device_type_id,szBuf,10);
this->m_szDeviceTypeId.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->revision,szBuf1,10);
itoa((int)pDevice->sub_revision,szBuf2,10);
sprintf(szBuf,"%s.%s",szBuf1,szBuf2);
this->m_szRevision.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
memset(szBuf1,0,sizeof(szBuf1));
memset(szBuf2,0,sizeof(szBuf2));
itoa((int)pDevice->revision_year,szBuf1,10);
itoa((int)pDevice->revision_month,szBuf2,10);
itoa((int)pDevice->revision_day,szBuf3,10);
sprintf(szBuf,"%s.%s.%s",szBuf1,szBuf2,szBuf3);
this->m_szRevDate.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
memset(szBuf1,0,sizeof(szBuf1));
memset(szBuf2,0,sizeof(szBuf2));
memset(szBuf3,0,sizeof(szBuf3));
itoa((int)pDevice->device_address,szBuf,10);
this->m_szDeviceAddr.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->analog_count,szBuf,10);
this->m_szAnalogCntr.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->energy_count,szBuf,10);
this->m_szEnergyCntr.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->di_count,szBuf,10);
this->m_szDiCntr.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->enable_count,szBuf,10);
this->m_szEnableCntr.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->do_count,szBuf,10);
this->m_szDoCntr.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->setting_sect_count,szBuf,10);
this->m_szSetSecCntr.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->current_sect + 1,szBuf,10);
this->m_szCurrentSec.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->item_in_sect,szBuf,10);
this->m_szItemInSec.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->mmi_revision,szBuf1,10);
itoa((int)pDevice->mmi_sub_revision,szBuf2,10);
sprintf(szBuf,"%s.%s",szBuf1,szBuf2);
this->m_szMMIRev.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
memset(szBuf1,0,sizeof(szBuf1));
memset(szBuf2,0,sizeof(szBuf2));
itoa((int)pDevice->used_setting_sec_count,szBuf,10);
this->m_EditUsedSecCntr.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->alarm_count,szBuf,10);
this->m_szAlarmCntr.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->act_count,szBuf,10);
this->m_szActCntr.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
itoa((int)pDevice->time_mod,szBuf,10);
this->m_szTimeMode.SetWindowText(szBuf);
memset(szBuf,0,sizeof(szBuf));
}
}
m_nTimerFlag--;
}
CFormView::OnTimer(nIDEvent);
}
void CDeviceInfoView::OnDestroy()
{
CFormView::OnDestroy();
// TODO: Add your message handler code here
KillTimer(1);
}
void CDeviceInfoView::OnTest()
{
// TODO: Add your control notification handler code here
//GetDocument()->ReqALLInfo();
// GetDocument()->WriteConfigFile();
// GetDocument()->ReadConfigFile();
GetDocument()->MainReset();
}
void CDeviceInfoView::OnTest2()
{
// TODO: Add your control notification handler code here
GetDocument()->SignOut(0);
GetDocument()->SignOut(1);
GetDocument()->m_bLogIn = 0;
// GetDocument()->ReadConfigFile();
}
void CDeviceInfoView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
// TODO: Add your specialized code here and/or call the base class
if(bActivate == FALSE)
{
KillTimer(1);
}
else
{
SetTimer(1,500,NULL);
}
CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -