From 118063daa33bf4f365c62bf4a3f384e06466c980 Mon Sep 17 00:00:00 2001 From: schodet Date: Wed, 10 Sep 2003 18:22:47 +0000 Subject: Mise à jour 2003 --- 2003/i/buzz/src/automate/action.cc | 155 ++++---------------------------- 2003/i/buzz/src/automate/action.h | 100 +++++---------------- 2003/i/buzz/src/automate/expression.cc | 12 +++ 2003/i/buzz/src/automate/expression.h | 27 ++++-- 2003/i/buzz/src/automate/grammar.yy | 18 ++-- 2003/i/buzz/src/automate/lexer.ll | 12 ++- 2003/i/buzz/src/automate/receptivite.cc | 77 ++-------------- 2003/i/buzz/src/automate/receptivite.h | 61 ++----------- 8 files changed, 109 insertions(+), 353 deletions(-) (limited to '2003/i') diff --git a/2003/i/buzz/src/automate/action.cc b/2003/i/buzz/src/automate/action.cc index 19b401a..8842543 100644 --- a/2003/i/buzz/src/automate/action.cc +++ b/2003/i/buzz/src/automate/action.cc @@ -60,132 +60,43 @@ ActionMotorTurnAngle::start (void) Motor::getInstance ().turnAngle (m_d, m_a); } -/*Definition de l'action liée à INITIALISATION*/ - -//Constructeur -ActionInitialisation::ActionInitialisation() -{ -} - -// Destructeur -ActionInitialisation::~ActionInitialisation() -{ -} - -void ActionInitialisation::start(void) -{ - -} - - -/*Definition de l'action liée à RECHERCHER*/ - -//Constructeur -ActionRechercher::ActionRechercher() -{ -} - -// Destructeur -ActionRechercher::~ActionRechercher() -{ -} - -void ActionRechercher::start(void) -{ - -} - - -/*Definition de l'action liée à ROTATION*/ - -//Constructeur -ActionRotation::ActionRotation() -{ -} - -// Destructeur -ActionRotation::~ActionRotation() -{ -} - -void ActionRotation::start(void) -{ - -} - - -/*Definition de l'action liée à ATTEINDRE*/ - -//Constructeur -ActionAtteindre::ActionAtteindre() -{ -} - -// Destructeur -ActionAtteindre::~ActionAtteindre() -{ -} - -void ActionAtteindre::start(void) -{ - -} - - -/*Definition de l'action liée à NB_PALET_PILE*/ - -//Constructeur -ActionNbPaletPile::ActionNbPaletPile() -{ -} - -// Destructeur -ActionNbPaletPile::~ActionNbPaletPile() -{ -} - -void ActionNbPaletPile::start(void) -{ - -} - - -/*Definition de l'action liée à NB_PALET_STOCKE*/ - -//Constructeur -ActionNbPaletStocke::ActionNbPaletStocke() +void +ActionServo::start (void) { + Busp::getInstance ().getServo ().position (m_pos); } -// Destructeur -ActionNbPaletStocke::~ActionNbPaletStocke() +void +ActionIa::start (void) { + switch (m_num) + { + } } -void ActionNbPaletStocke::start(void) +void +ActionIaVar::start (void) { - + Ia::getInstance ().setVar (m_var, m_num); } - -/*Definition de l'action liée à MISE_EN_PLACE*/ +/*Definition de l'action liée à INITIALISATION*/ //Constructeur -ActionMiseEnPlace::ActionMiseEnPlace() +ActionInitialisation::ActionInitialisation() { } // Destructeur -ActionMiseEnPlace::~ActionMiseEnPlace() +ActionInitialisation::~ActionInitialisation() { } -void ActionMiseEnPlace::start(void) +void ActionInitialisation::start(void) { } - /*Definition de l'action liée à REPERER_COULEUR*/ //Constructeur @@ -204,40 +115,4 @@ void ActionRepererCouleur::start(void) } - -/*Definition de l'action liée à RETOURNER*/ - -//Constructeur -ActionRetourner::ActionRetourner() -{ -} - -// Destructeur -ActionRetourner::~ActionRetourner() -{ -} - -void ActionRetourner::start(void) -{ - -} - -/*Definition de l'action liée à PLACER_PINCE*/ - -//Constructeur -ActionPlacerPince::ActionPlacerPince(int _position) -{ - m_position = _position; -} - -// Destructeur -ActionPlacerPince::~ActionPlacerPince() -{ -} - -void ActionPlacerPince::start(void) -{ - -} - } diff --git a/2003/i/buzz/src/automate/action.h b/2003/i/buzz/src/automate/action.h index 65bc6e0..6cc37f6 100644 --- a/2003/i/buzz/src/automate/action.h +++ b/2003/i/buzz/src/automate/action.h @@ -48,75 +48,39 @@ namespace Automate ActionMotorTurnAngle (int d, int a = -1) { m_d = d; m_a = a; } void start (void); }; - - class ActionInitialisation : public Action - { - public: - // Constructeur - ActionInitialisation (void); - // Destructeur - ~ActionInitialisation () ; - void start (void); - }; - class ActionRechercher : public Action + class ActionServo : public Action { - public: - // Constructeur - ActionRechercher (void); - // Destructeur - ~ActionRechercher () ; - void start (void); - }; - - class ActionRotation : public Action - { - public: - // Constructeur - ActionRotation (void); - // Destructeur - ~ActionRotation () ; - void start (void); + int m_pos; + public: + ActionServo (int pos) { m_pos = pos; } + void start (void); }; - class ActionAtteindre : public Action + class ActionIa : public Action { - public: - // Constructeur - ActionAtteindre (void); - // Destructeur - ~ActionAtteindre () ; - void start (void); + int m_num; + public: + ActionIa (int num) { m_num = num; } + void start (void); }; - class ActionNbPaletPile : public Action + class ActionIaVar : public Action { - public: - // Constructeur - ActionNbPaletPile (void); - // Destructeur - ~ActionNbPaletPile () ; - void start (void); + int m_num, m_var; + public: + ActionIaVar (int var, int num) { m_var = var; m_num = num; } + void start (void); }; - - class ActionNbPaletStocke : public Action + + class ActionInitialisation : public Action { public: - // Constructeur - ActionNbPaletStocke (void); - // Destructeur - ~ActionNbPaletStocke () ; - void start (void); - }; - - class ActionMiseEnPlace : public Action - { - public: - // Constructeur - ActionMiseEnPlace (void); - // Destructeur - ~ActionMiseEnPlace () ; - void start (void); + // Constructeur + ActionInitialisation (void); + // Destructeur + ~ActionInitialisation () ; + void start (void); }; class ActionRepererCouleur : public Action @@ -130,26 +94,6 @@ namespace Automate void start (void); }; - class ActionRetourner : public Action - { - public: - // Constructeur - ActionRetourner (void); - // Destructeur - ~ActionRetourner () ; - void start (void); - }; - - class ActionPlacerPince : public Action - { - int m_position; - public: - // Constructeur - ActionPlacerPince (int); - // Destructeur - ~ActionPlacerPince () ; - void start (void); - }; } #endif // action_h diff --git a/2003/i/buzz/src/automate/expression.cc b/2003/i/buzz/src/automate/expression.cc index 99d73b8..f963f93 100644 --- a/2003/i/buzz/src/automate/expression.cc +++ b/2003/i/buzz/src/automate/expression.cc @@ -49,4 +49,16 @@ ExpressionNumOp::val (void) return 0; } +int +ExpressionIaVar::val (void) +{ + return Ia::getInstance ().getVar (m_var); +} + +int +ExpressionPalets::val (void) +{ + int p = Busp::getInstance ().getCapteurs ().get (); +} + } diff --git a/2003/i/buzz/src/automate/expression.h b/2003/i/buzz/src/automate/expression.h index c349bed..8680103 100644 --- a/2003/i/buzz/src/automate/expression.h +++ b/2003/i/buzz/src/automate/expression.h @@ -8,16 +8,16 @@ namespace Automate { class Expression - { + { public: // Destructeur. virtual ~Expression (); // Retourne la valeur de l'expression. virtual int val (void) = 0; - }; + }; class ExpressionNum : public Expression - { + { int m_num; public: // Constructeur. @@ -26,10 +26,10 @@ namespace Automate ~ExpressionNum (); // Retourne la valeur de l'expression. int val (void); - }; + }; class ExpressionNumOp : public Expression - { + { char m_op; Expression *m_left, *m_right; public: @@ -42,7 +42,22 @@ namespace Automate ~ExpressionNumOp (); // Retourne la valeur de l'expression. int val (void); - }; + }; + + class ExpressionIaVar : public Expression + { + int m_var; + public: + ExpressionIaVar (int var) { m_var = var; } + int val (void); + }; + + class ExpressionPalets : public Expression + { + public: + int val (void); + }; + } #endif // expression_h diff --git a/2003/i/buzz/src/automate/grammar.yy b/2003/i/buzz/src/automate/grammar.yy index af57931..114e322 100644 --- a/2003/i/buzz/src/automate/grammar.yy +++ b/2003/i/buzz/src/automate/grammar.yy @@ -34,7 +34,7 @@ Grafcet *input_grafcet; %token FLOAT %token BOOL %token STRING -%token ERR GOTO +%token ERR GOTO SI %token EQ NEQ LEQ GEQ %token INITIALISATION @@ -87,7 +87,7 @@ grafcet: /* Rien */ { $$ = new Grafcet (); } | grafcet etape { $$ = $1; $$->m_grafcet.push_back (Grafcet::Elem ($2)); } | grafcet action { $$ = $1; $$->m_grafcet.push_back (Grafcet::Elem ($2)); } - | grafcet receptivite { $$ = $1; $$->m_grafcet.push_back (Grafcet::Elem ($2)); } + | grafcet SI receptivite { $$ = $1; $$->m_grafcet.push_back (Grafcet::Elem ($3)); } | grafcet transition { $$ = $1; $$->m_grafcet.push_back (Grafcet::Elem ($2)); } ; @@ -95,6 +95,11 @@ etape: '#' NUM { $$ = new Etape ($2); } ; action: PRINT STRING { $$ = new ActionPrint (*$2); delete $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); } + | INITIALISATION { $$ = new ActionInitialisation ();} | RECHERCHER { $$ = new ActionRechercher ();} | ROTATION { $$ = new ActionRotation ();} @@ -104,15 +109,14 @@ action: PRINT STRING { $$ = new ActionPrint (*$2); delete $2; } | MISE_EN_PLACE { $$ = new ActionMiseEnPlace ();} | REPERER_COULEUR NUM { $$ = new ActionRepererCouleur ($2);} | RETOURNER { $$ = new ActionRetourner ();} - | 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);} ; receptivite: BOOL { $$ = new ReceptiviteBool ($1); } + | ROBOT_RECULE { $$ = new ReceptMotorFinnish; } + | ROBOT_AVANCE { $$ = new ReceptMotorFinnish; } + | INIT { $$ = new ReceptInit (); } | PALETS_TROUVES { $$ = new ReceptPaletsTrouves (); } | PALETS NUM { $$ = new ReceptPalets ($2); } @@ -120,8 +124,6 @@ receptivite: | COULEUR_ADVERSE NUM { $$ = new ReceptCouleurAdverse ($2); } | PINCE_ANGLE NUM { $$ = new ReceptPinceAngle ($2); } | PINCE_POS NUM { $$ = new ReceptPincePos ($2); } - | 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 3847970..074067c 100644 --- a/2003/i/buzz/src/automate/lexer.ll +++ b/2003/i/buzz/src/automate/lexer.ll @@ -25,6 +25,8 @@ STRING \"[^\n"]\" %% +"si" return SI; + "init" return INIT; //si robot initialise "palets_trouves" return PALETS_TROUVES; //si palets trouve durant la recherche "palets" return PALETS; //param:num ex:palets 1 valeurs possibles:1,2,3 nombre de palets dans la pile @@ -58,13 +60,21 @@ STRING \"[^\n"]\" "<=" return LEQ; ">=" return GEQ; -[-#+=*/<>()] return yytext[0]; +[-!#+=*/<>()] return yytext[0]; {FLOAT} { yylval.fl = strtod (yytext, 0); return FLOAT; } +"p1" { yylval.num = 0; return NUM; } +"p1+" { yylval.num = 1; return NUM; } +"p2" { yylval.num = 2; return NUM; } +"p2+" { yylval.num = 3; return NUM; } +"p3" { yylval.num = 4; return NUM; } +"p3+" { yylval.num = 5; return NUM; } +"pt" { yylval.num = 8; return NUM; } + {NUM} { yylval.num = strtol (yytext, 0, 0); return NUM; diff --git a/2003/i/buzz/src/automate/receptivite.cc b/2003/i/buzz/src/automate/receptivite.cc index eb92388..391dc33 100644 --- a/2003/i/buzz/src/automate/receptivite.cc +++ b/2003/i/buzz/src/automate/receptivite.cc @@ -4,6 +4,7 @@ // #include "receptivite.h" #include "motor/motor.h" +#include "ia/ia.h" namespace Automate { @@ -83,57 +84,25 @@ ReceptMotorFinnish::test (void) return Motor::getInstance ().finnish (); } -//Definition de la receptivité liée à PLACER_PINCE - -// Destructeur. -ReceptInit::~ReceptInit () -{ -} - -// Retourne la valeur de la receptivité. -bool ReceptInit::test (void) -{ - return false; -} - - -//Definition de la receptivité liée à PALETS_TROUVES - -// Destructeur. -ReceptPaletsTrouves::~ReceptPaletsTrouves () -{ -} - -// Retourne la valeur de la receptivité. -bool ReceptPaletsTrouves::test (void) -{ - return false; -} - - -//Definition de la receptivité liée à PALETS - -// Destructeur. -ReceptPalets::~ReceptPalets () +bool +ReceptPaletTrouve::test (void) { + return Ia::getInstance ().paletFound (); } -// Retourne la valeur de la receptivité. -bool ReceptPalets::test (void) +bool +ReceptCapteur::test (void) { - return false; + return Busp::getInstance ().getCapteurs ().get () & m_mask; } - -//Definition de la receptivité liée à STOCKE - // Destructeur. -ReceptStocke::~ReceptStocke () +ReceptInit::~ReceptInit () { } // Retourne la valeur de la receptivité. -bool ReceptStocke::test (void) +bool ReceptInit::test (void) { return false; } @@ -152,32 +121,4 @@ bool ReceptCouleurAdverse::test (void) return false; } - -//Definition de la receptivité liée à PINCE_ANGLE - -// Destructeur. -ReceptPinceAngle::~ReceptPinceAngle () -{ -} - -// Retourne la valeur de la receptivité. -bool ReceptPinceAngle::test (void) -{ - return false; -} - - -//Definition de la receptivité liée à PINCE_POS - -// Destructeur. -ReceptPincePos::~ReceptPincePos () -{ -} - -// Retourne la valeur de la receptivité. -bool ReceptPincePos::test (void) -{ - return false; -} - } diff --git a/2003/i/buzz/src/automate/receptivite.h b/2003/i/buzz/src/automate/receptivite.h index d670b5c..cc9cf52 100644 --- a/2003/i/buzz/src/automate/receptivite.h +++ b/2003/i/buzz/src/automate/receptivite.h @@ -66,46 +66,27 @@ namespace Automate bool test (void); }; - /*Ajout des conditions du grafcet, un objet par condition*/ - - class ReceptInit : public Receptivite + class ReceptPaletTrouve : public Receptivite { public: - // Destructeur. - ~ReceptInit (); - // Retourne la valeur de la receptivité. bool test (void); }; - class ReceptPaletsTrouves : public Receptivite - { + class ReceptCapteurs : public Receptivite + { + int m_mask; public: - // Destructeur. - ~ReceptPaletsTrouves (); - // Retourne la valeur de la receptivité. + ReceptCapteurs (int m_mask); bool test (void); - }; + }; - class ReceptPalets : public Receptivite - { - int m_nbpalets; - public: - // Constructeur. - ReceptPalets (int _nbpalets) { m_nbpalets = _nbpalets; } - // Destructeur. - ~ReceptPalets (); - // Retourne la valeur de la receptivité. - bool test (void); - }; + /*Ajout des conditions du grafcet, un objet par condition*/ - class ReceptStocke : public Receptivite + class ReceptInit : public Receptivite { - int m_nbstocke; public: - // Constructeur. - ReceptStocke (int _nbstocke) { m_nbstocke = _nbstocke; } // Destructeur. - ~ReceptStocke (); + ~ReceptInit (); // Retourne la valeur de la receptivité. bool test (void); }; @@ -122,30 +103,6 @@ namespace Automate bool test (void); }; - class ReceptPinceAngle : public Receptivite - { - int m_angle; - public: - // Constructeur. - ReceptPinceAngle (int _angle) { m_angle = _angle;} - // Destructeur. - ~ReceptPinceAngle (); - // Retourne la valeur de la receptivité. - bool test (void); - }; - - class ReceptPincePos : public Receptivite - { - int m_position; - public: - // Constructeur. - ReceptPincePos (int _position) { m_position = _position; } - // Destructeur. - ~ReceptPincePos (); - // Retourne la valeur de la receptivité. - bool test (void); - }; - } #endif // receptivite_h -- cgit v1.2.3