#ifndef grafcet_h #define grafcet_h // grafcet.h // buzz - Programme du robot Efrei Robotique I1-I2 2003 // Copyright (C) 2003 Nicolas Schodet #include "etape.h" #include "action.h" #include "receptivite.h" #include "transition.h" #include namespace Automate { class Grafcet { public: // Type d'un élément du grafcet. enum ElemType { etape, action, receptivite, transition }; // Structure des éléments. struct Elem { ElemType type; union { Etape *etape; Action *action; Receptivite *receptivite; Transition *transition; } elem; // Constructeurs. Elem (Etape *_etape) { type = etape; elem.etape = _etape; } Elem (Action *_action) { type = action; elem.action = _action; } Elem (Receptivite *_receptivite) { type = receptivite; elem.receptivite = _receptivite; } Elem (Transition *_transition) { type = transition; elem.transition = _transition; } }; // Contient le grafcet complet. vector m_grafcet; // Etapes actives. enum ActiveStep { inactive, start, active, stop }; vector m_active_etapes; // Pointeur vers l'instance unique du grafcet. static Grafcet *m_instance; public: // Constructeurs. Grafcet (); Grafcet (const char *filename); // Destructeur. ~Grafcet (); // Retourne une référence vers l'instance. static Grafcet &getInstance () { return *m_instance; } // Lance l'execution d'un pas, c'est à dire, retourne le plus vite // possible. void run (void); }; } #endif // grafcet_h