21 string result = label;
22 std::replace( result.begin(), result.end(),
' ',
'_');
28 ofstream file(fileName.c_str());
29 file << ptaMoore.
name() << endl;
32 for(Component::StateIterator stateIt = ptaMoore.
stateBegin();
41 file << endl << 0 << endl;
46 vector<string> transitions;
52 string transitionBase;
56 transitions.push_back(transition);
60 file << events.size() << endl;
61 for(set<string>::const_iterator it = events.begin(); it != events.end(); ++it)
65 file << endl << 0 << endl;
70 file << endl << transitions.size() << endl;
71 for(vector<string>::size_type i = 0; i < transitions.size(); ++i)
73 file << transitions[i] << endl;
99 ifstream
log(filename);
101 while (std::getline(log, line))
103 std::istringstream iss(line);
112 const Event & evt = EventFactory::factory()->
getEvent(event);
118 currentMoore = itMoore->target();
124 currentMoore = targetMoore;
128 Transition previousMoore = *currentMoore.inEdgeBegin();
129 currentMoore = previousMoore.source();
133 for(Component::OutputTransitionIterator oit = ptaMoore.
outputTransitionBegin(previousMoore.target());
144 ifstream log2(filename);
145 while (std::getline(log2, line))
147 std::istringstream iss(line);
154 bool stateCreationMoore =
false;
158 const Event & evt = EventFactory::factory()->
getEvent(event);
164 currentMoore = itMoore->target();
170 currentMoore=targetMoore;
171 stateCreationMoore =
true;
176 Transition previousMoore = *currentMoore.inEdgeBegin();
179 if(stateCreationMoore)
183 string counter = ptaMoore.
getLabel(currentMoore);
184 string faultClass = counter +
" " + type;
186 ptaMoore.
newTransition(previousMoore.source(),targetFaultMoore,
194 string label = ptaMoore.
getLabel(currentMoore);
195 std::set<string> labels;
196 istringstream iss2(label);
198 while(iss2 >> faultClass)
200 labels.insert(faultClass);
204 for(
const string & lbl : labels)
206 faultClass += lbl +
" ";
209 ptaMoore.
newTransition(previousMoore.source(),targetFaultMoore,
212 for(Component::OutputTransitionIterator oit = ptaMoore.
outputTransitionBegin(previousMoore.target());
237 ifstream
log(filename);
239 while (std::getline(log, line))
241 std::istringstream iss(line);
250 const Event & evt = EventFactory::factory()->
getEvent(event);
256 current = it->target();
269 ifstream log2(filename);
270 while (std::getline(log2, line))
272 std::istringstream iss(line);
277 const Event & fault = EventFactory::factory()->
getEvent(type);
281 bool stateCreation =
false;
285 const Event & evt = EventFactory::factory()->
getEvent(event);
292 current = it->target();
299 stateCreation =
true;
305 current = previous.source();
308 current = targetFault;
331 string fals =
"false";
334 for(
unsigned i = 0; i < varNames.size(); ++i)
336 string assign = varNames[i] + op + ((
id % 2 == 0) ? fals : tru);
337 result += (i < varNames.size() -1) ? assign +
"," : assign;
346 string notS =
" not ";
347 string andS =
" and ";
349 for(
unsigned i = 0; i < varNames.size(); ++i)
351 string assign = (
id % 2 == 0) ? notS + varNames[i] : varNames[i];
352 result += (i < varNames.size() -1) ? assign + andS : assign;
364 os <<
"componenttype PTA {" << std::endl;
366 vector<string> varNames(encodingSize);
368 for(
unsigned i = 0; i < varNames.size(); ++i)
372 varNames[i] = stream.str();
373 os <<
" var " << varNames[i] <<
": bool;" << std::endl;
376 for(
auto & event : pta.
events())
380 os <<
" event " <<
event <<
";" << std::endl;
390 os <<
" observable event " << *it <<
";" << std::endl;
400 unsigned counter = 0;
402 stream <<
" transition T" << *it;
403 os << stream.str() << std::endl;
408 stringstream stream2;
409 stream2 << stream.str() <<
"_" << ++counter;
410 os << stream2.str() <<
" " 416 os <<
" triggeredby " << *it <<
";" << std::endl << std::endl;
420 for(
auto & event : pta.
events())
424 unsigned counter = 0;
426 stream <<
" transition T" << event;
427 os << stream.str() << std::endl;
432 stringstream stream2;
433 stream2 << stream.str() <<
"_" << ++counter;
434 os << stream2.str() <<
" " 440 os <<
" triggeredby " <<
event <<
";" << std::endl << std::endl;
443 os <<
"}" << std::endl << std::endl;
444 os <<
"component pta0 = PTA;" << std::endl;
462 ifstream
log(filename);
464 while (std::getline(log, line))
466 std::istringstream iss(line);
474 const Event & evt = EventFactory::factory()->
getEvent(event);
481 current = it->target();
493 const Event & faultEvt = EventFactory::factory()->
getEvent(type);
506 current = it->target();
509 const Event & endEvt = EventFactory::factory()->
getEvent(
"$");
525 ofstream file(targetName +
".orange");
533 int main(
int argc,
char ** argv)
535 string fileName = argv[1];
536 string targetName = argv[2];
void MooreEncoding(const string &filename)
static Event getEvent(const Label &evtLabel)
virtual bool component2dot(const string &fileName) const
virtual bool exportDesCompModel(const string &filename) const
string stringOf(unsigned &counter)
OutputEventTransitionIterator outputEventTransitionBegin(State s, Event e) const
string replaceSpace(const string &label)
Diades::Graph::Edge Transition
void setMask(const ObservableMask &mask)
StateIterator stateBegin() const
const Label & nickname() const
void MealyEncoding(const string &filename, const string &targetName)
string encodeSourceState(unsigned id, const vector< string > &varNames)
const StateLabel & getLabel(State state) const
EventTransitionIterator eventTransitionEnd(const Event &e) const
StateIterator stateEnd() const
OutputEventTransitionIterator outputEventTransitionEnd(State s, Event e) const
void MealyEncodingV1(const string &filename)
void makeUnobservable(const Event &e)
TransitionIterator transitionEnd() const
void deleteState(State state)
static void init(size_t capacity)
An observable Component defined as a automaton.
void setName(const string &name)
const string & name() const
AutFsm::Transition Transition
DdAutFsm::EventPropertyId Event
EventIterator observableBegin() const
const Event & noEvent() const
InitialStateIterator initialStateBegin() const
EventIterator observableEnd() const
void setInitial(State state)
unsigned numberOfStates() const
EventTransitionIterator eventTransitionBegin(const Event &e) const
OutputTransitionIterator outputTransitionBegin(State s) const
const ObservableMask & mask() const
int main(int argc, char **argv)
virtual bool component2dot(const string &fileName) const
TransitionIterator transitionBegin() const
unordered_set< Transition >::const_iterator OutputEventTransitionIterator
const Event & getEvent(Transition t) const
virtual bool exportDesCompModel(const string &filename) const
void insertEvent(const Event &event)
string encodeTargetState(unsigned id, const vector< string > &varNames)
void addMask(const Event &e, const Event &obs)
Log log(Logger logger, const string &msg)
Diades::Graph::Node State
Transition newTransition(State source, State target, Event event)
bool isUnobservable(const Event &e) const
void component2Orange(const ObservableComponent &pta, ostream &os)
void exportToDesComp(const Component &ptaMoore, const string &fileName)
const set< Event > & events() const
OutputTransitionIterator outputTransitionEnd(State s) const