summaryrefslogtreecommitdiffstats
path: root/src/uscxml/debug
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-07-23 20:34:15 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-07-23 20:34:15 (GMT)
commitafbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c (patch)
tree5cfa0f6db2af351c730c230a6d665b51d33cb0c7 /src/uscxml/debug
parentdc5f5ddfa10bf91524e6f7555c263eaea069dcb0 (diff)
downloaduscxml-afbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c.zip
uscxml-afbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c.tar.gz
uscxml-afbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c.tar.bz2
More work on lua datamodel
Diffstat (limited to 'src/uscxml/debug')
-rw-r--r--src/uscxml/debug/SCXMLDotWriter.cpp108
-rw-r--r--src/uscxml/debug/SCXMLDotWriter.h22
2 files changed, 65 insertions, 65 deletions
diff --git a/src/uscxml/debug/SCXMLDotWriter.cpp b/src/uscxml/debug/SCXMLDotWriter.cpp
index 88db575..16269a9 100644
--- a/src/uscxml/debug/SCXMLDotWriter.cpp
+++ b/src/uscxml/debug/SCXMLDotWriter.cpp
@@ -28,7 +28,7 @@ namespace uscxml {
using namespace Arabica::DOM;
using namespace Arabica::XPath;
-
+
SCXMLDotWriter::SCXMLDotWriter() {
_iteration = 0;
_indentation = 0;
@@ -56,7 +56,7 @@ SCXMLDotWriter::SCXMLDotWriter(Interpreter interpreter,
anchIter->element = _scxml;
if (anchIter->childDepth >= 0 && anchIter->transDepth == -1)
anchIter->transDepth = anchIter->childDepth;
-
+
_portType = anchIter->type;
assembleGraph(anchIter->element, anchIter->childDepth, anchIter->transDepth + 1);
}
@@ -121,7 +121,7 @@ void SCXMLDotWriter::writeTo(std::ostream& os) {
if (_histories.find(edgeIter->to)->second.from == _histories.find(edgeIter->to)->second.to)
continue;
}
-
+
os << getPrefix() << "\"" << edgeIter->from << "\"";
if (edgeIter->fromPort.size() > 0) {
os << std::string(":\"") + edgeIter->fromPort + "\":e";
@@ -129,7 +129,7 @@ void SCXMLDotWriter::writeTo(std::ostream& os) {
os << ":__name";
}
os << " -> ";
-
+
if (_histories.find(edgeIter->to) != _histories.end()) {
os << getPrefix() << "\"" << _histories.find(edgeIter->to)->second.to << "\"";
if (_histories.find(edgeIter->to)->second.toPort.size() > 0) {
@@ -153,11 +153,11 @@ void SCXMLDotWriter::writeTo(std::ostream& os) {
os << " [color=\"black\"]";
}
os << std::endl;
-
+
}
-
+
_indentation--;
-
+
os << "}" << std::endl;
}
@@ -191,7 +191,7 @@ void SCXMLDotWriter::assembleGraph(const Element<std::string>& state, int32_t ch
_graph[nodeId].node = state;
_graph[nodeId].portType = _portType;
-
+
if (childDepth == 0 && transDepth == 0) {
_graph[nodeId].isBorder = true;
}
@@ -250,7 +250,7 @@ void SCXMLDotWriter::assembleGraph(const Element<std::string>& state, int32_t ch
}
}
-
+
/**
* Walk the complete graph and draw reachable subset
*/
@@ -263,11 +263,11 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri
std::list<Node<std::string> > invisParents;
bool isVisible = (_graph.find(stateId) != _graph.end());
-
+
bool subgraph = InterpreterImpl::isCompound(stateElem) || InterpreterImpl::isParallel(stateElem);
bool fatherIsParallel = (stateElem.getParentNode() &&
- stateElem.getParentNode().getNodeType() == Node_base::ELEMENT_NODE &&
- InterpreterImpl::isParallel(Element<std::string>(stateElem.getParentNode())));
+ stateElem.getParentNode().getNodeType() == Node_base::ELEMENT_NODE &&
+ InterpreterImpl::isParallel(Element<std::string>(stateElem.getParentNode())));
if (subgraph) {
_indentation++;
@@ -282,13 +282,13 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri
os << getPrefix() << (fatherIsParallel ? "style=dashed" : "style=solid") << std::endl;
// os << getPrefix() << "ranksep=\"equally\"" << std::endl;
-
+
}
if (isVisible) {
// this state is visible!
const DotState& dotState = _graph.find(stateId)->second;
-
+
// is this a subgraph?
os << std::endl;
@@ -321,32 +321,32 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri
// is the state initial?
bool isInitial = _interpreter.getImpl()->isInitial(stateElem);
- // if (isInitial)
- // os << getPrefix() << "style=filled, fillcolor=lightgrey, " << std::endl;
+ // if (isInitial)
+ // os << getPrefix() << "style=filled, fillcolor=lightgrey, " << std::endl;
DotState::mmap_s_e_t::const_iterator destIterF, destIterB;
std::list<std::string> outPorts; // count unique keys
switch (dotState.portType) {
- case PORT_TARGET: // outports are per target
- for(DotState::mmap_s_e_t::const_iterator it = dotState.targets.begin(), end = dotState.targets.end();
- it != end;
- it = dotState.targets.upper_bound(it->first)) {
- outPorts.push_back(it->first);
- }
- break;
- case PORT_EVENT: // outports are per event
- for(DotState::mmap_s_e_t::const_iterator it = dotState.events.begin(), end = dotState.events.end();
- it != end;
- it = dotState.events.upper_bound(it->first)) {
- outPorts.push_back(it->first);
- }
- break;
- case PORT_TRANSITION:
- for (int i = 0; i < dotState.transitions.size(); i++) {
- outPorts.push_back(idForNode(dotState.transitions[i]));
- }
- break;
+ case PORT_TARGET: // outports are per target
+ for(DotState::mmap_s_e_t::const_iterator it = dotState.targets.begin(), end = dotState.targets.end();
+ it != end;
+ it = dotState.targets.upper_bound(it->first)) {
+ outPorts.push_back(it->first);
+ }
+ break;
+ case PORT_EVENT: // outports are per event
+ for(DotState::mmap_s_e_t::const_iterator it = dotState.events.begin(), end = dotState.events.end();
+ it != end;
+ it = dotState.events.upper_bound(it->first)) {
+ outPorts.push_back(it->first);
+ }
+ break;
+ case PORT_TRANSITION:
+ for (int i = 0; i < dotState.transitions.size(); i++) {
+ outPorts.push_back(idForNode(dotState.transitions[i]));
+ }
+ break;
}
os << getPrefix() << "label = < " << std::endl;
@@ -366,17 +366,17 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri
os << " <tr><td port=\"__name\" rowspan=\"" << outPorts.size() + 1 << "\"><b>" << nameForNode(stateElem) << "</b></td></tr>" << std::endl;
switch (dotState.portType) {
- case PORT_TARGET: // outports are per target
- writePerTargetPorts(os, outPorts, dotState);
- break;
- case PORT_EVENT: // outports are per event
- writePerEventPorts(os, outPorts, dotState);
- break;
- case PORT_TRANSITION:
- writePerTransitionPorts(os, outPorts, dotState);
- break;
+ case PORT_TARGET: // outports are per target
+ writePerTargetPorts(os, outPorts, dotState);
+ break;
+ case PORT_EVENT: // outports are per event
+ writePerEventPorts(os, outPorts, dotState);
+ break;
+ case PORT_TRANSITION:
+ writePerTransitionPorts(os, outPorts, dotState);
+ break;
}
-
+
// write details of the state
if (details.size() > 0) {
@@ -445,12 +445,12 @@ void SCXMLDotWriter::writePerTargetPorts(std::ostream& os, const std::list<std::
DotState::mmap_s_e_t::const_iterator destIterF, destIterB;
for(std::list<std::string>::const_iterator nameIter = outPorts.begin(); nameIter != outPorts.end(); nameIter++) {
-
+
// gather all events that activate the transition
std::string portName = *nameIter;
DotEdge edge(stateId, portName);
edge.fromPort = portName;
-
+
std::multimap<std::string, std::string> eventConds; // event to condition
std::pair <DotState::mmap_s_e_t::const_iterator, DotState::mmap_s_e_t::const_iterator> targetKeyRange = dotState.targets.equal_range(portName);
for (destIterB = targetKeyRange.first; destIterB != targetKeyRange.second; ++destIterB) {
@@ -467,11 +467,11 @@ void SCXMLDotWriter::writePerTargetPorts(std::ostream& os, const std::list<std::
}
if (_graph.find(portName) != _graph.end())
_edges.insert(edge);
-
+
typedef std::multimap<std::string, std::string>::iterator condIter_t;
std::stringstream outPortSS;
outPortSS << "<b>" << portName << "</b><br align=\"right\" />";
-
+
std::string opener = "{";
std::string closer;
std::string seperator;
@@ -479,19 +479,19 @@ void SCXMLDotWriter::writePerTargetPorts(std::ostream& os, const std::list<std::
for(iterA = eventConds.begin(); iterA != eventConds.end(); iterA = iterB) {
std::string eventName = iterA->first;
bool hasCondition = false;
-
+
std::pair <condIter_t, condIter_t> condRange = eventConds.equal_range(eventName);
for (iterB = condRange.first; iterB != condRange.second; ++iterB) {
hasCondition = true;
}
-
+
outPortSS << opener << seperator << eventName << (hasCondition ? "" : "");
seperator = ", ";
opener = "";
closer = "}";
}
outPortSS << closer;
-
+
os << " <tr><td port=\"" << portEscape(portName) << "\" align=\"right\">" << outPortSS.str() << "</td></tr>" << std::endl;
}
@@ -582,7 +582,7 @@ std::string SCXMLDotWriter::getDetailedLabel(const Element<std::string>& elem, i
if (HAS_ATTR(childElems.item(i), "event "))
details.name += "<br />event = " + ATTR(childElems.item(i), "event");
}
-
+
// send ---------
if (iequals(TAGNAME(childElems.item(i)), "send")) {
if (HAS_ATTR(childElems.item(i), "id"))
@@ -718,7 +718,7 @@ std::string SCXMLDotWriter::nameForNode(const Node<std::string>& node) {
std::string elemName;
if (node.getNodeType() == Node_base::ELEMENT_NODE) {
Element<std::string> elem = (Element<std::string>)node;
-
+
if (false) {
} else if (elem.getTagName() == "scxml") {
if (elem.hasAttribute("name") && !UUID::isUUID(elem.getAttribute("name"))) {
diff --git a/src/uscxml/debug/SCXMLDotWriter.h b/src/uscxml/debug/SCXMLDotWriter.h
index 79ea6c1..3ac697f 100644
--- a/src/uscxml/debug/SCXMLDotWriter.h
+++ b/src/uscxml/debug/SCXMLDotWriter.h
@@ -68,9 +68,9 @@ public:
Arabica::DOM::Element<std::string> element;
int32_t childDepth;
int32_t transDepth;
-
+
PortType type;
-
+
operator bool() const {
return childDepth != -1 || transDepth != -1 || element;
}
@@ -94,7 +94,7 @@ public:
std::set<std::string> childs;
std::set<std::string> initialchilds;
-
+
typedef std::multimap<std::string, Arabica::DOM::Element<std::string> > mmap_s_e_t;
};
@@ -108,7 +108,7 @@ public:
DotEdge() : type(EDGE_TRANSIION) {}
DotEdge(const std::string& from, const std::string& to) : type(EDGE_TRANSIION), from(from), to(to) {
}
-
+
bool operator< (const DotEdge& other) const {
return from + fromPort + to + toPort > other.from + other.fromPort + other.to + other.toPort;
}
@@ -121,7 +121,7 @@ public:
std::string toPort;
std::string toCompass;
};
-
+
SCXMLDotWriter();
~SCXMLDotWriter();
@@ -162,14 +162,14 @@ protected:
const Arabica::DOM::Element<std::string>& transition);
void assembleGraph(const Arabica::DOM::Element<std::string>& start,
- int32_t childDepth = std::numeric_limits<int32_t>::max(),
- int32_t transDepth = std::numeric_limits<int32_t>::max());
+ int32_t childDepth = std::numeric_limits<int32_t>::max(),
+ int32_t transDepth = std::numeric_limits<int32_t>::max());
void writeStateElement(std::ostream& os, const Arabica::DOM::Element<std::string>& state);
-
+
void writePerTransitionPorts(std::ostream& os, const std::list<std::string>& outPorts, const DotState& dotState);
void writePerEventPorts(std::ostream& os, const std::list<std::string>& outPorts, const DotState& dotState);
void writePerTargetPorts(std::ostream& os, const std::list<std::string>& outPorts, const DotState& dotState);
-
+
void writeUnknownNode(std::ostream& os, const std::string& targetId);
int _iteration;
@@ -179,7 +179,7 @@ protected:
std::map<std::string, DotState> _graph;
std::set<DotEdge> _edges;
-
+
// these are only set in ephemeral instances per monitor call
Arabica::DOM::Element<std::string> _transition;
Arabica::DOM::Element<std::string> _scxml;
@@ -187,7 +187,7 @@ protected:
std::string _xmlNSPrefix;
std::list<StateAnchor> _anchors;
std::map<std::string, DotEdge> _histories;
-
+
PortType _portType;
};