 |
Belle II Software
release-05-02-19
|
12 #include <framework/core/Module.h>
13 #include <framework/core/Path.h>
14 #include <framework/core/ModuleManager.h>
16 #include <framework/core/DataFlowVisualization.h>
17 #include <framework/datastore/DataStore.h>
25 const std::string unknownfillcolor =
"gray82";
42 std::ofstream file(filename.c_str());
43 file <<
"digraph allModules {\n";
44 file <<
" rankdir=LR;\n";
45 file <<
" compound=true;\n";
49 const bool steeringFileFlow =
true;
50 for (
const ModulePtr& mod : path.buildModulePathList())
65 file <<
" \"" << name <<
"\" [shape=box,style=filled,fillcolor=" << unknownfillcolor <<
"];\n";
70 B2INFO(
"Data flow diagram created. You can use 'dot dataflow.dot -Tps -o dataflow.ps' to create a PostScript file from it.");
76 const std::string graphname = pathName.empty() ?
"clusterMain" : (
"cluster" + pathName);
77 file <<
" subgraph \"" << graphname <<
"\" {\n";
78 if (pathName.empty()) {
79 file <<
" rank=min;\n";
81 file <<
" rank=same;\n";
83 file <<
" style=solid;\n";
84 file <<
" color=grey;\n";
85 file <<
" \"" << graphname <<
"_inv\" [shape=point,style=invis];\n";
86 std::string lastModule(
"");
88 for (
const ModulePtr& mod : path.getModules()) {
90 file <<
" \"" << module <<
"\";\n";
91 if (!lastModule.empty()) {
92 file <<
" \"" << lastModule <<
"\" -> \"" << module <<
"\" [color=black];\n";
94 if (mod->hasCondition()) {
95 for (
const auto& condition : mod->getAllConditions()) {
96 const std::string& conditionName = condition.getString();
97 plotPath(file, *condition.getPath(), conditionName);
98 file <<
" \"" << module <<
"\" -> \"cluster" << conditionName <<
"_inv\" " <<
99 "[color=grey,lhead=\"cluster" << conditionName <<
"\",label=\"" << conditionName <<
"\",fontcolor=grey];\n";
111 const std::string& label = mod.getName();
112 if (!steeringFileFlow)
113 file <<
"digraph \"" << name <<
"\" {\n";
114 file <<
" " << name <<
" [label=\"" << label <<
"\"];\n";
120 const std::set<std::string>& entries = moduleInfo.
entries[i];
121 const std::set<std::string>& relations = moduleInfo.
relations[i];
125 for (
const std::string& dsentry : entries) {
126 if (!steeringFileFlow)
127 file <<
" \"" << dsentry <<
"\" [shape=box,style=filled,fillcolor=" << fillcolor <<
"];\n";
130 file <<
" \"" << name <<
"\" -> \"" << dsentry <<
"\" [color=" << arrowcolor <<
"];\n";
133 file <<
" \"" << dsentry <<
"\" -> \"" << name <<
"\" [color=" << arrowcolor <<
"];\n";
137 for (
const std::string& relname : relations) {
138 size_t pos = relname.rfind(
"To");
139 if (pos == std::string::npos or pos != relname.find(
"To")) {
140 B2WARNING(
"generateModulePlot(): couldn't split relation name!");
145 const std::string from = relname.substr(0, pos);
146 const std::string to = relname.substr(pos + 2);
150 if (!steeringFileFlow)
151 file <<
" \"" << from <<
"\" [shape=box,style=filled,fillcolor=" << unknownfillcolor <<
"];\n";
154 if (!steeringFileFlow)
155 file <<
" \"" << to <<
"\" [shape=box,style=filled,fillcolor=" << unknownfillcolor <<
"];\n";
158 file <<
" \"" << from <<
"\" -> \"" << to <<
"\" [color=" << arrowcolor <<
",style=dashed];\n";
162 if (!steeringFileFlow)
181 const std::string filename = module +
".dot";
183 std::ofstream file(filename.c_str());
184 v.generateModulePlot(file, *modulePtr,
false);
193 for (
const auto& entry : info.entries) {
194 if (entry.count(name) != 0)
std::shared_ptr< Module > registerModule(const std::string &moduleName, std::string sharedLibPath="") noexcept(false)
Creates an instance of a module and registers it to the ModuleManager.
virtual void terminate()
This method is called at the end of the event processing.
DependencyMap & getDependencyMap()
Return map of depedencies between modules.
static ModuleManager & Instance()
Exception is thrown if the requested module could not be created by the ModuleManager.
static DataStore & Instance()
Instance of singleton Store.
Collect information about the dependencies between modules.
static void executeModuleAndCreateIOPlot(const std::string &module)
Create independent I/O graph for a single module (without requiring a steering file).
void visualizePath(const std::string &filename, const Path &path)
Create graphs with datastore inputs/outputs of each module in path.
@ c_Output
registered output.
std::string m_arrowcolor[DependencyMap::c_NEntryTypes]
arrow colors.
DataFlowVisualization(const DependencyMap *dependencyMap)
Constructor.
void setModule(const Module &mod)
Set the current module (for getCurrentModuleInfo())
const DependencyMap * m_map
Stores information on inputs/outputs of each module, as obtained by require()/createEntry();.
std::set< std::string > m_unknownArrays
set of array only being used in relations, for steering file visualisation.
std::string m_fillcolor[DependencyMap::c_NEntryTypes]
fill colors.
void generateModulePlot(std::ofstream &file, const Module &mod, bool steeringFileFlow=false)
Create I/O graph for a single module (written to file).
Abstract base class for different kinds of events.
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
@ c_NEntryTypes
size of this enum.
std::set< std::string > m_allOutputs
set of all outputs, for steering file visualisation.
static std::string getModuleID(const Module &mod)
Return unique ID for given module.
Implements a path consisting of Module and/or Path objects.
class to visualize data flow between modules.
bool checkArrayUnknown(const std::string &name, const DependencyMap::ModuleInfo &info)
If the given array name isn't found in any of info's fields, it is added to m_unknownArrays (and true...
virtual void initialize()
Initialize the Module.
const std::map< std::string, ModuleInfo > & getModuleInfoMap() const
return information on inputs/outputs of each module, as obtained by requireInput()/optionalInput()/re...
@ c_OptionalInput
optional input.
std::set< std::string > m_allInputs
set of all inputs (including optionals), for steering file visualisation.
static void plotPath(std::ofstream &file, const Path &path, const std::string &pathName="")
Create a subgraph for the given Path (including conditional paths).
std::set< std::string > relations[c_NEntryTypes]
relations between them.
Stores information on inputs/outputs of a module, as obtained by requireInput()/optionalInput()/regis...
std::set< std::string > entries[c_NEntryTypes]
objects/arrays.