-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplug.hpp
189 lines (155 loc) · 4.59 KB
/
plug.hpp
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
* Simulation@Home Competition
* File: plug.hpp
* Author: Jiongkun Xie
* Affiliation: Multi-Agent Systems Lab.
* University of Science and Technology of China
*/
#ifndef __home_plug_HPP__
#define __home_plug_HPP__
#include <string>
#include <vector>
#include <boost/cstdint.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/array.hpp>
namespace _home
{
class Message;
/**
* @class Plug
* defines a common entry for platform of Home Simulation.
*/
class Plug
{
private:
class TKernel;
typedef boost::shared_ptr<Message> MessagePtr;
public:
/**
* Destructor
*/
virtual ~Plug();
/**
* Run the client's event processing loop for the test.
*/
void Run();
protected:
/**
* Constructor
* @param _name is the team name
*/
Plug(const std::string& _name);
/**
* The processing of a plan should be implemented in this function.
*/
virtual void Plan() = 0;
/**
* If something need to be destructed after planning,
* this function should be overloaded.
*/
virtual void Fini() {}
/**
* Gets the team name.
*/
const std::string& GetName() const { return mName; }
/**
* Gets the name of the test
*/
const std::string& GetTestName() const { return mTestName; }
/**
* Gets the description of the environment.
*/
const std::string& GetEnvDes() const { return mEnvDes; }
/**
* Gets the description of the task.
*/
const std::string& GetTaskDes() const { return mTaskDes; }
/**
* Atomic action Move
* @param x location number
* @return if the action is successful or not
*/
bool Move(unsigned int x);
/**
* Atomic action PickUp
* @param a object number
* @return if the action is successful or not
*/
bool PickUp(unsigned int a);
/**
* Atomic action PutDown
* @param a object number
* @return if the action is successful or not
*/
bool PutDown(unsigned int a);
/**
* Atomic action ToPlate
* @param a object number
* @return if the action is successful or not
*/
bool ToPlate(unsigned int a);
/**
* Atomic action FromPlate
* @param a object number
* @return if the action is successful or not
*/
bool FromPlate(unsigned int a);
/**
* Atomic action Open
* @param a object number
* @return if the action is successful or not
*/
bool Open(unsigned int a);
/**
* Atomic action Close
* @param a object number
* @return if the action is successful or not
*/
bool Close(unsigned int a);
/**
* Atomic action PutIn
* @param a small object number
* @param b big object number
* @return if the action is successful or not
*/
bool PutIn(unsigned int a, unsigned int b);
/**
* Atomic action TakeOut
* @param a small object number
* @param b big object number
* @return if the action is successful or not
*/
bool TakeOut(unsigned int a, unsigned int b);
/**
* Atomic action AskLoc
* @param a object number
* @return "not_known" means don't know where 'a' is
* "(on a b)", "(near a b)", or "(inside a b)" means
* the spacial relation with 'b'
*/
std::string AskLoc(unsigned int a);
/**
* Atomic action Sense
* @param A_ return set of numbers for the object observed
*/
void Sense(std::vector<unsigned int>& A_);
private:
/**
* Connects to the server.
*/
bool Conncet();
/**
* Communicate with the server.
*/
MessagePtr SendMsg(const MessagePtr& msg);
private:
std::string mName;
std::string mTestName;
std::string mEnvDes;
std::string mTaskDes;
TKernel* mKernel;
boost::array<boost::uint8_t, 4> mMsgLen;
};//Plug
}//_home
#endif//__home_plug_HPP__
//end of file