-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrealagv.cpp
More file actions
48 lines (36 loc) · 955 Bytes
/
realagv.cpp
File metadata and controls
48 lines (36 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "realagv.h"
#include "network/tcpclient.h"
RealAgv::RealAgv(int id,std::string name,std::string ip,int port):
Agv(id,name,ip,port),
tcpClient(nullptr)
{
}
RealAgv::~RealAgv(){
if (tcpClient)delete tcpClient;
}
void RealAgv::init()
{
TcpClient::ClientReadCallback onread = std::bind(&RealAgv::onRead, this, std::placeholders::_1, std::placeholders::_2);
TcpClient::ClientConnectCallback onconnect = std::bind(&RealAgv::onConnect, this);
TcpClient::ClientDisconnectCallback ondisconnect = std::bind(&RealAgv::onDisconnect, this);
tcpClient = new TcpClient(ip, port, onread, onconnect, ondisconnect);
}
void RealAgv::onRead(const char *data, int len)
{
}
void RealAgv::onConnect()
{
//TODO
}
void RealAgv::onDisconnect()
{
//TODO
}
void RealAgv::reconnect()
{
tcpClient->resetConnect(ip, port);
}
bool RealAgv::send(const char *data, int len)
{
return tcpClient->sendToServer(data, len);
}