summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/plugins')
-rw-r--r--src/uscxml/plugins/Plugins.cpp1
-rw-r--r--src/uscxml/plugins/Plugins.h1
-rw-r--r--src/uscxml/plugins/element/postpone/PostponeElement.cpp25
-rw-r--r--src/uscxml/plugins/element/postpone/PostponeElement.h7
-rw-r--r--src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp2
-rw-r--r--src/uscxml/plugins/invoker/http/HTTPServletInvoker.h1
-rw-r--r--src/uscxml/plugins/invoker/system/SystemInvoker.cpp44
-rw-r--r--src/uscxml/plugins/invoker/system/SystemInvoker.h40
-rw-r--r--src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp8
-rw-r--r--src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h2
10 files changed, 111 insertions, 20 deletions
diff --git a/src/uscxml/plugins/Plugins.cpp b/src/uscxml/plugins/Plugins.cpp
index ba27728..65740e1 100644
--- a/src/uscxml/plugins/Plugins.cpp
+++ b/src/uscxml/plugins/Plugins.cpp
@@ -6,6 +6,7 @@ namespace uscxml {
PLUMA_PROVIDER_SOURCE(DataModelImpl, 1, 1);
PLUMA_PROVIDER_SOURCE(IOProcessorImpl, 1, 1);
PLUMA_PROVIDER_SOURCE(InvokerImpl, 1, 1);
+PLUMA_PROVIDER_SOURCE(ElementImpl, 1, 1);
#endif
} \ No newline at end of file
diff --git a/src/uscxml/plugins/Plugins.h b/src/uscxml/plugins/Plugins.h
index 1e6ac0b..338dcaf 100644
--- a/src/uscxml/plugins/Plugins.h
+++ b/src/uscxml/plugins/Plugins.h
@@ -9,6 +9,7 @@ namespace uscxml {
#ifdef BUILD_AS_PLUGINS
PLUMA_PROVIDER_HEADER(IOProcessorImpl);
PLUMA_PROVIDER_HEADER(InvokerImpl);
+PLUMA_PROVIDER_HEADER(ElementImpl);
PLUMA_PROVIDER_HEADER(DataModelImpl);
#endif
diff --git a/src/uscxml/plugins/element/postpone/PostponeElement.cpp b/src/uscxml/plugins/element/postpone/PostponeElement.cpp
index 96cda6f..53782e1 100644
--- a/src/uscxml/plugins/element/postpone/PostponeElement.cpp
+++ b/src/uscxml/plugins/element/postpone/PostponeElement.cpp
@@ -40,6 +40,12 @@ void PostponeElement::enterElement(const Arabica::DOM::Node<std::string>& node)
}
}
+ // chaining causes the event to fire if the condition was true since postponing
+ bool chained = false;
+ if (HAS_ATTR(node, "chaining")) {
+ chained = boost::iequals(ATTR(node, "chaining"), "true");
+ }
+
// when will we refire the event?
std::string until;
try {
@@ -85,36 +91,29 @@ void PostponeElement::enterElement(const Arabica::DOM::Node<std::string>& node)
}
#endif
Event currEvent = _interpreter->getCurrentEvent();
- Resubmitter::postpone(currEvent, until, 0, _interpreter);
+ Resubmitter::postpone(currEvent, until, 0, chained, _interpreter);
}
void PostponeElement::exitElement(const Arabica::DOM::Node<std::string>& node) {
}
-void PostponeElement::Resubmitter::postpone(const Event& event, std::string until, uint64_t timeout, Interpreter* interpreter) {
+void PostponeElement::Resubmitter::postpone(const Event& event, std::string until, uint64_t timeout, bool chained, Interpreter* interpreter) {
Resubmitter* resubmitter = getInstance(interpreter);
- resubmitter->_postponedEvents.push_back(Postponed(event, until, timeout));
+ resubmitter->_postponedEvents.push_back(Postponed(event, until, timeout, chained));
}
void PostponeElement::Resubmitter::onStableConfiguration(Interpreter* interpreter) {
std::list<Postponed>::iterator eventIter = _postponedEvents.begin();
+ bool dispatched = false;
while(eventIter != _postponedEvents.end()) {
try {
// LOG(INFO) << "Reevaluating: >> " << eventIter->first << " <<";
- if (eventIter->timeout > 0 && tthread::chrono::system_clock::now() < eventIter->timeout) {
- // TODO: We should use an event queue
-// LOG(INFO) << " -> Timeout";
- eventIter->event.name += ".timeout";
- interpreter->receive(eventIter->event, true);
- _postponedEvents.erase(eventIter);
- break;
- }
- if (interpreter->getDataModel().evalAsBool(eventIter->until)) {
+ if ((!dispatched || eventIter->chaining) && interpreter->getDataModel().evalAsBool(eventIter->until)) {
// LOG(INFO) << " -> is TRUE";
eventIter->event.name += ".postponed";
interpreter->receive(eventIter->event, true);
_postponedEvents.erase(eventIter);
- break;
+ dispatched = true;
}
// LOG(INFO) << " -> is FALSE";
} catch (Event e) {
diff --git a/src/uscxml/plugins/element/postpone/PostponeElement.h b/src/uscxml/plugins/element/postpone/PostponeElement.h
index eb7a738..268493f 100644
--- a/src/uscxml/plugins/element/postpone/PostponeElement.h
+++ b/src/uscxml/plugins/element/postpone/PostponeElement.h
@@ -13,11 +13,12 @@ namespace uscxml {
class PostponeElement : public ExecutableContentImpl {
public:
struct Postponed {
- Postponed(const Event& event, const std::string& until, long timeout) :
- event(event), until(until), timeout(timeout) {}
+ Postponed(const Event& event, const std::string& until, long timeout, bool chaining = false) :
+ event(event), until(until), timeout(timeout), chaining(chaining) {}
Event event;
std::string until;
uint64_t timeout;
+ bool chaining;
};
PostponeElement() {}
@@ -48,7 +49,7 @@ protected:
}
static Resubmitter* getInstance(Interpreter* interpreter);
- static void postpone(const Event& event, std::string until, uint64_t timeout, Interpreter* interpreter);
+ static void postpone(const Event& event, std::string until, uint64_t timeout, bool chained, Interpreter* interpreter);
// InterpreterMonitor
void onStableConfiguration(Interpreter* interpreter);
diff --git a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp
index a3556c2..ad7bb15 100644
--- a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp
+++ b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp
@@ -30,7 +30,7 @@ HTTPServletInvoker::HTTPServletInvoker(Interpreter* interpreter) {
while(!HTTPServer::registerServlet(path.str(), this)) {
path.clear();
path.str();
- path << _interpreter->getName() << toStr(i++);
+ path << _interpreter->getName() << i++;
}
}
diff --git a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h
index 5d2d4b9..024616d 100644
--- a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h
+++ b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h
@@ -35,6 +35,7 @@ public:
virtual void setURL(const std::string& url) {
_url = url;
}
+ bool canAdaptPath() { return false; }
tthread::recursive_mutex& getMutex() {
return _mutex;
diff --git a/src/uscxml/plugins/invoker/system/SystemInvoker.cpp b/src/uscxml/plugins/invoker/system/SystemInvoker.cpp
new file mode 100644
index 0000000..492d6d3
--- /dev/null
+++ b/src/uscxml/plugins/invoker/system/SystemInvoker.cpp
@@ -0,0 +1,44 @@
+#include "SystemInvoker.h"
+#include <glog/logging.h>
+
+#ifdef BUILD_AS_PLUGINS
+#include <Pluma/Connector.hpp>
+#endif
+
+namespace uscxml {
+
+#ifdef BUILD_AS_PLUGINS
+PLUMA_CONNECTOR
+bool connect(pluma::Host& host) {
+ host.add(new SystemInvokerProvider());
+ return true;
+}
+#endif
+
+SystemInvoker::SystemInvoker() {
+}
+
+SystemInvoker::~SystemInvoker() {
+};
+
+boost::shared_ptr<IOProcessorImpl> SystemInvoker::create(Interpreter* interpreter) {
+ boost::shared_ptr<SystemInvoker> invoker = boost::shared_ptr<SystemInvoker>(new SystemInvoker());
+ invoker->_interpreter = interpreter;
+ return invoker;
+}
+
+Data SystemInvoker::getDataModelVariables() {
+ Data data;
+ return data;
+}
+
+void SystemInvoker::send(const SendRequest& req) {
+}
+
+void SystemInvoker::cancel(const std::string sendId) {
+}
+
+void SystemInvoker::invoke(const InvokeRequest& req) {
+}
+
+} \ No newline at end of file
diff --git a/src/uscxml/plugins/invoker/system/SystemInvoker.h b/src/uscxml/plugins/invoker/system/SystemInvoker.h
new file mode 100644
index 0000000..1440e79
--- /dev/null
+++ b/src/uscxml/plugins/invoker/system/SystemInvoker.h
@@ -0,0 +1,40 @@
+#ifndef SYSTEMINVOKER_H_W09J90F0
+#define SYSTEMINVOKER_H_W09J90F0
+
+#include <uscxml/Interpreter.h>
+
+#ifdef BUILD_AS_PLUGINS
+#include "uscxml/plugins/Plugins.h"
+#endif
+
+namespace uscxml {
+
+class SystemInvoker : public InvokerImpl {
+public:
+ SystemInvoker();
+ virtual ~SystemInvoker();
+ virtual boost::shared_ptr<IOProcessorImpl> create(Interpreter* interpreter);
+
+ virtual std::set<std::string> getNames() {
+ std::set<std::string> names;
+ names.insert("system");
+ names.insert("http://uscxml.tk.informatik.tu-darmstadt.de/#system");
+ return names;
+ }
+
+ virtual Data getDataModelVariables();
+ virtual void send(const SendRequest& req);
+ virtual void cancel(const std::string sendId);
+ virtual void invoke(const InvokeRequest& req);
+
+protected:
+};
+
+#ifdef BUILD_AS_PLUGINS
+PLUMA_INHERIT_PROVIDER(SystemInvoker, Invoker);
+#endif
+
+}
+
+
+#endif /* end of include guard: SYSTEMINVOKER_H_W09J90F0 */
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp
index 6c7a8fc..ad47896 100644
--- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp
+++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp
@@ -51,9 +51,11 @@ boost::shared_ptr<IOProcessorImpl> EventIOProcessor::create(Interpreter* interpr
// register at http server
std::string path = interpreter->getName();
- path += "/basichttp";
- if (!HTTPServer::registerServlet(path, io.get())) {
- LOG(ERROR) << "Cannot register basichttp ioprocessor at " << path << ": " << " already taken";
+ int i = 2;
+ while (!HTTPServer::registerServlet(path + "/basichttp", io.get())) {
+ std::stringstream ss;
+ ss << interpreter->getName() << i++;
+ path = ss.str();
}
return io;
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h
index 70c6bea..9bb717b 100644
--- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h
+++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h
@@ -43,6 +43,8 @@ public:
_url = url;
}
+ bool canAdaptPath() { return false; }
+
// URLMonitor
void downloadStarted(const URL& url);
void downloadCompleted(const URL& url);