DiaDes  0.1
DIAgnosis of Discrete-Event System
FaultPattern.hh
Go to the documentation of this file.
1 #ifndef __DIADES__AUTOMATA__FAULTMODEL__HH
2 #define __DIADES__AUTOMATA__FAULTMODEL__HH
3 #include<fstream>
4 #include<set>
5 #include<list>
6 #include<unordered_set>
7 #include<diades/graph/Graph.hh>
11 
12 
13 using std::unordered_set;
14 using std::set;
15 using namespace Diades::Graph;
16 
17 namespace Diades
18 {
19  namespace Automata
20  {
21 
40  {
41  public:
49  {
50  private:
52  int _id;
53 
54  public:
61  EventOccurrence(Event event, int identifier): _event(event),_id(identifier){}
62 
67  EventOccurrence():_event(),_id(){}
68 
74  EventOccurrence(const EventOccurrence & occurrence):_event(occurrence.event()),_id(occurrence.identifier()){}
75 
83  EventOccurrence & operator=(const EventOccurrence & occurrence){
84  if(this != &occurrence)
85  {
86  _event = occurrence.event();
87  _id = occurrence.identifier();
88  }
89  return *this;
90  }
91 
92 
93 
100  Event event() const { return _event;}
101 
108  int identifier() const { return _id; }
109 
117  bool operator==(const EventOccurrence & occurrence)
118  {
119  return (event() == occurrence.event()) && (identifier() == occurrence.identifier());
120  }
121 
130  friend ostream & operator<<(ostream & os, const EventOccurrence & occurrence)
131  {
132  return os << occurrence.event() << "#" << occurrence.identifier();
133  }
134 
135 
136 
137  };
138  protected:
143  unordered_set<Event> _events;
144  public:
149  FaultPattern();
150 
154  virtual ~FaultPattern() {}
155 
161  virtual void pattern2Dot(const string & filename);
162 
163 
170  virtual const Graph::Graph & graph() const { return _graph; }
171 
172 
180  virtual bool isFinal(Node s) const { return (s.valid() && (&s.owner() == &_graph) && (_finalNodes[s]==1)); }
181 
182 
190  bool containsEvent(Event event) const { return _events.find(event) != _events.end(); }
191 
198  virtual Node initial() const { return _initialNode; }
199 
206  virtual const EventOccurrence & eventOccurrenceOf(Edge edge) const { return _edgeMap[edge]; }
207 
208  };
209 
210 
218  {
219  public:
228  };
229 
230 
231 
239  {
240  public:
248  MultipleFaultEventPattern(const set<Event> & events);
249  };
250 
251 
252 
259  {
260  public:
268  MultipleFaultEventOccurrencePattern(const list<Event> & events);
269  };
270 
271 
279  {
280  public:
288  DisjunctiveFaultPattern(const list<FaultPattern *> & patterns);
289  };
290 
291 
292 
293  };
294 };
295 
296 #endif
EdgeMap< EventOccurrence > _edgeMap
the constraint graph
EventOccurrence & operator=(const EventOccurrence &occurrence)
Definition: FaultPattern.hh:83
friend ostream & operator<<(ostream &os, const EventOccurrence &occurrence)
bool valid() const
Definition: NodeImpl.hh:23
EventOccurrence(const EventOccurrence &occurrence)
Definition: FaultPattern.hh:74
virtual const EventOccurrence & eventOccurrenceOf(Edge edge) const
const Graph & owner() const
Definition: NodeImpl.hh:46
virtual Node initial() const
bool containsEvent(Event event) const
Node _initialNode
the occurrence of Event associated to each Edge of the Graph
virtual const Graph::Graph & graph() const
Namespace of the Diades project.
bool operator==(const EventOccurrence &occurrence)
virtual bool isFinal(Node s) const
NodeMap< int > _finalNodes
initial state of the pattern graph
unordered_set< Event > _events
set of final states of the constraint graph, status == 1 (final) == 0 (non-final) ...
Namespace of the Graph library (libGraph)
Definition: BFS.hh:9
EventOccurrence(Event event, int identifier)
the identifier of the occurrence
Definition: FaultPattern.hh:61