DiaDes  0.1
DIAgnosis of Discrete-Event System
Functions
ActiveDiagnoser.cc File Reference
#include <string>
#include <vector>
#include <set>
#include <iostream>
#include <fstream>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/positional_options.hpp>
#include <boost/program_options/variables_map.hpp>
#include <boost/program_options/parsers.hpp>
#include <utils/StringTools.hh>
#include <automata/Event.hh>
#include <automata/ObservableComponent.hh>
#include <automata/SpecialisedActiveDiagnoser.hh>
#include <sdmdl/SdmdlParser.hpp>
#include <sdmdl/SdmdlLexer.hpp>
#include <sdmdl/Unfolding.hh>

Go to the source code of this file.

Functions

string tag (SpecialisedActiveDiagnoser::Tag tag)
 
int export2Hydiag (const SpecialisedActiveDiagnoser &diagnoser, const string &filename)
 
int initialiseModelFromDesComp (const string &filename, ObservableComponent &globalModel, const set< string > &shortNameFaults, unordered_map< string, string > &dictionary, set< string > &faults, set< string > &nominals)
 
int initialiseModelFromSdmdl (const string &filename, ObservableComponent &globalModel, VariableFactory &factory, const set< string > &shortNameIgnored, const set< string > &shortNameFaults, unordered_map< string, string > &dictionary, set< string > &faults, set< string > &nominals)
 
int initialiseDiagnosers (const ObservableComponent &model, const set< string > &faults, unordered_map< string, string > &dictionnary, unordered_map< string, SpecialisedActiveDiagnoser *> &activeDiagnoser)
 
void printUsage (const po::options_description &desc)
 
int main (int ac, char **av)
 

Detailed Description

This file is the main file of the command dd-active-diagnoser

Usage: dd-active-diagnoser --help | [file.sdmdl | file.des_comp] [--fault evt1]* [--ignored evt]* --had --dot
   Compute the active diagnoser of the file 'file.sdmdl' or the file 'file.des_comp'
   The events listed after '--fault' are considered as fault events.
       The events listed after '--ignored' are simply ignored INPUT events in the model 'file.sdmdl'
       (this option is simply ignored if the model is in 'des_comp' format. Any event that is in the model but
       not listed as a fault or as an ignored event is considered as a normal event.

Definition in file ActiveDiagnoser.cc.

Function Documentation

◆ export2Hydiag()

int export2Hydiag ( const SpecialisedActiveDiagnoser diagnoser,
const string &  filename 
)

Export the active diagnoser in the had format (Hydiag Active Diagnoser format)

Parameters
diagnoserthe diagnoser to export
fileNameexported file
Returns
true if the export is a success The format is defined as follows: Format of the file to import:
Number_of_diagnoser_states
Number_of_observable_events
Initial_Belief_State_1
Belief_State_2 Belief_State_3 Belief_State_4 ...
observable_event_1 observable_event_2 ...
target_index_1_1  target_2_1  ...
...
target_index_Number_of_observable_events_1 ...
A belief state is a string without whitespaces An observable event is a string without whitespaces A belief state has index i if it is the ith belief state listed in the file. An observable event has index i if it is the i+1th belief state listed in the file. Therefore, the initial state has index 0, etc. The set of index ending the file describes a transition matrix. target_index_i_j denotes the index of the diagnoser state that is the target of the diagnoser state whose index is j when the observable event whose index is i occurs. If such index does not exist, it prints -1. Indexes start from 1. The format of Belief_State_i is
(q,N) or (q,Y) or (q,D) or (q,U)

where q is an integer that identifies the state of the active diagnoser and N,Y,D,U are the tags associated to the fault (N for NO, the fault is not there (Safe)) (Y for Yes, the fault is surely there (Sure)), (D for Discriminable, the fault might have occurred and a sequence of actions might be able to confirm or infirm this occurrence) (U for Undiscriminable, the fault might have occurred but it is impossible from now on to confirm or infirm its occurrence).

Definition at line 121 of file ActiveDiagnoser.cc.

References Diades::Automata::Component::behaviour(), Diades::Automata::Component::events(), initial, Diades::Automata::SpecialisedActiveDiagnoser::initialState(), Diades::Automata::SpecialisedActiveDiagnoser::isHole(), Diades::Automata::Component::numberOfStates(), Diades::Automata::Component::outputEventTransitionBegin(), Diades::Automata::Component::outputEventTransitionEnd(), Diades::Automata::Component::stateBegin(), Diades::Automata::Component::stateEnd(), states, tag(), and Diades::Automata::SpecialisedActiveDiagnoser::tag().

Referenced by main().

◆ initialiseDiagnosers()

int initialiseDiagnosers ( const ObservableComponent model,
const set< string > &  faults,
unordered_map< string, string > &  dictionnary,
unordered_map< string, SpecialisedActiveDiagnoser *> &  activeDiagnoser 
)

Initialise a specialised diagnoser for each fault (see SAFEPROCESS article)

Parameters
modelthe global model (global automaton) that describes the bevaviour of the system
faultsthe set of fault events to deal with, one active diagnoser will be computed for each fault
dictionarythe dictionary of event labels (if the model is in sdmdl format)
activeDiagnoserthe resulting set of active diagnosers
Returns
0 if success, something else otherwise

Definition at line 449 of file ActiveDiagnoser.cc.

References Diades::Utils::log(), and Diades::Automata::Component::name().

Referenced by main().

◆ initialiseModelFromDesComp()

int initialiseModelFromDesComp ( const string &  filename,
ObservableComponent globalModel,
const set< string > &  shortNameFaults,
unordered_map< string, string > &  dictionary,
set< string > &  faults,
set< string > &  nominals 
)

Initialise the global model from a smdl description

Parameters
filenamethe filename of the sdmdl description
globalModelthe resulting global model
shortNameFaultsthe set of events that are considered as faulty during the generation
dictionarythe resulting mapping of event labels
faultsthe resulting set of fault event labels (long version)
nominalsthe resulting set of nominal event labels (long version)
Returns
0 if success, something else otherwise

Definition at line 270 of file ActiveDiagnoser.cc.

References Diades::Automata::Component::events(), Diades::Automata::Component::import(), and Diades::Utils::log().

Referenced by main().

◆ initialiseModelFromSdmdl()

int initialiseModelFromSdmdl ( const string &  filename,
ObservableComponent globalModel,
VariableFactory &  factory,
const set< string > &  shortNameIgnored,
const set< string > &  shortNameFaults,
unordered_map< string, string > &  dictionary,
set< string > &  faults,
set< string > &  nominals 
)

Initialise the global model from a smdl description

Parameters
filenamethe filename of the sdmdl description
globalModelthe resulting global model
shortNameIgnoredthe set of events that will be ignored dureing the generation
shortNameFaultsthe set of events that are considered as faulty during the generation
dictionarythe resulting mapping of event labels
faultsthe resulting set of fault event labels (long version)
nominalsthe resulting set of nominal event labels (long version)
Returns
0 if success, something else otherwise

Definition at line 329 of file ActiveDiagnoser.cc.

References Diades::Automata::Component::import(), Diades::Utils::log(), and verbose().

Referenced by main().

◆ main()

int main ( int  ac,
char **  av 
)

The main function of the program 'dd-active-diagnoser'

Parameters
acthe number of options
avthe program option line
Returns
0 if the program correctly runs, something else otherwise.

Definition at line 508 of file ActiveDiagnoser.cc.

References export2Hydiag(), Diades::Utils::getFileExtension(), initialiseDiagnosers(), initialiseModelFromDesComp(), initialiseModelFromSdmdl(), options(), printUsage(), and suffixes.

◆ printUsage()

void printUsage ( const po::options_description &  desc)

Print the usage of the program

Parameters
descthe current option descriptions

Definition at line 481 of file ActiveDiagnoser.cc.

Referenced by getParameter(), main(), readParameters(), and setOptions().

◆ tag()

string tag ( SpecialisedActiveDiagnoser::Tag  tag)
Parameters
taga give tag
Returns
a string that identifies the given tag (Undiscriminable -> U), (Discriminable -> D) (Safe -> N (No)), (Sure -> Y (Yes))

Definition at line 56 of file ActiveDiagnoser.cc.

Referenced by export2Hydiag().