hio_module.cpp
Go to the documentation of this file.
1 /** @file hio_module.cpp Class describing the I/O based hierarchy */
2 
3 /* Hierarchical IO Systems Plug-In for FAU Discrete Event Systems Library (libfaudes)
4 
5  Copyright (C) 2006 Sebastian Perk
6  Copyright (C) 2006 Thomas Moor
7  Copyright (C) 2006 Klaus Schmidt
8 
9 */
10 
11 #include "hio_module.h"
12 
13 namespace faudes {
14 
15 // Constructor
17 }
18 
19 
20  // Copy constructor
21  HioModule::HioModule(const HioModule& rOtherHioModule) {
22  mOpConstr = rOtherHioModule.OpConstr();
23  mPlant = rOtherHioModule.Plant();
24  mController = rOtherHioModule.Controller();
25  mChildren = rOtherHioModule.Children();
26  mEnvironment = rOtherHioModule.Environment();
27  mEnvConstr = rOtherHioModule.EnvConstr();
28  TypeHioModule(rOtherHioModule.TypeHioModule());
29  mIndex = rOtherHioModule.Index();
30  mName = rOtherHioModule.Name();
31  Position(rOtherHioModule.Xpos(), rOtherHioModule.Ypos());
32  }
33 
34  //HioModule::Clear()
36  {
37  mEnvConstr.Clear();
38  mOpConstr.Clear();
40  mPlant.Clear();
41  mIndex = 0;
42  for (int i=0; i<5; i++)
43  mType[i] = 0;
44  mXpos = 0;
45  mYpos = 0;
46  mName = "";
47  mChildren.clear();
48  }
49 
50  // HioModule::Name()
51  std::string HioModule::Name() const {
52  return mName;
53  }
54 
55  // HioModule::Name(rName)
56  void HioModule::Name(const std::string& rName){
57  mName = rName;
58  }
59 
60  // HioModule::Index()
62  return mIndex;
63  }
64 
65  // HioModule::Index(Index)
66  void HioModule::Index(const Idx Index){
67  mIndex = Index;
68  }
69 
70  // HioModule::OpConstr(rOpConstr)
71  void HioModule::OpConstr(const HioConstraint& rOpConstr){
72  mOpConstr = rOpConstr;
73  }
74 
75  // HioModule::OpConstr()
77  return mOpConstr;
78  }
79 
80  // HioModule::Plant(HioPlant)
81  void HioModule::Plant(const HioPlant& rHioPlant){
82  mPlant = rHioPlant;
83  }
84 
85  // HioModule::Plant()
87  return mPlant;
88  }
89 
90  // HioModule::Controller(HioController)
91  void HioModule::Controller(const HioController& rHioController){
92  mController = rHioController;
93  }
94 
95  // HioModule::Controller()
97  return mController;
98  }
99 
100  // HioModule::Children(rChildren)
101  void HioModule::Children(const std::vector<HioModule*>& rChildren) {
102  mChildren = rChildren;
103  }
104 
105  // HioModule::Children
106  std::vector<HioModule*> HioModule::Children() const {
107  return mChildren;
108  }
109 
110  // HioModule::Environment(HioEnvironment)
111  void HioModule::Environment(const HioEnvironment& rHioEnvironment){
112  mEnvironment = rHioEnvironment;
113  }
114 
115  // HioModule::Environment()
117  return mEnvironment;
118  }
119 
120  // HioModule::EnvConstr(rEnvConstr)
121  void HioModule::EnvConstr(const HioConstraint& rEnvConstr){
122 
123  mEnvConstr = rEnvConstr;
124  }
125 
126  // HioModule::EnvConstr()
128  return mEnvConstr;
129  }
130 
131  // HioModule::InsChild(rChild)
133  mChildren.push_back(rChild);
134  }
135 
136  /////////////////////////////////////////////////////////////////////
137  // from here to end of file: design specific functions by M.Musunoi
138  // will be outsourced to something like hiodesign.cpp
139 
140  // function to set mXpos and mYpos of the HioModule
141  void HioModule::Position(const int Xpos, const int Ypos){
142 
143  mXpos = Xpos;
144  mYpos = Ypos;
145  }
146 
147  // function to set the type of HioModule
148  void HioModule::TypeHioModule(int type[5]){
149 
150  for (int i=0; i<=4; i++)
151  mType[i] = type[i];
152  }
153 
154 
155 
156  //ReadHioPlant: this function reads the models from the given library and
157  //creates a general IOModulX which can be afterwards personalised.
158  void HioModule::ReadHioPlant(const std::string path)
159  {
160 
163 
164  std::string myType;
165 
166  //read and set the IO Plant
167  std::string HioPlantFile = path+"plant.gen";
168  mPlant.Read(HioPlantFile.c_str());
169 
170  //searching for the token reader "Type", and set the type of the HioPlant
171  TokenReader tReader(HioPlantFile.c_str());
172  Token token;
173  token.SetString("Type");
174  tReader.ReadBegin("Type");
175  while(tReader.Peek(token)) {
176  // break on end
177  if (token.Type() == Token::End) {
178  break;
179  }
180  myType = tReader.ReadString();
181  continue;
182  }
183 
184  //set mType
185  for(int i=0 ;i<=4;i++)
186  {
187  char tmpChar = myType.at(i);
188  std::stringstream Str;
189  Str << tmpChar;
190  int d;
191  Str >> d;
192 
193  mType[i] = d;
194  }
195 
196  //read and set the Operator-Constraint
197  std::string LpFile = path+"constrP.gen";
198  mOpConstr.Read(LpFile.c_str());
199 
200 
201  //load and set the Environment-Constraint
202  std::string LeFile = path+"constrE.gen";
203  mEnvConstr.Read(LeFile.c_str());
204 
205  } //end of ReadHioPlant()
206 
207 
208  //loadLibEnv: this function loads the model of interaction of IO-Plants with
209  //the environment and creates a general IOEnvironment.
210  void HioModule::ReadHioEnv(const std::string path)
211 
212  {
213  std::string EnvFile = path+"environment.gen";
214  mEnvironment.Read(EnvFile.c_str());
215  }
216 
217 
218  //AdjusTimedGenerator: this function converts a generator by renaming all events from
219  //"CBx_..." to "CBi_...";
221  const int i,
222  Generator& rResGen)
223  {
224  EventSet newAlph;
225  TransSet::Iterator tit;
226  StateSet::Iterator sit;
227  EventSet::Iterator evit;
228  std::string toSeti = ToStringInteger(i);
229  std::string toSet = "CB"+toSeti+"_";
230 
231 
232  //check if generator not already in converted form; if already converted, return
233  //sperk: throw exception?
234  for (evit = rOldGen.AlphabetBegin(); evit != rOldGen.AlphabetEnd(); ++evit)
235  {
236 
237  std::string oldName = rOldGen.Alphabet().SymbolicName(*evit);
238  //int loc1 = oldName.find(toSet, 0);
239  //if( loc1 != std::string::npos )
240  if( oldName.find(toSet, 0) != std::string::npos )
241  {
242  std::cout<<"At least one event already converted";
243  rResGen = rOldGen;
244  return;
245  }
246  }
247 
248  // first state to be inserted in the new, empty rResult generator
249  int state = 1;
250 
251  //rename events an insert the resulting alphabet in rResult
252  AdjustAlphabet(rOldGen.Alphabet(), i, newAlph);
253  rResGen.InjectAlphabet(newAlph);
254 
255  //insert states in rResult;
256  for (sit = rOldGen.StatesBegin(); sit != rOldGen.StatesEnd(); ++sit)
257  {
258  rResGen.InsMarkedState(ToStringInteger(state));
259  //if actual state also init state then mark it as init state in rResult too;
260  if(rOldGen.ExistsInitState(state))
261  rResGen.SetInitState(ToStringInteger(state));
262 
263  state++;
264  }
265 
266  //iterate through all states
267  for (sit = rOldGen.StatesBegin(); sit != rOldGen.StatesEnd(); ++sit)
268  {
269  //iterate through all transitions of the actual state; rename the events
270  //of each transition and insert the new transition in rResult
271  for (tit = rOldGen.TransRelBegin(*sit); tit != rOldGen.TransRelEnd(*sit); ++tit)
272  {
273  std::string oldName = rOldGen.EventName(tit->Ev);
274  int loc1 = oldName.find("_", 0);
275  std::string newName = oldName.erase(0,loc1+1);
276  newName = toSet + oldName;
277 
278  Idx idx_event = rResGen.EventIndex(newName);
279  rResGen.SetTransition(tit->X1, idx_event, tit->X2);
280  }
281  }
282 
283  } //END ADJUSTGENERATOR
284 
285 
286  // AdjustHioPlant(): convenience function (derived from AdjusTimedGenerator())to
287  // allow also the conversion of HioPlants
289  const HioPlant& rOldHioPlant,
290  const int i,
291  HioPlant& rResGen)
292  {
293  EventSet newAlph;
294  EventSet::Iterator evit;
295  TransSet::Iterator tit;
296  StateSet::Iterator sit;
297  std::string toSeti = ToStringInteger(i);
298  std::string toSet = "CB"+toSeti+"_";
299 
300  //check if generator not already in converted form
301  for (evit = rOldHioPlant.AlphabetBegin(); evit != rOldHioPlant.AlphabetEnd(); ++evit)
302  {
303 
304  std::string oldName = rOldHioPlant.Alphabet().SymbolicName(*evit);
305  //int loc1 = oldName.find(toSet, 0);
306  //if( loc1 != std::string::npos )
307  if( oldName.find(toSet, 0) != std::string::npos )
308  {
309  std::cout<<"At least one event already converted";
310  rResGen = rOldHioPlant;
311  return;
312  }
313  }
314  // first state to be inserted in the new, empty rResult generator
315  int state = 1;
316 
317  //rename events by preserving the events attributes
318  //Yp-Events
319  AdjustAlphabet(rOldHioPlant.YpEvents(), i, newAlph);
320  for(evit = newAlph.Begin(); evit != newAlph.End(); ++evit)
321  rResGen.InsYpEvent(*evit);
322  newAlph.Clear();
323 
324  //Up-Events
325  AdjustAlphabet(rOldHioPlant.UpEvents(), i, newAlph);
326  for(evit = newAlph.Begin(); evit != newAlph.End(); ++evit)
327  rResGen.InsUpEvent(*evit);
328  newAlph.Clear();
329 
330  //Ye-Events
331  AdjustAlphabet(rOldHioPlant.YeEvents(), i, newAlph);
332  for(evit = newAlph.Begin(); evit != newAlph.End(); ++evit)
333  rResGen.InsYeEvent(*evit);
334  newAlph.Clear();
335 
336  //Ue-Events
337  AdjustAlphabet(rOldHioPlant.UeEvents(), i, newAlph);
338  for(evit = newAlph.Begin(); evit != newAlph.End(); ++evit)
339  rResGen.InsUeEvent(*evit);
340  newAlph.Clear();
341 
342  //insert states in rResult;
343  for (sit = rOldHioPlant.StatesBegin(); sit != rOldHioPlant.StatesEnd(); ++sit)
344  {
345  rResGen.InsMarkedState(ToStringInteger(state));
346  //if actual state also init state then mark it as init state in rResult too;
347  if(rOldHioPlant.ExistsInitState(state))
348  rResGen.SetInitState(ToStringInteger(state));
349 
350  state++;
351  }
352  //iterate through all states
353  for (sit = rOldHioPlant.StatesBegin(); sit != rOldHioPlant.StatesEnd(); ++sit)
354  {
355  //iterate through all transitions of the actual state; rename the events
356  //of each transition and insert the new transition in rResult
357  for (tit = rOldHioPlant.TransRelBegin(*sit); tit != rOldHioPlant.TransRelEnd(*sit); ++tit)
358  {
359  std::string oldName = rOldHioPlant.EventName(tit->Ev);
360  int loc1 = oldName.find("_", 0);
361  std::string newName = oldName.erase(0,loc1+1);
362  newName = toSet + oldName;
363 
364  Idx idx_event = rResGen.EventIndex(newName);
365  rResGen.SetTransition(tit->X1, idx_event, tit->X2);
366  }
367  }
368  } //End of AdjustHioPlant()
369 
370 
371  // AdjustAlph(): this function converts an alphabet by renaming all events from
372  // "CBx_..." to "CBi_...";
373  // Warning: This function does not preserves the attributes of the events!
375  const EventSet& rOldAlph,
376  const int i,
377  EventSet& rResAlph)
378  {
379  EventSet::Iterator evit;
380  std::string toSeti = ToStringInteger(i);
381  std::string toSet = "CB"+toSeti+"_";
382 
383  //check if alphabet not already in converted form
384  for (evit = rOldAlph.Begin(); evit != rOldAlph.End(); ++evit)
385  {
386  std::string oldName = rOldAlph.SymbolicName(*evit);
387  //int loc1 = oldName.find(toSet, 0);
388  //if( loc1 != std::string::npos )
389  if( oldName.find(toSet, 0) != std::string::npos )
390  {
391  std::cout<<"At least one event already converted";
392  rResAlph = rOldAlph;
393  return;
394  }
395  }
396 
397  //iterate through the alphabet and adjust every event
398  for (evit = rOldAlph.Begin(); evit != rOldAlph.End(); ++evit)
399  {
400  std::string oldName = rOldAlph.SymbolicName(*evit);
401  int loc1 = oldName.find("_", 0);
402  std::string newName1 = oldName.erase(0,loc1+1);
403  std::string newName = toSet + oldName;
404 
405  rResAlph.Insert(newName);
406 
407  }
408  } //End of AdjustAlphabet
409 
410 
411  // AdjustEnvironmet: This function adjusts the master copy (IOEnviromntX) to
412  // the two IO-Plants.
414  const HioEnvironment& rHioEnvX,
415  const HioModule* rHioModule1,
416  const HioModule* rHioModule2,
417  HioEnvironment& rResEnv)
418  {
419  EventSet tmpAlph;
420  EventSet::Iterator evit;
421  StateSet::Iterator sit;
422  TransSet::Iterator tit;
423 
424 
425 
426  tmpAlph = rHioEnvX.Alphabet();
427  int leftId, rightId; //
428  int state = 1;
429  // strings to replace the standard event names: CBx_, CBy_, CBxy_
430  std::string toRepl_left, toRepl_right, toRepl_ext;
431 
432  // check the relative position of the 2 HioModule to each other and prepare
433  // the strings to be set, according to the Id of each IOMOdule
434  if (rHioModule1->Xpos() <= rHioModule2->Xpos())
435  {
436  //HioModule1 at the left of HioModule2
437  leftId = rHioModule1->Index();
438  toRepl_left = "CB"+ToStringInteger(leftId)+"_";
439 
440  rightId = rHioModule2->Index();
441  toRepl_right = "CB"+ToStringInteger(rightId)+"_";
442 
443  toRepl_ext = "CB"+ToStringInteger(leftId)+
444  ToStringInteger(rightId)+"_";
445  }
446  else
447  {
448  //HioModule1 at the right of HioModule2
449  leftId = rHioModule2->Index();
450  toRepl_left = "CB"+ToStringInteger(leftId)+"_";
451 
452  rightId = rHioModule1->Index();
453  toRepl_right = "CB"+ToStringInteger(rightId)+"_";
454 
455  toRepl_ext = "CB"+ToStringInteger(leftId)+
456  ToStringInteger(rightId)+"_";
457  }
458 
459  //check if generator not already in converted form
460  for (evit = rHioEnvX.AlphabetBegin(); evit != rHioEnvX.AlphabetEnd(); ++evit)
461  {
462 
463  std::string oldName = rHioEnvX.Alphabet().SymbolicName(*evit);
464  //int loc1 = oldName.find(toRepl_ext, 0);
465  //if( loc1 != std::string::npos )
466  if( oldName.find(toRepl_ext, 0) != std::string::npos )
467  {
468  std::cout<<"At least one event already converted";
469  rResEnv = rHioEnvX;
470  return;
471  }
472  }
473 
474  //**********************Adjust the Alphabet****************
475  //iterate through all events and replace
476  // CBx_-events with toRepl_left
477  // CBy_-events with toRepl_right
478  // CBxy_-events with toRepl_ext
479  for (evit = tmpAlph.Begin(); evit != tmpAlph.End(); ++evit)
480  {
481  //get actual event name
482  std::string eventName = tmpAlph.SymbolicName(*evit);
483 
484  // actual event is a "left-Plant" event? (Ye or Ue)
485  std::string::size_type loc1 = eventName.find("CBx_", 0);
486  if (loc1 != std::string::npos)
487  {
488  eventName.erase(0, 4);
489  std::string newEvent = toRepl_left+eventName;
490  //std::string newEvent = eventName.replace(0,toRepl_left.size(), toRepl_left);
491  if(rHioEnvX.IsYe(*evit))
492  {
493  rResEnv.InsYeEvent(newEvent);
494  }
495  else
496  {
497  rResEnv.InsUeEvent(newEvent);
498  }
499  }
500  else
501  {
502  // actual event is a "right-Plant" event?
503  std::string::size_type loc2 = eventName.find("CBy_", 0);
504  if (loc2 != std::string::npos)
505  {
506  eventName.erase(0, 4);
507  std::string newEvent = toRepl_right+eventName;
508  if(rHioEnvX.IsYe(*evit))
509  {
510  rResEnv.InsYeEvent(newEvent);
511  }
512  else
513  {
514  rResEnv.InsUeEvent(newEvent);
515  }
516  }
517 
518  else
519  {
520  // actual event is a "external interaction" event? (YL or UL)
521  std::string::size_type loc3 = eventName.find("CBxy_", 0);
522  if (loc3 != std::string::npos)
523  {
524  eventName.erase(0, 5);
525  std::string newEvent = toRepl_ext+eventName;
526  if(rHioEnvX.IsYl(*evit))
527  {
528  rResEnv.InsYlEvent(newEvent);
529  }
530  else
531  {
532  rResEnv.InsUlEvent(newEvent);
533  }
534  }
535 
536  }
537  }
538  }//*************************** End Adjust Alphabet***************
539 
540  // insert states into result generator
541  for (sit = rHioEnvX.StatesBegin(); sit != rHioEnvX.StatesEnd(); ++sit)
542  {
543  rResEnv.InsMarkedState(ToStringInteger(state));
544  //if actual state also init state then mark it as init state in rResEnv too;
545  if(rHioEnvX.ExistsInitState(state))
546  rResEnv.SetInitState(ToStringInteger(state));
547 
548  state++;
549  } //End Insert States
550 
551 
552  //***************************Adjust Transitions************************
553  // iterate through all states and all transitions. For every trasition check the
554  // event name, and rename it as described in the sequence "Adjust Alphabet"
555  for (sit = rHioEnvX.StatesBegin(); sit != rHioEnvX.StatesEnd(); ++sit)
556  {
557  //iterate through all transitions of the actuall state;
558  for (tit = rHioEnvX.TransRelBegin(*sit); tit != rHioEnvX.TransRelEnd(*sit); ++tit)
559  {
560  std::string eventName = rHioEnvX.EventName(tit->Ev);
561 
562  // actual event is a "left-Plant" event?
563  std::string::size_type loc1 = eventName.find("CBx_", 0);
564  if (loc1 != std::string::npos)
565  {
566  eventName.erase(0, 4);
567  std::string newEvent = toRepl_left+eventName;
568  eventName = newEvent;
569  }
570  else
571  {
572  // actual event is a "right-Plant" event?
573  std::string::size_type loc2 = eventName.find("CBy_", 0);
574  if (loc2 != std::string::npos)
575  {
576  eventName.erase(0, 4);
577  std::string newEvent = toRepl_right+eventName;
578  eventName = newEvent;
579  }
580  else
581  {
582  // actual event is a "external interaction" event?
583  std::string::size_type loc3 = eventName.find("CBxy_", 0);
584  if (loc3 != std::string::npos)
585  {
586  eventName.erase(0, 5);
587  std::string newEvent = toRepl_ext+eventName;
588  eventName = newEvent;
589  }
590  }
591  }
592 
593  // insert transition into result
594  Idx idx_event = rResEnv.EventIndex(eventName);
595  rResEnv.SetTransition(tit->X1, idx_event, tit->X2);
596  } // end for-loop over transition
597  } // end for-loop over states
598 
599  } // end of AdjustHioEnvironment()
600 
601 
602  // AdjustHioController: This function adjust an already computed IOController to
603  // apply with the two IO-Plants (that enforces a well-defined specification).
605  const HioController& rHioController,
606  const HioModule* rHioModule1,
607  const HioModule* rHioModule2,
608  HioController& rResEnv)
609  {
610  EventSet tmpAlph;
611  EventSet::Iterator evit;
612  StateSet::Iterator sit;
613  TransSet::Iterator tit;
614 
615  tmpAlph = rHioController.Alphabet();
616  int leftId, rightId; //
617  int state = 1;
618 
619  // strings to replace the standard event names: CBx_, CBy_, CBxy_
620  std::string toRepl_left, toRepl_right, toRepl_ext;
621 
622 
623  // check the relative position of the 2 HioModule to each other and prepare
624  // the strings to be set, according to the Id of each IOMOdule
625  if (rHioModule1->Xpos() <= rHioModule2->Xpos())
626  {
627  //HioModule1 at the left of HioModule2
628  leftId = rHioModule1->Index();
629  toRepl_left = "CB"+ToStringInteger(leftId)+"_";
630 
631  rightId = rHioModule2->Index();
632  toRepl_right = "CB"+ToStringInteger(rightId)+"_";
633 
634  toRepl_ext = "CB"+ToStringInteger(leftId)+
635  ToStringInteger(rightId)+"_";
636  }
637  else
638  {
639  //HioModule1 at the right of HioModule2
640  leftId = rHioModule2->Index();
641  toRepl_left = "CB"+ToStringInteger(leftId)+"_";
642 
643  rightId = rHioModule1->Index();
644  toRepl_right = "CB"+ToStringInteger(rightId)+"_";
645 
646  toRepl_ext = "CB"+ToStringInteger(leftId)+
647  ToStringInteger(rightId)+"_";
648  }
649 
650  //check if generator not already in converted form
651  for (evit = rHioController.AlphabetBegin(); evit != rHioController.AlphabetEnd(); ++evit)
652  {
653 
654  std::string oldName = rHioController.Alphabet().SymbolicName(*evit);
655  //int loc1 = oldName.find(toRepl_ext, 0);
656  //if( loc1 != std::string::npos )
657  if( oldName.find(toRepl_ext, 0) != std::string::npos )
658  {
659  std::cout<<"At least one event already converted";
660  rResEnv = rHioController;
661  return;
662  }
663  }
664 
665  //**********************Adjust the Alphabet****************
666  //iterate thru all events and replace
667  // CBx_-events with toRepl_left
668  // CBy_-events with toRepl_right
669  // CBxy_-events with toRepl_ext
670  for (evit = tmpAlph.Begin(); evit != tmpAlph.End(); ++evit)
671  {
672  //get actual event name
673  std::string eventName = tmpAlph.SymbolicName(*evit);
674 
675  // actual event is a "left-Plant" event?
676  std::string::size_type loc1 = eventName.find("CBx_", 0);
677  if (loc1 != std::string::npos)
678  {
679  eventName.erase(0, 4);
680  std::string newEvent = toRepl_left+eventName;
681  rResEnv.InsEvent(newEvent);
682  }
683  else
684  {
685  // actual event is a "right-Plant" event?
686  std::string::size_type loc2 = eventName.find("CBy_", 0);
687  if (loc2 != std::string::npos)
688  {
689  eventName.erase(0, 4);
690  std::string newEvent = toRepl_right+eventName;
691  rResEnv.InsEvent(newEvent);
692  }
693  else
694  {
695  // actual event is a "external interaction" event?
696  std::string::size_type loc3 = eventName.find("CBxy_", 0);
697  if (loc3 != std::string::npos)
698  {
699  eventName.erase(0, 5);
700  std::string newEvent = toRepl_ext+eventName;
701  rResEnv.InsEvent(newEvent);
702  }
703  }
704  }
705  }//*************************** End Adjust Alphabet***************
706 
707  // insert states into result generator
708  for (sit = rHioController.StatesBegin(); sit != rHioController.StatesEnd(); ++sit)
709  {
710  rResEnv.InsMarkedState(ToStringInteger(state));
711  //if actual state also init state then mark it as init state in rResEnv too;
712  if(rHioController.ExistsInitState(state))
713  rResEnv.SetInitState(ToStringInteger(state));
714 
715  state++;
716  } //End Insert States
717 
718 
719  //***************************Adjust Transitions************************
720  // iterate through all states and all transitions. For every trasition check the
721  // event name, and rename it as described in the sequence "Adjust Alphabet"
722  for (sit = rHioController.StatesBegin(); sit != rHioController.StatesEnd(); ++sit)
723  {
724  //iterate through all transitions of the actuall state;
725  for (tit = rHioController.TransRelBegin(*sit); tit != rHioController.TransRelEnd(*sit); ++tit)
726  {
727  std::string eventName = rHioController.EventName(tit->Ev);
728 
729  // actual event is a "left-Plant" event?
730  std::string::size_type loc1 = eventName.find("CBx_", 0);
731  if (loc1 != std::string::npos)
732  {
733  eventName.erase(0, 4);
734  std::string newEvent = toRepl_left+eventName;
735  eventName = newEvent;
736  }
737  else
738  {
739  // actual event is a "right-Plant" event?
740  std::string::size_type loc2 = eventName.find("CBy_", 0);
741  if (loc2 != std::string::npos)
742  {
743  eventName.erase(0, 4);
744  std::string newEvent = toRepl_right+eventName;
745  eventName = newEvent;
746  }
747  else
748  {
749  // actual event is a "external interaction" event?
750  std::string::size_type loc3 = eventName.find("CBxy_", 0);
751  if (loc3 != std::string::npos)
752  {
753  eventName.erase(0, 5);
754  std::string newEvent = toRepl_ext+eventName;
755  eventName = newEvent;
756  }
757  }
758  }
759 
760  // insert transition into result
761  Idx idx_event = rResEnv.EventIndex(eventName);
762  rResEnv.SetTransition(tit->X1, idx_event, tit->X2);
763  } // end for-loop over transition
764  } // end for-loop over states
765 
766  } //End Adjust IOController
767 
768 
769  // RenameHioModule: this function personalises a HioModule by renaming the content
770  // of the single modules member
771  void HioModule::RenameHioModule(const int i)
772  {
773  HioPlant tmpHioPlant;
774  Generator tmpOpConstr, tmpEnvConstr;
775  HioEnvironment tmpHioEnv;
776 
777  //adjust the mPlant member
778  AdjustHioPlant(mPlant, i, tmpHioPlant);
779 
780  //adjust the constraints
781  AdjusTimedGenerator(mOpConstr, i, tmpOpConstr);
782  AdjusTimedGenerator(mEnvConstr, i, tmpEnvConstr);
783 
784  //set the members
785  mPlant = tmpHioPlant;
786  mOpConstr = tmpOpConstr;
787  mEnvConstr = tmpEnvConstr;
788 
789  //adjust the Id
790  mIndex = i;
791 
792  //adjust the name:
793  mName = "CB"+ToStringInteger(i);
794 
795  //check if also an environment is available, if so adjust it too
796  if(mChildren.size() != 0)
797  {
799  mEnvironment = tmpHioEnv;
800  }
801 
802  }// end of RenameHioModule()
803 
804 
805  // chooseSpec: this function searches through an apappropriate folder for available
806  // specifications.
807  std::vector<std::string> HioModule::ChooseSpec(
808  const std::string path)
809  {
810  int capacity = 0;
811  int size;
812  std::string loc_path = "";
813  std::set<std::string> tmpSpecSet;
814  std::vector<std::string> listSpec, pathList;
815  std::list<std::string>::iterator itstr;
816 
817  //check to max capacity
818  size = mChildren.size();
819  std::cout<<"Number of children: "<<size<<std::endl;
820  for(int i=0; i<size; i++)
821  {
822  //The "mType"-array stores at pos 0 the capacity of an plant model
823  capacity = mChildren[i]->TypeHioModule()[0] + capacity;
824  }
825 
826  //prepare the local path to read from
827  std::string cap = "SpecCB";
828  std::vector<std::string> allPath;
829  for (int i=1; i<=capacity;i++)
830  {
831  cap = cap + ToStringInteger(i);
832  loc_path = path+cap+"/";
833  allPath.push_back(loc_path);
834  }
835  //list the available specifications
836  for (int i=0; i<capacity;i++)
837  {
838  // e.g.: resultin string = ../Spec/SpecCB123/
839  loc_path = allPath[i];
840  std::cout<<"Final path: "<<loc_path<<std::endl;
841  //check folder for specification and show them to the user
842  tmpSpecSet = ReadDirectory(loc_path);
843  std::set< std::string >:: iterator fit=tmpSpecSet.begin();
844  for(; fit!=tmpSpecSet.end(); fit++)
845  {
846  listSpec.push_back(*fit);
847  std::string tmpPath;
848  tmpPath = loc_path+*fit+"/";
849  pathList.push_back(tmpPath);
850  }
851  }
852 
853  std::cout<<"There are "<<listSpec.size()<<" spec. available"<<std::endl;
854  size = listSpec.size();
855  for(int i=0; i<size;i++)
856  {
857  std::cout<<"Option: "<<i+1<<":"<<listSpec[i]<<std::endl;
858  }
859  //delete....
860  //int choise=1;
861  //std::cin>>choise;
862 
863  //encode specification type to the user
864  //EncodeType(listSpec[choise-1].c_str());
865 
866  //loc_path = loc_path+listSpec[choise-1]+"/";
867 
868  //loc_path = pathList[choise-1];
869  //ReadHioPlant(loc_path.c_str());
870 
871  //std::cout<<"My type is: "<<mType[0]<<mType[1]<<mType[2]<<mType[3]<<mType[4]<<std::endl;
872 
873  //do this as a final step....
874  //RenameHioModule(mId);
875  return listSpec;
876 
877  }// end of chooseSpec()
878 
879  // function to compute the IOController
881 
882  // FindController: check if an IO-Controller is already available; if case
883  // of a positive result (print the IOController statistics) and inform the
884  // user about the found IO-Controller. The user can decide whether or not
885  // the found IO-Controller will be used, or to compute a new IO-Controller.
886  if(FindController())
887  {
888  HioController tmpHioController;
889  std::string loc_path, choice;
890 
891  loc_path = MyPath()+"ioController.gen";
892  tmpHioController.Read(loc_path.c_str());
893  tmpHioController.SWrite();
894  std::cout<<"Controller found..! Accept(Y)? / New controller(N)?"<<std::endl;
895  std::cin>>choice;
896 
897  if(choice == "y" || choice == "Y")
898  {
899  mController = tmpHioController;
900  return;
901  }
902 
903  }
904  else
905  {
906  std::cout<<"Controller NOT found..!"<<std::endl;
907  }
908  Generator IOShufflemin, IOShuffle;
909  std::cout.flush()<<"Starting IOShuffle...1"<<std::endl;
910  HioShuffle_Musunoi(mChildren[0]->Plant(), mChildren[1]->Plant(), 1, IOShufflemin);
911 
912  std::cout.flush()<<" ...done!"<<std::endl;
913  StateMin(IOShufflemin, IOShuffle);
914 
915  //Start parallel composition with environment and load the local constraints
916  Generator ioShCB12parEnv, locConstr;
917 
918  Parallel(IOShuffle, mEnvironment, ioShCB12parEnv);
919  //remove generator that are not in use anymore
920  IOShuffle.Clear();
921 
922  Generator tmp1, tmp2; // generator for intermediate result
923  Parallel(mChildren[0]->OpConstr(), mChildren[0]->EnvConstr(), tmp1);
924  Parallel(mChildren[1]->OpConstr(), mChildren[1]->EnvConstr(), tmp2);
925  Parallel(tmp1, tmp2, locConstr);
926 
927  //remove generator that are not in use anymore
928  tmp1.Clear();
929  tmp2.Clear();
930 
931 
932  //Start HIO_SYNTHESIS
933 
934  Generator extConstr;
935 
936  //external constraints
937  Parallel(mOpConstr, mEnvConstr, extConstr);
938 
939  std::cout<<"**********************//////\\\\\\*******************"<<std::endl;
940  std::cout<<"Everything went fine so far...startig HIO_SYNTHESIS..."<<std::endl;
941  std::cout<<"**********************\\\\\\//////*******************"<<std::endl;
942 
943  //temp generators and event-sets for intermediate results
944  Generator tmpController, tmpHioGen;
945  EventSet Yp, Up, Yc, Uc, Ye, Ue;
946 
947  Yp = (mChildren[0]->Plant().YpEvents()+mChildren[1]->Plant().YpEvents());
948  Up = (mChildren[0]->Plant().UpEvents()+mChildren[1]->Plant().UpEvents());
949  Yc = (mPlant.YpEvents());
950  Uc = (mPlant.UpEvents());
951  Ye = (mPlant.YeEvents());
952  Ue = (mPlant.UeEvents());
953 
954  tmpHioGen.Assign(mPlant);
955 
956  //start the hio-synthesis
957  HioSynth_Musunoi(ioShCB12parEnv, mPlant, extConstr, locConstr, Yp, Up, tmpController);
958 
959  mController = tmpController;
960 
961 
962  EventSet::Iterator evit;
963  // As the result of the controller synthesis is a genarator, we set the
964  // event properties in order to obtain a HioController
965  for(evit = Yc.Begin(); evit != Yc.End(); ++evit)
966  mController.SetYc(*evit);
967 
968  for(evit = Uc.Begin(); evit != Uc.End(); ++evit)
969  mController.SetUc(*evit);
970 
971  Yp.DWrite();
972  for(evit = Yp.Begin(); evit != Yp.End(); ++evit)
973  mController.SetYp(*evit);
974 
975  for(evit = Up.Begin(); evit != Up.End(); ++evit)
976  mController.SetUp(*evit);
977 
978  std::cout.flush()<<"...Done"<<std::endl;
979 
980  std::string filename = "Controller"+ToStringInteger(mIndex)+".gen";
981  mController.Write(filename.c_str());
982 
983 
984  } //End of Compute();
985 
986 
987  //FindController(): this function searches in the folder of a choosen
988  //specification for an already computed IO-controller which enforces this
989  //specification (sought: "ioController.gen")
991  {
992 
993  //the path where to look up for the sought IO-Controller is based on the
994  //type of the specification
995  std::set<std::string> folderContent;
996  std::string loc_path;
997 
998  //find the local path
999  loc_path = MyPath();
1000  folderContent = ReadDirectory(loc_path);
1001  std::set< std::string >:: iterator fit=folderContent.begin();
1002  for(; fit!=folderContent.end(); fit++)
1003  if (*fit== "ioController.gen")
1004  return true;
1005 
1006  return false;
1007  } //End of FindController()
1008 
1009 
1010  // Save: this function saves the computed controller in the same folder with
1011  // the specification that this controller enforces
1013  {
1014  std::string loc_path;
1015  loc_path = MyPath();
1016  loc_path = loc_path+"ioController.gen";
1017 
1018  mController.Write(loc_path.c_str());
1019  } //End of SaveController()
1020 
1021 
1022  //MyPath: based on the type of the HioModule, this is a convenience function to
1023  // establish the local path where to Write/Read from.
1024  std::string HioModule::MyPath()
1025  {
1026  int capacity = mType[0];
1027  std::vector<std::string> folderContent;
1028  std::string cap, loc_path, sub_folder;
1029 
1030 
1031  for (int i=1; i<=capacity; i++)
1032  {
1033  cap = cap + ToStringInteger(i);
1034  }
1035 
1036  for (int i=0; i<5;i++)
1037  {
1038  sub_folder = sub_folder+ToStringInteger(mType[i]);
1039  }
1040 
1041  //path to search
1042  loc_path = "Data/Spec/SpecCB"+cap+"/"+sub_folder+"/";
1043  return loc_path;
1044  } //end MyPath()
1045 
1046 
1047  /**********************************************
1048  **********************************************
1049  *
1050  * functions to call properties of the HioModule
1051  **********************************************
1052  ***********************************************/
1053 
1054  // function to call the x-Positon of the HioModule
1055  int HioModule::Xpos() const {
1056 
1057  return mXpos;
1058  }
1059 
1060 
1061  // function to call the y-Positon of the HioModule
1062  int HioModule::Ypos() const {
1063 
1064  return mYpos;
1065  }
1066 
1067  // function to call the type of the HioModule
1069 
1070  int* type = new int[5];
1071  for (int i=0; i<=4; i++)
1072  type[i] = mType[i];
1073 
1074  return type;
1075  }
1076 
1077 
1078  // function to encode to Type of the HioModule
1079  void HioModule::EncodeType(const std::string type) {
1080 
1081  std::cout<<"***********Capacity: "<<type.at(0)<<"******"<<std::endl;
1082  std::cout<<"*Take from left: "<<type.at(1)<<"* "<<" *Take from right: "<<type.at(2)<<"*"<<std::endl;
1083  std::cout<<"*Deliver to left: "<<type.at(3)<<"* "<<" *Deliver to right: "<<type.at(4)<<"*"<<std::endl;
1084 
1085  }
1086 
1087  /*******************************************************************************
1088  ***************************END OF IOMODULE CLASS DEFINITION********************
1089  ******************************************************************************/
1090 
1091 
1092  // GroupHioModules: This function groups two or more HioModules to a new HioModule.
1094  const std::vector<HioModule*>& rChildren,
1095  HioModule& rParentModule)
1096  {
1097  int size = rChildren.size();
1098  float Id =0;
1099  for (int i =0; i < size; i++)
1100  {
1101  rParentModule.InsChild(rChildren[i]);
1102  std::cout<<"insert #"<<i<<"- ModuleID: "<<rChildren[i]->Index();
1103  // Id is composed of children Id's
1104  Id = pow(10, size-i-1)*rChildren[i]->Index()+Id;
1105  std::cout<<".."<<Id<<std::endl;
1106  }
1107  std::cout<<"Id set!"<<std::endl;
1108  //read the environment describing the interaction between the grouped components
1109  HioEnvironment HioEnv("Data/envCBxy.gen");
1110 
1111  //set the new Id of the module, and adjust the environment
1112  int intId = int(Id);
1113  rParentModule.Environment(HioEnv);
1114  rParentModule.RenameHioModule(intId);
1115 
1116  }// end of GroupHioModule()
1117 
1118 
1119  //CreateSpec()
1120  void CreateSpec(int mType[5], HioPlant& rHioSpec, Generator& constrP, Generator& constrE)
1121  {
1122 
1123  // initiate several variables; variables to store information about the number
1124  // of the take and deliver actions and last known state.
1125  int loaded, fl, fr, tol, tor, i_lastState, index;
1126  std::string s_lastQy, s_lastQup, s_lastQue, s_lastState, s_lastQy_stby, s_newQy_stby;
1127  std::string s_lastQupFL, s_lastQupFR, s_lastQup2L, s_lastQup2R, s_newQy_FR, s_newQy_FL, s_newQy_2L, s_newQy_2R;
1128 
1129  s_lastQup = s_lastQupFL = s_lastQupFR = s_newQy_stby = "ErrQy";
1130  fl=fr=tol=tor=i_lastState=index=loaded=0;
1131 
1132  //Insert alphabet
1133  rHioSpec.InsYpEvent("CBx_free");
1134  rHioSpec.InsYpEvent("CBx_busy");
1135  rHioSpec.InsUpEvent("CBx_stby");
1136  rHioSpec.InsUpEvent("CBx_FL");
1137  rHioSpec.InsUpEvent("CBx_FR");
1138  rHioSpec.InsUpEvent("CBx_2L");
1139  rHioSpec.InsUpEvent("CBx_2R");
1140  rHioSpec.InsYeEvent("CBx_req_fl");
1141  rHioSpec.InsYeEvent("CBx_req_fr");
1142  rHioSpec.InsYeEvent("CBx_wpar_fl");
1143  rHioSpec.InsYeEvent("CBx_wpar_fr");
1144  rHioSpec.InsYeEvent("CBx_wpar_tl");
1145  rHioSpec.InsYeEvent("CBx_wpar_tr");
1146  rHioSpec.InsUeEvent("CBx_pack");
1147  rHioSpec.InsUeEvent("CBx_nack");
1148 
1149  //Insert error state
1150  rHioSpec.InsMarkedState("ErrQy");
1151 
1152  //1. Create init state and the first transitions; in order to save the last added
1153  // state and/or transition, set the respective variable ("s_lastQup", "i_lastState")
1154  rHioSpec.InsInitState("1");
1155  rHioSpec.SetMarkedState("1");
1156  rHioSpec.InsMarkedState("2");
1157  rHioSpec.SetTransition("1", "CBx_free", "2");
1158  s_lastQup = "2";
1159  rHioSpec.SetTransition("2", "CBx_stby", "1");
1160  i_lastState = 2;
1161 
1162  /*************** Interpretation of mType[] *******
1163  ************* Capacity: mType[0] *********
1164  ************* Take from left: mType[1] *********
1165  ************* Take from right: mType[2] *********
1166  ************* Deliver to left: mType[3] *********
1167  ************* Deliver to left: mType[4] *********
1168  ************************************************/
1169 
1170 
1171  //2. so called "Qy_stby" - states are of states were we decied if an other
1172  // "Take from..." or "Deliver to..." - cycle must be added to the specification.
1173  // This are also states where the specification branch out, so it is important
1174  // to keep this state in order to implement all transitions starting here.
1175 
1176  // "index" - stores the information about the capacity, i.e. how many times we
1177  // need to add the "Take from..." "Deliver from" cycle
1178  for(int i=0; i<mType[0]; i++)
1179  {
1180  s_lastQy_stby = s_newQy_stby;
1181  index++;
1182 
1183  //if no piece loaded yet, deliver actions would lead to an Error state
1184  if(loaded == 0)
1185  {
1186  rHioSpec.SetTransition(s_lastQup, "CBx_2L", "ErrQy");
1187  s_lastQup2L = "ErrQy";
1188  rHioSpec.SetTransition(s_lastQup, "CBx_2R", "ErrQy");
1189  s_lastQup2R = "ErrQy";
1190  }
1191 
1192  // the value of "fl" holds how many "Take from left"-cycles we already implemented
1193  // in the specification. If the fl < requested "Take from left"- operations,
1194  // implement an other one.
1195  if(fl<mType[1])
1196  {
1197  // if index = 1 then we are in the first implementation cycle
1198  // so need to insert a new state. (in the next cycles, this
1199  // state will have be already inserted -> see "else" statement)
1200  if(!(index > 1))
1201  {
1202  s_lastState = ToStringInteger(i_lastState+1);
1203  rHioSpec.InsMarkedState(s_lastState);
1204  }
1205  else
1206  {
1207  // hold that the last inserted state is "Qy"-state that
1208  // we arrive through a "Take from" - transition
1209  s_lastState = s_newQy_FL;
1210  }
1211 
1212  //insert the corresponding "Take from" - transition
1213  rHioSpec.SetTransition(s_lastQup, "CBx_FL", s_lastState);
1214  s_lastQy = s_lastState;
1215  i_lastState++;
1216 
1217  //insert the corresponding "request from" - transition;
1218  //therefor we first need to insert a new state
1219  s_lastState = ToStringInteger(i_lastState+1);
1220  rHioSpec.InsMarkedState(s_lastState);
1221  rHioSpec.SetTransition(s_lastQy, "CBx_req_fl", s_lastState);
1222  s_lastQue = s_lastState;
1223  i_lastState++;
1224 
1225  //insert the corresponding "acknowledge" - transition
1226  //therefor we first need to insert a new state
1227  s_lastState = ToStringInteger(i_lastState+1);
1228  rHioSpec.InsMarkedState(s_lastState);
1229  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_lastState);
1230  s_lastQy = s_lastState;
1231  i_lastState++;
1232 
1233  //Ue must be free -> insert transition to error-state
1234  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1235 
1236  //insert the corresponding "busy" - transition
1237  //therefor we first need to insert a new state
1238  s_lastState = ToStringInteger(i_lastState+1);
1239  rHioSpec.InsMarkedState(s_lastState);
1240  rHioSpec.SetTransition(s_lastQy, "CBx_busy", s_lastState);
1241  s_lastQupFL = s_lastState;
1242  i_lastState++;
1243 
1244  //update the status of the loaded number of pieces
1245  loaded = index;
1246  //update the number of implemented "Take from Left" - cycles
1247  fl++;
1248 
1249  }
1250  //Up must be free -> insert transition to error-state;
1251  else
1252  {
1253  rHioSpec.SetTransition(s_lastQup, "CBx_FL", "ErrQy");
1254  s_lastQupFL = "ErrQy";
1255  }
1256 
1257 
1258  //as "Take from left" or "Take from right" are simetrical, the implementation
1259  //is also the same as above
1260  // the value of "fr" holds how many "Take from right"-cycles we already implemented
1261  // in the specification. If the fr < requested "Take from right"- operations,
1262  // implement an other one.
1263  if(fr<mType[2])
1264  {
1265  // if index = 1 then we are in the first implementation cycle
1266  // so need to insert a new state. (in the next cycles, this
1267  // state will have be already inserted -> see "else" statement)
1268  if(!(index > 1))
1269  {
1270  s_lastState = ToStringInteger(i_lastState+1);
1271  rHioSpec.InsMarkedState(s_lastState);
1272  }
1273  else
1274  {
1275  // hold that the last inserted state is "Qy"-state that
1276  // we arrive through a "Take from" - transition
1277  s_lastState = s_newQy_FR;
1278  }
1279 
1280  //insert the corresponding "Take from" - transition
1281  rHioSpec.SetTransition(s_lastQup, "CBx_FR", s_lastState);
1282  s_lastQy = s_lastState;
1283  i_lastState++;
1284 
1285  //insert the corresponding "request from" - transition;
1286  //therefor we first need to insert a new state
1287  s_lastState = ToStringInteger(i_lastState+1);
1288  rHioSpec.InsMarkedState(s_lastState);
1289  rHioSpec.SetTransition(s_lastQy, "CBx_req_fr", s_lastState);
1290  s_lastQue = s_lastState;
1291  i_lastState++;
1292 
1293  //insert the corresponding "acknowledge" - transition
1294  //therefor we first need to insert a new state
1295  s_lastState = ToStringInteger(i_lastState+1);
1296  rHioSpec.InsMarkedState(s_lastState);
1297  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_lastState);
1298  s_lastQy = s_lastState;
1299  i_lastState++;
1300 
1301  //Ue must be free -> insert transition to error-state
1302  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1303 
1304  //insert the corresponding "busy" - transition
1305  //therefor we first need to insert a new state
1306  s_lastState = ToStringInteger(i_lastState+1);
1307  rHioSpec.InsMarkedState(s_lastState);
1308  rHioSpec.SetTransition(s_lastQy, "CBx_busy", s_lastState);
1309  s_lastQupFR = s_lastState;
1310  i_lastState++;
1311 
1312  //update the status of the loaded number of pieces
1313  loaded = index;
1314  //update the number of implemented "Take from Right" - cycles
1315  fr++;
1316  }
1317  //Up must be free -> insert transition to error-state;
1318  else
1319  {
1320  rHioSpec.SetTransition(s_lastQup, "CBx_FR", "ErrQy");
1321  s_lastQupFR = "ErrQy";
1322  }
1323 
1324  // as far as the last QupFL or QupFR did not lead to an error state (i.e. the
1325  // requested number of "Take from..." achieved) insert a new stbyState in order
1326  // to start the new cycle of "Take from..."
1327  if((s_lastQupFL != "ErrQy") ||(s_lastQupFR != "ErrQy"))
1328  {
1329  s_lastState = ToStringInteger(i_lastState+1);
1330  rHioSpec.InsMarkedState(s_lastState);
1331  s_newQy_stby = s_lastState;
1332  i_lastState++;
1333 
1334  }
1335 
1336  //here is the standby case handeled, if before a "Take from left" - command occured
1337  if(s_lastQupFL != "ErrQy")
1338  {
1339  // insert the stby transition
1340  s_lastState = ToStringInteger(i_lastState+1);
1341  rHioSpec.InsMarkedState(s_lastState);
1342  rHioSpec.SetTransition(s_lastQupFL, "CBx_stby", s_lastState);
1343  s_lastQy = s_lastState;
1344  i_lastState++;
1345 
1346  // insert the corresponding environment transition
1347  s_lastState = ToStringInteger(i_lastState+1);
1348  rHioSpec.InsMarkedState(s_lastState);
1349  rHioSpec.SetTransition(s_lastQy, "CBx_wpar_fl", s_lastState);
1350  s_lastQue = s_lastState;
1351  i_lastState++;
1352 
1353  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_newQy_stby);
1354  //Ue must be free -> insert transition to error-state
1355  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1356 
1357  }
1358 
1359  //here is the standby case handeled, if before a "Take from right" - command occured
1360  if(s_lastQupFR != "ErrQy")
1361  {
1362  // insert the stby transition
1363  s_lastState = ToStringInteger(i_lastState+1);
1364  rHioSpec.InsMarkedState(s_lastState);
1365  rHioSpec.SetTransition(s_lastQupFR, "CBx_stby", s_lastState);
1366  s_lastQy = s_lastState;
1367  i_lastState++;
1368 
1369  // insert the corresponding environment transition
1370  s_lastState = ToStringInteger(i_lastState+1);
1371  rHioSpec.InsMarkedState(s_lastState);
1372  rHioSpec.SetTransition(s_lastQy, "CBx_wpar_fr", s_lastState);
1373  s_lastQue = s_lastState;
1374  i_lastState++;
1375 
1376  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_newQy_stby);
1377  //Ue must be free -> insert transition to error-state
1378  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1379  }
1380 
1381  //setup the stanby-loop
1382  if((s_lastQupFL != "ErrQy") ||(s_lastQupFR != "ErrQy"))
1383  {
1384  s_lastState = ToStringInteger(i_lastState+1);
1385  rHioSpec.InsMarkedState(s_lastState);
1386  rHioSpec.SetTransition(s_newQy_stby, "CBx_busy", s_lastState);
1387  s_lastQup = s_lastState;
1388  i_lastState++;
1389  rHioSpec.SetTransition(s_lastState, "CBx_stby", s_newQy_stby);
1390  }
1391 
1392 
1393 
1394  //insert shared 2L-state if the number of "Deliver to Left" transitions is not
1395  //already acheived. By shared we mean the "Deliver to Left" transition
1396  //starting from the stby state, where no communication with the environment occurs
1397  if(tol<mType[3])
1398  {
1399  s_lastState = ToStringInteger(i_lastState+1);
1400  rHioSpec.InsMarkedState(s_lastState);
1401  s_newQy_2L = s_lastState;
1402  i_lastState++;
1403  }
1404  else tol++;
1405 
1406  //insert 'shared' 2R-state if the number of "Deliver to Right" transitions is not
1407  //already acheived; By shared we mean the "Deliver to Right" transition
1408  //starting from the stby state, where no communication with the environment occurs;
1409  if(tor<mType[4])
1410  {
1411  s_lastState = ToStringInteger(i_lastState+1);
1412  rHioSpec.InsMarkedState(s_lastState);
1413  s_newQy_2R = s_lastState;
1414  i_lastState++;
1415  }
1416  else tor++;
1417 
1418  // if at least one piece is available (fl or fr != 0) continue with the
1419  // implementation of the 2L action
1420  if(tol<mType[3] && (fl !=0 ||fr !=0))
1421  {
1422  // if the last FL led to an Error State, then don't implement
1423  // the "Deliver to..." action (as this would start from an
1424  // Error State - ErrQy)
1425  if(s_lastQupFL != "ErrQy")
1426  {
1427  //insert the corresponding "Deliver to..." - transition
1428  s_lastState = ToStringInteger(i_lastState+1);
1429  rHioSpec.InsMarkedState(s_lastState);
1430  rHioSpec.SetTransition(s_lastQupFL, "CBx_2L", s_lastState);
1431  s_lastQy = s_lastState;
1432  i_lastState++;
1433 
1434  //insert the corresponding "request to..." - transition
1435  s_lastState = ToStringInteger(i_lastState+1);
1436  rHioSpec.InsMarkedState(s_lastState);
1437  rHioSpec.SetTransition(s_lastQy, "CBx_wpar_fl", s_lastState);
1438  s_lastQue = s_lastState;
1439  i_lastState++;
1440 
1441  //Enivronment acknowledge
1442  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_newQy_2L);
1443  //Ue must be free -> insert transition to error-state
1444  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1445  }
1446 
1447  // if the last FR led to an Error State, then don't implement
1448  // the "Deliver to..." action (as this would start from an
1449  // Error State - ErrQy)
1450  if(s_lastQupFR != "ErrQy")
1451  {
1452  //insert the corresponding "Deliver to..." - transition
1453  s_lastState = ToStringInteger(i_lastState+1);
1454  rHioSpec.InsMarkedState(s_lastState);
1455  rHioSpec.SetTransition(s_lastQupFR, "CBx_2L", s_lastState);
1456  s_lastQy = s_lastState;
1457  i_lastState++;
1458 
1459  //insert the corresponding "request to..." - transition
1460  s_lastState = ToStringInteger(i_lastState+1);
1461  rHioSpec.InsMarkedState(s_lastState);
1462  rHioSpec.SetTransition(s_lastQy, "CBx_wpar_fr", s_lastState);
1463  s_lastQue = s_lastState;
1464  i_lastState++;
1465 
1466  //Enivronment acknowledge
1467  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_newQy_2L);
1468  //Ue must be free -> insert transition to error-state
1469  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1470 
1471 
1472  }
1473  // Both deliver actions (2L, 2R) contiue on
1474  // the same path
1475  // Environment receieved the piece
1476  s_lastState = ToStringInteger(i_lastState+1);
1477  rHioSpec.InsMarkedState(s_lastState);
1478  rHioSpec.SetTransition(s_newQy_2L, "CBx_wpar_tl", s_lastState);
1479  s_lastQue = s_lastState;
1480  i_lastState++;
1481 
1482  if(loaded ==1)
1483  {
1484  //up to here only one piece loaded -> go back to init state
1485  rHioSpec.SetTransition(s_lastQue, "CBx_pack", "1");
1486  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1487  }
1488  else
1489  {
1490  //if more then one piece loaded go to the last stby state
1491  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_lastQy_stby);
1492  //Ue must be free -> insert transition to error-state
1493  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1494  }
1495 
1496  //increase number of delivered pieces
1497  tol++;
1498 
1499  }
1500 
1501  // Uc must be free: if last Qup was an Error state, still insert the "Deliver to..."
1502  // action leading also to an Error state
1503  else
1504  {
1505  if(s_lastQupFL != "ErrQy")
1506  {
1507  rHioSpec.SetTransition(s_lastQupFL, "CBx_2L", "ErrQy");
1508  }
1509  if(s_lastQupFR != "ErrQy")
1510  {
1511  rHioSpec.SetTransition(s_lastQupFR, "CBx_2L", "ErrQy");
1512  }
1513  }
1514 
1515  // if at least one piece is available (fl or fr != 0) continue with the
1516  // implementation of the 2R action
1517  if(tor<mType[4] && (fl !=0 ||fr !=0))
1518  {
1519  // if the last FL led to an Error State, then don't implement
1520  // the "Deliver to..." action (as this would start from an
1521  // Error State - ErrQy)
1522  if(s_lastQupFL != "ErrQy")
1523  {
1524  //insert the corresponding "Deliver to..." - transition
1525  s_lastState = ToStringInteger(i_lastState+1);
1526  rHioSpec.InsMarkedState(s_lastState);
1527  rHioSpec.SetTransition(s_lastQupFL, "CBx_2R", s_lastState);
1528  s_lastQy = s_lastState;
1529  i_lastState++;
1530 
1531  //insert the corresponding "request to..." - transition
1532  s_lastState = ToStringInteger(i_lastState+1);
1533  rHioSpec.InsMarkedState(s_lastState);
1534  rHioSpec.SetTransition(s_lastQy, "CBx_wpar_fl", s_lastState);
1535  s_lastQue = s_lastState;
1536  i_lastState++;
1537 
1538  //Enivronment acknowledge
1539  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_newQy_2R);
1540  //Ue must be free -> insert transition to error-state
1541  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1542 
1543  }
1544 
1545  // if the last FR led to an Error State, then don't implement
1546  // the "Deliver to..." action (as this would start from an
1547  // Error State - ErrQy)
1548  if(s_lastQupFR != "ErrQy")
1549  {
1550  //insert the corresponding "Deliver to..." - transition
1551  s_lastState = ToStringInteger(i_lastState+1);
1552  rHioSpec.InsMarkedState(s_lastState);
1553  rHioSpec.SetTransition(s_lastQupFR, "CBx_2R", s_lastState);
1554  s_lastQy = s_lastState;
1555  i_lastState++;
1556 
1557  //insert the corresponding "request to..." - transition
1558  s_lastState = ToStringInteger(i_lastState+1);
1559  rHioSpec.InsMarkedState(s_lastState);
1560  rHioSpec.SetTransition(s_lastQy, "CBx_wpar_fr", s_lastState);
1561  s_lastQue = s_lastState;
1562  i_lastState++;
1563 
1564  //Enivronment acknowledge
1565  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_newQy_2R);
1566  //Ue must be free -> insert transition to error-state
1567  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1568 
1569  }
1570  // Both deliver actions (2L, 2R) contiue on
1571  // the same path
1572  // Environment receieved the piece
1573  s_lastState = ToStringInteger(i_lastState+1);
1574  rHioSpec.InsMarkedState(s_lastState);
1575  rHioSpec.SetTransition(s_newQy_2R, "CBx_wpar_tr", s_lastState);
1576  s_lastQue = s_lastState;
1577  i_lastState++;
1578 
1579  if(loaded ==1)
1580  {
1581  //up to here only one piece loaded -> go back to init state
1582  rHioSpec.SetTransition(s_lastQue, "CBx_pack", "1");
1583  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1584  }
1585  //if more then one piece loaded go to the last stby state
1586  else
1587  {
1588  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_lastQy_stby);
1589  //Ue must be free -> insert transition to error-state
1590  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1591  }
1592 
1593  // increase number of delivered pieces
1594  tor++;
1595 
1596  }
1597  // Uc must be free: if last Qup was an Error state, still insert the "Deliver to..."
1598  // action leading also to an Error state
1599  else
1600  {
1601 
1602  if(s_lastQupFL != "ErrQy")
1603  {
1604  rHioSpec.SetTransition(s_lastQupFL, "CBx_2R", "ErrQy");
1605  }
1606  if(s_lastQupFR != "ErrQy")
1607  {
1608  rHioSpec.SetTransition(s_lastQupFR, "CBx_2R", "ErrQy");
1609  }
1610  }
1611 
1612  //insert the next FL action after an FL or FR action already occured;
1613  if(fl<mType[1])
1614  {
1615  s_lastState = ToStringInteger(i_lastState+1);
1616  rHioSpec.InsMarkedState(s_lastState);
1617  s_newQy_FL = s_lastState;
1618  i_lastState++;
1619  }
1620 
1621  //insert the next FL action after an FL or FR action already occured;
1622  if(fr<mType[2])
1623  {
1624  s_lastState = ToStringInteger(i_lastState+1);
1625  rHioSpec.InsMarkedState(s_lastState);
1626  s_newQy_FR = s_lastState;
1627  i_lastState++;
1628  }
1629 
1630  // if last action was a FL, implement the corresponding environment events (wpar_fl)
1631  // before continue with the next take from action
1632  if((s_lastQupFL != "ErrQy") && fl <mType[1])
1633 
1634  {
1635  //insert the "Take from..." transition
1636  s_lastState = ToStringInteger(i_lastState+1);
1637  rHioSpec.InsMarkedState(s_lastState);
1638  rHioSpec.SetTransition(s_lastQupFL, "CBx_FL", s_lastState);
1639  s_lastQy = s_lastState;
1640  i_lastState++;
1641 
1642  //insert the environment transition
1643  s_lastState = ToStringInteger(i_lastState+1);
1644  rHioSpec.InsMarkedState(s_lastState);
1645  rHioSpec.SetTransition(s_lastQy, "CBx_wpar_fl", s_lastState);
1646  s_lastQue = s_lastState;
1647  i_lastState++;
1648 
1649  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_newQy_FL);
1650  //Ue must be free -> insert transition to error-state
1651  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1652 
1653  }
1654  //Up must be free -> insert transition to error-state;
1655  else
1656  if(fl<mType[1])
1657  {
1658  rHioSpec.SetTransition(s_lastQupFL, "CBx_FL", "ErrQy");
1659  }
1660  // if last action was a FL, implement the corresponding environment events (wpar_fl)
1661  // before continue with the next take from action
1662  if((s_lastQupFL != "ErrQy") && fr <mType[2])
1663 
1664  {
1665  //insert the "Take from..." transition
1666  s_lastState = ToStringInteger(i_lastState+1);
1667  rHioSpec.InsMarkedState(s_lastState);
1668  rHioSpec.SetTransition(s_lastQupFL, "CBx_FR", s_lastState);
1669  s_lastQy = s_lastState;
1670  i_lastState++;
1671 
1672  //insert the environment transition
1673  s_lastState = ToStringInteger(i_lastState+1);
1674  rHioSpec.InsMarkedState(s_lastState);
1675  rHioSpec.SetTransition(s_lastQy, "CBx_wpar_fl", s_lastState);
1676  s_lastQue = s_lastState;
1677  i_lastState++;
1678 
1679  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_newQy_FR);
1680  //Ue must be free -> insert transition to error-state
1681  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1682 
1683  }
1684  //Up must be free -> insert transition to error-state;
1685  else
1686  if(fl<mType[1])
1687  {
1688  rHioSpec.SetTransition(s_lastQupFL, "CBx_FR", "ErrQy");
1689  }
1690 
1691 
1692  // if last action was a FR, implement the corresponding environment events (wpar_fl)
1693  // before continue with the next take from action
1694  if((s_lastQupFR != "ErrQy") && fl <mType[1])
1695 
1696  {
1697  //insert the "Take from..." transition
1698  s_lastState = ToStringInteger(i_lastState+1);
1699  rHioSpec.InsMarkedState(s_lastState);
1700  rHioSpec.SetTransition(s_lastQupFR, "CBx_FL", s_lastState);
1701  s_lastQy = s_lastState;
1702  i_lastState++;
1703 
1704  //insert the environment transition
1705  s_lastState = ToStringInteger(i_lastState+1);
1706  rHioSpec.InsMarkedState(s_lastState);
1707  rHioSpec.SetTransition(s_lastQy, "CBx_wpar_fr", s_lastState);
1708  s_lastQue = s_lastState;
1709  i_lastState++;
1710 
1711  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_newQy_FL);
1712  //Ue must be free -> insert transition to error-state
1713  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1714 
1715  }
1716  //Up must be free -> insert transition to error-state;
1717  else
1718  if (fr<mType[2])
1719  {
1720  rHioSpec.SetTransition(s_lastQupFR, "CBx_FL", "ErrQy");
1721  }
1722 
1723  // if last action was a FR, implement the corresponding environment events (wpar_fl)
1724  // before continue with the next take from action
1725  if((s_lastQupFR != "ErrQy") && fr <mType[2])
1726 
1727  {
1728  //insert the "Take from..." transition
1729  s_lastState = ToStringInteger(i_lastState+1);
1730  rHioSpec.InsMarkedState(s_lastState);
1731  rHioSpec.SetTransition(s_lastQupFR, "CBx_FR", s_lastState);
1732  s_lastQy = s_lastState;
1733  i_lastState++;
1734 
1735  //insert the environment transition
1736  s_lastState = ToStringInteger(i_lastState+1);
1737  rHioSpec.InsMarkedState(s_lastState);
1738  rHioSpec.SetTransition(s_lastQy, "CBx_wpar_fr", s_lastState);
1739  s_lastQue = s_lastState;
1740  i_lastState++;
1741 
1742  rHioSpec.SetTransition(s_lastQue, "CBx_pack", s_newQy_FR);
1743  //Ue must be free -> insert transition to error-state
1744  rHioSpec.SetTransition(s_lastQue, "CBx_nack", "ErrQy");
1745  }
1746  //Up must be free -> insert transition to error-state;
1747  else
1748  if (fr<mType[2])
1749  {
1750  rHioSpec.SetTransition(s_lastQupFR, "CBx_FR", "ErrQy");
1751  }
1752 
1753 
1754 
1755  // insert the remaining "Deliver to..." transition;
1756  if(tol <= mType[3])
1757  rHioSpec.SetTransition(s_lastQup, "CBx_2L", s_newQy_2L);
1758  else
1759  // Up must be free -> insert transition to error-state;
1760  rHioSpec.SetTransition(s_lastQup, "CBx_2L", "ErrQy");
1761 
1762  // insert the remaining "Deliver to..." transition;
1763  if(tor <= mType[4])
1764  rHioSpec.SetTransition(s_lastQup, "CBx_2R", s_newQy_2R);
1765  else
1766  // Up must be free -> insert transition to error-state;
1767  rHioSpec.SetTransition(s_lastQup, "CBx_2R", "ErrQy");
1768 
1769  // finaly, if the numer of maximal capacity is achieved, insert remaining transition
1770  // in order to ensure the I/O plant format of the specification;
1771  if(index == mType[0])
1772  {
1773  if(s_lastQup != "ErrQy")
1774  {
1775  rHioSpec.SetTransition(s_lastQup, "CBx_FR", "ErrQy");
1776  rHioSpec.SetTransition(s_lastQup, "CBx_FL", "ErrQy");
1777  }
1778 
1779  if(s_lastQupFL != "ErrQy")
1780  {
1781  rHioSpec.SetTransition(s_lastQupFL, "CBx_FL", "ErrQy");
1782  rHioSpec.SetTransition(s_lastQupFL, "CBx_FR", "ErrQy");
1783  }
1784 
1785  if(s_lastQupFR != "ErrQy")
1786  {
1787  rHioSpec.SetTransition(s_lastQupFR, "CBx_FR", "ErrQy");
1788  rHioSpec.SetTransition(s_lastQupFR, "CBx_FL", "ErrQy");
1789  }
1790 
1791  rHioSpec.SWrite();
1792 
1793  // for the creaded specification create now also the constraints which describe
1794  // the condition of completeness and Yp-liveness
1795  CreateConstraint(mType, constrP, constrE);
1796 
1797  }// end if
1798 
1799  }// end for-loop: see comment at begin of the (main)loop ->
1800  // "index" - stores the information about the capacity, i.e. how many
1801  // times we need to add the "Take from..." "Deliver from" cycle
1802 
1803  }// end createSpec()
1804 
1805 
1806  // This function creates constraints which describe the condition of completeness
1807  // and Yp-liveness of a Specification. The implementation follows the same algorithm
1808  // as the CreateSpec() function, and has the same limitation: it is only for use
1809  // with a specific model
1810  void CreateConstraint(int mType[5], Generator& constrP, Generator& constrE)
1811  {
1812 
1813  int i_lastState, fl, fr, tol, tor;
1814  i_lastState = fl = fr = tol = tor = 0;
1815 
1816  std::string s_lastState, s_lastQup, s_lastQy, s_newQy, s_return;
1817  s_lastState = s_lastQup = s_lastQy = s_newQy = s_return = "";
1818 
1819  // the environment constraint constrE: this is an automata with one state,
1820  // one event and no transitions
1821  constrE.InsEvent("CBx_nack");
1822  constrE.InsInitState("1");
1823  constrE.SetMarkedState("1");
1824 
1825  // the operator constraint constrP
1826  constrP.InsEvent("CBx_free");
1827  constrP.InsEvent("CBx_busy");
1828  constrP.InsEvent("CBx_stby");
1829  constrP.InsEvent("CBx_FL");
1830  constrP.InsEvent("CBx_FR");
1831  constrP.InsEvent("CBx_2L");
1832  constrP.InsEvent("CBx_2R");
1833 
1834  // insert the states and transitions that are independent of the type of the
1835  // constraint
1836  constrP.InsInitState("1");
1837  constrP.SetMarkedState("1");
1838  s_return = "1";
1839  s_lastQy = "1";
1840  constrP.InsMarkedState("2");
1841  constrP.SetTransition("1", "CBx_free", "2");
1842  constrP.SetTransition("1", "CBx_busy", "2");
1843  i_lastState = 2;
1844  s_lastQup = "2";
1845 
1846  // start the main loop
1847  for (int i=0; i<mType[0]; i++)
1848  {
1849 
1850  //insert shared state Qy
1851  if(fl<mType[1] || fr<mType[2])
1852  {
1853  s_lastState = ToStringInteger(i_lastState+1);
1854  constrP.InsMarkedState(s_lastState);
1855  s_newQy = s_lastState;
1856  constrP.SetTransition(s_lastQup, "CBx_stby", s_lastQy);
1857  i_lastState++;
1858 
1859  }
1860  // insert "Take from left" transition if number of needed transitions not
1861  // already achieved
1862  if(fl<mType[1])
1863  {
1864  constrP.SetTransition(s_lastQup, "CBx_FL", s_newQy);
1865  fl++;
1866  }
1867 
1868  // insert "Take from right" transition if number of needed transitions not
1869  // already achieved
1870  if(fr<mType[2])
1871  {
1872  constrP.SetTransition(s_lastQup, "CBx_FR", s_newQy);
1873  fr++;
1874  }
1875  // i>0 only after we implemented at least one "Take from..." action; if i==0
1876  // "Deliver to..." action will be not implemented, as a deliver action is not
1877  // possible yet
1878  if(i>0)
1879  {
1880  //insert 2L-Trans
1881  if(tol<mType[3])
1882  {
1883  // insert corresponding "Deliver to..." transition
1884  // and increase the number of implemented "Deliver
1885  // to..." transitions
1886  constrP.SetTransition(s_lastQup, "CBx_2L", s_return);
1887  tol++;
1888  }
1889 
1890  //insert 2R-Trans
1891  if(tor<mType[4])
1892  {
1893  // insert corresponding "Deliver to..." transition
1894  // and increase the number of implemented "Deliver
1895  // to..." transitions
1896  constrP.SetTransition(s_lastQup, "CBx_2R", s_return);
1897  tor++;
1898  }
1899 
1900  // store the last state
1901  s_return = s_lastQy;
1902  }
1903 
1904  // implement stby loop
1905  s_lastState = ToStringInteger(i_lastState+1);
1906  constrP.InsMarkedState(s_lastState);
1907  constrP.SetTransition(s_newQy, "CBx_free", s_lastState);
1908  constrP.SetTransition(s_newQy, "CBx_busy", s_lastState);
1909  constrP.SetTransition(s_lastState, "CBx_stby", s_newQy);
1910  s_lastQup = s_lastState;
1911  i_lastState++;
1912 
1913  // as i starts at 0, check if the limit is achieved and implemet the remaining
1914  // "Deliver to..." transitions
1915  if(i+1 == mType[0])
1916  {
1917  if(tol<mType[3])
1918  {
1919  constrP.SetTransition(s_lastQup, "CBx_2L", s_return);
1920  tol++;
1921  }
1922 
1923  if(tor<mType[4])
1924  {
1925  constrP.SetTransition(s_lastQup, "CBx_2R", s_return);
1926  tor++;
1927  }
1928  }
1929  // store the last state
1930  s_lastQy = s_newQy;
1931 
1932  }//end for-loop - see comment at begin of the loop ->
1933  // "index" - stores the information about the capacity, i.e. how many
1934  // times we need to add the "Take from..." "Deliver from" cycle
1935 
1936 
1937  }// End create Constraint
1938 
1939 } // end namespace faudes*******end namespace faudes********end namespace faudes
1940 
1941 /********************************END*******************************************/
Recurring structure in hierarchies designed according to the I/O based DES framework.
Definition: hio_module.h:41
std::string Name() const
Return name of HioModule.
Definition: hio_module.cpp:51
void AdjusTimedGenerator(const Generator &rOldGen, const int i, Generator &rResGen)
This function converts a generator by renaming all events from "CBx_..." to "CBi_....
Definition: hio_module.cpp:220
std::vector< HioModule * > Children() const
Return Children of HioModule.
Definition: hio_module.cpp:106
int Xpos() const
function to call the x-Position of the HioModule
void OpConstr(const HioConstraint &rOpConstr)
Set Operator-Constraint of HioModule.
Definition: hio_module.cpp:71
void TypeHioModule(int type[5])
This is a function to set the type of the HioModule; by type we mean an array of length 5 where each ...
Definition: hio_module.cpp:148
void EncodeType(const std::string type)
function to encode to Type of the HioModule (function has only an informational character).
HioModule(void)
constructor
Definition: hio_module.cpp:16
HioController Controller() const
Return HioController of HioModule.
Definition: hio_module.cpp:96
void ReadHioPlant(const std::string path)
This function reads the model from the given library and sets the following private variables of the ...
Definition: hio_module.cpp:158
int Ypos() const
function to call the y-Position of the HioModule
void Index(const Idx Index)
Set index of HioModule.
Definition: hio_module.cpp:66
void Environment(const HioEnvironment &rHioEnvironment)
Set HioEnvironment of HioModule.
Definition: hio_module.cpp:111
void ReadHioEnv(const std::string path)
This function reads the model describing the interaction of IO-Plants with the environment and sets t...
Definition: hio_module.cpp:210
HioEnvironment Environment() const
Return HioEnvironment of HioModule.
Definition: hio_module.cpp:116
void EnvConstr(const HioConstraint &rEnvConstr)
Set Environment-Constraint of HioModule.
Definition: hio_module.cpp:121
void Name(const std::string &rName)
Set name of HioModule.
Definition: hio_module.cpp:56
HioPlant Plant() const
Return HioPlant of HioModule.
Definition: hio_module.cpp:86
void AdjustAlphabet(const EventSet &rOldAlph, const int i, EventSet &rResAlph)
This function converts an alphabet by renaming all events from "CBx_..." to "CBi_....
Definition: hio_module.cpp:374
void AdjustHioPlant(const HioPlant &rOldHioPlant, const int i, HioPlant &rResult)
AdjustHioPlant(): convenience function (derived from AdjusTimedGenerator())to allow also the conversi...
Definition: hio_module.cpp:288
HioConstraint OpConstr() const
Return Operator-Constraint of HioModule.
Definition: hio_module.cpp:76
std::string mName
Definition: hio_module.h:497
bool FindController()
FindController(): this function searches in the folder of a chosen specification for an already compu...
Definition: hio_module.cpp:990
HioEnvironment mEnvironment
Definition: hio_module.h:515
HioConstraint mOpConstr
Definition: hio_module.h:503
HioConstraint EnvConstr() const
Return Environment-Constraint of HioModule.
Definition: hio_module.cpp:127
HioController mController
Definition: hio_module.h:509
std::vector< std::string > ChooseSpec(const std::string path)
chooseSpec: this function searches through an appropriate folder (based on the maximal capacity resul...
Definition: hio_module.cpp:807
HioConstraint mEnvConstr
Definition: hio_module.h:518
int * TypeHioModule() const
function to call the Type of the HioModule
void Position(const int Xpos, const int Ypos)
This is a function to set the x and y position of the HioModule.
Definition: hio_module.cpp:141
void SaveController()
Save: this function saves the computed controller in the same folder with the specification that this...
std::string MyPath()
MyPath(): based on the type of the HioModule, this is a convenience function to establish the local p...
void RenameHioModule(const int i)
this function renames all relevant member of the HioModule.
Definition: hio_module.cpp:771
void Clear()
Clear all members of the HioModule.
Definition: hio_module.cpp:35
void InsChild(HioModule *rChild)
Insert HioModule to list of children.
Definition: hio_module.cpp:132
std::vector< HioModule * > mChildren
Definition: hio_module.h:512
void AdjustHioEnvironment(const HioEnvironment &rHioEnvX, const HioModule *rHioModule1, const HioModule *rHioModule2, HioEnvironment &rResEnv)
AdjustEnvironment(): In order to describe the interaction between two IO-Plants we use the IO-Environ...
Definition: hio_module.cpp:413
void Plant(const HioPlant &rHioPlant)
Set HioPlant of HioModule.
Definition: hio_module.cpp:81
Idx Index() const
Return index of HioModule.
Definition: hio_module.cpp:61
void Compute()
Compute: this function prepares the data required for HioSynth() function.
Definition: hio_module.cpp:880
void Controller(const HioController &rHioController)
Set HioController of HioModule.
Definition: hio_module.cpp:91
Set of indices with symbolic names.
Definition: cfl_nameset.h:69
void SymbolicName(Idx index, const std::string &rName)
Set new name for existing index.
bool Insert(const Idx &rIndex)
Add an element by index.
void SetYp(Idx index)
Mark event as Yp-event (by index)
void SetYc(Idx index)
Mark event as Yc-event (by index)
void SetUc(Idx index)
Mark event as Uc-event (by index)
void SetUp(Idx index)
Mark event Up-event(by index)
void InsYeEvent(Idx index)
Add an existing Ye-event to generator.
void InsUeEvent(Idx index)
Add an existing Ue-event to generator.
void InsUlEvent(Idx index)
Add an existing Ul-event to generator.
bool IsYe(Idx index) const
Is event Ye-event(by index)
bool IsYl(Idx index) const
Is event Yl-event (by index)
void InsYlEvent(Idx index)
Add an existing Yl-event to generator.
EventSet UeEvents(void) const
Get EventSet with Ue-events.
Definition: hio_plant.h:1252
void InsYpEvent(Idx index)
Add an existing Yp-event to generator.
Definition: hio_plant.h:997
void InsUeEvent(Idx index)
Add an existing Ue-event to generator.
Definition: hio_plant.h:1149
EventSet UpEvents(void) const
Get EventSet with Up-events.
Definition: hio_plant.h:1118
void InsUpEvent(Idx index)
Add an existing Up-event to generator.
Definition: hio_plant.h:1015
void InsYeEvent(Idx index)
Add an existing Ye-event to generator.
Definition: hio_plant.h:1131
EventSet YpEvents(void) const
Get EventSet with Yp-events.
Definition: hio_plant.h:1107
EventSet YeEvents(void) const
Get EventSet with Ye-events.
Definition: hio_plant.h:1241
TBaseSet< Transition, TransSort::X1EvX2 >::Iterator Iterator
Iterator on transition.
Definition: cfl_transset.h:269
virtual void Clear(void)
Clear generator data.
bool InsEvent(Idx index)
Add an existing event to alphabet by index.
const TaEventSet< EventAttr > & Alphabet(void) const
Return const reference to alphabet.
bool SetTransition(Idx x1, Idx ev, Idx x2)
Add a transition to generator by indices.
A TokenReader reads sequential tokens from a file or string.
std::string ReadString(void)
Read string token.
void ReadBegin(const std::string &rLabel)
Open a section by specified label.
bool Peek(Token &token)
Peek next token.
Tokens model atomic data for stream IO.
Definition: cfl_token.h:53
@ End
<\label> (end of section)
Definition: cfl_token.h:84
void SetString(const std::string &rName)
Initialize as String token.
Definition: cfl_token.cpp:84
TokenType Type(void) const
Get token Type.
Definition: cfl_token.cpp:198
void DWrite(const Type *pContext=0) const
Write configuration data to console, debugging format.
Definition: cfl_types.cpp:225
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
Read configuration data from file with label specified.
Definition: cfl_types.cpp:261
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
void SWrite(TokenWriter &rTw) const
Write statistics comment to TokenWriter.
Definition: cfl_types.cpp:256
Base class of all FAUDES generators.
StateSet::Iterator StatesBegin(void) const
Iterator to Begin() of state set.
bool SetTransition(Idx x1, Idx ev, Idx x2)
Add a transition to generator by indices.
const EventSet & Alphabet(void) const
Return const reference to alphabet.
Idx InsMarkedState(void)
Create new anonymous state and set as marked state.
virtual vGenerator & Assign(const Type &rSrc)
Copy from other faudes type.
TransSet::Iterator TransRelBegin(void) const
Iterator to Begin() of transition relation.
EventSet::Iterator AlphabetBegin(void) const
Iterator to Begin() of alphabet.
void SetInitState(Idx index)
Set an existing state as initial state by index.
Idx EventIndex(const std::string &rName) const
Event index lookup.
StateSet::Iterator StatesEnd(void) const
Iterator to End() of state set.
TransSet::Iterator TransRelEnd(void) const
Iterator to End() of transition relation.
void SetMarkedState(Idx index)
Set an existing state as marked state by index.
Idx InsInitState(void)
Create new anonymous state and set as initial state.
bool InsEvent(Idx index)
Add an existing event to alphabet by index.
std::string EventName(Idx index) const
Event name lookup.
EventSet::Iterator AlphabetEnd(void) const
Iterator to End() of alphabet.
bool ExistsInitState(Idx index) const
Test existence of state in mInitStates.
virtual void Clear(void)
Clear generator data.
void InjectAlphabet(const EventSet &rNewalphabet)
Set mpAlphabet without consistency check.
virtual void Clear(void)
Clear all set.
Definition: cfl_baseset.h:1902
Iterator End(void) const
Iterator to the end of set.
Definition: cfl_baseset.h:1896
Iterator Begin(void) const
Iterator to the begin of set.
Definition: cfl_baseset.h:1891
void StateMin(const Generator &rGen, Generator &rResGen)
State set minimization.
void Parallel(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
Parallel composition.
Class describing the I/O based hierarchy.
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
void CreateConstraint(int mType[5], Generator &constrP, Generator &constrE)
This function creates constraints which describe the condition of completeness and Yp-liveness of a S...
void GroupHioModules(const std::vector< HioModule * > &rChildren, HioModule &rParentModule)
GroupHioModules: This function groups two or more HioModules to a new HioModule.
void AdjustHioController(const HioController &rHioController, const HioModule *rHioModule1, const HioModule *rHioModule2, HioController &rResEnv)
Definition: hio_module.cpp:604
void HioSynth_Musunoi(const Generator &rPlant, const HioPlant &rSpec, const Generator &rConstr, const Generator &rLocConstr, const EventSet &rYp, const EventSet &rUp, Generator &rController)
std::string ToStringInteger(Int number)
integer to string
Definition: cfl_helper.cpp:43
std::set< std::string > ReadDirectory(const std::string &rDirectory)
Read the contents of the specified directors.
Definition: cfl_helper.cpp:336
void HioShuffle_Musunoi(const HioPlant &rPlantA, const HioPlant &rPlantB, int depth, Generator &rIOShuffAB)
void CreateSpec(int mType[5], HioPlant &rHioSpec, Generator &constrP, Generator &constrE)
This function creates new specification given by the type ("xxxxx") Note: The core of this function i...

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen