[DEV/DEBUG] add an API to have better dot display and correct reversi display of stream in dot

This commit is contained in:
Edouard DUPIN 2016-11-17 00:18:49 +01:00
parent 2483530165
commit afc8b186c7
5 changed files with 144 additions and 44 deletions

View File

@ -59,6 +59,20 @@ void audio::drain::Algo::configurationChange() {
}
}
std::string audio::drain::Algo::getDotDesc() {
std::string out;
if (m_input.getFormat() != m_output.getFormat()) {
out += "\\nformat: " + etk::to_string(m_input.getFormat()) + "->" + etk::to_string(m_output.getFormat());
}
if (m_input.getMap() != m_output.getMap()) {
out += "\\nmap: " + etk::to_string(m_input.getMap()) + "->" + etk::to_string(m_output.getMap());
}
if (m_input.getFrequency() != m_output.getFrequency()) {
out += "\\nsamplerate: " + etk::to_string(m_input.getFrequency()) + "->" + etk::to_string(m_output.getFrequency());
}
return out;
}
size_t audio::drain::Algo::needInputData(size_t _output) {
size_t input = _output;
/* NOT good at all ...

View File

@ -47,6 +47,8 @@ namespace audio {
void setType(const std::string& _type) {
m_type = _type;
}
public:
virtual std::string getDotDesc();
private:
bool m_temporary;
public:

View File

@ -456,62 +456,115 @@ static void link(etk::FSNode& _node, const std::string& _first, const std::strin
}
}
void audio::drain::Process::generateDot(etk::FSNode& _node, int32_t _offset, int32_t _basicID, std::string& _nameIn, std::string& _nameOut, bool _reserseGraph) {
void audio::drain::Process::generateDot(etk::FSNode& _node,
int32_t _offset,
int32_t _basicID,
std::string& _nameIn,
std::string& _nameOut,
bool _reserseGraph) {
_node << " subgraph clusterNode_" << _basicID << "_process {\n";
_node << " label=\"Drain::Process" << (_reserseGraph?"_R":"_N") << "\";\n";
_node << " node [shape=ellipse];\n";
if (_reserseGraph == false) {
// ----------------------
// -- STEP 1 --
// ----------------------
_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in";
_node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat())
<< "\\n freq=" << getInputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n";
} else {
_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out";
_node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat())
<< "\\n freq=" << getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n";
}
std::string connectString = _nameIn;
_node << " node [shape=box];\n";
if (_reserseGraph == false) {
// ----------------------
// -- STEP 2 --
// ----------------------
std::string connectString = _nameIn;
_node << " node [shape=box];\n";
// ----------------------
// -- STEP 3 --
// ----------------------
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
if (m_listAlgo[iii] == nullptr) {
continue;
}
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n";
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
if (m_listAlgo[iii]->getName() != "") {
_node << "\\nname='" << m_listAlgo[iii]->getName() << "'";
}
std::string tmpDesc = m_listAlgo[iii]->getDotDesc();
if (tmpDesc.size() != 0) {
_node << tmpDesc;
}
_node << "\" ];\n";
link(_node, connectString, "->", connectStringSecond);
connectString = connectStringSecond;
}
} else {
//for (int32_t iii=m_listAlgo.size()-1; iii>=0; --iii) {
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
if (m_listAlgo[iii] == nullptr) {
continue;
}
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n";
link(_node, connectStringSecond, "<-", connectString);
connectString = connectStringSecond;
}
}
_node << " node [shape=ellipse];\n";
if (_reserseGraph == false) {
// ----------------------
// -- STEP 4 --
// ----------------------
_node << " node [shape=ellipse];\n";
// ----------------------
// -- STEP 5 --
// ----------------------
_nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out";
_node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat())
<< "\\n freq=" << getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n";
// ----------------------
// -- STEP 6 --
// ----------------------
link(_node, connectString, "->", _nameOut);
} else {
// ----------------------
// -- STEP 1 --
// ----------------------
_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out";
_node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat())
<< "\\n freq=" << getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n";
// ----------------------
// -- STEP 2 --
// ----------------------
std::string connectString = _nameIn;
_node << " node [shape=box];\n";
// ----------------------
// -- STEP 3 --
// ----------------------
for (int32_t iii=m_listAlgo.size()-1; iii>=0; --iii) {
//for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
if (m_listAlgo[iii] == nullptr) {
continue;
}
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
if (m_listAlgo[iii]->getName() != "") {
_node << "\\nname='" << m_listAlgo[iii]->getName() << "'";
}
std::string tmpDesc = m_listAlgo[iii]->getDotDesc();
if (tmpDesc.size() != 0) {
_node << tmpDesc;
}
_node << "\" ];\n";
//link(_node, connectStringSecond, "<-", connectString);
link(_node, connectString, "<-", connectStringSecond);
//link(_node, connectStringSecond, "->", connectString);
connectString = connectStringSecond;
}
// ----------------------
// -- STEP 4 --
// ----------------------
_node << " node [shape=ellipse];\n";
// ----------------------
// -- STEP 5 --
// ----------------------
_nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in";
_node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat())
<< "\\n freq=" << getInputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n";
}
if (_reserseGraph == false) {
link(_node, connectString, "->", _nameOut);
} else {
link(_node, _nameOut, "<-", connectString);
// ----------------------
// -- STEP 6 --
// ----------------------
link(_node, connectString, "<-", _nameOut);
}
_node << " }\n";
}
@ -540,7 +593,15 @@ void audio::drain::Process::generateDotProcess(etk::FSNode& _node, int32_t _offs
continue;
}
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n";
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
if (m_listAlgo[iii]->getName() != "") {
_node << "\\nname='" << m_listAlgo[iii]->getName() << "'";
}
std::string tmpDesc = m_listAlgo[iii]->getDotDesc();
if (tmpDesc.size() != 0) {
_node << tmpDesc;
}
_node << "\" ];\n";
link(_node, connectString, "->", connectStringSecond);
connectString = connectStringSecond;
}
@ -551,7 +612,15 @@ void audio::drain::Process::generateDotProcess(etk::FSNode& _node, int32_t _offs
continue;
}
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n";
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
if (m_listAlgo[iii]->getName() != "") {
_node << "\\nname='" << m_listAlgo[iii]->getName() << "'";
}
std::string tmpDesc = m_listAlgo[iii]->getDotDesc();
if (tmpDesc.size() != 0) {
_node << tmpDesc;
}
_node << "\" ];\n";
link(_node, connectStringSecond, "<-", connectString);
connectString = connectStringSecond;
}

View File

@ -310,7 +310,7 @@ std::vector<audio::format> audio::drain::Volume::getFormatSupportedInput() {
};
std::vector<audio::format> audio::drain::Volume::getFormatSupportedOutput() {
std::vector<audio::format> tmp;
std::vector<audio::format> tmp;
if (m_input.getFormat() == audio::format_float) {
tmp.push_back(audio::format_float);
}
@ -378,11 +378,11 @@ void audio::drain::Volume::addVolumeStage(const ememory::SharedPtr<audio::drain:
bool audio::drain::Volume::setParameter(const std::string& _parameter, const std::string& _value) {
if (_parameter == "FLOW") {
// set Volume ...
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
if (m_volumeList[iii] == nullptr) {
for (auto &it : m_volumeList) {
if (it == nullptr) {
continue;
}
if (m_volumeList[iii]->getName() == "FLOW") {
if (it->getName() == "FLOW") {
float value = 0;
if (sscanf(_value.c_str(), "%fdB", &value) != 1) {
return false;
@ -392,7 +392,7 @@ bool audio::drain::Volume::setParameter(const std::string& _parameter, const std
DRAIN_ERROR("Can not set volume ... : '" << _parameter << "' out of range : [-300..300]");
return false;
}
m_volumeList[iii]->setVolume(value);
it->setVolume(value);
DRAIN_DEBUG("Set volume : FLOW = " << value << " dB (from:" << _value << ")");
volumeChange();
return true;
@ -406,12 +406,12 @@ bool audio::drain::Volume::setParameter(const std::string& _parameter, const std
std::string audio::drain::Volume::getParameter(const std::string& _parameter) const {
if (_parameter == "FLOW") {
// set Volume ...
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
if (m_volumeList[iii] == nullptr) {
for (auto &it : m_volumeList) {
if (it == nullptr) {
continue;
}
if (m_volumeList[iii]->getName() == "FLOW") {
return etk::to_string(m_volumeList[iii]->getVolume()) + "dB";
if (it->getName() == "FLOW") {
return etk::to_string(it->getVolume()) + "dB";
}
}
}
@ -422,11 +422,11 @@ std::string audio::drain::Volume::getParameter(const std::string& _parameter) co
std::string audio::drain::Volume::getParameterProperty(const std::string& _parameter) const {
if (_parameter == "FLOW") {
// set Volume ...
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
if (m_volumeList[iii] == nullptr) {
for (auto &it : m_volumeList) {
if (it == nullptr) {
continue;
}
if (m_volumeList[iii]->getName() == "FLOW") {
if (it->getName() == "FLOW") {
return "[-300..300]dB";
}
}
@ -435,3 +435,16 @@ std::string audio::drain::Volume::getParameterProperty(const std::string& _param
return "[ERROR]";
}
std::string audio::drain::Volume::getDotDesc() {
std::string out = audio::drain::Algo::getDotDesc();
for (auto &it : m_volumeList) {
if (it == nullptr) {
continue;
}
out += "\\n" + it->getName() + "=" + etk::to_string(it->getVolume()) + "dB";
if (it->getMute() == true) {
out += " MUTE";
}
}
return out;
}

View File

@ -92,6 +92,8 @@ namespace audio {
virtual std::string getParameterProperty(const std::string& _parameter) const;
public:
void volumeChange();
public:
virtual std::string getDotDesc();
};
}
}