4_cgenerator.cpp

Go to the documentation of this file.
00001 
00021 #include "libfaudes.h"
00022 
00023 
00024 // we make the faudes namespace available to our program
00025 using namespace faudes;
00026 
00027 
00028 
00029 
00031 // main program
00033 
00034 int main() {
00035 
00036 
00038   // Constructors & Assignment Operator
00040 
00041   // Create an empty cGenerator object
00042 
00043   cGenerator cgen1;
00044 
00045   // Create a cGenerator by reading a Generator file 
00046   // Events default to uncontrollable
00047 
00048   cGenerator cgen2("data/simplemachine.gen");
00049 
00050   // Create a cGenerator by reading a cGenerator file 
00051 
00052   cGenerator cgen3("data/csimplemachine.gen");
00053 
00054   // Copy constructor & assignment operator
00055   // (same behaviour as in Generator class)
00056 
00057   cGenerator cgen4(cgen3); 
00058   cgen4 = cgen3;           
00059 
00060   cgen4.Write("tmp_csimplemachine.gen");
00061 
00063   // Controllable events
00065 
00066   // Insert an event and set it controllable 
00067 
00068   cgen1.InsControllableEvent(1); // by index
00069   cgen1.InsControllableEvent("newcevent1"); // by symbolic name
00070 
00071   // Insert an event and set it uncontrollable 
00072 
00073   cgen1.InsUncontrollableEvent(2); // by index
00074   cgen1.InsUncontrollableEvent("newcevent2"); // by symbolic name
00075 
00076   // Set an existing event controllable
00077 
00078   cgen1.SetControllable(2); // by index
00079   cgen1.SetControllable((const std::string&) "newcevent2"); // by symbolic name
00080 
00081   // Set an existing event uncontrollable
00082 
00083   cgen1.ClrControllable(1); // by index
00084   cgen1.ClrControllable((const std::string&) "newcevent1"); // by symbolic name
00085 
00086   // Test wether an event is controllable
00087 
00088   bool bool_eventcontrollable = cgen1.Controllable(1); // by index
00089   bool_eventcontrollable = cgen1.Controllable("newcevent1"); // by symbolic name
00090 
00091   // Retrieve an EventSet containing all the controllabe events of the
00092   // cGenerator
00093 
00094   EventSet eset_cevents = cgen2.ControllableEvents();
00095 
00096   // Retrieve an EventSet containing all the uncontrollabe events of the
00097   // cGenerator
00098 
00099   EventSet eset_ucevents = cgen2.UncontrollableEvents();
00100 
00102   // SIMPLE SYNTHESIS EXAMPLE
00104  
00105   // compose plant dynamics from two very simple machines 
00106   Generator tempgen, machinea, machineb;
00107   cGenerator cplant; 
00108  
00109   tempgen.Read("data/verysimplemachine.gen");
00110   tempgen.Version("1",machinea);
00111   tempgen.Version("2",machineb);
00112   Parallel(machinea,machineb,cplant);
00113 
00114   // declare controllable events
00115   EventSet contevents;
00116   contevents.Insert("alpha_1");
00117   contevents.Insert("alpha_2");
00118   cplant.SetControllable(contevents);
00119 
00120   // write to file
00121   cplant.Write("tmp_cplant12.gen");
00122 
00123   // report to console
00124 
00125   std::cout << "################################\n";
00126   std::cout << "# tutorial, plant model \n";
00127   cplant.DWrite();
00128   std::cout << "################################\n";
00129 
00130   // read specification 
00131 
00132   Generator specification;
00133   specification.Read("data/buffer.gen");
00134   InvProject(specification,cplant.Alphabet()); // self-loop
00135   specification.Name("simple machines specification");
00136 
00137   // write to file
00138   specification.Write("tmp_specification12.gen");
00139 
00140   // report to console
00141 
00142   std::cout << "################################\n";
00143   std::cout << "# tutorial, specification \n";
00144   specification.DWrite();
00145   std::cout << "################################\n";
00146 
00147   // run synthesis algorithm
00148   
00149   cGenerator supervisor;
00150   cSupConNB(cplant,specification,supervisor);
00151   supervisor.Name("simple machines supervisor");
00152   supervisor.Write("tmp_supervisor12.gen");
00153 
00154   // report to console
00155 
00156   std::cout << "################################\n";
00157   std::cout << "# tutorial, supervisor\n";
00158   supervisor.DWrite();
00159   std::cout << "################################\n";
00160 
00161 
00162   return 0;
00163 }
00164 
00165 
00166 

Generated on Fri May 9 11:26:47 2008 for libFAUDES 2.09b by  doxygen 1.4.4