|
From: <sgv...@us...> - 2011-03-02 18:04:58
|
Revision: 249
http://simspark.svn.sourceforge.net/simspark/?rev=249&view=rev
Author: sgvandijk
Date: 2011-03-02 18:04:51 +0000 (Wed, 02 Mar 2011)
Log Message:
-----------
- killsim command to kill the server through trainer protocol
Modified Paths:
--------------
trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp
trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h
Modified: trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp
===================================================================
--- trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp 2011-03-02 17:22:58 UTC (rev 248)
+++ trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp 2011-03-02 18:04:51 UTC (rev 249)
@@ -50,7 +50,7 @@
mCommandMap["select"] = CT_SELECT;
mCommandMap["kill"] = CT_KILL;
mCommandMap["repos"] = CT_REPOS;
-
+ mCommandMap["killsim"] = CT_KILLSIM;
// setup team index map
// Originally team sides were "L","R" and "N"
// But this seems to be unused
@@ -120,6 +120,15 @@
GetLog()->Error() << "ERROR: (TrainerCommandParser) Unable to get GameControlServer\n";
}
+ mSimServer = shared_dynamic_cast<SimulationServer>
+ (GetCore()->Get("/sys/server/simulation"));
+
+ if (mGameControl.get() == 0)
+ {
+ GetLog()->Error() << "ERROR: (TrainerCommandParser) Unable to get SimulationServer\n";
+ }
+
+
}
void TrainerCommandParser::OnUnlink()
@@ -212,6 +221,9 @@
case CT_REPOS:
ParseReposCommand(predicate);
break;
+ case CT_KILLSIM:
+ ParseKillSimCommand(predicate);
+ break;
default:
return false;
}
@@ -699,3 +711,7 @@
}
}
+void TrainerCommandParser::ParseKillSimCommand(const oxygen::Predicate & predicate)
+{
+ mSimServer->Quit();
+}
Modified: trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h
===================================================================
--- trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h 2011-03-02 17:22:58 UTC (rev 248)
+++ trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h 2011-03-02 18:04:51 UTC (rev 249)
@@ -32,6 +32,7 @@
#include <salt/vector.h>
#include <soccertypes.h>
#include <soccerruleaspect/soccerruleaspect.h>
+#include <oxygen/simulationserver/simulationserver.h>
namespace oxygen
{
@@ -52,7 +53,8 @@
CT_ACK,
CT_SELECT,
CT_KILL,
- CT_REPOS
+ CT_REPOS,
+ CT_KILLSIM
};
typedef std::map<std::string, ECommandType> TCommandMap;
@@ -123,6 +125,12 @@
predicate
*/
void ParseReposCommand(const oxygen::Predicate & predicate);
+
+ /** parses and executes the killsim command contained in the given
+ predicate
+ */
+ void ParseKillSimCommand(const oxygen::Predicate & predicate);
+
protected:
TCommandMap mCommandMap;
@@ -138,7 +146,9 @@
boost::shared_ptr<oxygen::BaseParser> mSexpParser;
//! cached reference to the game control server
boost::shared_ptr<oxygen::GameControlServer> mGameControl;
-
+ //! cached reference to the simulation server
+ boost::shared_ptr<oxygen::SimulationServer> mSimServer;
+
bool mGetAck;
std::string mAckString;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pat...@us...> - 2015-02-07 20:31:20
|
Revision: 386
http://sourceforge.net/p/simspark/svn/386
Author: patmac369
Date: 2015-02-07 20:31:12 +0000 (Sat, 07 Feb 2015)
Log Message:
-----------
Adding new training command parser commands for setting the game time and score. They are the following commands:
(time <time>)
(score (left <score>) (right <score>))
Also removing a couple unecessary messages in the repos command that were being printed to stderr for debugging purposes.
Modified Paths:
--------------
trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp
trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h
Modified: trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp
===================================================================
--- trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp 2015-02-06 04:28:44 UTC (rev 385)
+++ trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.cpp 2015-02-07 20:31:12 UTC (rev 386)
@@ -52,6 +52,8 @@
mCommandMap["repos"] = CT_REPOS;
mCommandMap["killsim"] = CT_KILLSIM;
mCommandMap["reqfullstate"] = CT_REQFULLSTATE;
+ mCommandMap["time"] = CT_TIME;
+ mCommandMap["score"] = CT_SCORE;
// setup team index map
// Originally team sides were "L","R" and "N"
@@ -235,6 +237,12 @@
case CT_REQFULLSTATE:
mMonitorControl->RequestFullState();
break;
+ case CT_TIME:
+ ParseTimeCommand(predicate);
+ break;
+ case CT_SCORE:
+ ParseScoreCommand(predicate);
+ break;
default:
return false;
@@ -661,7 +669,7 @@
void TrainerCommandParser::ParseReposCommand(const oxygen::Predicate & predicate)
{
- cerr << "repos 2" << endl;
+ //cerr << "repos 2" << endl;
Predicate::Iterator unumParam(predicate);
int unum;
@@ -714,7 +722,7 @@
ballPos = ballBody->GetPosition();
SoccerBase::GetTransformParent(**iter, agent_aspect);
- cerr << "repos 3" << endl;
+ //cerr << "repos 3" << endl;
Vector3f new_pos = mSoccerRule->RepositionOutsidePos(ballPos, (*iter)->GetUniformNumber(), (*iter)->GetTeamIndex());
SoccerBase::MoveAgent(agent_aspect, new_pos);
@@ -727,3 +735,91 @@
{
mSimServer->Quit();
}
+
+void TrainerCommandParser::ParseTimeCommand(const oxygen::Predicate & predicate)
+{
+ Predicate::Iterator timeParam(predicate);
+ float time;
+
+ if (predicate.GetValue(timeParam,time))
+ {
+ if (time >= 0)
+ {
+ mGameState->SetTime(time);
+ }
+ else
+ {
+ GetLog()->Debug()
+ << "(TrainerCommandParser) ERROR: value of time "
+ << time << " cannot be a negative value\n";
+ return;
+ }
+ }
+ else
+ {
+ GetLog()->Debug()
+ << "(TrainerCommandParser) ERROR: could not parse time "
+ << time << "\n";
+ return;
+ }
+}
+
+void TrainerCommandParser::ParseScoreCommand(const oxygen::Predicate & predicate)
+{
+ Predicate::Iterator leftScoreParam(predicate);
+ int scoreLeft;
+ if (predicate.FindParameter(leftScoreParam, "left"))
+ {
+ if (!predicate.GetValue(leftScoreParam, scoreLeft))
+ {
+ GetLog()->Debug()
+ << "(TrainerCommandParser) ERROR: could not parse score left "
+ << scoreLeft << "\n";
+ return;
+ }
+ }
+ else
+ {
+ GetLog()->Debug()
+ << "(TrainerCommandParser) ERROR: could not find score left\n";
+ return;
+ }
+
+
+ Predicate::Iterator rightScoreParam(predicate);
+ int scoreRight;
+ if (predicate.FindParameter(rightScoreParam, "right"))
+ {
+ if (!predicate.GetValue(rightScoreParam, scoreRight))
+ {
+ GetLog()->Debug()
+ << "(TrainerCommandParser) ERROR: could not parse score right "
+ << scoreRight << "\n";
+ return;
+ }
+ }
+ else
+ {
+ GetLog()->Debug()
+ << "(TrainerCommandParser) ERROR: could not find score right\n";
+ return;
+ }
+
+ if (scoreLeft < 0)
+ {
+ GetLog()->Debug()
+ << "(TrainerCommandParser) ERROR: score left "
+ << scoreLeft << " cannot be negative\n";
+ return;
+ }
+
+ if (scoreRight < 0)
+ {
+ GetLog()->Debug()
+ << "(TrainerCommandParser) ERROR: score right "
+ << scoreRight << " cannot be negative\n";
+ return;
+ }
+
+ mGameState->SetScores(scoreLeft, scoreRight);
+}
Modified: trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h
===================================================================
--- trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h 2015-02-06 04:28:44 UTC (rev 385)
+++ trunk/rcssserver3d/plugin/soccer/trainercommandparser/trainercommandparser.h 2015-02-07 20:31:12 UTC (rev 386)
@@ -56,7 +56,9 @@
CT_KILL,
CT_REPOS,
CT_KILLSIM,
- CT_REQFULLSTATE
+ CT_REQFULLSTATE,
+ CT_TIME,
+ CT_SCORE
};
typedef std::map<std::string, ECommandType> TCommandMap;
@@ -132,7 +134,18 @@
predicate
*/
void ParseKillSimCommand(const oxygen::Predicate & predicate);
+
+ /** parses and executes the time command contained in the given
+ predicate
+ */
+ void ParseTimeCommand(const oxygen::Predicate & predicate);
+
+ /** parses and executes the score command contained in the given
+ predicate
+ */
+ void ParseScoreCommand(const oxygen::Predicate & predicate);
+
protected:
TCommandMap mCommandMap;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|