]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
robomon: Add button for strategy switching.
authorMichal Vokac <vokac.m@gmail.com>
Sat, 12 May 2012 00:11:14 +0000 (02:11 +0200)
committerMichal Vokac <vokac.m@gmail.com>
Sat, 12 May 2012 00:11:14 +0000 (02:11 +0200)
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
src/robomon/RobomonAtlantis.h

index f2e9a5ff5a6cce3909b3ba46b387b57d643687a3..7995af1d8108856a40a11fb9ca87b99b71dac23b 100644 (file)
@@ -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)
index 7a8c32c0e0282e446d312b968efb10a665d1566c..f62fe99c9b7d28bd683abd43a54d9990ff9bd307 100644 (file)
@@ -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;