summaryrefslogtreecommitdiff
path: root/2003/i/buzz/src/automate/grafcet.h
blob: ba86e8736e9da7f989b99bad77fae13650a77329 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#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 <vector>

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<Elem> m_grafcet;
    // Etapes actives.
    enum ActiveStep
      {
	inactive, start, active, stop
      };
    vector<ActiveStep> 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