summaryrefslogtreecommitdiff
path: root/2003/i/buzz/src/automate/grafcet.h
blob: 09b87a1cd002753f2ecc7202383e719ffcead4d1 (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
71
72
73
74
75
76
77
78
79
#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 GrafcetElemType
      {
	etape, action, receptivite, transition
      };
    // Structure des �l�ments.
    struct GrafcetElem
      {
	GrafcetElemType type;
	union
	  {
	    Etape *etape;
	    Action *action;
	    Receptivite *receptivite;
	    Transition *transition;
	  } elem;
	// Constructeurs.
	GrafcetElem (Etape *_etape)
	  {
	    type = etape;
	    elem.etape = _etape;
	  }
	GrafcetElem (Action *_action)
	  {
	    type = action;
	    elem.action = _action;
	  }
	GrafcetElem (Receptivite *_receptivite)
	  {
	    type = receptivite;
	    elem.receptivite = _receptivite;
	  }
	GrafcetElem (Transition *_transition)
	  {
	    type = transition;
	    elem.transition = _transition;
	  }
      };
    // Contient le grafcet complet.
    vector<GrafcetElem> 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; }
};

}

#endif // grafcet_h