diff options
Diffstat (limited to 'src/uscxml')
-rw-r--r-- | src/uscxml/Interpreter.cpp | 1 | ||||
-rw-r--r-- | src/uscxml/messages/InvokeRequest.h | 3 | ||||
-rw-r--r-- | src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp | 5 | ||||
-rw-r--r-- | src/uscxml/transform/ChartToPromela.cpp | 21 | ||||
-rw-r--r-- | src/uscxml/transform/ChartToPromela.h | 2 |
5 files changed, 24 insertions, 8 deletions
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 6aca93c..4dabcb9 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -1805,6 +1805,7 @@ void InterpreterImpl::delayedSend(void* userdata, std::string eventName) { void InterpreterImpl::invoke(const Arabica::DOM::Element<std::string>& element) { InvokeRequest invokeReq; + invokeReq.elem = element; invokeReq.Event::eventType = Event::EXTERNAL; try { // type diff --git a/src/uscxml/messages/InvokeRequest.h b/src/uscxml/messages/InvokeRequest.h index ac5f6f7..7cecf8d 100644 --- a/src/uscxml/messages/InvokeRequest.h +++ b/src/uscxml/messages/InvokeRequest.h @@ -60,7 +60,8 @@ protected: std::string type; std::string src; bool autoForward; - + Arabica::DOM::Element<std::string> elem; + friend USCXML_API std::ostream& operator<< (std::ostream& os, const InvokeRequest& sendReq); }; diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp index 9506867..5a447c4 100644 --- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp @@ -19,6 +19,7 @@ #include "USCXMLInvoker.h" #include <glog/logging.h> +#include "uscxml/DOMUtils.h" #ifdef BUILD_AS_PLUGINS #include <Pluma/Connector.hpp> @@ -88,6 +89,10 @@ void USCXMLInvoker::invoke(const InvokeRequest& req) { LOG(ERROR) << "Cannot invoke nested SCXML interpreter, neither src attribute nor content nor DOM is given"; } if (_invokedInterpreter) { + if (req.elem && HAS_ATTR(req.elem, "initial")) { + _invokedInterpreter.setInitalConfiguration(InterpreterImpl::tokenize(ATTR(req.elem, "initial"))); + } + DataModel dataModel(_invokedInterpreter.getImpl()->getDataModel()); _invokedInterpreter.getImpl()->setParentQueue(&_parentQueue); diff --git a/src/uscxml/transform/ChartToPromela.cpp b/src/uscxml/transform/ChartToPromela.cpp index 092a284..9d297ad 100644 --- a/src/uscxml/transform/ChartToPromela.cpp +++ b/src/uscxml/transform/ChartToPromela.cpp @@ -1566,7 +1566,7 @@ void ChartToPromela::writeExecutableContent(std::ostream& stream, const Arabica: } else if(TAGNAME(nodeElem) == "log") { std::string label = (HAS_ATTR(nodeElem, "label") ? ATTR(nodeElem, "label") : ""); - std::string expr = (HAS_ATTR(nodeElem, "expr") ? ATTR(nodeElem, "expr") : ""); + std::string expr = (HAS_ATTR(nodeElem, "expr") ? ADAPT_SRC(ATTR(nodeElem, "expr")) : ""); std::string trimmedExpr = boost::trim_copy(expr); bool isStringLiteral = (boost::starts_with(trimmedExpr, "\"") || boost::starts_with(trimmedExpr, "'")); @@ -2034,7 +2034,7 @@ void ChartToPromela::writeDeclarations(std::ostream& stream) { } stream << "hidden int " << _prefix << "_index; /* helper for indexless foreach loops */" << std::endl; - stream << "hidden int " << _prefix << "_pid; /* the process id running this machine */" << std::endl; + stream << "hidden int " << _prefix << "procid; /* the process id running this machine */" << std::endl; stream << "bool " << _prefix << "spontaneous; /* whether to take spontaneous transitions */" << std::endl; stream << "bool " << _prefix << "done; /* is the state machine stopped? */" << std::endl; stream << "bool " << _prefix << "canceled; /* is the state machine canceled? */" << std::endl; @@ -2078,6 +2078,11 @@ void ChartToPromela::writeDeclarations(std::ostream& stream) { std::string identifier = (HAS_ATTR_CAST(data, "id") ? ATTR_CAST(data, "id") : ""); std::string expression = (HAS_ATTR_CAST(data, "expr") ? ATTR_CAST(data, "expr") : ""); + if (expression.size() == 0 && HAS_ATTR_CAST(data, "src")) { + URL dataSrc(ATTR_CAST(data, "src")); + dataSrc.toAbsolute(_baseURI); + expression = dataSrc.getInContent(); + } std::string type = boost::trim_copy(HAS_ATTR_CAST(data, "type") ? ATTR_CAST(data, "type") : ""); _dataModelVars.insert(identifier); @@ -2220,11 +2225,11 @@ void ChartToPromela::writeStartInvoker(std::ostream& stream, const Arabica::DOM: void ChartToPromela::writeFSM(std::ostream& stream) { NodeSet<std::string> transitions; - stream << "proctype " << _prefix << "run() {" << std::endl; + stream << "proctype " << (_prefix.size() == 0 ? "machine_" : _prefix) << "run() {" << std::endl; stream << " " << _prefix << "done = false;" << std::endl; stream << " " << _prefix << "canceled = false;" << std::endl; stream << " " << _prefix << "spontaneous = true;" << std::endl; - stream << " " << _prefix << "_pid = _pid;" << std::endl; + stream << " " << _prefix << "procid = _pid;" << std::endl; // write initial transition // transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", _startState); // assert(transitions.size() == 1); @@ -2301,7 +2306,7 @@ void ChartToPromela::writeFSM(std::ostream& stream) { stream << " if" << std::endl; stream << " :: (tmpE.delay < lowestDelay || lowestDelay == 0) -> {" << std::endl; stream << " lowestDelay = tmpE.delay;" << std::endl; - stream << " nextPid = " << queueIter->second->_prefix << "_pid;" << std::endl; + stream << " nextPid = " << queueIter->second->_prefix << "procid;" << std::endl; stream << " }" << std::endl; stream << " :: else -> skip;" << std::endl; stream << " fi;" << std::endl; @@ -2627,7 +2632,7 @@ void ChartToPromela::writeMain(std::ostream& stream) { } if (_globalEventSource) _globalEventSource.writeStart(stream, 1); - stream << " run " << _prefix << "run() priority 10;" << std::endl; + stream << " run " << (_prefix.size() == 0 ? "machine_" : _prefix) << "run() priority 10;" << std::endl; stream << "}" << std::endl; } @@ -2717,6 +2722,10 @@ void ChartToPromela::initNodes() { // std::cout << invokes[i] << std::endl; + // we found machines but have no prefix + if (_prefix.length() == 0) + _prefix = "MAIN_"; + _machines[invokes[i]] = new ChartToPromela(nested); _machines[invokes[i]]->_analyzer = _analyzer; _machines[invokes[i]]->_parent = this; diff --git a/src/uscxml/transform/ChartToPromela.h b/src/uscxml/transform/ChartToPromela.h index e322eaf..2523bf6 100644 --- a/src/uscxml/transform/ChartToPromela.h +++ b/src/uscxml/transform/ChartToPromela.h @@ -280,7 +280,7 @@ public: void writeTo(std::ostream& stream); protected: - ChartToPromela(const Interpreter& other) : TransformerImpl(), ChartToFSM(other), _analyzer(NULL), _machinesAll(NULL), _parent(NULL), _parentTopMost(NULL), _machinesAllPerId(NULL), _prefix("MAIN_") {} + ChartToPromela(const Interpreter& other) : TransformerImpl(), ChartToFSM(other), _analyzer(NULL), _machinesAll(NULL), _parent(NULL), _parentTopMost(NULL), _machinesAllPerId(NULL) {} void initNodes(); |