diag_2_languagediagnosis.cpp
Go to the documentation of this file.
1/** @file diag_2_languagediagnosis.cpp
2Illustrate diagnosability with respect to a specification language.
3@ingroup Tutorials
4@include diag_2_languagediagnosis.cpp
5*/
6
7#include "libfaudes.h"
8
9using namespace faudes;
10
11
12int main(void) {
13
14 // **********************************************************************
15 //
16 // Language-Diagnosability Verification
17 //
18
19 // Declare common variables
20 System gen, specGen;
21 EventSet highEvents;
22 Diagnoser diagnoser;
23 std::string reportString;
24
25 // Report to console
26 std::cout << "################################\n";
27 std::cout << "# languag-diagnosability, system_2_language, specifiation_2_language \n";
28 std::cout << "# a) read data \n";
29
30 // Read input generators for plant and specification
31 gen.Read("data/diag_system_2_language.gen");
32 specGen.Read("data/diag_specification_2_language.gen");
33
34 // Write input generator to gen file for html docu
35 gen.Write("tmp_diag_system_2_language.gen");
36 specGen.Write("tmp_diag_specification_2_language.gen");
37
38 // Report to console
39 std::cout << "run language-diagnosability test (expect result FAIL)\n";
40
41 // Test generator gen for diagnosability with respect to failure partition failureTypes
42 bool isdiag = IsLanguageDiagnosable(gen,specGen,reportString);
43 if(isdiag){
44 std::cout << "System is diagnosable." << std::endl;
45 }
46 else {
47 std::cout << "System is not diagnosable." << std::endl;
48 std::cout << reportString << std::endl;
49 }
50
51 // Record test case
52 FAUDES_TEST_DUMP("test lang diag",isdiag);
53
54 // **********************************************************************
55 //
56 // Language-Diagnoser Computation
57 //
58
59 // Report to console
60 std::cout << "# language-diagnoser, system_2_language, specifiation_2_language \n";
61
62 // Synthesis
63 LanguageDiagnoser(gen,specGen,diagnoser);
64
65 // Write diagnoser to gen file for html docu
66 diagnoser.Write("tmp_diag_diagnoser_2.gen");
67
68 // Record test case
69 FAUDES_TEST_DUMP("test lang diag",diagnoser);
70
71 // **********************************************************************
72 //
73 // Abstraction-based Diagnosis - Loop-Preserving Observer
74 //
75
76 // Report to console
77 std::cout << "################################\n";
78 std::cout << "# language-diagnoser, abstraction based diagnosis\n";
79
80 // Read input generator and abstraction alphabet
81 gen.Read("data/diag_system_2_abstraction_fails.gen");
82 highEvents.Read("data/diag_abstrAlph_2_abstraction_fails.alph","Alphabet");
83
84 // Write input generator to gen file for html docu
85 gen.Write("tmp_diag_system_2_abstraction_fails.gen");
86
87 // Test
88 std::cout << "# test loop-preserving observer property (expect FAIL)\n";
89 bool islpo = IsLoopPreservingObserver(gen,highEvents);
90 if(islpo){
91 std::cout << "Abstraction is loop-preserving observer." << std::endl;
92 }
93 else {
94 std::cout << "Abstraction is not a loop-preserving observer." << std::endl;
95 }
96
97 std::cout << "################################\n";
98 std::cout << "# compute loop-preserving observer, system_2_abstraction_fails \n";
99 EventSet highAlph;
100 LoopPreservingObserver(gen,highEvents,highAlph);
101 std::cout << "# Abstraction Alphabet \n";
102 highAlph.Write();
103
104 // Record test case
105 FAUDES_TEST_DUMP("observer fail",islpo);
106 FAUDES_TEST_DUMP("observer pass",highAlph);
107
108 return 0;
109}
#define FAUDES_TEST_DUMP(mes, dat)
Definition cfl_utils.h:505
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
void Write(const Type *pContext=0) const
int main(void)
void LanguageDiagnoser(const System &rGen, const System &rSpec, Diagnoser &rDiagGen)
void LoopPreservingObserver(const System &rGen, const EventSet &rInitialHighAlph, EventSet &rHighAlph)
bool IsLoopPreservingObserver(const System &rGen, const EventSet &rHighAlph)
bool IsLanguageDiagnosable(const System &rGen, const System &rSpec)

libFAUDES 2.33k --- 2025.09.16 --- c++ api documentaion by doxygen