ios_1_system.cpp

Go to the documentation of this file.
00001 /** @file ios_1_system.cpp  
00002 
00003 Tutorial, I/O systems
00004 
00005 
00006 @ingroup Tutorials 
00007 
00008 @include ios_1_system.cpp
00009 
00010 */
00011 
00012 #include "libfaudes.h"
00013 
00014 // make the faudes namespace available to our program
00015 using namespace faudes;
00016 
00017 
00018 
00019 /////////////////
00020 // main program
00021 /////////////////
00022 
00023 int main() {
00024 
00025   ////////////////////////////////////////////
00026   // Constructors 
00027   ////////////////////////////////////////////
00028 
00029   // construct from file
00030   IoSystem sys1("data/ios_system1.gen");
00031 
00032   // copy construct
00033   IoSystem sys2(sys1);
00034 
00035   // assign 
00036   IoSystem sys3 = sys2;
00037 
00038   // inspect result on console
00039   std::cout << "################################\n";
00040   std::cout << "# tutorial, io system 1 \n";
00041   sys3.Write();
00042   std::cout << "################################\n";
00043 
00044   // graph output 
00045   sys1.GraphWrite("tmp_ios_system1.svg");
00046 
00047   // output for doku
00048   sys1.Write("tmp_ios_system1.gen");
00049 
00050 
00051   ///////////////////////////////////////////////
00052   // Inspect/Edit I/O attributes
00053   ///////////////////////////////////////////////
00054 
00055   // events, result on console
00056   std::cout << "################################\n";
00057   std::cout << "# input events, output events\n";
00058   sys3.InputEvents().Write();
00059   sys3.OutputEvents().Write();
00060   std::cout << "################################\n";
00061 
00062   // maniputlate some state attributes
00063   // (to configure set state, see also IoSystem())
00064   sys3.SetOutputState("s1");
00065   sys3.SetInputState("s3");
00066   sys3.ClrOutputState("s2");
00067 
00068   // swap event status all together
00069   EventSet inevs = sys3.InputEvents();
00070   EventSet outevs = sys3.OutputEvents();
00071   sys3.ClrOutputEvent(outevs);
00072   sys3.SetInputEvent(outevs);
00073   sys3.ClrInputEvent(inevs);
00074   sys3.SetOutputEvent(inevs);
00075 
00076   // inspect result on console
00077   std::cout << "################################\n";
00078   std::cout << "# tutorial, manipulated io system 1 \n";
00079   sys3.Write();
00080   std::cout << "################################\n";
00081        
00082   ///////////////////////////////////////////////
00083   // Test I/O structure
00084   ///////////////////////////////////////////////
00085 
00086   // the test will set the state attributes accordingly
00087   bool isio=IsIoSystem(sys1);
00088 
00089   // sys1 from file will pass the test
00090   if(!isio) std::cout << "#### test FAILED (test case error) \n";
00091 
00092   // report
00093   std::cout << "################################\n";
00094   std::cout << "# tutorial, sys1 test io properties \n";
00095   sys1.InputStates().Write();
00096   sys1.OutputStates().Write();
00097   std::cout << "################################\n";
00098 
00099   // however, the input is not free
00100   bool isfree=IsInputLocallyFree(sys1);
00101   if(isfree) std::cout << "#### test PASSED (test case error) \n";
00102   IoFreeInput(sys1);
00103 
00104   // report
00105   std::cout << "################################\n";
00106   std::cout << "# tutorial, sys1 with free input\n";
00107   sys1.Write();
00108   std::cout << "################################\n";
00109 
00110   // output for doku
00111   sys1.Write("tmp_ios_system1f.gen");
00112 
00113   // however, the input is still not omega-free
00114   StateSet qerr;
00115   bool iswfree=IsInputOmegaFree(sys1,qerr);
00116   if(iswfree) std::cout << "#### test PASSED (test case error) \n";
00117 
00118   // report
00119   std::cout << "################################\n";
00120   std::cout << "# tutorial, sys1 error states\n";
00121   sys1.WriteStateSet(qerr);
00122   std::cout << "################################\n";
00123 
00124   // Record testcase
00125   FAUDES_TEST_DUMP("sys1", sys1);
00126   FAUDES_TEST_DUMP("isio", isio);
00127   FAUDES_TEST_DUMP("isfree", isfree);
00128   FAUDES_TEST_DUMP("iswfree", iswfree);
00129   FAUDES_TEST_DUMP("qerr", qerr);
00130 
00131   return 0 ;
00132 
00133 }
00134 
00135 
00136 
00137 

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen