diag_languagediagnosis.h

Go to the documentation of this file.
00001 /** @file diag_languagediagnosis.h
00002 Functions to check a system's diagnosability with respect to a specification automaton and compute a language-diagnoser.
00003 */
00004 
00005 #ifndef DIAG_LANGUAGEDIAGNOSIS_H
00006 #define DIAG_LANGUAGEDIAGNOSIS_H
00007 
00008 #include <vector>
00009 #include "corefaudes.h"
00010 #include "diag_generator.h"
00011 #include "diag_eventdiagnosis.h"
00012 #include "op_obserververification.h"
00013 
00014 #include "diag_debug.h"
00015 
00016 namespace faudes {
00017 
00018 ///////////////////////////////////////////////////////////////////////////////
00019 // Functions for specification framework
00020 ///////////////////////////////////////////////////////////////////////////////
00021 /** @name Functions (diagnosability with respect to a specification) */
00022 /** @{ doxygen group */
00023 
00024 /**
00025 Tests a system's diagnosability with respect to a given specification. 
00026 @param rGen
00027   Input generator.
00028 @param rSpec 
00029   Specification automaton. 
00030 @param rReportString
00031   User-readable information of violating condition (in case of negative test result).
00032 @return
00033   True if input generator is diagnosable.
00034 @ingroup DiagnosisPlugIn
00035 */
00036 bool IsLanguageDiagnosableX(const System& rGen, const System& rSpec, std::string& rReportString);
00037 
00038 /** @} doxygen group */
00039 
00040 /**
00041 Compute G_o for a generator that marks the faulty behaviour of a plant. 
00042 Every specification violation will be labelled with label "F".
00043 @param rGenMarkedNonSpecBehaviour
00044   Input generator that specifies specification violations by marked states. 
00045 @param rGobs
00046   Output variable for G_o.
00047 */
00048 void ComputeGobs(const System& rGenMarkedNonSpecBehaviour, Diagnoser& rGobs);
00049 
00050 /**
00051 Compute the reachability from a state of a generator that marks its faulty behaviour. 
00052 States are said to be reachable if they can be reached through a trace that consists 
00053 of arbitrarily many unobservable events followed by one observable event. 
00054 @param rGen
00055   Input generator.
00056 @param rUnobsEvents
00057   Unobservable events in the generators alphabet.
00058 @param State
00059   A state of the generators state set.
00060 @param rReachabilityMap
00061   Output variable for the reachability. Maps occurring observable events to the reachable generator states and a label that contains information about specification violations.
00062 */
00063 void ComputeReachability(const System& rGen, const EventSet& rUnobsEvents, Idx State, 
00064                 std::map<Idx,std::multimap<Idx,DiagLabelSet> >& rReachabilityMap);
00065 
00066 /**
00067 Auxiliary function for ComputeReachability(const System&, const EventSet&, Idx State,  std::map<Idx,std::multimap< Idx,DiagLabelSet> >&). Is recursively called for every occurring state on the trace (that consists of arbitrarily many unobservable events followed by one observable event).
00068 @param rGen
00069   Input generator.
00070 @param rUnobsEvents
00071   Unobservable events in the generators alphabet. 
00072 @param State
00073   The current state within the trace. 
00074 @param done
00075   Progress.
00076 @param rReachabilityMap
00077   Output variable for the reachability. Maps occurring observable events to the reachable generator states and a label that contains information about specification violations. 
00078  */                      
00079  void ComputeReachabilityRecursive(const System& rGen, const EventSet& rUnobsEvents, Idx State, StateSet done, 
00080                      std::map<Idx,std::multimap<Idx,DiagLabelSet> >& rReachabilityMap);
00081 
00082 
00083 /**
00084  * Function definition for run-time interface 
00085  */
00086 bool IsLanguageDiagnosable(const System& rGen, const System& rSpec);
00087 
00088 enum VerifierStateLabel{NORMAL,CONFUSED,BLOCK};
00089 
00090 struct VerifierState{
00091   Idx mSpec1State;
00092   Idx mSpec2State;
00093   Idx mPlantState;
00094   VerifierStateLabel mLabel;
00095   
00096   
00097   VerifierState(Idx state1 = 0, Idx state2 = 0, Idx state3 = 0, VerifierStateLabel label = NORMAL){ mSpec1State = state1; mSpec2State = state2; mPlantState = state3; mLabel = label; }
00098 
00099   bool operator<  (const VerifierState&   rOther) const{
00100     if(mSpec1State < rOther.mSpec1State)
00101       return true;
00102     else if(mSpec1State > rOther.mSpec1State)
00103       return false;
00104     if(mSpec2State < rOther.mSpec2State)
00105       return true;
00106     else if(mSpec2State > rOther.mSpec2State)
00107       return false;
00108     if(mPlantState < rOther.mPlantState)
00109       return true;
00110     else 
00111       return false;
00112   }
00113 };
00114 
00115 /** 
00116   * Test function to verify language-diagnosability
00117   */
00118 bool IsLanguageDiagnosable(const System& rGen, const System rSpec, std::string& rReportString);
00119 
00120 /** @name Functions (verification and computation of loop-preserving observers) */
00121 /** @{ doxygen group */
00122 
00123 /**
00124   * Verifies a loop-preserving observer. 
00125   * @param rGen
00126   *   Original generator.
00127   * @param rHighAlph
00128   *   Abstraction alphabet. 
00129   * @return 
00130   *   True if natural projection is a loop-preserving observer
00131   * @ingroup DiagnosisPlugIn
00132 */
00133 bool IsLoopPreservingObserver(const System& rGen, const EventSet& rHighAlph);
00134 
00135 /** 
00136   * Computes a loop-preserving observer with minimal state size of the abstraction
00137   * @param rGen
00138   * Original generator
00139   * @param rInitialHighAlph
00140   % Initial abstraction alphabet
00141   * @param rHighAlph
00142   * Resulting abstraction alphabet
00143   * @ingroup DiagnosisPlugIn
00144   */
00145 void LoopPreservingObserver(const System& rGen, const EventSet& rInitialHighAlph, EventSet& rHighAlph);
00146 
00147 /** @} doxygen group */
00148 
00149 /** rec_ComputeLoopPreservingObserver(rGen, rInitialHighAlph, rHighAlph, rDdffVector,  numberEvents,  currentNumberEvents,  currentLocation, hosenEvents) */
00150 bool rec_ComputeLoopPreservingObserver(const System& rGen, const EventSet& rInitialHighAlph, EventSet& rHighAlph, 
00151   const std::vector<Idx>& rDdffVector, Idx numberEvents, Idx currentNumberEvents, Idx currentLocation, EventSet chosenEvents);
00152 
00153   
00154 /** @name Functions (diagnoser computation) */
00155 /** @{ doxygen group */
00156 
00157 /**
00158  * Compute a standard diagnoser from an input generator and a specification.
00159   * @param rGen
00160   *   Input plant
00161   * @param rSpec
00162   *   Specification generator.
00163   * @param rDiagGen
00164   *   Diagnoser generator for output. 
00165   * @ingroup DiagnosisPlugIn
00166 */
00167 void LanguageDiagnoser(const System& rGen, const System& rSpec, Diagnoser& rDiagGen);
00168 
00169 /** @} doxygen group */
00170 
00171 } // namespace faudes
00172 
00173 #endif

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