diag_2_languagediagnosis.cpp
Go to the documentation of this file.
1 /** @file diag_2_languagediagnosis.cpp
2 Illustrate diagnosability with respect to a specification language.
3 @ingroup Tutorials
4 @include diag_2_languagediagnosis.cpp
5 */
6 
7 #include "libfaudes.h"
8 
9 using namespace faudes;
10 
11 
12 int 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)
Test protocol record macro ("mangle" filename for platform independance)
Definition: cfl_helper.h:483
Set of indices with symbolic names.
Definition: cfl_nameset.h:69
Generator with controllability attributes.
Provides the structure and methods to build and handle diagnosers.
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
Read configuration data from file with label specified.
Definition: cfl_types.cpp:261
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
int main(void)
void LanguageDiagnoser(const System &rGen, const System &rSpec, Diagnoser &rDiagGen)
Compute a standard diagnoser from an input generator and a specification.
void LoopPreservingObserver(const System &rGen, const EventSet &rInitialHighAlph, EventSet &rHighAlph)
Computes a loop-preserving observer with minimal state size of the abstraction.
bool IsLoopPreservingObserver(const System &rGen, const EventSet &rHighAlph)
Verifies a loop-preserving observer.
Includes all libFAUDES headers, incl plugings
libFAUDES resides within the namespace faudes.
bool IsLanguageDiagnosable(const System &rGen, const System &rSpec)
Function definition for run-time interface.

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen