?? mainfrm.cpp
字號(hào):
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "SimSensor.h"
#include "NodeSetDlg.h"
#include "Sink.h"
#include "Node.h"
#include "MsgCenter.h"
#include "MainFrm.h"
#include "AreaCollectCmdDlg.h"
#include "SimSensorView.h"
#include "GraphView.h"
//#include "ListMsgView.h"
#include "MsgListView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CMsgCenter MsgCenter;
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_COMMAND(ID_NODE_SET, OnNodeSet)
ON_COMMAND(ID_FILE_NEW, OnFileNew)
ON_COMMAND(ID_START_COLLECT_DATA, OnStartCollectData)
ON_COMMAND(ID_STOP_COLLECT_DATA, OnStopCollectData)
ON_COMMAND(ID_END_NODE_WORKING, OnEndNodeWorking)
ON_WM_CLOSE()
ON_COMMAND(ID_AREA_COLLECT_CMD, OnAreaCollectCmd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
//g_Radium = 0;
g_NodeSet = false;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnNodeSet()
{
CNodeSetDlg NodeSetDlg;
if ( g_NodeSet ) {
CNodeStrain *pStrain;
EnterCriticalSection(&(MsgCenter.Locked[0][1]));
pStrain = MsgCenter.pNodeStrain[0][1];
LeaveCriticalSection(&(MsgCenter.Locked[0][1]));
if (pStrain!=NULL) {
MessageBox("請(qǐng)先結(jié)束傳感器網(wǎng)絡(luò)任務(wù)!","提示");
return;
}
}
NodeSetDlg.DoModal ();
// TODO: Add your command handler code here
}
void CMainFrame::OnFileNew()
{
// TODO: Add your command handler code here
}
void CMainFrame::OnStartCollectData()
{
// TODO: Add your command handler code here
//MsgCenter.SendMsg (0,0,-1,-1,3);
CNode::AllStopCollectData = FALSE;
}
void CMainFrame::OnStopCollectData()
{
// TODO: Add your command handler code here
//MsgCenter.SendMsg (0,0,-1,-1,4);
CNode::AllStopCollectData = TRUE;
}
void CMainFrame::OnEndNodeWorking()
{
// TODO: Add your command handler code here
//CNodeStrain *pStrain;
CNode::NodeEnd = TRUE;
/*do {
Sleep(5);
EnterCriticalSection(&(MsgCenter.Locked[0][1]));
pStrain = MsgCenter.pNodeStrain[0][1];
LeaveCriticalSection(&(MsgCenter.Locked[0][1]));
}while(pStrain!=NULL);
CSink::SinkEnd = true;
do {
Sleep(5);
EnterCriticalSection(&(MsgCenter.Locked[0][0]));
pStrain = MsgCenter.pNodeStrain[0][0];
LeaveCriticalSection(&(MsgCenter.Locked[0][0]));
}while(pStrain!=NULL);
//MessageBox("所有傳感器都已結(jié)束工作了!","提示");*/
}
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
if ( g_NodeSet ) {
CNodeStrain *pStrain;
EnterCriticalSection(&(MsgCenter.Locked[0][1]));
pStrain = MsgCenter.pNodeStrain[0][1];
LeaveCriticalSection(&(MsgCenter.Locked[0][1]));
if (pStrain!=NULL) {
MessageBox("請(qǐng)先結(jié)束傳感器網(wǎng)絡(luò)任務(wù)!","提示");
return;
}
}
CFrameWnd::OnClose();
}
void CMainFrame::OnAreaCollectCmd()
{
// TODO: Add your command handler code here
CAreaCollectCmdDlg AreaCollectCmdDlg;
if ( g_NodeSet )
AreaCollectCmdDlg.DoModal ();
}
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
m_split.CreateSplit(this, RUNTIME_CLASS(CSimSensorView),RUNTIME_CLASS(CGraphView),RUNTIME_CLASS(CMsgListView),pContext);
return TRUE;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -