ios_1_system.cpp
Go to the documentation of this file.
1 /** @file ios_1_system.cpp
2 
3 Tutorial, I/O systems
4 
5 
6 @ingroup Tutorials
7 
8 @include ios_1_system.cpp
9 
10 */
11 
12 #include "libfaudes.h"
13 
14 // make the faudes namespace available to our program
15 using namespace faudes;
16 
17 
18 
19 /////////////////
20 // main program
21 /////////////////
22 
23 int main() {
24 
25  ////////////////////////////////////////////
26  // Constructors
27  ////////////////////////////////////////////
28 
29  // construct from file
30  IoSystem sys1("data/ios_system1.gen");
31 
32  // copy construct
33  IoSystem sys2(sys1);
34 
35  // assign
36  IoSystem sys3 = sys2;
37 
38  // inspect result on console
39  std::cout << "################################\n";
40  std::cout << "# tutorial, io system 1 \n";
41  sys3.Write();
42  std::cout << "################################\n";
43 
44  // graph output
45  sys1.GraphWrite("tmp_ios_system1.svg");
46 
47  // output for doku
48  sys1.Write("tmp_ios_system1.gen");
49 
50 
51  ///////////////////////////////////////////////
52  // Inspect/Edit I/O attributes
53  ///////////////////////////////////////////////
54 
55  // events, result on console
56  std::cout << "################################\n";
57  std::cout << "# input events, output events\n";
58  sys3.InputEvents().Write();
59  sys3.OutputEvents().Write();
60  std::cout << "################################\n";
61 
62  // maniputlate some state attributes
63  // (to configure set state, see also IoSystem())
64  sys3.SetOutputState("s1");
65  sys3.SetInputState("s3");
66  sys3.ClrOutputState("s2");
67 
68  // swap event status all together
69  EventSet inevs = sys3.InputEvents();
70  EventSet outevs = sys3.OutputEvents();
71  sys3.ClrOutputEvent(outevs);
72  sys3.SetInputEvent(outevs);
73  sys3.ClrInputEvent(inevs);
74  sys3.SetOutputEvent(inevs);
75 
76  // inspect result on console
77  std::cout << "################################\n";
78  std::cout << "# tutorial, manipulated io system 1 \n";
79  sys3.Write();
80  std::cout << "################################\n";
81 
82  ///////////////////////////////////////////////
83  // Test I/O structure
84  ///////////////////////////////////////////////
85 
86  // the test will set the state attributes accordingly
87  bool isio=IsIoSystem(sys1);
88 
89  // sys1 from file will pass the test
90  if(!isio) std::cout << "#### test FAILED (test case error) \n";
91 
92  // report
93  std::cout << "################################\n";
94  std::cout << "# tutorial, sys1 test io properties \n";
95  sys1.InputStates().Write();
96  sys1.OutputStates().Write();
97  std::cout << "################################\n";
98 
99  // however, the input is not free
100  bool isfree=IsInputLocallyFree(sys1);
101  if(isfree) std::cout << "#### test PASSED (test case error) \n";
102  IoFreeInput(sys1);
103 
104  // report
105  std::cout << "################################\n";
106  std::cout << "# tutorial, sys1 with free input\n";
107  sys1.Write();
108  std::cout << "################################\n";
109 
110  // output for doku
111  sys1.Write("tmp_ios_system1f.gen");
112 
113  // however, the input is still not omega-free
114  StateSet qerr;
115  bool iswfree=IsInputOmegaFree(sys1,qerr);
116  if(iswfree) std::cout << "#### test PASSED (test case error) \n";
117 
118  // report
119  std::cout << "################################\n";
120  std::cout << "# tutorial, sys1 error states\n";
121  sys1.WriteStateSet(qerr);
122  std::cout << "################################\n";
123 
124  // Record testcase
125  FAUDES_TEST_DUMP("sys1", sys1);
126  FAUDES_TEST_DUMP("isio", isio);
127  FAUDES_TEST_DUMP("isfree", isfree);
128  FAUDES_TEST_DUMP("iswfree", iswfree);
129  FAUDES_TEST_DUMP("qerr", qerr);
130 
131  return 0 ;
132 
133 }
134 
135 
136 
137 

libFAUDES 2.26g --- 2015.08.17 --- c++ api documentaion by doxygen