From d3f518a5fcbbd8c4fe0a19c20d6a4162403b8ae0 Mon Sep 17 00:00:00 2001 From: Michal Vokac Date: Sat, 12 May 2012 02:11:14 +0200 Subject: [PATCH] robomon: Add button for strategy switching. How to use only one function for this purpose? I do not want to use func_1 for sending value 1 and func_0 for sending value 0. --- src/robomon/RobomonAtlantis.cpp | 17 +++++++++++++++++ src/robomon/RobomonAtlantis.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/robomon/RobomonAtlantis.cpp b/src/robomon/RobomonAtlantis.cpp index f2e9a5ff..7995af1d 100644 --- a/src/robomon/RobomonAtlantis.cpp +++ b/src/robomon/RobomonAtlantis.cpp @@ -182,6 +182,9 @@ void RobomonAtlantis::createMiscGroupBox() colorChoser = new QCheckBox("&Team color"); layout->addWidget(colorChoser); + + strategyButton= new QPushButton(tr("Strategy")); + layout->addWidget(strategyButton); miscGroupBox->setLayout(layout); } @@ -350,6 +353,8 @@ void RobomonAtlantis::createActions() connect(startPlug, SIGNAL(stateChanged(int)), this, SLOT(sendStart(int))); connect(colorChoser, SIGNAL(stateChanged(int)), this, SLOT(setTeamColor(int))); + connect(strategyButton, SIGNAL(pressed()), this, SLOT(changeStrategy_1())); + connect(strategyButton, SIGNAL(released()), this, SLOT(changeStrategy_0())); /* obstacle simulation */ simulationEnabled = 0; @@ -363,6 +368,18 @@ void RobomonAtlantis::createActions() this, SLOT(changeObstacle(QPointF))); } +void RobomonAtlantis::changeStrategy_1() +{ + orte.robot_switches.strategy = true; + ORTEPublicationSend(orte.publication_robot_switches); +} + +void RobomonAtlantis::changeStrategy_0() +{ + orte.robot_switches.strategy = false; + ORTEPublicationSend(orte.publication_robot_switches); +} + void RobomonAtlantis::setVoltage33(int state) { if (state) diff --git a/src/robomon/RobomonAtlantis.h b/src/robomon/RobomonAtlantis.h index 7a8c32c0..f62fe99c 100644 --- a/src/robomon/RobomonAtlantis.h +++ b/src/robomon/RobomonAtlantis.h @@ -81,6 +81,8 @@ private slots: void changeObstacle(QPointF position); void sendStart(int plug); void setTeamColor(int plug); + void changeStrategy_1(); + void changeStrategy_0(); /************************************************************ * ORTE @@ -164,6 +166,7 @@ private: QLabel *fsm_motion_state; QCheckBox *startPlug; QCheckBox *colorChoser; + QPushButton *strategyButton; public: /* robot */ Robot *robotRefPos; -- 2.39.2