24 std::string& rReportStr)
26 FD_DF(
"IsHioControllerForm("<< rHioController.
Name() <<
",...)");
35 rErrEvSet.
Name(
"rErrEvSet");
38 rErrTrSet.
Name(
"rErrTrSet");
41 rErrStSet.
Name(
"rErrStSet");
50 bool finalResult =
true;
52 bool localResult =
true;
65 EventSet::Iterator evit;
66 StateSet::Iterator sit;
70 rReportStr.append(
"#########################################################\n");
71 rReportStr.append(
"########## IsHioControllerForm("+rHioController.
Name()+
",...) - test results:\n");
76 rReportStr.append(
"##### fail: generator is not deterministic!\n");
77 if(initStates.
Size()>1) {
78 rErrStSet = initStates;
79 rReportStr.append(
"##### (amongst others, there is more than one initial state)\n");
84 rReportStr.append(
"#####\n");
90 rReportStr.append(
"########## Condition (i):\n");
94 rReportStr.append(
"##### fail: empty YP alphabet.\n");
99 rReportStr.append(
"##### fail: empty UP alphabet.\n");
104 rReportStr.append(
"##### fail: empty YC alphabet.\n");
109 rReportStr.append(
"##### fail: empty UC alphabet.\n");
122 if(!rErrEvSet.
Empty()){
123 rReportStr.append(
"##### fail: found events with missing or ambiguous attribute, see rErrEvSet:\n");
124 rReportStr.append(rErrEvSet.
ToString()+
"\n");
125 rReportStr.append(
"##### Condition (i) failed.\n");
126 rReportStr.append(
"########## Termination due to crucial failure. ##########\n");
127 rReportStr.append(
"#########################################################\n");
130 if(localResult) rReportStr.append(
"##### Condition (i) passed.\n");
131 else rReportStr.append(
"##### Condition (i) failed.\n");
132 rReportStr.append(
"#####\n");
138 rReportStr.append(
"########## Condition (ii):\n");
142 for(sit = accessibleStates.
Begin(); sit != accessibleStates.
End(); ++sit) {
148 bool goodState =
true;
152 if(activeEv.
Empty()) {
159 evit = activeEv.
Begin();
160 isUc = rHioController.
IsUc(*evit);
161 isYcUp = rHioController.
IsYc(*evit);
162 isUp = rHioController.
IsUp(*evit);
163 isYp = rHioController.
IsYp(*evit);
165 for(; evit != activeEv.
End(); evit++) {
166 if( (isUc && !rHioController.
IsUc(*evit)) ||
167 ((isYcUp||isUp) && (!rHioController.
IsYc(*evit) && (!rHioController.
IsUp(*evit)))) ||
168 (isYp && !rHioController.
IsYp(*evit)) ){
176 if(isUp && rHioController.
IsYc(*evit)) {
184 if(!goodState)
continue;
189 rHioController.
SetQUc(*sit);
197 rHioController.
SetQUp(*sit);
201 rHioController.
SetQYp(*sit);
206 if(localResult) rReportStr.append(
"##### Condition (ii) passed.\n");
209 rReportStr.append(
"##### fail: found states with undecidable attribute:\n");
210 rReportStr.append(locErrStSet.
ToString()+
"\n");
211 rReportStr.append(
"##### Condition (ii) failed.\n");
212 rReportStr.append(
"########## Termination due to crucial failure. ##########\n");
213 rReportStr.append(
"###################### No success. ######################\n");
214 rReportStr.append(
"#########################################################\n");
219 rReportStr.append(
"#####\n");
225 rReportStr.append(
"########## Condition (iii):\n");
228 if(!(initStates <= rQYP)) {
229 rReportStr.append(
"##### fail: some init state(s) is (are) not a QYP-state:\n");
230 locErrStSet=initStates-rQYP;
231 rReportStr.append(locErrStSet.
ToString()+
"\n");
237 if(localResult) rReportStr.append(
"##### Condition (iii) passed.\n");
238 else rReportStr.append(
"##### Condition (iii) failed.\n");
239 rReportStr.append(
"#####\n");
246 rReportStr.append(
"########## Condition (iv):\n");
249 for(sit = rQYP.
Begin(); sit != rQYP.
End(); ++sit) {
252 if ( !( rQYcUp.
Exists(tit->X2) || rQUp.
Exists(tit->X2) ) ) {
262 if(localResult) rReportStr.append(
"##### Condition (iv) passed.\n");
264 rReportStr.append(
"##### fail: found YP-transitions leading to wrong states:\n");
265 rReportStr.append(locErrTrSet.
ToString()+
"\n");
267 rReportStr.append(
"##### Condition (iv) failed.\n");
269 rReportStr.append(
"#####\n");
275 rReportStr.append(
"########## Condition (v):\n");
278 for(sit = rQUp.
Begin(); sit != rQUp.
End(); ++sit) {
280 if(!rQYP.
Exists(tit->X2)) {
289 if(localResult) rReportStr.append(
"##### Condition (v) passed.\n");
291 rReportStr.append(
"##### fail: found UP-transitions leading to wrong states, see rErrTrSet:\n");
292 rReportStr.append(locErrTrSet.
ToString()+
"\n");
294 rReportStr.append(
"##### Condition (v) failed.\n");
296 rReportStr.append(
"#####\n");
302 rReportStr.append(
"########## Condition (vi):\n");
306 for(sit = rQYcUp.
Begin(); sit != rQYcUp.
End(); ++sit) {
309 if( (rHioController.
IsUp(tit->Ev) && !rQYP.
Exists(tit->X2)) ||
310 (rHioController.
IsYc(tit->Ev) && !rQUc.
Exists(tit->X2)) ){
319 if(localResult) rReportStr.append(
"##### Condition (vi) passed.\n");
321 rReportStr.append(
"##### fail: found YC- or UP-transitions leading to wrong states:\n");
322 rReportStr.append(locErrTrSet.
ToString()+
"\n");
324 rReportStr.append(
"##### Condition (vi) failed.\n");
326 rReportStr.append(
"#####\n");
332 rReportStr.append(
"########## Condition (vii):\n");
335 for(sit = rQUc.
Begin(); sit != rQUc.
End(); ++sit) {
337 if(!rQUp.
Exists(tit->X2)) {
346 if(localResult) rReportStr.append(
"##### Condition (vii) passed.\n");
348 rReportStr.append(
"##### fail: found UC-transitions leading to wrong states:\n");
349 rReportStr.append(locErrTrSet.
ToString()+
"\n");
351 rReportStr.append(
"##### Condition (vii) failed.\n");
353 rReportStr.append(
"#####\n");
359 rReportStr.append(
"########## Condition (viii):\n");
362 for(sit = rQUc.
Begin(); sit != rQUc.
End(); ++sit) {
372 if(localResult) rReportStr.append(
"##### Condition (viii) passed.\n");
374 rReportStr.append(
"##### fail: found QUc-states with inactive UC-events:\n");
375 rReportStr.append(locErrStSet.
ToString()+
"\n");
377 rReportStr.append(
"##### Condition (viii) failed.\n");
379 rReportStr.append(
"#####\n");
385 rReportStr.append(
"########## Condition (ix):\n");
388 for(sit = rQYP.
Begin(); sit != rQYP.
End(); ++sit) {
398 if(localResult) rReportStr.append(
"##### Condition (ix) passed.\n");
400 rReportStr.append(
"##### fail: found QYP-states with inactive YP-events:\n");
401 rReportStr.append(locErrStSet.
ToString()+
"\n");
403 rReportStr.append(
"##### Condition (ix) failed.\n");
405 rReportStr.append(
"#####\n");
411 rReportStr.append(
"########## Condition (x):\n");
414 if(!(accessibleStates<=rHioController.
MarkedStates())) {
419 if(localResult) rReportStr.append(
"##### Condition (x) passed.\n");
421 rReportStr.append(
"##### fail: not all accessible states are marked:\n");
422 locErrStSet = accessibleStates - rHioController.
MarkedStates();
424 rReportStr.append(locErrStSet.
ToString()+
"\n");
426 rReportStr.append(
"##### Condition (x) failed.\n");
428 rReportStr.append(
"#####\n");
434 rReportStr.append(
"########## Condition (xi):\n");
437 if(!deadEnds.
Empty()) {
441 rReportStr.append(
"##### fail: found dead ends:\n");
442 rReportStr.append(deadEnds.
ToString()+
"\n");
444 rReportStr.append(
"##### Condition (xi) failed.\n");
446 rReportStr.append(
"##### Condition (xi) passed.\n");
451 rReportStr.append(
"########## Condition (xii):\n");
456 rReportStr.append(
"##### warning: non-accessible states have been removed.\n");
457 rReportStr.append(
"##### Condition (xii) repaired.\n");
459 else rReportStr.append(
"##### Condition (xii) passed.\n");
465 rReportStr.append(
"##################### Final result: #####################\n");
467 rReportStr.append(
"######### Generator is in HioControllerForm. #########\n");
468 rReportStr.append(
"#########################################################\n");
472 rReportStr.append(
"########### Generator is NOT in HioControllerForm. ###########\n");
473 rReportStr.append(
"#########################################################\n");
487 return IsHioControllerForm(rHioController, QUc, QYP, QUp, QYcUp, ErrEvSet, ErrTrSet, ErrStSet, rReportStr);
496 std::string ReportStr;
498 return IsHioControllerForm(rHioController, QUc, QYP, QUp, QYcUp, ErrEvSet, ErrTrSet, ErrStSet, ReportStr);
#define FD_DF(message)
Debug: optional report on user functions.
Idx Insert(void)
Insert new index to set.
Set of indices with symbolic names.
EventSet PEvents(void) const
Get EventSet with P-events.
EventSet YcEvents(void) const
Get EventSet with Yc-events.
void SetQYcUp(Idx index)
Mark event as QYcUp-state (by index)
EventSet CEvents(void) const
Get EventSet with E-events.
void SetQUc(Idx index)
Mark event as QUc-state (by index)
EventSet UcEvents(void) const
Get EventSet with Uc-events.
EventSet YpEvents(void) const
Get EventSet with Yp-events.
bool IsUc(Idx index) const
Is event Uc-event (by index)
void SetQYp(Idx index)
Mark state as QYP-state (by index)
bool IsUp(Idx index) const
Is event Up-event(by index)
void SetQUp(Idx index)
Mark event as QUp-state (by index)
bool IsYp(Idx index) const
Is event Yp-event(by index)
EventSet UpEvents(void) const
Get EventSet with Up-events.
bool IsYc(Idx index) const
Is event Yc-event (by index)
bool Insert(const Transition &rTransition)
Add a Transition.
TBaseSet< Transition, TransSort::X1EvX2 >::Iterator Iterator
Iterator on transition.
const TaEventSet< EventAttr > & Alphabet(void) const
Return const reference to alphabet.
std::string ToString(const std::string &rLabel="", const Type *pContext=0) const
Write configuration data to a string.
const StateSet & MarkedStates(void) const
Return const ref of marked states.
EventSet ActiveEventSet(Idx x1) const
Return active event set at state x1.
const StateSet & InitStates(void) const
Const ref to initial states.
TransSet::Iterator TransRelBegin(void) const
Iterator to Begin() of transition relation.
bool Accessible(void)
Make generator accessible.
bool IsAccessible(void) const
Check if generator is accessible.
StateSet AccessibleSet(void) const
Compute set of accessible states.
void Name(const std::string &rName)
Set the generator's name.
TransSet::Iterator TransRelEnd(void) const
Iterator to End() of transition relation.
bool IsDeterministic(void) const
Check if generator is deterministic.
bool Empty(void) const
Test whether if the TBaseSet is Empty.
bool Exists(const T &rElem) const
Test existence of element.
virtual void Clear(void)
Clear all set.
Iterator End(void) const
Iterator to the end of set.
virtual void InsertSet(const TBaseSet &rOtherSet)
Insert elements given by rOtherSet.
Iterator Begin(void) const
Iterator to the begin of set.
const std::string & Name(void) const
Return name of TBaseSet.
Idx Size(void) const
Get Size of TBaseSet.
Generator with I/O-controller attributes.
libFAUDES resides within the namespace faudes.
bool IsHioControllerForm(HioController &rHioController, StateSet &rQUc, StateSet &rQYP, StateSet &rQUp, StateSet &rQYcUp, EventSet &rErrEvSet, TransSet &rErrTrSet, StateSet &rErrStSet, std::string &rReportStr)
IsHioControllerForm: check if rHioController is in I/O-controller form and assign state attributes.
void HioStatePartition(HioConstraint &rHioConstraint)
Function definition for run-time interface.