32 #include<utils/CmdInterface.hh> 52 string description=
"Usage: dd-fault-generate\n\t --help |\n\t [--seed randomSeed] [--faultMax nbFaultMax] [file1.des_comp ...] \n\n\t Generate randomly a set of fault events out of the models. If no model file is\n\t provided as argument, read the input standard. The set of chosen faults\n\t is printed on the standard output.";
77 int main(
int argc,
char ** argv)
81 unsigned faultMax = 0;
83 list<string> modelFiles;
87 if(getOption<Option>(argv[index],
options,currentOption))
89 if(
isSet[currentOption])
95 isSet[currentOption] =
true;
101 if((index!=1) || (argc !=2))
103 printError(
"Incorrect use of option --help.");
114 getParameter<unsigned>(argc,argv,index,faultMax);
120 getParameter<unsigned>(argc, argv, index, seed);
133 vector<string>::const_iterator it =
137 printError(
"Unrecognized file extension in file name: " +
string(argv[index]));
144 modelFiles.push_back(
string(argv[index]));
151 vector<Event> unobservables;
152 if(modelFiles.empty())
160 for(ObservableComponent::EventIterator it = component.
eventBegin();
166 unobservables.push_back(*it);
178 for(
const string & filename : modelFiles)
182 ifstream file(filename.c_str());
185 for(ObservableComponent::EventIterator it = component.
eventBegin();
191 unobservables.push_back(*it);
204 if(faultMax < unobservables.size())
213 set<unsigned> indexes;
215 for(
const unsigned & index : indexes)
217 cout << unobservables[index] <<
" ";
InputIterator getFileExtension(const std::basic_string< CharType, CharTraits > &fileName, InputIterator begin, InputIterator end)
unsigned initialiseSeed()
vector< bool > isSet(numberOfOptions, false)
void selectNValues(unsigned int min, unsigned int max, unsigned int n, set< unsigned > &result)
void initialiseRandomGenerator()
An observable Component defined as a automaton.
virtual bool importDesCompModel(const string &filename)
Random generation utilities.
unsigned numberOfFileExtensions
EventIterator eventBegin() const
const ObservableMask & mask() const
vector< string > options(numberOfOptions)
void printError(string parameter, string message)
int main(int argc, char **argv)
EventIterator eventEnd() const
bool isUnobservable(const Event &e) const
Logging facilities for the Diades projects.
long generateRandomValue(long lower, long upper)
vector< string > fileExtensions(numberOfFileExtensions)
void printUsage(const po::options_description &desc)