DiaDes  0.1
DIAgnosis of Discrete-Event System
BddStateMachineEncoding.hh
Go to the documentation of this file.
1 
8 #ifndef __DIADES__SDMDL_EXPERIMENTAL__BDDSTATEMACHINEENCODING__HH__
9 #define __DIADES__SDMDL_EXPERIMENTAL__BDDSTATEMACHINEENCODING__HH__
10 
11 #include <vector>
17 
18 namespace Diades
19 {
20  namespace Sdmdl
21  {
22  namespace Experimental
23  {
24 
30  template<typename StateProperty, typename FaultProperty>
31  BddStateMachine &
33  BddStateMachine & result)
34  {
35  for (auto it = component.transitionBegin();
36  it != component.transitionEnd();
37  ++it)
38  {
39  stringstream stream1;
40  stream1 << component.getEvent(*it);
41  const Formula & event = result.event(result.eventVariable().getValue(stream1.str()));
42  stringstream stream2;
43  stream2 << component.getStatePropertyId(it->source());
44  const Formula & source = result.factory().newFormula(result.stateVariable(),
45  result.stateVariable().getValue(stream2.str()));
46 
47 
48 
49  stringstream stream3;
50  stream3 << component.getStatePropertyId(it->target());
51  const Formula & target = result.factory().newFormula(result.nextStateVariable(),
52  result.nextStateVariable().getValue(stream3.str()));
53  result.addTransitions(source && target && event);
54  }
55  return result;
56  }
57 
58  template<typename StateProperty, typename FaultProperty>
61  BddStateMachine & result)
62  {
63  for (auto & evt: component.events())
64  {
65  result.addEvent(evt);
66  }
67  return result;
68  }
69 
70  template<typename StateProperty, typename FaultProperty>
73 
74  BddStateMachine & result)
75  {
76 
77  for (auto it = component.initialStateBegin();
78  it != component.initialStateEnd(); ++it)
79  {
80  stringstream stream;
81  stream << component.getStatePropertyId(*it);
82  result.addInitialStates(result.factory().newFormula(result.stateVariable(),
83  result.stateVariable().getValue(stream.str())));
84  }
85  return result;
86  }
87 
88  template<typename StateProperty, typename FaultProperty>
91  Variable & stateVar,
92  Variable & nextStateVar,
93  Variable & event,
94  BddStateMachine & result)
95  {
96  result.clear();
97  result.setEventVariable(event);
98  result.setStateVariable(stateVar);
99  result.setNextStateVariable(nextStateVar);
101  encodeEvent(component, result);
102  encodeInitialStates(component, result);
103  encodeTransitions(component,result);
104  return result;
105  }
106  };
107  }
108 }
109 
110 
111 
112 #endif
113 
const Value & getValue(const string &label) const
BddStateMachine & encode(const Diades::Automata::Experimental::StateMachine< StateProperty, FaultProperty > &component, Variable &stateVar, Variable &nextStateVar, Variable &event, BddStateMachine &result)
BddStateMachine & encodeInitialStates(const Diades::Automata::Experimental::StateMachine< StateProperty, FaultProperty > &component, BddStateMachine &result)
const SlStates & addInitialStates(const SlStates &newInitialStates)
Formula class using BDD.
InitialStateIterator initialStateEnd() const
Variable & setStateVariable(Variable &stateVar)
Variable & setEventVariable(Variable &event)
const EventPropertyId & getEvent(Transition t) const
const vector< EventPropertyId > & events() const
const SlEvents & event(const Value &eventValue) const
Namespace of the Diades project.
BddStateMachine & encodeTransitions(const Diades::Automata::Experimental::StateMachine< StateProperty, FaultProperty > &component, BddStateMachine &result)
InitialStateIterator initialStateBegin() const
const Formula & newFormula(const Variable &variable, const Value &value) const
TransitionIterator transitionBegin() const
BddStateMachine & encodeEvent(const Diades::Automata::Experimental::StateMachine< StateProperty, FaultProperty > &component, BddStateMachine &result)
Variable & setNextStateVariable(Variable &nextStateVar)
const StatePropertyId & getStatePropertyId(State state) const
const SlTransitions & addTransitions(const SlTransitions &transition)