-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandHandle.cpp
More file actions
executable file
·69 lines (50 loc) · 1.5 KB
/
CommandHandle.cpp
File metadata and controls
executable file
·69 lines (50 loc) · 1.5 KB
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
#include "CommandHandle.h"
CommandHandle::CommandHandle( TRoboCupConnection * connetion, CommandQuene * cmdQuene )
{
//mCommand.empty();
mConnetion = connetion;
mCmdQuene = cmdQuene;
}
CommandHandle::~CommandHandle()
{
}
bool CommandHandle::SendPlayerInformation( int playerNo, string teamName )
{
char cmd[128];
sprintf( cmd, "(init (unum %d)(teamname %s))", playerNo, teamName.c_str() );
SendCommand( cmd );
}
bool CommandHandle::SendPlayerInitializePosition( float initX, float initY, float initZ, float initAng )
{
char cmd[128];
sprintf( cmd, "(move %0.2f %0.2f %0.2f %0.2f)", initX, initY, initZ, initAng );
SendCommand( cmd );
}
bool CommandHandle::SendPlayerBeamPosition( float beamX, float beamY, float beamAng )
{
char cmd[128];
sprintf( cmd, "(beam %0.2f %0.2f %0.2f)", beamX, beamY, beamAng );
SendCommand( cmd );
}
bool CommandHandle::SendCommand( const char * str ) const
{
string fin = string(str) + "(syn)";
return mConnetion->sendCommand( fin.c_str() );
}
bool CommandHandle::SendCommand()
{
string cmd;
mCmdQuene->PopCommand( cmd );
mCmdQuene->ClearCommand();
///////////////////////////////////////
// For Debug //
///////////////////////////////////////
//static int msgNum = 0;
//msgNum ++;
//char numString[15];
//sprintf( numString, "( %d )", msgNum );
//string sendMsg = string(numString) + cmd;
//SendCommand( sendMsg.data() );
///////////////////////////////////////
SendCommand( cmd.c_str() );
}