DiaDes
0.1
DIAgnosis of Discrete-Event System
|
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <diades/utils/Random.hh>
#include <diades/utils/Verbose.hh>
#include <diades/automata/ComposableModel.hh>
#include <diades/automata/SyncRulesLoad.hh>
#include "CmdInterface.hh"
#include "Simulator.hh"
Go to the source code of this file.
Functions | |
vector< string > | fileExtensions (numberOfFileExtensions) |
vector< string > | options (numberOfOptions) |
vector< bool > | isSet (numberOfOptions, false) |
void | initialiseOptions () |
void | clean (vector< Diades::Automata::ObservableComponent *> &components) |
bool | readParameters (int argc, char **argv, vector< unsigned > &values, vector< set< string > > &noevents, set< string > &modelFiles, string &ruleFile, string &xmlFile, string &ptaLogFile, bool &faultGeneration, bool &interactiveMode) |
bool | readModels (const set< string > &modelFiles, const string &ruleFile, vector< Diades::Automata::ObservableComponent *> &components, Diades::Automata::ParametrizedSynchronisation &rules) |
void | generateFaults (unsigned seed, const vector< Diades::Automata::ObservableComponent *> components, list< Diades::Automata::Event > &faults) |
void | writeTimedSimulation (const list< Diades::Automata::Event > &simulation, const Diades::Automata::ObservableMask &mask, set< Diades::Automata::Event > &observables, set< Diades::Automata::Event > &nonObservables, unsigned timeMin, unsigned timeMax, unsigned &nbObs) |
void | writeUntimedSimulation (const list< Diades::Automata::Event > &simulation, const Diades::Automata::ObservableMask &mask, set< Diades::Automata::Event > &observables, set< Diades::Automata::Event > &nonObservables, unsigned &nbObs) |
void | writeFinalPartOfSimulation (const list< Diades::Automata::Event > &simulation, bool faultGeneration, const list< Diades::Automata::Event > &faults, const set< Diades::Automata::Event > &identifiables, const set< Diades::Automata::Event > &nonIdentifiables, unsigned nbObs, const set< Diades::Automata::Event > &events, const Diades::Automata::ObservableMask &mask) |
void | writeSimulation (const list< Diades::Automata::Event > &simulation, vector< unsigned > &values, bool faultGeneration, const list< Diades::Automata::Event > &faults, const set< Diades::Automata::Event > &events, const Diades::Automata::ObservableMask &mask) |
bool | startInteractiveSimulation (const vector< Diades::Automata::ObservableComponent *> components, const Diades::Automata::ParametrizedSynchronisation &rules, Diades::Automata::ObservableMask &mask, set< Diades::Automata::Event > &events, list< Diades::Automata::Event > &simulation) |
bool | startNonInteractiveSimulation (const vector< Diades::Automata::ObservableComponent *> components, const Diades::Automata::ParametrizedSynchronisation &rules, const vector< unsigned > &values, const vector< set< string > > &noevents, Diades::Automata::ObservableMask &mask, set< Diades::Automata::Event > &events, list< Diades::Automata::Event > &simulation, unsigned simNb) |
void | exportLogIntoPtaLogFile (const vector< Diades::Automata::ObservableComponent *> &components, const Diades::Automata::ParametrizedSynchronisation &rules, const list< Diades::Automata::Event > &simulation, const Diades::Automata::ObservableMask &mask, ostream &file) |
int | main (int argc, char **argv) |
Variables | |
unsigned | numberOfOptions = 12 |
unsigned | numberOfFileExtensions = 2 |
string | description = "Usage: dd-simulate\n\t --help |\n\t model1.des_comp [model2.des_comp ... sync.rules]\n\t [--seed randomSeed]\n\t [--noevent e3 e4 ....]\n\t [--obsMin nbObsMin]\n\t [--obsMax nbObsMax]\n\t [--timeMin minSeconds]\n\t [--timeMax maxSeconds]\n\t [--generateFaults]\n\t [--xml simulation.xml]\n\t [--interactive]\n\t [--ptalog output.pta_log]\n\t [--nbSim number]\n\n\n Write an observable scenario on the standard output based on \n the model that contains at least one occurrence of the event e1, e2 \n and that does not contain the events e3 e4. The generated scenario \n contains [nbObsMin,nbObsMax] observations. If set, the delay between\n two event occurrences is in [minSeconds,maxSeconds]. Optionnaly, a xml\n file can be generated with option --xml. \n The option --generateFaults randomly selects unobservable events in\n the model that will be considered as fault in the generated scenario.\n --interactive is the interactive mode, invalidate any other simulation\n option. --ptalog write the observable simulation in a pta_log file.\n --nbSim defines the number of simulations (default is 1)" |
enum FileExtension |
Enumerator | |
---|---|
DESCOMP | |
DESCOMP | |
RULES | |
DESCOMP | |
DESCOMP | |
RULES | |
XML | |
ABSTRACTION | |
DIAGNOSER | |
DESCOMP | |
ARCHV | |
DESCOMP | |
RULES | |
XML | |
DESCOMP | |
RULES | |
XML | |
RULES |
Definition at line 65 of file Simulate.cc.
enum Option |
Definition at line 61 of file Simulate.cc.
void clean | ( | vector< Diades::Automata::ObservableComponent *> & | components | ) |
Clean the allocated structure for components
components | the set of loaded components |
Definition at line 104 of file Simulate.cc.
References Diades::Utils::LoggerFactory::destroy(), and Diades::Automata::EventFactory::destroy().
Referenced by main(), and readModels().
void exportLogIntoPtaLogFile | ( | const vector< Diades::Automata::ObservableComponent *> & | components, |
const Diades::Automata::ParametrizedSynchronisation & | rules, | ||
const list< Diades::Automata::Event > & | simulation, | ||
const Diades::Automata::ObservableMask & | mask, | ||
ostream & | file | ||
) |
Definition at line 633 of file Simulate.cc.
References Diades::Automata::SynchronisationRules::beginOfSynchronisedEvents(), Diades::Automata::SynchronisationRules::endOfSynchronisedEvents(), Diades::Automata::ObservableMask::isUnobservable(), Diades::Automata::ObservableMask::noEvent(), and Diades::Automata::ObservableMask::observableBegin().
Referenced by main().
vector<string> fileExtensions | ( | numberOfFileExtensions | ) |
Referenced by initialiseOptions(), and readParameters().
void generateFaults | ( | unsigned | seed, |
const vector< Diades::Automata::ObservableComponent *> | components, | ||
list< Diades::Automata::Event > & | faults | ||
) |
Generate faulty events from the component's models
seed | the random seed to initialise the generator |
components | the models of the component |
faults | the events that are select as faults. Note that the components are updated so that the selected events are set to faulty. |
Definition at line 351 of file Simulate.cc.
References Diades::Utils::generateRandomValue(), initialiseRandomGenerator(), and Diades::Utils::selectNValues().
Referenced by main().
void initialiseOptions | ( | ) |
Definition at line 77 of file Simulate.cc.
References DESCOMP, fileExtensions(), GENERATEFAULTS, HELP, INTERACTIVE, NBSIM, NOEVT, OBSMAX, OBSMIN, options(), PTALOG, RULES, SEED, TIMEMAX, TIMEMIN, and XML.
Referenced by main(), and setOptions().
vector<bool> isSet | ( | numberOfOptions | , |
false | |||
) |
Referenced by readParameters(), writeSimulation(), writeTimedSimulation(), and writeUntimedSimulation().
int main | ( | int | argc, |
char ** | argv | ||
) |
Main function of the program simulate
Basically, this function analyses the parameters to initiate the simulation.
argc | the number of parameters |
argv | the list of parameters |
Definition at line 692 of file Simulate.cc.
References clean(), exportLogIntoPtaLogFile(), generateFaults(), initialiseOptions(), Diades::Utils::initialiseSeed(), NBSIM, numberOfOptions, Diades::Automata::ParametrizedSynchronisation::open(), readModels(), readParameters(), SEED, startInteractiveSimulation(), startNonInteractiveSimulation(), and writeSimulation().
vector<string> options | ( | numberOfOptions | ) |
Referenced by initialiseOptions(), main(), and readParameters().
bool readModels | ( | const set< string > & | modelFiles, |
const string & | ruleFile, | ||
vector< Diades::Automata::ObservableComponent *> & | components, | ||
Diades::Automata::ParametrizedSynchronisation & | rules | ||
) |
Real the models from the input files
modelFiles | the list of des_comp files |
ruleFile | the file of the synchronisation rules |
components | the set of components to be loaded |
rules | the synchronisation rules that are loaded |
Definition at line 316 of file Simulate.cc.
References clean(), Diades::Automata::loadSynchronisationRules(), Diades::CmdInterface::printCommandLineError(), and Diades::Utils::saveLog().
Referenced by main(), and readParameters().
bool readParameters | ( | int | argc, |
char ** | argv, | ||
vector< unsigned > & | values, | ||
vector< set< string > > & | noevents, | ||
set< string > & | modelFiles, | ||
string & | ruleFile, | ||
string & | xmlFile, | ||
string & | ptaLogFile, | ||
bool & | faultGeneration, | ||
bool & | interactiveMode | ||
) |
Read the parameters of the dd-simulate command
argc | the number of arguments |
argv | the list of arguments |
values | set the values for timeMin timeMax obsMin obsMax seed |
noevents | set the 'noevent' list |
modelFiles | set the name of the model files |
ruleFile | set the name of the rule file |
xmlFile | set the name of the xml output |
ptaLogFile | set the name of the pta_log output |
faultGeneration | set whether faults must be generated at simulation time |
interactiveMode | set the interactive mode |
Definition at line 132 of file Simulate.cc.
References DESCOMP, description, fileExtensions(), GENERATEFAULTS, Diades::Utils::getFileExtension(), HELP, INTERACTIVE, isSet(), NBSIM, NOEVT, OBSMAX, OBSMIN, options(), Diades::CmdInterface::printCommandLineError(), printUsage(), PTALOG, readModels(), RULES, SEED, TIMEMAX, TIMEMIN, and XML.
Referenced by main().
bool startInteractiveSimulation | ( | const vector< Diades::Automata::ObservableComponent *> | components, |
const Diades::Automata::ParametrizedSynchronisation & | rules, | ||
Diades::Automata::ObservableMask & | mask, | ||
set< Diades::Automata::Event > & | events, | ||
list< Diades::Automata::Event > & | simulation | ||
) |
Definition at line 521 of file Simulate.cc.
References Diades::Automata::ComposableModel::component(), Diades::Automata::Component::events(), Diades::Automata::interactiveSimulation(), Diades::Utils::saveLog(), and toStream().
Referenced by main().
bool startNonInteractiveSimulation | ( | const vector< Diades::Automata::ObservableComponent *> | components, |
const Diades::Automata::ParametrizedSynchronisation & | rules, | ||
const vector< unsigned > & | values, | ||
const vector< set< string > > & | noevents, | ||
Diades::Automata::ObservableMask & | mask, | ||
set< Diades::Automata::Event > & | events, | ||
list< Diades::Automata::Event > & | simulation, | ||
unsigned | simNb | ||
) |
Definition at line 572 of file Simulate.cc.
References Diades::Automata::ComposableModel::component(), Diades::Automata::Component::events(), NOEVT, OBSMAX, OBSMIN, Diades::Utils::saveLog(), SEED, Diades::Automata::simulate(), and toStream().
Referenced by main().
void writeFinalPartOfSimulation | ( | const list< Diades::Automata::Event > & | simulation, |
bool | faultGeneration, | ||
const list< Diades::Automata::Event > & | faults, | ||
const set< Diades::Automata::Event > & | identifiables, | ||
const set< Diades::Automata::Event > & | nonIdentifiables, | ||
unsigned | nbObs, | ||
const set< Diades::Automata::Event > & | events, | ||
const Diades::Automata::ObservableMask & | mask | ||
) |
Definition at line 474 of file Simulate.cc.
References Diades::Utils::isNotIn(), Diades::Automata::ObservableMask::observableBegin(), Diades::Automata::ObservableMask::observableEnd(), toStream(), and Diades::Utils::unaryAnd().
Referenced by writeSimulation().
void writeSimulation | ( | const list< Diades::Automata::Event > & | simulation, |
vector< unsigned > & | values, | ||
bool | faultGeneration, | ||
const list< Diades::Automata::Event > & | faults, | ||
const set< Diades::Automata::Event > & | events, | ||
const Diades::Automata::ObservableMask & | mask | ||
) |
Definition at line 502 of file Simulate.cc.
References isSet(), TIMEMAX, TIMEMIN, writeFinalPartOfSimulation(), writeTimedSimulation(), and writeUntimedSimulation().
Referenced by main().
void writeTimedSimulation | ( | const list< Diades::Automata::Event > & | simulation, |
const Diades::Automata::ObservableMask & | mask, | ||
set< Diades::Automata::Event > & | observables, | ||
set< Diades::Automata::Event > & | nonObservables, | ||
unsigned | timeMin, | ||
unsigned | timeMax, | ||
unsigned & | nbObs | ||
) |
Definition at line 383 of file Simulate.cc.
References Diades::Automata::ObservableMask::isObservable(), isSet(), setVerboseLevel(), Diades::Automata::timeStamp(), Diades::Utils::VbOutput, and XML.
Referenced by writeSimulation().
void writeUntimedSimulation | ( | const list< Diades::Automata::Event > & | simulation, |
const Diades::Automata::ObservableMask & | mask, | ||
set< Diades::Automata::Event > & | observables, | ||
set< Diades::Automata::Event > & | nonObservables, | ||
unsigned & | nbObs | ||
) |
Definition at line 437 of file Simulate.cc.
References Diades::Automata::ObservableMask::isObservable(), isSet(), setVerboseLevel(), toStream(), Diades::Utils::VbOutput, and XML.
Referenced by writeSimulation().
string description = "Usage: dd-simulate\n\t --help |\n\t model1.des_comp [model2.des_comp ... sync.rules]\n\t [--seed randomSeed]\n\t [--noevent e3 e4 ....]\n\t [--obsMin nbObsMin]\n\t [--obsMax nbObsMax]\n\t [--timeMin minSeconds]\n\t [--timeMax maxSeconds]\n\t [--generateFaults]\n\t [--xml simulation.xml]\n\t [--interactive]\n\t [--ptalog output.pta_log]\n\t [--nbSim number]\n\n\n Write an observable scenario on the standard output based on \n the model that contains at least one occurrence of the event e1, e2 \n and that does not contain the events e3 e4. The generated scenario \n contains [nbObsMin,nbObsMax] observations. If set, the delay between\n two event occurrences is in [minSeconds,maxSeconds]. Optionnaly, a xml\n file can be generated with option --xml. \n The option --generateFaults randomly selects unobservable events in\n the model that will be considered as fault in the generated scenario.\n --interactive is the interactive mode, invalidate any other simulation\n option. --ptalog write the observable simulation in a pta_log file.\n --nbSim defines the number of simulations (default is 1)" |
Definition at line 75 of file Simulate.cc.
Referenced by readParameters().
unsigned numberOfFileExtensions = 2 |
Definition at line 69 of file Simulate.cc.
unsigned numberOfOptions = 12 |
Definition at line 68 of file Simulate.cc.
Referenced by main().