📄 newsocket.cpp
字号:
// NewSocket.cpp : implementation file
//
#include "stdafx.h"
#include "Server.h"
#include "NewSocket.h"
#include "ServerDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNewSocket
CNewSocket::CNewSocket()
{
// row=0;
}
CNewSocket::~CNewSocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CNewSocket, CAsyncSocket)
//{{AFX_MSG_MAP(CNewSocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CNewSocket member functions
void CNewSocket::OnReceive(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
m_nLength=Receive(m_szBuffer,4096,0);
CServerApp* pServerApp=(CServerApp*)AfxGetApp();
CServerDlg* pServerDlg=(CServerDlg*)pServerApp->m_pMainWnd;
if (_strnicmp(m_szBuffer,"Open",4)==0) {
pServerDlg->OnOpen();
strncpy(m_szBuffer,"OK",2);
m_nLength=2;
AsyncSelect(FD_WRITE);
/*
if (!pServerDlg->m_bOpened) {
pServerDlg->OnOpen();
strncpy(m_szBuffer,"OK",2);
m_nLength=2;
}
else{
strncpy(m_szBuffer,"Fail",4);
m_nLength=4;
AsyncSelect(FD_WRITE);
}
*/
}
else if (_strnicmp(m_szBuffer,"Stop",4)==0) {
pServerDlg->OnOpen();
strncpy(m_szBuffer,"OK",2);
m_nLength=2;
AsyncSelect(FD_WRITE);
}
else if (_strnicmp(m_szBuffer,"GoHome",6)==0) {
pServerDlg->OnGohome();
strncpy(m_szBuffer,"OK",2);
m_nLength=2;
AsyncSelect(FD_WRITE);
}
else if (_strnicmp(m_szBuffer,"Refresh",7)==0) {
pServerDlg->GetJointValue();
strncpy(m_szBuffer,"OK",2);
m_nLength=2;
AsyncSelect(FD_WRITE);
}
// AsyncSelect(FD_WRITE);
CAsyncSocket::OnReceive(nErrorCode);
}
void CNewSocket::OnSend(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
Send(m_szBuffer,m_nLength,0);
AsyncSelect(FD_READ);
CAsyncSocket::OnSend(nErrorCode);
}
/////////////////////////////////////////////////////////////////////////////
// CNewDataSocket
CNewDataSocket::CNewDataSocket()
{
}
CNewDataSocket::~CNewDataSocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CNewDataSocket, CAsyncSocket)
//{{AFX_MSG_MAP(CNewDataSocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CNewDataSocket member functions
void CNewDataSocket::OnReceive(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
CServerApp* pApp=(CServerApp*)AfxGetApp();
CServerDlg* pDlg=(CServerDlg*)pApp->m_pMainWnd;
m_nLength=Receive(m_nData,sizeof(m_nData),0);
// double temp[8];
if (pDlg->m_bOpened) {
// m_obArray.Add(temp);
for(int i=0;i<8;i++)
angle[(pDlg->row)][i]=m_nData[i];
pDlg->Move();
// row+=1;
}
AsyncSelect(FD_READ);
CAsyncSocket::OnReceive(nErrorCode);
}
void CNewDataSocket::OnSend(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
CAsyncSocket::OnSend(nErrorCode);
}
/////////////////////////////////////////////////////////////////////////////
// CNewBackDataSocket
CNewBackDataSocket::CNewBackDataSocket()
{
}
CNewBackDataSocket::~CNewBackDataSocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CNewBackDataSocket, CAsyncSocket)
//{{AFX_MSG_MAP(CNewBackDataSocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CNewBackDataSocket member functions
void CNewBackDataSocket::OnReceive(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
CAsyncSocket::OnReceive(nErrorCode);
}
void CNewBackDataSocket::OnSend(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
Send(backAngle,sizeof(backAngle),0);
CAsyncSocket::OnSend(nErrorCode);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -