summaryrefslogtreecommitdiff
path: root/2003/i/buzz/src
diff options
context:
space:
mode:
authorschodet2003-05-27 08:50:10 +0000
committerschodet2003-05-27 08:50:10 +0000
commit9904293580850b6daf7b9884381d5284f859ae8a (patch)
treef63add334d60720bbd5d43ed417131a67ce305cd /2003/i/buzz/src
parente954638ce3d5aca73959db2f75725e97398389de (diff)
Petites modifs.
Diffstat (limited to '2003/i/buzz/src')
-rw-r--r--2003/i/buzz/src/automate/Makefile.defs4
-rw-r--r--2003/i/buzz/src/automate/action.cc52
-rw-r--r--2003/i/buzz/src/automate/action.h38
-rw-r--r--2003/i/buzz/src/automate/grammar.yy14
-rw-r--r--2003/i/buzz/src/automate/lexer.ll2
-rw-r--r--2003/i/buzz/src/automate/receptivite.cc35
-rw-r--r--2003/i/buzz/src/automate/receptivite.h32
7 files changed, 54 insertions, 123 deletions
diff --git a/2003/i/buzz/src/automate/Makefile.defs b/2003/i/buzz/src/automate/Makefile.defs
index d5eff12..17e424e 100644
--- a/2003/i/buzz/src/automate/Makefile.defs
+++ b/2003/i/buzz/src/automate/Makefile.defs
@@ -1,6 +1,8 @@
TARGETS += test_automate
+LIBS += automate.a
automate_a_SOURCES = grafcet.cc receptivite.cc action.cc grammar.cc lexer.cc expression.cc
-test_automate_SOURCES = test_automate.cc $(automate_a_SOURCES) erreur.a
+test_automate_SOURCES = test_automate.cc $(automate_a_SOURCES) erreur.a motor.a busp.a \
+ config.a serial.a
extra_clean += grammar.h grammar.cc lexer.cc
diff --git a/2003/i/buzz/src/automate/action.cc b/2003/i/buzz/src/automate/action.cc
index 3eca5ee..19b401a 100644
--- a/2003/i/buzz/src/automate/action.cc
+++ b/2003/i/buzz/src/automate/action.cc
@@ -3,6 +3,7 @@
// Copyright (C) 2003 Nicolas Schodet
//
#include "action.h"
+#include "motor/motor.h"
#include <iostream>
@@ -47,6 +48,18 @@ ActionPrint::start (void)
cout << m_s << endl;
}
+void
+ActionMotorGoDistance::start (void)
+{
+ Motor::getInstance ().goDistance (m_d, m_a);
+}
+
+void
+ActionMotorTurnAngle::start (void)
+{
+ Motor::getInstance ().turnAngle (m_d, m_a);
+}
+
/*Definition de l'action liée à INITIALISATION*/
//Constructeur
@@ -209,45 +222,6 @@ void ActionRetourner::start(void)
}
-
-/*Definition de l'action liée à AVANCER*/
-
-//Constructeur
-ActionAvancer::ActionAvancer(int _distance)
-{
- m_distance = _distance;
-}
-
-// Destructeur
-ActionAvancer::~ActionAvancer()
-{
-}
-
-void ActionAvancer::start(void)
-{
-
-}
-
-
-/*Definition de l'action liée à RECULER*/
-
-//Constructeur
-ActionReculer::ActionReculer(int _distance)
-{
- m_distance = _distance;
-}
-
-// Destructeur
-ActionReculer::~ActionReculer()
-{
-}
-
-void ActionReculer::start(void)
-{
-
-}
-
-
/*Definition de l'action liée à PLACER_PINCE*/
//Constructeur
diff --git a/2003/i/buzz/src/automate/action.h b/2003/i/buzz/src/automate/action.h
index 3224e8f..65bc6e0 100644
--- a/2003/i/buzz/src/automate/action.h
+++ b/2003/i/buzz/src/automate/action.h
@@ -33,6 +33,22 @@ namespace Automate
void start (void);
};
+ class ActionMotorGoDistance : public Action
+ {
+ int m_d, m_a;
+ public:
+ ActionMotorGoDistance (int d, int a = -1) { m_d = d; m_a = a; }
+ void start (void);
+ };
+
+ class ActionMotorTurnAngle : public Action
+ {
+ int m_d, m_a;
+ public:
+ ActionMotorTurnAngle (int d, int a = -1) { m_d = d; m_a = a; }
+ void start (void);
+ };
+
class ActionInitialisation : public Action
{
public:
@@ -124,28 +140,6 @@ namespace Automate
void start (void);
};
- class ActionAvancer : public Action
- {
- int m_distance;
- public:
- // Constructeur
- ActionAvancer (int);
- // Destructeur
- ~ActionAvancer () ;
- void start (void);
- };
-
- class ActionReculer : public Action
- {
- int m_distance;
- public:
- // Constructeur
- ActionReculer (int);
- // Destructeur
- ~ActionReculer () ;
- void start (void);
- };
-
class ActionPlacerPince : public Action
{
int m_position;
diff --git a/2003/i/buzz/src/automate/grammar.yy b/2003/i/buzz/src/automate/grammar.yy
index f9b8d52..af57931 100644
--- a/2003/i/buzz/src/automate/grammar.yy
+++ b/2003/i/buzz/src/automate/grammar.yy
@@ -95,17 +95,19 @@ etape: '#' NUM { $$ = new Etape ($2); }
;
action: PRINT STRING { $$ = new ActionPrint (*$2); delete $2; }
- | INITIALISATION { $$ = new ActionInit ();}
+ | INITIALISATION { $$ = new ActionInitialisation ();}
| RECHERCHER { $$ = new ActionRechercher ();}
| ROTATION { $$ = new ActionRotation ();}
- | AVANCER_PALET { $$ = new ActionAvancerPalet ();}
+ | AVANCER_PALET { /*$$ = new ActionAvancerPalet ();*/ }
| NB_PALET_PILE { $$ = new ActionNbPaletPile ();}
| NB_PALET_STOCKE { $$ = new ActionNbPaletStocke ();}
| MISE_EN_PLACE { $$ = new ActionMiseEnPlace ();}
| REPERER_COULEUR NUM { $$ = new ActionRepererCouleur ($2);}
| RETOURNER { $$ = new ActionRetourner ();}
- | AVANCER NUM { $$ = new ActionAvancer ($2);}
- | RECULER NUM { $$ = new ActionReculer ($2);}
+ | AVANCER NUM { $$ = new ActionMotorGoDistance ($2); }
+ | AVANCER NUM NUM { $$ = new ActionMotorGoDistance ($2, $3); }
+ | RECULER NUM { $$ = new ActionMotorGoDistance (-$2); }
+ | RECULER NUM NUM { $$ = new ActionMotorGoDistance (-$2, $3); }
| PLACER_PINCE NUM { $$ = new ActionPlacerPince ($2);}
;
@@ -118,8 +120,8 @@ receptivite:
| COULEUR_ADVERSE NUM { $$ = new ReceptCouleurAdverse ($2); }
| PINCE_ANGLE NUM { $$ = new ReceptPinceAngle ($2); }
| PINCE_POS NUM { $$ = new ReceptPincePos ($2); }
- | ROBOT_RECULE { $$ = new ReceptRobotRecule (); }
- | ROBOT_AVANCE { $$ = new ReceptRobotAvance (); }
+ | ROBOT_RECULE { $$ = new ReceptMotorFinnish; }
+ | ROBOT_AVANCE { $$ = new ReceptMotorFinnish; }
| receptivite '&' receptivite
{ $$ = new ReceptiviteBoolOp ($1, '&', $3); }
| receptivite '|' receptivite
diff --git a/2003/i/buzz/src/automate/lexer.ll b/2003/i/buzz/src/automate/lexer.ll
index 6110987..3847970 100644
--- a/2003/i/buzz/src/automate/lexer.ll
+++ b/2003/i/buzz/src/automate/lexer.ll
@@ -44,7 +44,7 @@ STRING \"[^\n"]\"
"atteindre" return AVANCER_PALET; //contient le chemineur pour arriver devant le palet cible
"nb_palet_pile" return NB_PALET_PILE; //Determine le nb de palet dans la pile cible
"nb_palet_stocke" return NB_PALET_STOCKE; //Determine le nb de palet stocke
-"mise_en_place" return MISE_EN_PLACE //Mise en place du palet ou de la pile cible ceux ci etant atteint
+"mise_en_place" return MISE_EN_PLACE; //Mise en place du palet ou de la pile cible ceux ci etant atteint
"reperer_couleur" return REPERER_COULEUR; //param:num vp:1:avant, 2:arriere
"retourner" return RETOURNER; //Retourne le palet de l'avant vers l'arriere ou inversemment
"avancer" return AVANCER; //param:num vp:1,2,..n avance le robot de une a n fois une longueur (fixe) en avant
diff --git a/2003/i/buzz/src/automate/receptivite.cc b/2003/i/buzz/src/automate/receptivite.cc
index 743602e..eb92388 100644
--- a/2003/i/buzz/src/automate/receptivite.cc
+++ b/2003/i/buzz/src/automate/receptivite.cc
@@ -3,6 +3,7 @@
// Copyright (C) 2003 Nicolas Schodet
//
#include "receptivite.h"
+#include "motor/motor.h"
namespace Automate
{
@@ -76,6 +77,12 @@ ReceptiviteCmpOp::test (void)
return false;
}
+bool
+ReceptMotorFinnish::test (void)
+{
+ return Motor::getInstance ().finnish ();
+}
+
//Definition de la receptivité liée à PLACER_PINCE
// Destructeur.
@@ -173,32 +180,4 @@ bool ReceptPincePos::test (void)
return false;
}
-
-//Definition de la receptivité liée à ROBOT_RECULE
-
-// Destructeur.
-ReceptRobotRecule::~ReceptRobotRecule ()
-{
-}
-
-// Retourne la valeur de la receptivité.
-bool ReceptRobotRecule::test (void)
-{
- return false;
-}
-
-
-//Definition de la receptivité liée à ROBOT_AVANCE
-
-// Destructeur.
-ReceptRobotAvance::~ReceptRobotAvance ()
-{
-}
-
-// Retourne la valeur de la receptivité.
-bool ReceptRobotAvance::test (void)
-{
- return false;
-}
-
}
diff --git a/2003/i/buzz/src/automate/receptivite.h b/2003/i/buzz/src/automate/receptivite.h
index bb147f8..d670b5c 100644
--- a/2003/i/buzz/src/automate/receptivite.h
+++ b/2003/i/buzz/src/automate/receptivite.h
@@ -60,13 +60,17 @@ namespace Automate
bool test (void);
};
+ class ReceptMotorFinnish : public Receptivite
+ {
+ public:
+ bool test (void);
+ };
+
/*Ajout des conditions du grafcet, un objet par condition*/
class ReceptInit : public Receptivite
{
public:
- // Constructeur.
- ReceptInit ();
// Destructeur.
~ReceptInit ();
// Retourne la valeur de la receptivité.
@@ -76,8 +80,6 @@ namespace Automate
class ReceptPaletsTrouves : public Receptivite
{
public:
- // Constructeur.
- ReceptPaletsTrouves ();
// Destructeur.
~ReceptPaletsTrouves ();
// Retourne la valeur de la receptivité.
@@ -144,28 +146,6 @@ namespace Automate
bool test (void);
};
- class ReceptRobotRecule : public Receptivite
- {
- public:
- // Constructeur
- ReceptRobotRecule ();
- // Destructeur.
- ~ReceptRobotRecule ();
- // Retourne la valeur de la receptivité.
- bool test (void);
- };
-
- class ReceptRobotAvance : public Receptivite
- {
- public:
- // Constructeur.
- ReceptRobotAvance ();
- // Destructeur.
- ~ReceptRobotAvance ();
- // Retourne la valeur de la receptivité.
- bool test (void);
- };
-
}
#endif // receptivite_h