hio_module.h
Go to the documentation of this file.
1 /** @file hio_module.h 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 #ifndef FAUDES_HIO_MODULE_H
12 #define FAUDES_HIO_MODULE_H
13 
14 #include "hio_functions.h"
15 #include <list>
16 #include <cmath>
17 
18 namespace faudes {
19 
20 /**
21 * Recurring structure in hierarchies designed according to the I/O based DES framework.
22 * The HioModule class is a composite pattern providing access to the components of a
23 * I/O-controller synthesis problem for a composite I/O-plant:
24 *
25 * - Operator-constraint: describes liveness properties of I/O-plant, together with
26 * environment-constraint
27 * - Plant: abstraction and at the same time specification of the external
28 * closed-loop behaviour of the HioModule.
29 * - Controller enforcing the desired behaviour
30 * - children-vector of (pointers to) subordinate HioModules
31 * - Environment
32 * - Environment-constraint: describes liveness properties of I/O-plant, together with
33 * operator-constraint
34 *
35 * The plants of the subordinate HioModules and the environment form the
36 * uncontrolled behaviour of the HioModule.
37 *
38 * @ingroup hiosysplugin
39 */
40 
41 class HioModule {
42 
43  public:
44 
45  /**
46  * constructor
47  */
48  HioModule(void);
49 
50 
51  /**
52  * copy constructor
53  */
54  HioModule(const HioModule& rOtherHioModule);
55 
56  /**
57  * virtual destructor
58  */
59  virtual ~HioModule(void) {};
60 
61  /**
62  * Clear all members of the HioModule
63  */
64  void Clear();
65 
66 
67  /**
68  * Set name of HioModule
69  *
70  * @param rName
71  * Name to set
72  */
73  void Name(const std::string& rName);
74 
75  /**
76  * Return name of HioModule
77  *
78  * @return
79  * Name of HioModule
80  */
81  std::string Name() const;
82 
83  /**
84  * Set index of HioModule.
85  *
86  * @param Index
87  * Index to set
88  */
89  void Index(const Idx Index);
90 
91  /**
92  * Return index of HioModule.
93  *
94  * @return
95  * Index of HioModule
96  */
97  Idx Index() const;
98 
99  /**
100  * Set Operator-Constraint of HioModule
101  *
102  * @param rOpConstr
103  * Operator-Constraint to set
104  */
105  void OpConstr(const HioConstraint& rOpConstr);
106 
107  /**
108  * Return Operator-Constraint of HioModule
109  *
110  * @return
111  * Operator-Constraint of HioModule
112  */
113  HioConstraint OpConstr() const;
114 
115  /**
116  * Set HioPlant of HioModule
117  *
118  * @param rHioPlant
119  * HioPlant to set
120  */
121  void Plant(const HioPlant& rHioPlant);
122 
123  /**
124  * Return HioPlant of HioModule
125  *
126  * @return
127  * HioPlant of HioModule
128  */
129  HioPlant Plant() const;
130 
131  /**
132  * Set HioController of HioModule
133  *
134  * @param rHioController
135  * HioController to set
136  */
137  void Controller(const HioController& rHioController);
138 
139  /**
140  * Return HioController of HioModule
141  *
142  * @return
143  * HioController of HioModule
144  */
145  HioController Controller() const;
146 
147  /**
148  * Return Children of HioModule
149  *
150  * @return
151  * Children of the HioModule
152  */
153  std::vector<HioModule*> Children() const;
154 
155  /**
156  * Set Children of HioModule
157  *
158  * @param rChildren
159  * vector of children to set
160  */
161  void Children(const std::vector<HioModule*>& rChildren);
162 
163  /**
164  * Set HioEnvironment of HioModule
165  *
166  * @param rHioEnvironment
167  * HioEnvironment to set
168  */
169  void Environment(const HioEnvironment& rHioEnvironment);
170 
171  /**
172  * Return HioEnvironment of HioModule
173  *
174  * @return
175  * HioEnvironment of HioModule
176  */
177  HioEnvironment Environment() const;
178 
179  /**
180  * Set Environment-Constraint of HioModule
181  *
182  * @param rEnvConstr
183  * Environment-Constraint to set
184  */
185  void EnvConstr(const HioConstraint& rEnvConstr);
186 
187  /**
188  * Return Environment-Constraint of HioModule
189  *
190  * @return
191  * Environment-Constraint of HioModule
192  */
193  HioConstraint EnvConstr() const;
194 
195  /**
196  * Insert HioModule to list of children
197  *
198  * @param rChild
199  * Child HioModule to insert to list of children
200  */
201  void InsChild(HioModule* rChild);
202 
203 //////////////////////////////////////////////////////////////////////////
204 // from here to 'private': M.Musunoi - design specific functions
205 
206 //### M.Musunoi ###
207  /**
208  * This is a function to set the x and y position of the HioModule.
209  *
210  * @param Xpos
211  * Position at the X-Axis of an x0y-System
212  * @param Ypos
213  * Position at the Y-Axis of an x0y-System
214  */
215  void Position(const int Xpos, const int Ypos);
216 //### M.Musunoi ###
217 
218 //### M.Musunoi ###
219  /**
220  * This is a function to set the type of the HioModule; by type we mean an array
221  * of length 5 where each position has a specific semnification:
222  *
223  * *************** Interpretation of mType[] *******
224  * ************* Capacity: mType[0] *********
225  * ************* Take from left: mType[1] *********
226  * ************* Take from right: mType[2] *********
227  * ************* Deliver to left: mType[3] *********
228  * ************* Deliver to left: mType[4] *********
229  * *************************************************
230  *
231  * @param type
232  * type of the HioModule
233  */
234  void TypeHioModule(int type[5]);
235 //### M.Musunoi ###
236 
237 
238  /**
239  * This function reads the model from the given library and
240  * sets the following private variables of the HioModule.
241  * The library must contain the following files:
242  *
243  * plantCBx.gen - IO-Plant model of the simulated work unit (to set mIOPlant);
244  * constrP_CBx.gen - Operator constraints of the IO Plant model (if the
245  * model doesn't require any operator constraints at
246  * least an empty generator must be available) (mLcConstr)
247  * constrE_CBx.gen - Environment constraints of the IO Plant model (at
248  * least an empty generator must be available) (mLeConstr)
249  *
250  * for GUI purpose:
251  * symbolic picture of the work unit in *.png format
252  *
253  * The file names must be given as described above, and the events respect the
254  * following format:
255  * "CBx_..." (e.g.: CBx_rdy, CBx_full, CBx_stby,...)
256  *
257  * @param path
258  * string path indicating to the folder of the library to load;
259  * (required format: ../CBx/)
260  *
261  * todo: for GUI load image
262  */
263  void ReadHioPlant(const std::string path);
264 
265 
266  /**
267  * This function reads the model describing the interaction of IO-Plants with
268  * the environment and sets the private variable mIOEnvironment. As a next
269  * logical step this generator must be adapted to the IO-Plants that interact
270  * with each other.
271  *
272  * @param path
273  * string path indicating to the folder of the library to load;
274  */
275  void ReadHioEnv(const std::string path);
276 
277 
278 /**
279  * This function converts a generator by renaming all events from
280  * "CBx_..." to "CBi_...";
281  *
282  * all properties of the input generator are inherited by the output generator;
283  * as a standard all events used in this plugin have the following name format:
284  * "CBx_..."
285  *
286  * @param rOldGen
287  * generator to convert
288  * @param i
289  * new parameter to replace x
290  * @param rResGen
291  * Reference to the resulting converted generator (result)
292  */
294  const Generator& rOldGen,
295  const int i,
296  Generator& rResGen);
297 
298 
299 /**
300  * AdjustHioPlant(): convenience function (derived from AdjusTimedGenerator())to
301  * allow also the conversion of HioPlants
302  *
303  * @param rOldHioPlant
304  * HioPlant to convert
305  * @param i
306  * new parameter to replace x
307  * @param rResult
308  * Reference to the resulting converted HioPlant (result)
309  */
310 void AdjustHioPlant(
311  const HioPlant& rOldHioPlant,
312  const int i,
313  HioPlant& rResult);
314 
315 
316 /**
317  * This function converts an alphabet by renaming all events from
318  * "CBx_..." to "CBi_...";
319  * as a standard all events used in this plugin have the following name format:
320  * "CBx_...";
321  * Warning: This function does not preserves the attributes of the events!
322  *
323  * @param rOldAlph
324  * Alphabet to convert
325  * @param i
326  * new parameter to replace x
327  *
328  * @param rResAlph
329  * Reference to the resulting converted alphabet (result)
330  */
331 void AdjustAlphabet(
332  const EventSet& rOldAlph,
333  const int i,
334  EventSet& rResAlph);
335 
336 
337 /**
338  * AdjustEnvironment(): In order to describe the interaction between two IO-Plants
339  * we use the IO-Environment. This function adjusts the master copy
340  * (IOEnvironmentX) to the two IO-Plants. The position of the plants to each
341  * other must be set.
342  *
343  * @param rHioEnvX
344  * the master copy generator of the environment model
345  * @param rHioModule1
346  * first HioModule
347  * @param rHioModule2
348  * second HioModule
349  * @param rResEnv
350  * Reference to the resulting environment.
351  */
353  const HioEnvironment& rHioEnvX,
354  const HioModule* rHioModule1,
355  const HioModule* rHioModule2,
356  HioEnvironment& rResEnv);
357 
358 
359 /**
360  * AdjustHioController: convenience function derived from AdjustHioEnvironment() in
361  * order to adjust an IOController to any two IO-Plants which must enforce a
362  * well-defined specification
363  *
364  * @param rHioController
365  * the input controller to convert
366  * @param HioModule1
367  * pointer to first HioModule
368  * @param HioModule2
369  * pointer to second HioModule
370  * @param rResCont
371  * Reference to resulting controller
372  */
374  const HioController& rHioController,
375  const HioModule* HioModule1,
376  const HioModule* HioModule2,
377  HioController& rResCont);
378 
379 
380 /**
381  * this function renames all relevant member of the HioModule. These are:
382  * mHioPlant, mLcConstr, mLeConstr, mHioEnvironment, mHioController, mName
383  *
384  * @param i
385  * the new Id of the HioModule
386  */
387 void RenameHioModule(const int i);
388 
389 
390  /**
391  * chooseSpec: this function searches through an appropriate folder (based on
392  * the maximal capacity resulting from the ChildList) for available
393  * specifications and allows the user to choose one of the found specifications;
394  * After the user has chosen a specification, this function sets the IO-Plant,
395  * the constraints and the alphabets of the actual HioModule.
396  * The path must have the following format: "../Spec/"
397  *
398  * Warning: The computation of the IO-Controller is not triggered by this function,
399  * it must be started separately!
400  *
401  * @param path
402  * Path to the folder containing the specifications
403  * @return
404  * list of strings with available specifications
405  */
406 std::vector<std::string> ChooseSpec(
407  const std::string path);
408 
409  /**
410  * Compute: this function prepares the data required for HioSynth() function.
411  * If all data is available, HioSynth() is called and the resulting generator
412  * is the IOController for the given specification.
413  */
414  void Compute();
415 
416 
417  /**
418  * FindController(): this function searches in the folder of a chosen
419  * specification for an already computed IO-controller which enforces this
420  * specification.
421  * Furthermore must the IO-controller only be adjusted to the IO-Modules that
422  * we need to control. (to adjust call adjustController())
423  * @return
424  * true if a IO-Controller is available
425  */
426  bool FindController();
427 
428 
429  /**
430  * Save: this function saves the computed controller in the same folder with
431  * the specification that this controller enforces
432  */
433  void SaveController();
434 
435 
436  /**
437  * MyPath(): based on the type of the HioModule, this is a convenience
438  * function to establish the local path where to Write/Read from. (This function
439  * is used up to now only by FindController() and SaveController())
440  *
441  * @return
442  * string: path to the actual IO-Module
443  */
444  std::string MyPath();
445 
446  /**********************************************
447  **********************************************
448  *
449  * functions to call properties of the HioModule
450  **********************************************
451  ***********************************************/
452 
453  /**
454  * function to call the x-Position of the HioModule
455  *
456  * @return
457  * x-Position of the HioModule
458  */
459  int Xpos() const;
460 
461  /**
462  * function to call the y-Position of the HioModule
463  *
464  * @return
465  * y-Position of the HioModule
466  */
467  int Ypos() const;
468 
469  /**
470  * function to call the Type of the HioModule
471  *
472  * @return
473  * array of length 5 describing the type of the HioModule
474  */
475  int* TypeHioModule() const;
476 
477  /**
478  * function to encode to Type of the HioModule (function has only an
479  * informational character).
480  *
481  * *************** Interpretation of mType[] *******
482  * ************* Capacity: mType[0] *********
483  * ************* Take from left: mType[1] *********
484  * ************* Take from right: mType[2] *********
485  * ************* Deliver to left: mType[3] *********
486  * ************* Deliver to left: mType[4] *********
487  * *************************************************
488  *
489  * @param type
490  * the type to be encoded
491  */
492  void EncodeType(const std::string type);
493 
494  private:
495 
496  //Name
497  std::string mName;
498 
499  //Identity
501 
502  // Operator-Constraint
504 
505  // I/O-Plant
507 
508  // IO-Controller
510 
511  // Children
512  std::vector<HioModule*> mChildren;
513 
514  // IO-Environment
516 
517  // Environment-Constraint
519 
520  /////////////////////////////////////////////////////////////////////
521  // from here to end of file: design specific functions by M.Musunoi
522  // will be outsourced to something like hiodesign.h
523 
524  // operational mode of the HioModule
525  int mType[5];
526 
527  // define the position in a x0y coordinate system; mXpos = 0 and mYpos =0 is
528  // reserved for the general IOModule CBx
529  int mXpos;
530  int mYpos;
531 
532  }; // end of HioModule class definition
533 
534 /*******************************************************************************
535  ***************************END OF IOMODULE CLASS DEFINITION********************
536  ******************************************************************************/
537 
538 /**
539  * GroupHioModules: This function groups two or more HioModules to a new HioModule. The new
540  * HioModule represents the uncontrolled behaviour of the composed HioModules.
541  *
542  * @param rChildren
543  * vector of HioModules to group
544  * @param rParentModule
545  * resulting HioModule
546  */
547 void GroupHioModules(
548  const std::vector<HioModule*>& rChildren,
549  HioModule& rParentModule);
550 
551 /**
552  * This function creates new specification given by the type ("xxxxx")
553  * Note: The core of this function is a template specification model (SpecCB12.gen).
554  * Based on this model are the specifications created, by simply adding corresponding
555  * states and transitions. Hence, for different models, this function can not be
556  * used directly, but can serve as an example.
557  *
558  * @param mType
559  * By the type we specify the desired behaviour we want to model
560  * @param rHioSpec
561  * HioPlant reference to the resulting specification (result)
562  * @param constrP
563  * Generator to the resulting operator constraint for the specification
564  * @param constrE
565  * Generator to the resulting environment constraint for the specification
566  */
567 void CreateSpec(int mType[5], HioPlant& rHioSpec, Generator& constrP, Generator& constrE);
568 
569 /** This function creates constraints which describe the condition of completeness
570  * and Yp-liveness of a Specification. The implementation follows the same algorithm
571  * as the CreateSpec() function, and has the same limitation: it is only for use
572  * with a specific model
573  *
574  * @param mType
575  * By the type we specify type of the specification to build constraint for
576  * @param constrP
577  * Generator to the resulting operator constraint for the specification
578  * @param constrE
579  * Generator to the resulting environment constraint for the specification
580  */
581 void CreateConstraint(int mType[5], Generator& constrP, Generator& constrE);
582 
583 
584 } // end namespace faudes
585 
586 #endif
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 AdjustHioController(const HioController &rHioController, const HioModule *HioModule1, const HioModule *HioModule2, HioController &rResCont)
AdjustHioController: convenience function derived from AdjustHioEnvironment() in order to adjust an I...
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 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
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
virtual ~HioModule(void)
virtual destructor
Definition: hio_module.h:59
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
Set of indices with symbolic names.
Definition: cfl_nameset.h:69
Base class of all FAUDES generators.
Algorithms for hierarchical discrete event systems with inputs and outputs.
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 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