DiaDes
0.1
DIAgnosis of Discrete-Event System
|
This file implements the dd-run command that is used to run the model interactively (the model can be in aut/ddaut format). More...
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <regex>
#include <unordered_map>
#include <boost/program_options.hpp>
#include <diades/automata/experimental/AutFile.hh>
#include <diades/automata/experimental/DdAutFile.hh>
#include <diades/automata/experimental/DdAutFileDescriptor.hh>
#include <diades/automata/experimental/Printer.hh>
#include <diades/automata/experimental/StateMachine.hh>
#include <diades/automata/experimental/StateCreation.hh>
#include "../AutomataInterface.hh"
Go to the source code of this file.
Typedefs | |
using | State = AutFsm::State |
using | Transition = AutFsm::Transition |
using | Path = std::vector< std::pair< State, Transition > > |
using | TrIndexes = std::unordered_map< size_t, Transition > |
using | StIndexes = std::unordered_map< State::NodeId, State > |
using | Params = std::vector< std::string > |
Enumerations | |
enum | Command { back, commands, current, help, initial, next, path, start, quit, undo, unknown } |
Functions | |
const string | program ("dd-run") |
void | initialiseOptions (int argc, char *argv[], Poptions::options_description &desc, Poptions::variables_map &vm) |
void | printHelpCommand (Command cmd) |
Command | convertCommand (const std::string &cmd) |
size_t | runAut (const std::string &fileName) |
void | prompt (std::string &cmd) |
void | command (Command &cmd, Params ¶ms) |
void | initialiseStates (const DdAutFsm &fsm) |
void | printState (const DdAutFsm &fsm, const State &state, const DdAutStateManager &sManager) |
void | printTransition (const DdAutFsm &fsm, const Transition &transition, const DdAutEventManager &eManager, size_t index) |
void | printOutputTransitions (const DdAutFsm &fsm, const State &state, const DdAutEventManager &eManager, TrIndexes &transitions) |
void | printInputTransitions (const DdAutFsm &fsm, const State &state, const DdAutEventManager &eManager, TrIndexes &transitions) |
void | printCurrentState (const DdAutFsm &fsm, const State &state, const DdAutStateManager &sManager, const DdAutEventManager &eManager, TrIndexes &outputs, TrIndexes &inputs) |
void | printInitialStates (const DdAutFsm &fsm, const DdAutStateManager &sManager, const Params ¶ms) |
State::NodeId | getStateId (const std::string ¶m, bool &ok) |
size_t | getId (const std::string ¶m, bool &ok) |
void | initialiseFsm (const DdAutFsm &fsm, DdAutFsm::State &newInitialState, const DdAutStateManager &sManager, const DdAutEventManager &eManager, TrIndexes &outputs, TrIndexes &inputs, const Params ¶ms) |
void | commandNext (const DdAutFsm &fsm, Path ¤tPath, const DdAutStateManager &sManager, const DdAutEventManager &eManager, TrIndexes &outputs, TrIndexes &inputs, const Params ¶ms) |
void | commandBack (const DdAutFsm &fsm, Path ¤tPath, const DdAutStateManager &sManager, const DdAutEventManager &eManager, TrIndexes &outputs, TrIndexes &inputs, const Params ¶ms) |
void | printHelp (const Params ¶ms) |
void | commandCommands () |
void | commandInitial (const DdAutFsm &fsm, const DdAutStateManager &sManager, const Params ¶ms) |
void | commandStart (const DdAutFsm &fsm, Path ¤tPath, const DdAutStateManager &sManager, const DdAutEventManager &eManager, TrIndexes &outputs, TrIndexes &inputs, const Params ¶ms) |
void | commandCurrent (const DdAutFsm &fsm, Path ¤tPath, const DdAutStateManager &sManager, const DdAutEventManager &eManager, TrIndexes &outputs, TrIndexes &inputs) |
void | commandHelp (const Params ¶ms) |
void | commandUndo (const DdAutFsm &fsm, Path ¤tPath, const DdAutStateManager &sManager, const DdAutEventManager &eManager, TrIndexes &outputs, TrIndexes &inputs, const Params ¶ms) |
void | commandPath (const DdAutFsm &fsm, const Path ¤tPath, const DdAutStateManager &sManager, const DdAutEventManager &eManager, const Params ¶ms) |
void | commandUnknown () |
size_t | interactiveDdAut (const DdAutFsm &fsm, const DdAutStateManager &sManager, const DdAutEventManager &eManager) |
size_t | runDdaut (const std::string &fileName) |
size_t | runFsm (const std::string &fileName) |
int | main (int argc, char **argv) |
Variables | |
FileSuffixes | suffixes ({"aut","ddaut"}) |
std::unordered_map< Command, std::string > | cmds |
std::map< std::string, Command > | textTocmds |
std::unordered_map< Command, std::string > | cmdHelp |
StIndexes | states |
This file implements the dd-run command that is used to run the model interactively (the model can be in aut/ddaut format).
Definition in file Run.cc.
using Path = std::vector<std::pair<State,Transition> > |
using State = AutFsm::State |
using StIndexes = std::unordered_map<State::NodeId,State> |
using Transition = AutFsm::Transition |
using TrIndexes = std::unordered_map<size_t,Transition> |
enum Command |
Definition at line 240 of file Run.cc.
References convertCommand(), prompt(), and unknown.
Referenced by interactiveDdAut().
void commandBack | ( | const DdAutFsm & | fsm, |
Path & | currentPath, | ||
const DdAutStateManager & | sManager, | ||
const DdAutEventManager & | eManager, | ||
TrIndexes & | outputs, | ||
TrIndexes & | inputs, | ||
const Params & | params | ||
) |
Definition at line 479 of file Run.cc.
References back, getId(), printCurrentState(), and printHelpCommand().
Referenced by interactiveDdAut().
void commandCommands | ( | ) |
void commandCurrent | ( | const DdAutFsm & | fsm, |
Path & | currentPath, | ||
const DdAutStateManager & | sManager, | ||
const DdAutEventManager & | eManager, | ||
TrIndexes & | outputs, | ||
TrIndexes & | inputs | ||
) |
Definition at line 575 of file Run.cc.
References printCurrentState().
Referenced by interactiveDdAut().
void commandHelp | ( | const Params & | params | ) |
void commandInitial | ( | const DdAutFsm & | fsm, |
const DdAutStateManager & | sManager, | ||
const Params & | params | ||
) |
Definition at line 552 of file Run.cc.
References printInitialStates().
Referenced by interactiveDdAut().
void commandNext | ( | const DdAutFsm & | fsm, |
Path & | currentPath, | ||
const DdAutStateManager & | sManager, | ||
const DdAutEventManager & | eManager, | ||
TrIndexes & | outputs, | ||
TrIndexes & | inputs, | ||
const Params & | params | ||
) |
Definition at line 437 of file Run.cc.
References getId(), next, printCurrentState(), and printHelpCommand().
Referenced by interactiveDdAut().
void commandPath | ( | const DdAutFsm & | fsm, |
const Path & | currentPath, | ||
const DdAutStateManager & | sManager, | ||
const DdAutEventManager & | eManager, | ||
const Params & | params | ||
) |
Definition at line 632 of file Run.cc.
References Diades::Automata::Experimental::EventManager< _Event, _EventId, NullEvent, NullEventId, Hash >::getEvent(), Diades::Automata::Experimental::StateMachine< _StatePropertyId, _EventPropertyId, _NullStatePropertyId, _NullEventPropertyId >::getEvent(), path, printHelpCommand(), and printState().
Referenced by interactiveDdAut().
void commandStart | ( | const DdAutFsm & | fsm, |
Path & | currentPath, | ||
const DdAutStateManager & | sManager, | ||
const DdAutEventManager & | eManager, | ||
TrIndexes & | outputs, | ||
TrIndexes & | inputs, | ||
const Params & | params | ||
) |
Definition at line 560 of file Run.cc.
References initialiseFsm().
Referenced by interactiveDdAut().
void commandUndo | ( | const DdAutFsm & | fsm, |
Path & | currentPath, | ||
const DdAutStateManager & | sManager, | ||
const DdAutEventManager & | eManager, | ||
TrIndexes & | outputs, | ||
TrIndexes & | inputs, | ||
const Params & | params | ||
) |
Definition at line 600 of file Run.cc.
References printCurrentState(), printHelpCommand(), and undo.
Referenced by interactiveDdAut().
void commandUnknown | ( | ) |
Definition at line 680 of file Run.cc.
Referenced by interactiveDdAut().
Command convertCommand | ( | const std::string & | cmd | ) |
Definition at line 191 of file Run.cc.
References unknown.
Referenced by command(), and printHelp().
size_t getId | ( | const std::string & | param, |
bool & | ok | ||
) |
Definition at line 380 of file Run.cc.
Referenced by commandBack(), and commandNext().
State::NodeId getStateId | ( | const std::string & | param, |
bool & | ok | ||
) |
void initialiseFsm | ( | const DdAutFsm & | fsm, |
DdAutFsm::State & | newInitialState, | ||
const DdAutStateManager & | sManager, | ||
const DdAutEventManager & | eManager, | ||
TrIndexes & | outputs, | ||
TrIndexes & | inputs, | ||
const Params & | params | ||
) |
Definition at line 399 of file Run.cc.
References getStateId(), initialiseStates(), printCurrentState(), printHelpCommand(), and start.
Referenced by commandStart().
void initialiseOptions | ( | int | argc, |
char * | argv[], | ||
Poptions::options_description & | desc, | ||
Poptions::variables_map & | vm | ||
) |
void initialiseStates | ( | const DdAutFsm & | fsm | ) |
Definition at line 268 of file Run.cc.
References Diades::Automata::Experimental::StateMachine< _StatePropertyId, _EventPropertyId, _NullStatePropertyId, _NullEventPropertyId >::stateBegin(), and Diades::Automata::Experimental::StateMachine< _StatePropertyId, _EventPropertyId, _NullStatePropertyId, _NullEventPropertyId >::stateEnd().
Referenced by initialiseFsm().
size_t interactiveDdAut | ( | const DdAutFsm & | fsm, |
const DdAutStateManager & | sManager, | ||
const DdAutEventManager & | eManager | ||
) |
Definition at line 685 of file Run.cc.
References back, command(), commandBack(), commandCommands(), commandCurrent(), commandHelp(), commandInitial(), commandNext(), commandPath(), commands, commandStart(), commandUndo(), commandUnknown(), current, help, initial, next, path, quit, start, SUCCESS, undo, and unknown.
Referenced by runDdaut().
int main | ( | int | argc, |
char ** | argv | ||
) |
Main file of the dd-complete command
argc | |
argv |
Definition at line 849 of file Run.cc.
References initialiseOptions(), Diades::CmdInterface::printCommandLineError(), printUsage(), program(), and runFsm().
void printCurrentState | ( | const DdAutFsm & | fsm, |
const State & | state, | ||
const DdAutStateManager & | sManager, | ||
const DdAutEventManager & | eManager, | ||
TrIndexes & | outputs, | ||
TrIndexes & | inputs | ||
) |
Definition at line 331 of file Run.cc.
References printInputTransitions(), printOutputTransitions(), and printState().
Referenced by commandBack(), commandCurrent(), commandNext(), commandUndo(), and initialiseFsm().
void printHelp | ( | const Params & | params | ) |
Definition at line 521 of file Run.cc.
References convertCommand(), help, and printHelpCommand().
Referenced by commandHelp().
void printHelpCommand | ( | Command | cmd | ) |
Definition at line 185 of file Run.cc.
Referenced by commandBack(), commandNext(), commandPath(), commandUndo(), initialiseFsm(), printHelp(), and printInitialStates().
void printInitialStates | ( | const DdAutFsm & | fsm, |
const DdAutStateManager & | sManager, | ||
const Params & | params | ||
) |
Definition at line 345 of file Run.cc.
References initial, Diades::Automata::Experimental::StateMachine< _StatePropertyId, _EventPropertyId, _NullStatePropertyId, _NullEventPropertyId >::initialStateBegin(), Diades::Automata::Experimental::StateMachine< _StatePropertyId, _EventPropertyId, _NullStatePropertyId, _NullEventPropertyId >::initialStateEnd(), printHelpCommand(), and printState().
Referenced by commandInitial().
void printInputTransitions | ( | const DdAutFsm & | fsm, |
const State & | state, | ||
const DdAutEventManager & | eManager, | ||
TrIndexes & | transitions | ||
) |
Definition at line 315 of file Run.cc.
References Diades::Automata::Experimental::StateMachine< _StatePropertyId, _EventPropertyId, _NullStatePropertyId, _NullEventPropertyId >::inputTransitionBegin(), Diades::Automata::Experimental::StateMachine< _StatePropertyId, _EventPropertyId, _NullStatePropertyId, _NullEventPropertyId >::inputTransitionEnd(), and printTransition().
Referenced by printCurrentState().
void printOutputTransitions | ( | const DdAutFsm & | fsm, |
const State & | state, | ||
const DdAutEventManager & | eManager, | ||
TrIndexes & | transitions | ||
) |
Definition at line 299 of file Run.cc.
References Diades::Automata::Experimental::StateMachine< _StatePropertyId, _EventPropertyId, _NullStatePropertyId, _NullEventPropertyId >::outputTransitionBegin(), Diades::Automata::Experimental::StateMachine< _StatePropertyId, _EventPropertyId, _NullStatePropertyId, _NullEventPropertyId >::outputTransitionEnd(), and printTransition().
Referenced by printCurrentState().
void printState | ( | const DdAutFsm & | fsm, |
const State & | state, | ||
const DdAutStateManager & | sManager | ||
) |
Definition at line 285 of file Run.cc.
References Diades::Automata::Experimental::StatePropertyManager< _StateProperty, _StatePropertyId, NullStProperty, NullStPropertyId, Hash >::getStateProperty(), and Diades::Automata::Experimental::StateMachine< _StatePropertyId, _EventPropertyId, _NullStatePropertyId, _NullEventPropertyId >::getStatePropertyId().
Referenced by commandPath(), printCurrentState(), and printInitialStates().
void printTransition | ( | const DdAutFsm & | fsm, |
const Transition & | transition, | ||
const DdAutEventManager & | eManager, | ||
size_t | index | ||
) |
Definition at line 291 of file Run.cc.
References Diades::Automata::Experimental::EventManager< _Event, _EventId, NullEvent, NullEventId, Hash >::getEvent(), and Diades::Automata::Experimental::StateMachine< _StatePropertyId, _EventPropertyId, _NullStatePropertyId, _NullEventPropertyId >::getEvent().
Referenced by printInputTransitions(), and printOutputTransitions().
const string program | ( | "dd-run" | ) |
Referenced by main().
size_t runAut | ( | const std::string & | fileName | ) |
Load the file (aut file) and start the interactive run process
fileName | aut file to load |
Definition at line 210 of file Run.cc.
References Diades::Automata::Experimental::fromAutFile(), Diades::CmdInterface::printCommandLineError(), and SUCCESS.
Referenced by runFsm().
size_t runDdaut | ( | const std::string & | fileName | ) |
Load the file (ddaut file) and start the interactive run process
fileName | ddaut file to load |
Definition at line 781 of file Run.cc.
References Diades::Automata::Experimental::fsmFromDescriptor(), interactiveDdAut(), Diades::CmdInterface::printCommandLineError(), and Diades::Automata::Experimental::DdAutFileDescriptor::readStream().
Referenced by runFsm().
size_t runFsm | ( | const std::string & | fileName | ) |
Load the file (aut file) and start the interactive run process
fileName | aut file to load |
Definition at line 819 of file Run.cc.
References ERROR_UNHANDLED_EXCEPTION, Diades::CmdInterface::FileSuffixes::match(), Diades::CmdInterface::printCommandLineError(), runAut(), runDdaut(), and suffixes.
Referenced by main().
std::unordered_map<Command, std::string> cmds |
StIndexes states |
Definition at line 266 of file Run.cc.
Referenced by Diades::Automata::Trace::acceptors(), Diades::Automata::Experimental::Projection::aggregateElementaryBeliefStates(), Diades::Automata::Experimental::determine(), export2Hydiag(), generateLatexComponents(), generateLatexPreamble(), initialiseOptions(), StateTable::insert(), Diades::Automata::Component::isInitial(), Diades::Automata::Experimental::levelOfChoice(), main(), Diades::Automata::Experimental::ComposableModel< Fsm, StateCreator >::newState(), Diades::Automata::purgeNonPredecessors(), Diades::Automata::Experimental::setLevel(), Diades::Automata::Experimental::setLevelStateAndPropagate(), StateTable::StateTable(), and Diades::Automata::StateTable::StateTable().
FileSuffixes suffixes({"aut","ddaut"}) |
Referenced by runFsm().
std::map<std::string,Command> textTocmds |