From: <he...@us...> - 2013-06-12 20:53:34
|
Revision: 366 http://sourceforge.net/p/simspark/svn/366 Author: hedayat Date: 2013-06-12 20:53:27 +0000 (Wed, 12 Jun 2013) Log Message: ----------- Replace all Windows new lines with Unix ones for consistency Modified Paths: -------------- branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/export.h branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/soccercontrolframe.cpp branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/soccercontrolframe.h branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/soccercontrolframe_soccercommands.cpp branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/soccercontrolframe_soccercommands.h branches/gui-bullet/rcssserver3d/sparkgui/main.cpp branches/gui-bullet/spark/carbon/aboutdialog.cpp branches/gui-bullet/spark/carbon/aboutdialog.h branches/gui-bullet/spark/carbon/abstractcommand.cpp branches/gui-bullet/spark/carbon/abstractcommand.h branches/gui-bullet/spark/carbon/abstractcommandqueue.cpp branches/gui-bullet/spark/carbon/abstractcommandqueue.h branches/gui-bullet/spark/carbon/abstractplugin.cpp branches/gui-bullet/spark/carbon/abstractplugin.h branches/gui-bullet/spark/carbon/attachableframe.cpp branches/gui-bullet/spark/carbon/attachableframe.h branches/gui-bullet/spark/carbon/carbon.cpp branches/gui-bullet/spark/carbon/carbon.h branches/gui-bullet/spark/carbon/communicationmanager.cpp branches/gui-bullet/spark/carbon/communicationmanager.h branches/gui-bullet/spark/carbon/cutelogger/debugappender.cpp branches/gui-bullet/spark/carbon/cutelogger/debugappender.h branches/gui-bullet/spark/carbon/cutelogger/functionappender.cpp branches/gui-bullet/spark/carbon/cutelogger/functionappender.h branches/gui-bullet/spark/carbon/cutelogger/imessagereceiver.cpp branches/gui-bullet/spark/carbon/cutelogger/imessagereceiver.h branches/gui-bullet/spark/carbon/cutelogger/logger.cpp branches/gui-bullet/spark/carbon/cutelogger/logmessage.cpp branches/gui-bullet/spark/carbon/cutelogger/logmessage.h branches/gui-bullet/spark/carbon/cutelogger/logstream.cpp branches/gui-bullet/spark/carbon/cutelogger/logstream.h branches/gui-bullet/spark/carbon/cutelogger/logstreambuffer.cpp branches/gui-bullet/spark/carbon/cutelogger/logstreambuffer.h branches/gui-bullet/spark/carbon/cutelogger/messageobjectappender.cpp branches/gui-bullet/spark/carbon/cutelogger/messageobjectappender.h branches/gui-bullet/spark/carbon/cutelogger/messagereceiverappender.cpp branches/gui-bullet/spark/carbon/cutelogger/messagereceiverappender.h branches/gui-bullet/spark/carbon/frameattachmentpoint.cpp branches/gui-bullet/spark/carbon/frameattachmentpoint.h branches/gui-bullet/spark/carbon/glwidget.cpp branches/gui-bullet/spark/carbon/glwidget.h branches/gui-bullet/spark/carbon/guisettings_pluginsettings.cpp branches/gui-bullet/spark/carbon/guisettings_pluginsettings.h branches/gui-bullet/spark/carbon/guisettings_simulationsettings.cpp branches/gui-bullet/spark/carbon/guisettings_simulationsettings.h branches/gui-bullet/spark/carbon/guisimcontrol.cpp branches/gui-bullet/spark/carbon/guisimcontrol.h branches/gui-bullet/spark/carbon/guisimcontrol_c.cpp branches/gui-bullet/spark/carbon/inputqt.cpp branches/gui-bullet/spark/carbon/inputqt.h branches/gui-bullet/spark/carbon/isimcontrol.cpp branches/gui-bullet/spark/carbon/isimcontrol.h branches/gui-bullet/spark/carbon/libraryloader.cpp branches/gui-bullet/spark/carbon/libraryloader.h branches/gui-bullet/spark/carbon/main.cpp branches/gui-bullet/spark/carbon/matrixwidget.cpp branches/gui-bullet/spark/carbon/matrixwidget.h branches/gui-bullet/spark/carbon/menumanager.cpp branches/gui-bullet/spark/carbon/menumanager.h branches/gui-bullet/spark/carbon/menuobject.cpp branches/gui-bullet/spark/carbon/menuobject.h branches/gui-bullet/spark/carbon/menuobjectcall.cpp branches/gui-bullet/spark/carbon/menuobjectcall.h branches/gui-bullet/spark/carbon/menuobjectconnection.cpp branches/gui-bullet/spark/carbon/menuobjectconnection.h branches/gui-bullet/spark/carbon/menuobjectfile.cpp branches/gui-bullet/spark/carbon/menuobjectfile.h branches/gui-bullet/spark/carbon/menuobjectmenu.cpp branches/gui-bullet/spark/carbon/menuobjectmenu.h branches/gui-bullet/spark/carbon/menuobjectmenuaction.cpp branches/gui-bullet/spark/carbon/menuobjectmenuaction.h branches/gui-bullet/spark/carbon/menuobjecttoolbar.cpp branches/gui-bullet/spark/carbon/menuobjecttoolbar.h branches/gui-bullet/spark/carbon/namedactionreceiver.cpp branches/gui-bullet/spark/carbon/namedactionreceiver.h branches/gui-bullet/spark/carbon/numberedactionreceiver.cpp branches/gui-bullet/spark/carbon/numberedactionreceiver.h branches/gui-bullet/spark/carbon/openglmanager.cpp branches/gui-bullet/spark/carbon/openglmanager.h branches/gui-bullet/spark/carbon/plugin.cpp branches/gui-bullet/spark/carbon/plugin.h branches/gui-bullet/spark/carbon/plugindefinition.cpp branches/gui-bullet/spark/carbon/plugindefinition.h branches/gui-bullet/spark/carbon/plugindialog.cpp branches/gui-bullet/spark/carbon/plugindialog.h branches/gui-bullet/spark/carbon/plugininstantiatormodel.cpp branches/gui-bullet/spark/carbon/plugininstantiatormodel.h branches/gui-bullet/spark/carbon/pluginmanager.cpp branches/gui-bullet/spark/carbon/pluginmanager.h branches/gui-bullet/spark/carbon/pluginthread.cpp branches/gui-bullet/spark/carbon/pluginthread.h branches/gui-bullet/spark/carbon/plugintype.cpp branches/gui-bullet/spark/carbon/plugintype.h branches/gui-bullet/spark/carbon/process.cpp branches/gui-bullet/spark/carbon/process.h branches/gui-bullet/spark/carbon/serverthread.cpp branches/gui-bullet/spark/carbon/serverthread.h branches/gui-bullet/spark/carbon/settings.cpp branches/gui-bullet/spark/carbon/settings.h branches/gui-bullet/spark/carbon/settingsdialog.cpp branches/gui-bullet/spark/carbon/settingsdialog.h branches/gui-bullet/spark/carbon/settingstreeview.cpp branches/gui-bullet/spark/carbon/settingstreeview.h branches/gui-bullet/spark/carbon/settingswidget.cpp branches/gui-bullet/spark/carbon/settingswidget.h branches/gui-bullet/spark/carbon/setupdialog.cpp branches/gui-bullet/spark/carbon/setupdialog.h branches/gui-bullet/spark/carbon/setupframe.cpp branches/gui-bullet/spark/carbon/setupframe.h branches/gui-bullet/spark/carbon/signalplugin.cpp branches/gui-bullet/spark/carbon/signalplugin.h branches/gui-bullet/spark/carbon/simspark.cpp branches/gui-bullet/spark/carbon/simspark.h branches/gui-bullet/spark/carbon/simulation.cpp branches/gui-bullet/spark/carbon/simulation.h branches/gui-bullet/spark/carbon/simulationmanager.cpp branches/gui-bullet/spark/carbon/simulationmanager.h branches/gui-bullet/spark/carbon/simulationprocess.cpp branches/gui-bullet/spark/carbon/simulationprocess.h branches/gui-bullet/spark/carbon/simulationsetup.cpp branches/gui-bullet/spark/carbon/simulationsetup.h branches/gui-bullet/spark/carbon/simulationtask.cpp branches/gui-bullet/spark/carbon/simulationtask.h branches/gui-bullet/spark/carbon/simulationthread.cpp branches/gui-bullet/spark/carbon/simulationthread.h branches/gui-bullet/spark/carbon/sparkcommandqueue.cpp branches/gui-bullet/spark/carbon/sparkcommandqueue.h branches/gui-bullet/spark/carbon/sparkcommands.cpp branches/gui-bullet/spark/carbon/sparkcommands.h branches/gui-bullet/spark/carbon/sparkcontext.cpp branches/gui-bullet/spark/carbon/sparkcontext.h branches/gui-bullet/spark/carbon/sparkcontroller.cpp branches/gui-bullet/spark/carbon/sparkcontroller.h branches/gui-bullet/spark/carbon/sparkprocess.cpp branches/gui-bullet/spark/carbon/sparkprocess.h branches/gui-bullet/spark/carbon/sparkproperty.cpp branches/gui-bullet/spark/carbon/sparkproperty.h branches/gui-bullet/spark/carbon/sparkpropertycontrol.cpp branches/gui-bullet/spark/carbon/sparkpropertycontrol.h branches/gui-bullet/spark/carbon/sparkpropertycontrolbasic.cpp branches/gui-bullet/spark/carbon/sparkpropertycontrolbasic.h branches/gui-bullet/spark/carbon/sparkpropertydata.cpp branches/gui-bullet/spark/carbon/sparkpropertydata.h branches/gui-bullet/spark/carbon/sparkpropertyexecuter.cpp branches/gui-bullet/spark/carbon/sparkpropertyexecuter.h branches/gui-bullet/spark/carbon/sparkpropertylist.cpp branches/gui-bullet/spark/carbon/sparkpropertylist.h branches/gui-bullet/spark/carbon/sparkpropertymanager.cpp branches/gui-bullet/spark/carbon/sparkpropertymanager.h branches/gui-bullet/spark/carbon/sparkpropertytablewidget.cpp branches/gui-bullet/spark/carbon/sparkpropertytablewidget.h branches/gui-bullet/spark/carbon/sparkpropertywidget.cpp branches/gui-bullet/spark/carbon/sparkpropertywidget.h branches/gui-bullet/spark/carbon/sparksimulationthread.cpp branches/gui-bullet/spark/carbon/sparksimulationthread.h branches/gui-bullet/spark/carbon/sparktreemodel.cpp branches/gui-bullet/spark/carbon/sparktreemodel.h branches/gui-bullet/spark/carbon/sparktreeview.cpp branches/gui-bullet/spark/carbon/sparktreeview.h branches/gui-bullet/spark/carbon/taskdefinition.cpp branches/gui-bullet/spark/carbon/taskdefinition.h branches/gui-bullet/spark/carbon/toolseparatorbutton.cpp branches/gui-bullet/spark/carbon/toolseparatorbutton.h branches/gui-bullet/spark/carbon/topic.cpp branches/gui-bullet/spark/carbon/topic.h branches/gui-bullet/spark/carbon/topicregistration.cpp branches/gui-bullet/spark/carbon/topicregistration.h branches/gui-bullet/spark/carbon/treeitem.cpp branches/gui-bullet/spark/carbon/treeitem.h branches/gui-bullet/spark/carbon/typedlineedit.cpp branches/gui-bullet/spark/carbon/typedlineedit.h branches/gui-bullet/spark/carbon/vector2x3widget.cpp branches/gui-bullet/spark/carbon/vector2x3widget.h branches/gui-bullet/spark/carbon/vector3widget.cpp branches/gui-bullet/spark/carbon/vector3widget.h branches/gui-bullet/spark/carbon/vector4widget.cpp branches/gui-bullet/spark/carbon/vector4widget.h branches/gui-bullet/spark/carbon/windowdefinition.cpp branches/gui-bullet/spark/carbon/windowdefinition.h branches/gui-bullet/spark/carbon/windowmanager.cpp branches/gui-bullet/spark/carbon/windowmanager.h branches/gui-bullet/spark/guilayout/guigridlayout/export.h branches/gui-bullet/spark/guilayout/guigridlayout/guigridlayout.cpp branches/gui-bullet/spark/guilayout/guigridlayout/guigridlayout.h branches/gui-bullet/spark/guilayout/guisimplelayout/export.h branches/gui-bullet/spark/guilayout/guisimplelayout/guisimplelayout.cpp branches/gui-bullet/spark/guilayout/guisimplelayout/guisimplelayout.h branches/gui-bullet/spark/guiplugin/logframe/export.h branches/gui-bullet/spark/guiplugin/logframe/logframe.cpp branches/gui-bullet/spark/guiplugin/logframe/logframe.h branches/gui-bullet/spark/guiplugin/logframe/logframe_logsettings.cpp branches/gui-bullet/spark/guiplugin/logframe/logframe_logsettings.h branches/gui-bullet/spark/guiplugin/monitorframe/export.h branches/gui-bullet/spark/guiplugin/monitorframe/monitorframe.cpp branches/gui-bullet/spark/guiplugin/monitorframe/monitorframe.h branches/gui-bullet/spark/guiplugin/monitorframe/monitorframe_glconstants.cpp branches/gui-bullet/spark/guiplugin/monitorframe/monitorframe_glconstants.h branches/gui-bullet/spark/guiplugin/monitorframe/monitorframe_sparkglrender.cpp branches/gui-bullet/spark/guiplugin/monitorframe/monitorframe_sparkglrender.h branches/gui-bullet/spark/guiplugin/monitorframe/monitorframe_sparkglwidget.cpp branches/gui-bullet/spark/guiplugin/monitorframe/monitorframe_sparkglwidget.h branches/gui-bullet/spark/guiplugin/scenegraphframe/export.h branches/gui-bullet/spark/guiplugin/scenegraphframe/scenegraphframe.cpp branches/gui-bullet/spark/guiplugin/scenegraphframe/scenegraphframe.h branches/gui-bullet/spark/guiplugin/scenegraphframe/scenegraphframe_propertyframe.cpp branches/gui-bullet/spark/guiplugin/scenegraphframe/scenegraphframe_propertyframe.h branches/gui-bullet/spark/guiplugin/scenegraphframe/scenegraphframe_scenegraphwidget.cpp branches/gui-bullet/spark/guiplugin/scenegraphframe/scenegraphframe_scenegraphwidget.h branches/gui-bullet/spark/guiplugin/setupframe/export.h branches/gui-bullet/spark/guiplugin/setupframe/setupframe.cpp branches/gui-bullet/spark/guiplugin/setupframe/setupframe.h branches/gui-bullet/spark/guiplugin/simulationframe/export.h branches/gui-bullet/spark/guiplugin/simulationframe/simulationframe.cpp branches/gui-bullet/spark/guiplugin/simulationframe/simulationframe.h branches/gui-bullet/spark/guiplugin/simulationframe/simulationframe_taskwidget.cpp branches/gui-bullet/spark/guiplugin/simulationframe/simulationframe_taskwidget.h branches/gui-bullet/spark/plugin/inputqt/export.cpp branches/gui-bullet/spark/plugin/inputqt/inputqt.cpp branches/gui-bullet/spark/plugin/inputqt/inputqt.h branches/gui-bullet/spark/plugin/inputqt/inputsystemqt.cpp branches/gui-bullet/spark/plugin/inputqt/inputsystemqt.h branches/gui-bullet/spark/plugin/inputqt/inputsystemqt_c.cpp Modified: branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/export.h =================================================================== --- branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/export.h 2013-06-12 20:48:36 UTC (rev 365) +++ branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/export.h 2013-06-12 20:53:27 UTC (rev 366) @@ -1,14 +1,14 @@ -#ifndef EXPORT_LIB -#define EXPORT_LIB -/** - * \file soccercontrolframe/export.h - * \brief Exports the SoccerControlFrame class as a plugin from a shared library. - */ - -#include "soccercontrolframe.h" - -PLUGINS_EXPORT_BEGIN() -PLUGIN_EXPORT(SoccerControlFrame) -PLUGINS_EXPORT_END() - +#ifndef EXPORT_LIB +#define EXPORT_LIB +/** + * \file soccercontrolframe/export.h + * \brief Exports the SoccerControlFrame class as a plugin from a shared library. + */ + +#include "soccercontrolframe.h" + +PLUGINS_EXPORT_BEGIN() +PLUGIN_EXPORT(SoccerControlFrame) +PLUGINS_EXPORT_END() + #endif \ No newline at end of file Modified: branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/soccercontrolframe.cpp =================================================================== --- branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/soccercontrolframe.cpp 2013-06-12 20:48:36 UTC (rev 365) +++ branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/soccercontrolframe.cpp 2013-06-12 20:53:27 UTC (rev 366) @@ -1,610 +1,610 @@ -/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- - - this file is part of rcssserver3D - Author: Patrick Geib - Copyright (C) 2012 RoboCup Soccer Server 3D Maintenance Group - $Id$ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -//Local -#include "soccercontrolframe.h" -#include "soccercontrolframe_soccercommands.h" -#include "export.h" - -//Carbon -#include <pluginmanager.h> -#include <carbon.h> -#include <simulationmanager.h> -#include <simulation.h> -#include <sparkcontroller.h> -#include <guisimcontrol.h> -#include <serverthread.h> -#include <simspark.h> -#include <settings.h> - -//SimSpark -#include <oxygen/gamecontrolserver/gamecontrolserver.h> -#include <zeitgeist/leaf.h> - -//Soccer -#include "soccer/gamestateaspect/gamestateaspect.h" -#include "soccer/soccerruleaspect/soccerruleaspect.h" -#include "soccer/ballstateaspect/ballstateaspect.h" -//#include <agentstate/agentstate.h> - -//Boost -#include <boost/make_shared.hpp> - -//Qt -#include <QValidator> - -using namespace boost; -using namespace oxygen; -using namespace SoccerControlFrameUtil; - -//-------------------------------------------------------------- -// Static -//-------------------------------------------------------------- - -//Factory registration -REGISTER_EXPORT_FRAME(SoccerControlFrame, "soccercontrolframe", "Soccer", 1000) - -//Static class information -void SoccerControlFrame::saveClassInfo() -{ - //Description - setClassInfo(mClassId, AbstractPlugin::PI_DESCRIPTION, - tr("The soccer control frame can be used to monitor and control the state of a simspark soccer simulation.")); - - //Icon - setClassInfo(mClassId, AbstractPlugin::PI_ICON_NAME, ":soccer"); - - //Tags - QStringList tags; - tags << "soccer" << "spark" << "rcssserver3d"; - setClassInfo(mClassId, AbstractPlugin::PI_TAGS, tags); -} - -//-------------------------------------------------------------- -// SoccerFrameUpdateControl -//-------------------------------------------------------------- - -SoccerFrameUpdateControl::SoccerFrameUpdateControl(SoccerControlFrame* parent) - : mParent(parent), CommandQueue(0) -{ -} -SoccerFrameUpdateControl::~SoccerFrameUpdateControl() -{ -} - -void SoccerFrameUpdateControl::startCycle() -{ - emit stateStartCycle(); -} - -void SoccerFrameUpdateControl::endCycle() -{ - SparkCommand::CommandQueue::endCycle(); - emit stateEndCycle(); -} - -void SoccerFrameUpdateControl::waitCycle() -{ - SparkCommand::CommandQueue::waitCycle(); - emit stateWaitCycle(); -} - -//-------------------------------------------------------------- -// SoccerFrame -//-------------------------------------------------------------- -// Public -//-------------------------------------------------------------- - -SoccerControlFrame::SoccerControlFrame() : - mSettings(getCarbon()->getSettings()) -{ - //---------------- - //Layout - ui.setupUi(this); - loadFrameDesign(); - - //---------------- - //Variables - mInit = false; - mLastInitState = true; //--> 1 display update during initialization - mReadyUpdate = true; - mSelectedPlayer = -1; - mSelectedPlayMode = PM_NONE; - mUpdateTimer.setInterval(100); - - //---------------- - //Gui-Field init - ui.gameTimeEdit->setValidator(new QDoubleValidator(0.0, INT_MAX, 4, ui.gameTimeEdit)); - ui.team1GoalsEdit->setValidator(new QIntValidator(0, INT_MAX, ui.team1GoalsEdit)); - ui.team2GoalsEdit->setValidator(new QIntValidator(0, INT_MAX, ui.team2GoalsEdit)); - ui.team1PenaltiesEdit->setValidator(new QIntValidator(0, INT_MAX, ui.team1PenaltiesEdit)); - ui.team2PenaltiesEdit->setValidator(new QIntValidator(0, INT_MAX, ui.team2PenaltiesEdit)); - ui.batteryEdit->setValidator(new QDoubleValidator(0.0, INT_MAX, 4, ui.batteryEdit)); - - //---------------- - //Settings - - loadDefaultSettings(); - loadSettings(); - - //---------------- - //Menu Entries - - //---------------- - //Connections - Simulation* simulation = &*getCarbon()->getSimulationManager()->getSimulation(); - connect(simulation, SIGNAL(serverCreated(boost::shared_ptr<ServerThread>)), this, SLOT(updateServerCreated(boost::shared_ptr<ServerThread>))); - - connect(&mUpdateTimer, SIGNAL(timeout()), this, SLOT(readyUpdate())); -} - -SoccerControlFrame::~SoccerControlFrame() -{ - -} - -void SoccerControlFrame::init(const QStringList& parameters) -{ - //Combo box entries - mGameModes.clear(); - ui.playModeComboBox->clear(); - - mGameModes.insert(PM_BeforeKickOff, GameMode(0, PM_BeforeKickOff, true, tr("Before Kickoff"))); - mGameModes.insert(PM_KickOff_Left, GameMode(0, PM_KickOff_Left, true, tr("KickOff Left"))); - mGameModes.insert(PM_KickOff_Right, GameMode(0, PM_KickOff_Right, true, tr("KickOff Right"))); - mGameModes.insert(PM_PlayOn, GameMode(0, PM_PlayOn, true, tr("Play On"))); - mGameModes.insert(PM_KickIn_Left, GameMode(0, PM_KickIn_Left, true, tr("Kick-In Left"))); - mGameModes.insert(PM_KickIn_Right, GameMode(0, PM_KickIn_Right, true, tr("Kick-In Right"))); - mGameModes.insert(PM_CORNER_KICK_LEFT, GameMode(0, PM_CORNER_KICK_LEFT, true, tr("Corner Kick Left"))); - mGameModes.insert(PM_CORNER_KICK_RIGHT, GameMode(0, PM_CORNER_KICK_RIGHT, true, tr("Corner Kick Right"))); - mGameModes.insert(PM_GOAL_KICK_LEFT, GameMode(0, PM_GOAL_KICK_LEFT, true, tr("Goal Kick Left"))); - mGameModes.insert(PM_GOAL_KICK_RIGHT, GameMode(0, PM_GOAL_KICK_RIGHT, true, tr("Goal Kick Right"))); - mGameModes.insert(PM_OFFSIDE_LEFT, GameMode(0, PM_OFFSIDE_LEFT, true, tr("Offside Left"))); - mGameModes.insert(PM_OFFSIDE_RIGHT, GameMode(0, PM_OFFSIDE_RIGHT, true, tr("Offside Right"))); - mGameModes.insert(PM_GameOver, GameMode(0, PM_GameOver, true, tr("Game Over"))); - mGameModes.insert(PM_Goal_Left, GameMode(0, PM_Goal_Left, true, tr("Goal Left"))); - mGameModes.insert(PM_Goal_Right, GameMode(0, PM_Goal_Right, true, tr("Goal Right"))); - mGameModes.insert(PM_FREE_KICK_LEFT, GameMode(0, PM_FREE_KICK_LEFT, true, tr("Free Kick Left"))); - mGameModes.insert(PM_FREE_KICK_RIGHT, GameMode(0, PM_FREE_KICK_RIGHT, true, tr("Free Kick Right"))); - - int run = 0; - for (auto it = mGameModes.begin(); it != mGameModes.end(); it++) - { - it->mIndex = run; - ui.playModeComboBox->addItem(it->mName); - run++; - } - mSelectedPlayMode = PM_BeforeKickOff; - - tryInitSpark(); - updateDisplay(); -} - -bool SoccerControlFrame::initialized() -{ - return mInit; -} - -void SoccerControlFrame::loadSettings() -{ - -} - -void SoccerControlFrame::saveSettings() -{ - -} - -void SoccerControlFrame::loadDefaultSettings() -{ - mGameControlServerPath = "/sys/server/gamecontrol/"; - mGameStateAspectPath = "/sys/server/gamecontrol/GameStateAspect/"; - mSoccerRuleAspectPath = "/sys/server/gamecontrol/SoccerRuleAspect/"; - mBallStateAspectPath = "/sys/server/gamecontrol/BallStateAspect/"; -} - -//-------------------------------------------------------------- -// Protected -//-------------------------------------------------------------- - -bool SoccerControlFrame::tryInitSpark() -{ - //If already initialized, simply update - if (mInit) - updateDisplay(); - - //If there is no spark controller, try to get it - if (mSparkController.get() == 0) - { - mServerThread = getCarbon()->getSimulationManager()->getSparkServerThread(); - - if (mServerThread.get() == 0) - return false; - else - { - mSparkController = mServerThread->getSparkController(); - connect(&*mSparkController, SIGNAL(sparkRunning(SparkController*)), this, SLOT(updateSparkRunning(SparkController*))); - } - } - - //If there is a spark controller, check for SimSpark - if (mSparkController->getSpark().get() != 0) - { - //There is a controller and simspark-> initialize - - QString gameControlServer = mGameControlServerPath; - QString gameStateAspect = mGameStateAspectPath; - QString soccerRuleAspect = mSoccerRuleAspectPath; - QString ballStateAspect = mBallStateAspectPath; - - //Try to find soccer aspects - if (mSettings->beginGroup(this, true, 1000)) //lock - { - gameControlServer = mSettings->value("mGameControlServerPath", mGameControlServerPath).toString(); - gameStateAspect = mSettings->value("mGameStateAspectPath", mGameStateAspectPath).toString(); - soccerRuleAspect = mSettings->value("mSoccerRuleAspectPath", mSoccerRuleAspectPath).toString(); - ballStateAspect = mSettings->value("mBallStateAspectPath", mBallStateAspectPath).toString(); - mSettings->endGroup(true); //unlock - } - else - { - LOG_WARNING() << "Could not read Settings object in SoccerControlFrame. Using default values for control node paths."; - } - - SimSpark* spark = &*mSparkController->getSpark(); - boost::shared_ptr<GameControlServer> gameControl(shared_dynamic_cast<GameControlServer>(spark->GetCore()->Get(gameControlServer.toStdString()))); - boost::shared_ptr<GameStateAspect> gameState (shared_dynamic_cast<GameStateAspect> (spark->GetCore()->Get(gameStateAspect.toStdString()))); - boost::shared_ptr<SoccerRuleAspect> soccerRule (shared_dynamic_cast<SoccerRuleAspect> (spark->GetCore()->Get(soccerRuleAspect.toStdString()))); - boost::shared_ptr<BallStateAspect> ballState (shared_dynamic_cast<BallStateAspect> (spark->GetCore()->Get(ballStateAspect.toStdString()))); - - bool success = true; - if (!gameControl.get()) - { - LOG_ERROR() << "Soccer GameControlServer not found. Expected it to be at " << gameControlServer << "."; - success = false; - } - if (!gameState.get()) - { - LOG_ERROR() << "Soccer GameStateAspect not found. Expected it to be at " << gameStateAspect << "."; - success = false; - } - if (!soccerRule.get()) - { - LOG_ERROR() << "Soccer SoccerRuleAspect not found. Expected it to be at " << soccerRuleAspect << "."; - success = false; - } - if (!ballState.get()) - { - LOG_ERROR() << "Soccer BallStateAspect not found. Expected it to be at " << ballStateAspect << "."; - success = false; - } - - if (success == false) - { - //Init failed, return - mGameControlServer.reset(); - mRuleAspect.reset(); - mBallAspect.reset(); - mGameAspect.reset(); - return false; - } - - //All nodes found, init successful - mGameControlServer = gameControl; - mRuleAspect = soccerRule; - mBallAspect = ballState; - mGameAspect = gameState; - - //Register control node that polls an update every time a cycle ended - registerUpdater(); - - mInit = true; - updateDisplay(); - return true; - } - return false; -} - -void SoccerControlFrame::registerUpdater() -{ - shared_ptr<GuiSimControl> simControl = mSparkController->getSimulationControl().lock(); - if (simControl.get() == 0) - { - LOG_ERROR() << "No gui simulation control node found to register updater in."; - return; - } - - //Remove old updater (should happen automatically, just to be safe) - if (mUpdater.get() != 0) - { - simControl->unregisterSimControl(mUpdater); - mUpdater.reset(); - } - - //Create new updater - mUpdater = shared_ptr<SoccerFrameUpdateControl>(new SoccerFrameUpdateControl(this)); - simControl->registerSimControl(mUpdater); - connect(&*mUpdater, SIGNAL(stateEndCycle()), this, SLOT(onCycleFinished())); //Queued connection - connect(&*mUpdater, SIGNAL(stateWaitCycle()), this, SLOT(onCycleFinished())); //Queued connection - - //Start update timer - mUpdateTimer.start(); -} - -//-------------------------------------------------------------- -// Private -//-------------------------------------------------------------- - -//-------------------------------------------------------------- -// Protected Slots -//-------------------------------------------------------------- - -void SoccerControlFrame::updateServerCreated(boost::shared_ptr<ServerThread> server) -{ - mSparkController = server->getSparkController(); - connect(&*mSparkController, SIGNAL(sparkRunning(SparkController*)), this, SLOT(updateSparkRunning(SparkController*))); - tryInitSpark(); -} - -void SoccerControlFrame::updateSparkRunning(SparkController* controller) -{ - if (mSparkController.get() != 0) - { - if (mSparkController->getSpark().get() == controller->getSpark().get()) - { - tryInitSpark(); - } - } -} - -void SoccerControlFrame::onCycleFinished() -{ - updateDisplay(); - mReadyUpdate = false; -} - -//-------------------------------------------------------------- -// Public Slots -//-------------------------------------------------------------- - -void SoccerControlFrame::readyUpdate() -{ - mReadyUpdate = true; -} - -void SoccerControlFrame::updateDisplay() -{ - if (mLastInitState != mInit) - { - mLastInitState = mInit; - mUpdateCount = 0; - - ui.batteryEdit->setEnabled(mInit); - ui.temperatureEdit->setEnabled(mInit); - ui.gameTimeEdit->setEnabled(mInit); - ui.team1GoalsEdit->setEnabled(mInit); - ui.team2GoalsEdit->setEnabled(mInit); - ui.team1PenaltiesEdit->setEnabled(mInit); - ui.team2PenaltiesEdit->setEnabled(mInit); - - ui.gameTimeResetButton->setEnabled(mInit); - ui.resetBatteryButton->setEnabled(mInit); - ui.resetTemperatureButton->setEnabled(mInit); - ui.kickOffButton->setEnabled(mInit); - ui.playModeButton->setEnabled(mInit); - ui.playModeComboBox->setEnabled(mInit); - - mSelectedPlayer = -1; - } - - if (!mInit) - { - ui.batteryEdit->setText(""); - ui.temperatureEdit->setText(""); - ui.gameTimeEdit->setText(""); - ui.team1GoalsEdit->setText(""); - ui.team2GoalsEdit->setText(""); - ui.team1PenaltiesEdit->setText(""); - ui.team2PenaltiesEdit->setText(""); - ui.team1NameLabel->setText(tr("Left")); - ui.team2NameLabel->setText(tr("Right")); - ui.agentNameLabel->setText(""); - ui.agentTeamLabel->setText(""); - ui.playModeLabel->setText(tr("Not initialized.")); - } - - if (mInit && mReadyUpdate) - { - //Read and display non-changing values - if (mUpdateCount == 0) - { - } - - //Read and update changing values - ui.team1NameLabel->setText(mGameAspect->GetTeamName(TI_LEFT).c_str()); - ui.team2NameLabel->setText(mGameAspect->GetTeamName(TI_RIGHT).c_str()); - if (!ui.team1GoalsEdit->hasFocus()) ui.team1GoalsEdit->setText(QString::number(mGameAspect->GetScore(TI_LEFT))); - if (!ui.team2GoalsEdit->hasFocus()) ui.team2GoalsEdit->setText(QString::number(mGameAspect->GetScore(TI_RIGHT))); - if (!ui.team1PenaltiesEdit->hasFocus()) ui.team1PenaltiesEdit->setText("0"); - if (!ui.team2PenaltiesEdit->hasFocus()) ui.team2PenaltiesEdit->setText("0"); - - if (!ui.gameTimeEdit->hasFocus()) ui.gameTimeEdit->setText(QString::number(mGameAspect->GetTime())); - - auto pos = mGameModes.find((int)mGameAspect->GetPlayMode()); - if (pos == mGameModes.end()) - { - LOG_WARNING() << "Current game mode " << mGameAspect->GetPlayMode() << " is unknown."; - } - else - { - if (mUpdateCount == 0) - ui.playModeComboBox->setCurrentIndex(pos->mIndex); - ui.playModeLabel->setText(pos->mName); - } - - updatePlayerDisplay(); - } - - mUpdateCount++; -} - -void SoccerControlFrame::updatePlayerDisplay() -{ - if (mSelectedPlayer == -1) - return; - - if (!mInit) - return; -} - -void SoccerControlFrame::editGameTime() -{ - if (!mInit) - return; - - mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::SetTime>(mGameAspect, ui.gameTimeEdit->text().toFloat())); -} - -void SoccerControlFrame::resetGameTime() -{ - if (!mInit) - return; - - mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::SetTime>(mGameAspect, 0.0)); -} - -void SoccerControlFrame::editTeam1Goals() -{ - if (!mInit) - return; - - mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::SetTeamGoals>(mGameAspect, TI_LEFT, ui.team1GoalsEdit->text().toInt())); -} - -void SoccerControlFrame::editTeam2Goals() -{ - if (!mInit) - return; - - mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::SetTeamGoals>(mGameAspect, TI_LEFT, ui.team2GoalsEdit->text().toInt())); -} - -void SoccerControlFrame::editTeam1Penalties() -{ - if (!mInit) - return; -} - -void SoccerControlFrame::editTeam2Penalties() -{ - if (!mInit) - return; -} - -void SoccerControlFrame::selectPlayMode(int index) -{ - if (!mInit) - return; - - ui.playModeButton->setEnabled(false); - - for (auto it = mGameModes.begin(); it != mGameModes.end(); it++) - { - if (it->mIndex == index) - { - mSelectedPlayMode = it->mMode; - ui.playModeButton->setEnabled(it->mManual); - } - } -} - -void SoccerControlFrame::changePlayMode() -{ - if (!mInit) - return; - - mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::ChangePlayMode>(mGameAspect, mSelectedPlayMode)); -} - -void SoccerControlFrame::kickOff() -{ - if (!mInit) - return; - - mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::KickOff>(mGameAspect)); -} - -void SoccerControlFrame::clearPlayers() -{ - if (!mInit) - return; -} - - -void SoccerControlFrame::selectPlayer(int index) -{ - if (!mInit) - return; - - mSelectedPlayer = -1; - updatePlayerDisplay(); -} - -void SoccerControlFrame::editBattery() -{ - if (!mInit) - return; - - if (mSelectedPlayer == -1) - return; - -} - -void SoccerControlFrame::editTemperature() -{ - if (!mInit) - return; - - if (mSelectedPlayer == -1) - return; - -} - -void SoccerControlFrame::resetBattery() -{ - if (!mInit) - return; - - if (mSelectedPlayer == -1) - return; - -} - -void SoccerControlFrame::resetTemperature() -{ - if (!mInit) - return; - - if (mSelectedPlayer == -1) - return; - - +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Author: Patrick Geib + Copyright (C) 2012 RoboCup Soccer Server 3D Maintenance Group + $Id$ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +//Local +#include "soccercontrolframe.h" +#include "soccercontrolframe_soccercommands.h" +#include "export.h" + +//Carbon +#include <pluginmanager.h> +#include <carbon.h> +#include <simulationmanager.h> +#include <simulation.h> +#include <sparkcontroller.h> +#include <guisimcontrol.h> +#include <serverthread.h> +#include <simspark.h> +#include <settings.h> + +//SimSpark +#include <oxygen/gamecontrolserver/gamecontrolserver.h> +#include <zeitgeist/leaf.h> + +//Soccer +#include "soccer/gamestateaspect/gamestateaspect.h" +#include "soccer/soccerruleaspect/soccerruleaspect.h" +#include "soccer/ballstateaspect/ballstateaspect.h" +//#include <agentstate/agentstate.h> + +//Boost +#include <boost/make_shared.hpp> + +//Qt +#include <QValidator> + +using namespace boost; +using namespace oxygen; +using namespace SoccerControlFrameUtil; + +//-------------------------------------------------------------- +// Static +//-------------------------------------------------------------- + +//Factory registration +REGISTER_EXPORT_FRAME(SoccerControlFrame, "soccercontrolframe", "Soccer", 1000) + +//Static class information +void SoccerControlFrame::saveClassInfo() +{ + //Description + setClassInfo(mClassId, AbstractPlugin::PI_DESCRIPTION, + tr("The soccer control frame can be used to monitor and control the state of a simspark soccer simulation.")); + + //Icon + setClassInfo(mClassId, AbstractPlugin::PI_ICON_NAME, ":soccer"); + + //Tags + QStringList tags; + tags << "soccer" << "spark" << "rcssserver3d"; + setClassInfo(mClassId, AbstractPlugin::PI_TAGS, tags); +} + +//-------------------------------------------------------------- +// SoccerFrameUpdateControl +//-------------------------------------------------------------- + +SoccerFrameUpdateControl::SoccerFrameUpdateControl(SoccerControlFrame* parent) + : mParent(parent), CommandQueue(0) +{ +} +SoccerFrameUpdateControl::~SoccerFrameUpdateControl() +{ +} + +void SoccerFrameUpdateControl::startCycle() +{ + emit stateStartCycle(); +} + +void SoccerFrameUpdateControl::endCycle() +{ + SparkCommand::CommandQueue::endCycle(); + emit stateEndCycle(); +} + +void SoccerFrameUpdateControl::waitCycle() +{ + SparkCommand::CommandQueue::waitCycle(); + emit stateWaitCycle(); +} + +//-------------------------------------------------------------- +// SoccerFrame +//-------------------------------------------------------------- +// Public +//-------------------------------------------------------------- + +SoccerControlFrame::SoccerControlFrame() : + mSettings(getCarbon()->getSettings()) +{ + //---------------- + //Layout + ui.setupUi(this); + loadFrameDesign(); + + //---------------- + //Variables + mInit = false; + mLastInitState = true; //--> 1 display update during initialization + mReadyUpdate = true; + mSelectedPlayer = -1; + mSelectedPlayMode = PM_NONE; + mUpdateTimer.setInterval(100); + + //---------------- + //Gui-Field init + ui.gameTimeEdit->setValidator(new QDoubleValidator(0.0, INT_MAX, 4, ui.gameTimeEdit)); + ui.team1GoalsEdit->setValidator(new QIntValidator(0, INT_MAX, ui.team1GoalsEdit)); + ui.team2GoalsEdit->setValidator(new QIntValidator(0, INT_MAX, ui.team2GoalsEdit)); + ui.team1PenaltiesEdit->setValidator(new QIntValidator(0, INT_MAX, ui.team1PenaltiesEdit)); + ui.team2PenaltiesEdit->setValidator(new QIntValidator(0, INT_MAX, ui.team2PenaltiesEdit)); + ui.batteryEdit->setValidator(new QDoubleValidator(0.0, INT_MAX, 4, ui.batteryEdit)); + + //---------------- + //Settings + + loadDefaultSettings(); + loadSettings(); + + //---------------- + //Menu Entries + + //---------------- + //Connections + Simulation* simulation = &*getCarbon()->getSimulationManager()->getSimulation(); + connect(simulation, SIGNAL(serverCreated(boost::shared_ptr<ServerThread>)), this, SLOT(updateServerCreated(boost::shared_ptr<ServerThread>))); + + connect(&mUpdateTimer, SIGNAL(timeout()), this, SLOT(readyUpdate())); +} + +SoccerControlFrame::~SoccerControlFrame() +{ + +} + +void SoccerControlFrame::init(const QStringList& parameters) +{ + //Combo box entries + mGameModes.clear(); + ui.playModeComboBox->clear(); + + mGameModes.insert(PM_BeforeKickOff, GameMode(0, PM_BeforeKickOff, true, tr("Before Kickoff"))); + mGameModes.insert(PM_KickOff_Left, GameMode(0, PM_KickOff_Left, true, tr("KickOff Left"))); + mGameModes.insert(PM_KickOff_Right, GameMode(0, PM_KickOff_Right, true, tr("KickOff Right"))); + mGameModes.insert(PM_PlayOn, GameMode(0, PM_PlayOn, true, tr("Play On"))); + mGameModes.insert(PM_KickIn_Left, GameMode(0, PM_KickIn_Left, true, tr("Kick-In Left"))); + mGameModes.insert(PM_KickIn_Right, GameMode(0, PM_KickIn_Right, true, tr("Kick-In Right"))); + mGameModes.insert(PM_CORNER_KICK_LEFT, GameMode(0, PM_CORNER_KICK_LEFT, true, tr("Corner Kick Left"))); + mGameModes.insert(PM_CORNER_KICK_RIGHT, GameMode(0, PM_CORNER_KICK_RIGHT, true, tr("Corner Kick Right"))); + mGameModes.insert(PM_GOAL_KICK_LEFT, GameMode(0, PM_GOAL_KICK_LEFT, true, tr("Goal Kick Left"))); + mGameModes.insert(PM_GOAL_KICK_RIGHT, GameMode(0, PM_GOAL_KICK_RIGHT, true, tr("Goal Kick Right"))); + mGameModes.insert(PM_OFFSIDE_LEFT, GameMode(0, PM_OFFSIDE_LEFT, true, tr("Offside Left"))); + mGameModes.insert(PM_OFFSIDE_RIGHT, GameMode(0, PM_OFFSIDE_RIGHT, true, tr("Offside Right"))); + mGameModes.insert(PM_GameOver, GameMode(0, PM_GameOver, true, tr("Game Over"))); + mGameModes.insert(PM_Goal_Left, GameMode(0, PM_Goal_Left, true, tr("Goal Left"))); + mGameModes.insert(PM_Goal_Right, GameMode(0, PM_Goal_Right, true, tr("Goal Right"))); + mGameModes.insert(PM_FREE_KICK_LEFT, GameMode(0, PM_FREE_KICK_LEFT, true, tr("Free Kick Left"))); + mGameModes.insert(PM_FREE_KICK_RIGHT, GameMode(0, PM_FREE_KICK_RIGHT, true, tr("Free Kick Right"))); + + int run = 0; + for (auto it = mGameModes.begin(); it != mGameModes.end(); it++) + { + it->mIndex = run; + ui.playModeComboBox->addItem(it->mName); + run++; + } + mSelectedPlayMode = PM_BeforeKickOff; + + tryInitSpark(); + updateDisplay(); +} + +bool SoccerControlFrame::initialized() +{ + return mInit; +} + +void SoccerControlFrame::loadSettings() +{ + +} + +void SoccerControlFrame::saveSettings() +{ + +} + +void SoccerControlFrame::loadDefaultSettings() +{ + mGameControlServerPath = "/sys/server/gamecontrol/"; + mGameStateAspectPath = "/sys/server/gamecontrol/GameStateAspect/"; + mSoccerRuleAspectPath = "/sys/server/gamecontrol/SoccerRuleAspect/"; + mBallStateAspectPath = "/sys/server/gamecontrol/BallStateAspect/"; +} + +//-------------------------------------------------------------- +// Protected +//-------------------------------------------------------------- + +bool SoccerControlFrame::tryInitSpark() +{ + //If already initialized, simply update + if (mInit) + updateDisplay(); + + //If there is no spark controller, try to get it + if (mSparkController.get() == 0) + { + mServerThread = getCarbon()->getSimulationManager()->getSparkServerThread(); + + if (mServerThread.get() == 0) + return false; + else + { + mSparkController = mServerThread->getSparkController(); + connect(&*mSparkController, SIGNAL(sparkRunning(SparkController*)), this, SLOT(updateSparkRunning(SparkController*))); + } + } + + //If there is a spark controller, check for SimSpark + if (mSparkController->getSpark().get() != 0) + { + //There is a controller and simspark-> initialize + + QString gameControlServer = mGameControlServerPath; + QString gameStateAspect = mGameStateAspectPath; + QString soccerRuleAspect = mSoccerRuleAspectPath; + QString ballStateAspect = mBallStateAspectPath; + + //Try to find soccer aspects + if (mSettings->beginGroup(this, true, 1000)) //lock + { + gameControlServer = mSettings->value("mGameControlServerPath", mGameControlServerPath).toString(); + gameStateAspect = mSettings->value("mGameStateAspectPath", mGameStateAspectPath).toString(); + soccerRuleAspect = mSettings->value("mSoccerRuleAspectPath", mSoccerRuleAspectPath).toString(); + ballStateAspect = mSettings->value("mBallStateAspectPath", mBallStateAspectPath).toString(); + mSettings->endGroup(true); //unlock + } + else + { + LOG_WARNING() << "Could not read Settings object in SoccerControlFrame. Using default values for control node paths."; + } + + SimSpark* spark = &*mSparkController->getSpark(); + boost::shared_ptr<GameControlServer> gameControl(shared_dynamic_cast<GameControlServer>(spark->GetCore()->Get(gameControlServer.toStdString()))); + boost::shared_ptr<GameStateAspect> gameState (shared_dynamic_cast<GameStateAspect> (spark->GetCore()->Get(gameStateAspect.toStdString()))); + boost::shared_ptr<SoccerRuleAspect> soccerRule (shared_dynamic_cast<SoccerRuleAspect> (spark->GetCore()->Get(soccerRuleAspect.toStdString()))); + boost::shared_ptr<BallStateAspect> ballState (shared_dynamic_cast<BallStateAspect> (spark->GetCore()->Get(ballStateAspect.toStdString()))); + + bool success = true; + if (!gameControl.get()) + { + LOG_ERROR() << "Soccer GameControlServer not found. Expected it to be at " << gameControlServer << "."; + success = false; + } + if (!gameState.get()) + { + LOG_ERROR() << "Soccer GameStateAspect not found. Expected it to be at " << gameStateAspect << "."; + success = false; + } + if (!soccerRule.get()) + { + LOG_ERROR() << "Soccer SoccerRuleAspect not found. Expected it to be at " << soccerRuleAspect << "."; + success = false; + } + if (!ballState.get()) + { + LOG_ERROR() << "Soccer BallStateAspect not found. Expected it to be at " << ballStateAspect << "."; + success = false; + } + + if (success == false) + { + //Init failed, return + mGameControlServer.reset(); + mRuleAspect.reset(); + mBallAspect.reset(); + mGameAspect.reset(); + return false; + } + + //All nodes found, init successful + mGameControlServer = gameControl; + mRuleAspect = soccerRule; + mBallAspect = ballState; + mGameAspect = gameState; + + //Register control node that polls an update every time a cycle ended + registerUpdater(); + + mInit = true; + updateDisplay(); + return true; + } + return false; +} + +void SoccerControlFrame::registerUpdater() +{ + shared_ptr<GuiSimControl> simControl = mSparkController->getSimulationControl().lock(); + if (simControl.get() == 0) + { + LOG_ERROR() << "No gui simulation control node found to register updater in."; + return; + } + + //Remove old updater (should happen automatically, just to be safe) + if (mUpdater.get() != 0) + { + simControl->unregisterSimControl(mUpdater); + mUpdater.reset(); + } + + //Create new updater + mUpdater = shared_ptr<SoccerFrameUpdateControl>(new SoccerFrameUpdateControl(this)); + simControl->registerSimControl(mUpdater); + connect(&*mUpdater, SIGNAL(stateEndCycle()), this, SLOT(onCycleFinished())); //Queued connection + connect(&*mUpdater, SIGNAL(stateWaitCycle()), this, SLOT(onCycleFinished())); //Queued connection + + //Start update timer + mUpdateTimer.start(); +} + +//-------------------------------------------------------------- +// Private +//-------------------------------------------------------------- + +//-------------------------------------------------------------- +// Protected Slots +//-------------------------------------------------------------- + +void SoccerControlFrame::updateServerCreated(boost::shared_ptr<ServerThread> server) +{ + mSparkController = server->getSparkController(); + connect(&*mSparkController, SIGNAL(sparkRunning(SparkController*)), this, SLOT(updateSparkRunning(SparkController*))); + tryInitSpark(); +} + +void SoccerControlFrame::updateSparkRunning(SparkController* controller) +{ + if (mSparkController.get() != 0) + { + if (mSparkController->getSpark().get() == controller->getSpark().get()) + { + tryInitSpark(); + } + } +} + +void SoccerControlFrame::onCycleFinished() +{ + updateDisplay(); + mReadyUpdate = false; +} + +//-------------------------------------------------------------- +// Public Slots +//-------------------------------------------------------------- + +void SoccerControlFrame::readyUpdate() +{ + mReadyUpdate = true; +} + +void SoccerControlFrame::updateDisplay() +{ + if (mLastInitState != mInit) + { + mLastInitState = mInit; + mUpdateCount = 0; + + ui.batteryEdit->setEnabled(mInit); + ui.temperatureEdit->setEnabled(mInit); + ui.gameTimeEdit->setEnabled(mInit); + ui.team1GoalsEdit->setEnabled(mInit); + ui.team2GoalsEdit->setEnabled(mInit); + ui.team1PenaltiesEdit->setEnabled(mInit); + ui.team2PenaltiesEdit->setEnabled(mInit); + + ui.gameTimeResetButton->setEnabled(mInit); + ui.resetBatteryButton->setEnabled(mInit); + ui.resetTemperatureButton->setEnabled(mInit); + ui.kickOffButton->setEnabled(mInit); + ui.playModeButton->setEnabled(mInit); + ui.playModeComboBox->setEnabled(mInit); + + mSelectedPlayer = -1; + } + + if (!mInit) + { + ui.batteryEdit->setText(""); + ui.temperatureEdit->setText(""); + ui.gameTimeEdit->setText(""); + ui.team1GoalsEdit->setText(""); + ui.team2GoalsEdit->setText(""); + ui.team1PenaltiesEdit->setText(""); + ui.team2PenaltiesEdit->setText(""); + ui.team1NameLabel->setText(tr("Left")); + ui.team2NameLabel->setText(tr("Right")); + ui.agentNameLabel->setText(""); + ui.agentTeamLabel->setText(""); + ui.playModeLabel->setText(tr("Not initialized.")); + } + + if (mInit && mReadyUpdate) + { + //Read and display non-changing values + if (mUpdateCount == 0) + { + } + + //Read and update changing values + ui.team1NameLabel->setText(mGameAspect->GetTeamName(TI_LEFT).c_str()); + ui.team2NameLabel->setText(mGameAspect->GetTeamName(TI_RIGHT).c_str()); + if (!ui.team1GoalsEdit->hasFocus()) ui.team1GoalsEdit->setText(QString::number(mGameAspect->GetScore(TI_LEFT))); + if (!ui.team2GoalsEdit->hasFocus()) ui.team2GoalsEdit->setText(QString::number(mGameAspect->GetScore(TI_RIGHT))); + if (!ui.team1PenaltiesEdit->hasFocus()) ui.team1PenaltiesEdit->setText("0"); + if (!ui.team2PenaltiesEdit->hasFocus()) ui.team2PenaltiesEdit->setText("0"); + + if (!ui.gameTimeEdit->hasFocus()) ui.gameTimeEdit->setText(QString::number(mGameAspect->GetTime())); + + auto pos = mGameModes.find((int)mGameAspect->GetPlayMode()); + if (pos == mGameModes.end()) + { + LOG_WARNING() << "Current game mode " << mGameAspect->GetPlayMode() << " is unknown."; + } + else + { + if (mUpdateCount == 0) + ui.playModeComboBox->setCurrentIndex(pos->mIndex); + ui.playModeLabel->setText(pos->mName); + } + + updatePlayerDisplay(); + } + + mUpdateCount++; +} + +void SoccerControlFrame::updatePlayerDisplay() +{ + if (mSelectedPlayer == -1) + return; + + if (!mInit) + return; +} + +void SoccerControlFrame::editGameTime() +{ + if (!mInit) + return; + + mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::SetTime>(mGameAspect, ui.gameTimeEdit->text().toFloat())); +} + +void SoccerControlFrame::resetGameTime() +{ + if (!mInit) + return; + + mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::SetTime>(mGameAspect, 0.0)); +} + +void SoccerControlFrame::editTeam1Goals() +{ + if (!mInit) + return; + + mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::SetTeamGoals>(mGameAspect, TI_LEFT, ui.team1GoalsEdit->text().toInt())); +} + +void SoccerControlFrame::editTeam2Goals() +{ + if (!mInit) + return; + + mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::SetTeamGoals>(mGameAspect, TI_LEFT, ui.team2GoalsEdit->text().toInt())); +} + +void SoccerControlFrame::editTeam1Penalties() +{ + if (!mInit) + return; +} + +void SoccerControlFrame::editTeam2Penalties() +{ + if (!mInit) + return; +} + +void SoccerControlFrame::selectPlayMode(int index) +{ + if (!mInit) + return; + + ui.playModeButton->setEnabled(false); + + for (auto it = mGameModes.begin(); it != mGameModes.end(); it++) + { + if (it->mIndex == index) + { + mSelectedPlayMode = it->mMode; + ui.playModeButton->setEnabled(it->mManual); + } + } +} + +void SoccerControlFrame::changePlayMode() +{ + if (!mInit) + return; + + mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::ChangePlayMode>(mGameAspect, mSelectedPlayMode)); +} + +void SoccerControlFrame::kickOff() +{ + if (!mInit) + return; + + mUpdater->queueCommand(make_shared<SoccerControlFrameUtil::KickOff>(mGameAspect)); +} + +void SoccerControlFrame::clearPlayers() +{ + if (!mInit) + return; +} + + +void SoccerControlFrame::selectPlayer(int index) +{ + if (!mInit) + return; + + mSelectedPlayer = -1; + updatePlayerDisplay(); +} + +void SoccerControlFrame::editBattery() +{ + if (!mInit) + return; + + if (mSelectedPlayer == -1) + return; + +} + +void SoccerControlFrame::editTemperature() +{ + if (!mInit) + return; + + if (mSelectedPlayer == -1) + return; + +} + +void SoccerControlFrame::resetBattery() +{ + if (!mInit) + return; + + if (mSelectedPlayer == -1) + return; + +} + +void SoccerControlFrame::resetTemperature() +{ + if (!mInit) + return; + + if (mSelectedPlayer == -1) + return; + + } \ No newline at end of file Modified: branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/soccercontrolframe.h =================================================================== --- branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/soccercontrolframe.h 2013-06-12 20:48:36 UTC (rev 365) +++ branches/gui-bullet/rcssserver3d/guiplugin/soccercontrolframe/soccercontrolframe.h 2013-06-12 20:53:27 UTC (rev 366) @@ -1,391 +1,391 @@ -/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- - - this file is part of rcssserver3D - Author: Patrick Geib - Copyright (C) 2012 RoboCup Soccer Server 3D Maintenance Group - $Id$ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef SOCCERCONTROLFRAME_H -#define SOCCERCONTROLFRAME_H -/** - * \file soccercontrolframe.h - * \brief Contains SoccerControlFrame and SoccerFrameUpdateControl classes. - */ - -#include "ui_soccercontrolframe.h" -#include "attachableframe.h" -#include "isimcontrol.h" -#include "sparkcommandqueue.h" - -#include <boost/shared_ptr.hpp> -#include <QObject> -#include <QTimer> - -#include <soccer/soccertypes.h> - -class ServerThread; -class SimSpark; -class Settings; - -class SoccerFrameUpdateControl; -class SoccerControlFrame; - -class GameStateAspect; -class SoccerRuleAspect; -class BallStateAspect; - -namespace oxygen -{ - class GameControlServer; -} - -/*! - \brief Update command queue read and set soccer variables and settings in the SimSpark simulation. -*/ -class SoccerFrameUpdateControl : public QObject, public SparkCommand::CommandQueue // is ISimControl -{ - Q_OBJECT - -public: - //public functions - - /*! - \brief Constructor. - */ - SoccerFrameUpdateControl(SoccerControlFrame* parent); - /*! - \brief Destructor. - */ - ~SoccerFrameUpdateControl(); - - /*! - \brief Called when the simulation cycle starts. - - Emits stateStartCycle() - */ - virtual void startCycle(); - /*! - \brief Called when the simulation cycle ends. - - Executes update commands. - Emits stateEndCycle() - */ - virtual void endCycle(); - /*! - \brief Called when the simulation executes a wait-cycle. - - Executes update commands. - Emits stateWaitCycle() - */ - virtual void waitCycle(); - -public: signals: - //public signals - - /*! - \brief Emittet when simualtion cycle starts. - - Calls update function. - */ - void stateStartCycle(); - /*! - \brief Emitted when simulation cycle ends. - - Calls update function. - */ - void stateEndCycle(); - /*! - \brief Emitted when simulation executes a wait-cycle. - - Calls update function. - */ - void stateWaitCycle(); - -public: - //public members - - SoccerControlFrame* mParent; /*!< Parent frame. */ -}; - -/*! - \brief AttachableFrame plugin that displays the state of a Ssoccer simulation and can control it. - - The SoccerControlFrame will wait and try to identify a soccer simulation in every Spark ServerThread that is started. - When it has found a ServerThread that runs a soccer simulation, the frame will register an updater to the SparkController and repeatedly update the - view on soccer variables like the team names, goals and the game time. - - The soccer values can be changed. - A List of SoccerFrameUtil::SoccerCommand derived classes can queue update calls for soccer variables and safely change the current game state. - - \todo Player control not implemented yet. Anyway, for player control to be effective there need to be additional functions to control them. - At the moment the only available functions would be battery state and temperature. - - \todo Currently the frame only controls basic soccer game control with the GameStateAspect and GameControlServer. - Additional control with the BallStateAspect, SoccerRuleAspect and the trainer command parser could be added. -*/ -class SoccerControlFrame : public AttachableFrame -{ - Q_OBJECT - GUI_FRAME - -public: - //public types - - /*! - \brief Description of the current game mode. - - Contains all the soccer game modes (BeforeKickoff, GoalLeft, FreekickRight and so on) and is robust to extension of the game modes. - */ - struct GameMode - { - public: - //public functions - - /*! - \brief full constructor. - - \param index index of the game mode in the combobox - \param mode spark game mode id - \param manual can it be selected by the user - \param name name string of the game mode - */ - GameMode(int index, TPlayMode mode, bool manual, QString name) - : mIndex(index), mMode(mode), mName(name), mManual(manual) {} - - TPlayMode mMode; /*!< spark game mode id */ - QString mName; /*!< name string of the game mode */ - int mIndex; /*!< index of the game mode in the combobox */ - bool mManual; /*!< can it be selected by the user */ - }; - -public: - // public functions - - /*! - \brief Constructor. - */ - SoccerControlFrame(); - /*! - \brief Destructor. - */ - ~SoccerControlFrame(); - -public: - //public virtual functions - - /*! - \brief Initialization function. - - \param parameters parameter list (not used) - */ - virtual void init(const QStringList& parameters); - - /*! - \brief Loads settings from global settings object. - */ - virtual void loadSettings(); - /*! - \brief Saves settings to global settings object. - */ - virtual void saveSettings(); - /*! - \brief Initializes settings with default values. - */ - virtual void loadDefaultSettings(); - - /*! - \brief Returns true after initialization of SimSpark simulation access. - */ - bool initialized(); - -protected: - //protected functions - - /*! - \brief Tries to initialize spark simulation access. - - Will fail if there is no Spark-Server, if the server has no SparkController, if the controller has not initialized SimSpark, or - if the Simulation doe... [truncated message content] |