- // PeugeotDoc.cpp : implementation of the CPeugeotDoc class
- //
- #include "stdafx.h"
- #include "Peugeot.h"
- #include "PeugeotDoc.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CPeugeotDoc
- IMPLEMENT_DYNCREATE(CPeugeotDoc, CDocument)
- BEGIN_MESSAGE_MAP(CPeugeotDoc, CDocument)
- //{{AFX_MSG_MAP(CPeugeotDoc)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CPeugeotDoc construction/destruction
- CPeugeotDoc::CPeugeotDoc()
- {
- //初始化变量
- m_CmmPortType = CommPort;
- m_PrtType = Blank;
- m_MasterFlag = false;
- //网络口
- m_NetParam.TCPPrtType = NetParam.TCPServer;
- m_NetParam.LocalIPPort = 6666;
- m_NetParam.RemoteIPPort = 6666;
- CString sHostName;
- CString sIpAddress;
- GetLocalHostName(sHostName);
- GetIpAddress(sHostName,sIpAddress);
- m_NetParam.LocalIPAddr = sIpAddress;
- m_NetParam.RemoteIPAddr = sIpAddress;
- //
- m_pSrvSocketObj = NULL; //服务器
- m_pCltSocketObj = NULL; //客户端
- m_pUDPSocketObj = NULL;
- m_YXAddr = 257;
- m_YCAddr = 1793;
- m_YMAddr = 3073;
- m_YXNum = 5;
- m_YCNum = 5;
- m_YMNum = 5;
- m_pYXData = NULL;
- m_pYCData = NULL;
- m_pYMData = NULL;
- }
- CPeugeotDoc::~CPeugeotDoc()
- {
- if (m_pYXData!=NULL)
- delete[] m_pYXData;
- if (m_pYCData!=NULL)
- delete[] m_pYCData;
- if (m_pYMData!=NULL)
- delete[] m_pYMData;
- }
- BOOL CPeugeotDoc::OnNewDocument()
- {
- if (!CDocument::OnNewDocument())
- return FALSE;
- ((CEditView*)m_viewList.GetHead())->SetWindowText(NULL);
- // TODO: add reinitialization code here
- // (SDI documents will reuse this document)
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CPeugeotDoc serialization
- void CPeugeotDoc::Serialize(CArchive& ar)
- {
- if (ar.IsStoring())
- {
- // TODO: add storing code here
- //((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
- }
- else
- {
- // TODO: add loading code here
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // CPeugeotDoc diagnostics
- #ifdef _DEBUG
- void CPeugeotDoc::AssertValid() const
- {
- CDocument::AssertValid();
- }
- void CPeugeotDoc::Dump(CDumpContext& dc) const
- {
- CDocument::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CPeugeotDoc commands
- void CPeugeotDoc::NewStackAddr()
- {
- //若已经开辟空间,释放
- if (m_pYXData != NULL)
- {
- delete[] m_pYXData;
- m_pYXData = NULL;
- }
- if (m_pYCData != NULL)
- {
- delete[] m_pYCData;
- m_pYCData = NULL;
- }
- if (m_pYMData != NULL)
- {
- delete[] m_pYMData;
- m_pYMData = NULL;
- }
- /////////////////////////////////////
- //开辟内存空间,并初始化值
- m_pYXData = new BYTE[m_YXNum];
- m_pYCData = new int[m_YCNum];
- m_pYMData = new DWORD[m_YMNum];
- int i = 0;
- if (m_pYXData != NULL)
- for (i=0; i<m_YXNum; i++)
- m_pYXData[i] = 0x00;
- if (m_pYCData != NULL)
- for (i=0; i<m_YCNum; i++)
- m_pYCData[i] = 0x0000;
- if (m_pYMData != NULL)
- for (i=0; i<m_YMNum; i++)
- m_pYMData[i] = 0x0000;
- }