summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/invoker
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-01-20 17:34:02 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-01-20 17:34:02 (GMT)
commita0666b3ab907c0036f5e3f036b32e9ec5a6e551d (patch)
treed3db8b6beb8622fa41b87b0934d4702cf0b61819 /src/uscxml/plugins/invoker
parentf4f05b40c8c464daf1e11df6fcdb63d05766ed1f (diff)
downloaduscxml-a0666b3ab907c0036f5e3f036b32e9ec5a6e551d.zip
uscxml-a0666b3ab907c0036f5e3f036b32e9ec5a6e551d.tar.gz
uscxml-a0666b3ab907c0036f5e3f036b32e9ec5a6e551d.tar.bz2
Regenerated V8 DOM and beautified code
Diffstat (limited to 'src/uscxml/plugins/invoker')
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/CompositeDisplay.cpp147
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/CompositeDisplay.h50
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp576
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h110
-rw-r--r--src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp80
-rw-r--r--src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h16
-rw-r--r--src/uscxml/plugins/invoker/sample/SampleInvoker.cpp2
-rw-r--r--src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp10
-rw-r--r--src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp68
-rw-r--r--src/uscxml/plugins/invoker/umundo/UmundoInvoker.h2
10 files changed, 531 insertions, 530 deletions
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/CompositeDisplay.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/CompositeDisplay.cpp
index d7e247b..6d2a8e2 100644
--- a/src/uscxml/plugins/invoker/graphics/openscenegraph/CompositeDisplay.cpp
+++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/CompositeDisplay.cpp
@@ -11,117 +11,116 @@ CompositeDisplay::CompositeDisplay(unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height,
- int screenId)
-{
- _waitForViewOp = false;
- unsigned int tWidth = 0;
- unsigned int tHeight = 0;
- getResolution(tWidth, tHeight, screenId);
-
- osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
- traits->doubleBuffer = true;
- traits->sharedContext = 0;
- traits->screenNum = screenId;
-
- if (width == 0 || height == 0 || (width == tWidth && height == tHeight)) {
- // fullscreen
- traits->windowDecoration = false;
- traits->width = tWidth;
- traits->height = tHeight;
- traits->x = 0;
- traits->y = 0;
- } else {
- // Start with given resolution
- traits->windowDecoration = true;
- traits->x = x;
- traits->y = y;
- traits->width = width;
- traits->height = height;
- }
-
- _gc = osg::GraphicsContext::createGraphicsContext(traits.get());
- if (_gc.valid()) {
- _gc->setClearColor(osg::Vec4f(1.0f,1.0f,1.0f,1.0f));
- _gc->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- }
-
- _width = traits->width;
- _height = traits->height;
-
- setRunMaxFrameRate(30);
+ int screenId) {
+ _waitForViewOp = false;
+ unsigned int tWidth = 0;
+ unsigned int tHeight = 0;
+ getResolution(tWidth, tHeight, screenId);
+
+ osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
+ traits->doubleBuffer = true;
+ traits->sharedContext = 0;
+ traits->screenNum = screenId;
+
+ if (width == 0 || height == 0 || (width == tWidth && height == tHeight)) {
+ // fullscreen
+ traits->windowDecoration = false;
+ traits->width = tWidth;
+ traits->height = tHeight;
+ traits->x = 0;
+ traits->y = 0;
+ } else {
+ // Start with given resolution
+ traits->windowDecoration = true;
+ traits->x = x;
+ traits->y = y;
+ traits->width = width;
+ traits->height = height;
+ }
+
+ _gc = osg::GraphicsContext::createGraphicsContext(traits.get());
+ if (_gc.valid()) {
+ _gc->setClearColor(osg::Vec4f(1.0f,1.0f,1.0f,1.0f));
+ _gc->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ }
+
+ _width = traits->width;
+ _height = traits->height;
+
+ setRunMaxFrameRate(30);
// setRunFrameScheme(osgViewer::ViewerBase::ON_DEMAND);
- setThreadingModel(osgViewer::Viewer::AutomaticSelection);
+ setThreadingModel(osgViewer::Viewer::AutomaticSelection);
}
CompositeDisplay::~CompositeDisplay() {}
void CompositeDisplay::frame(double simulationTime) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- CompositeViewer::frame();
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ CompositeViewer::frame();
}
bool CompositeDisplay::checkNeedToDoFrame() {
- return CompositeViewer::checkNeedToDoFrame();
+ return CompositeViewer::checkNeedToDoFrame();
}
void CompositeDisplay::addView(const std::string& name, osg::Viewport* v, osgViewer::View* view) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
_viewports[name] = v;
-
+
_views[name] = view;
_views[name]->setName(name);
- _views[name]->getCamera()->setName(name);
- _views[name]->setCameraManipulator(new osgGA::TrackballManipulator);
-
- // add the state manipulator
- osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new osgGA::StateSetManipulator;
- statesetManipulator->setStateSet(_views[name]->getCamera()->getOrCreateStateSet());
- _views[name]->addEventHandler( statesetManipulator.get() );
+ _views[name]->getCamera()->setName(name);
+ _views[name]->setCameraManipulator(new osgGA::TrackballManipulator);
+
+ // add the state manipulator
+ osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new osgGA::StateSetManipulator;
+ statesetManipulator->setStateSet(_views[name]->getCamera()->getOrCreateStateSet());
+ _views[name]->addEventHandler( statesetManipulator.get() );
_views[name]->addEventHandler( new osgViewer::StatsHandler );
_views[name]->addEventHandler( new osgViewer::HelpHandler );
_views[name]->addEventHandler( new osgViewer::WindowSizeHandler );
_views[name]->addEventHandler( new osgViewer::ThreadingHandler );
-
- _views[name]->getCamera()->setViewport(v);
-
- // set graphic context
- _views[name]->getCamera()->setGraphicsContext(_gc.get());
- CompositeViewer::addView(_views[name]);
+
+ _views[name]->getCamera()->setViewport(v);
+
+ // set graphic context
+ _views[name]->getCamera()->setGraphicsContext(_gc.get());
+ CompositeViewer::addView(_views[name]);
}
-void CompositeDisplay::moveView(const std::string& name, osg::Viewport* v) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- const osg::GraphicsContext::Traits* traits = _gc->getTraits();
- osg::Viewport* absoluteVp = new osg::Viewport(v->x() * (traits->width/100.0),
- v->y() * (traits->height/100.0),
- v->width() * (traits->width/100.0),
- v->height() * (traits->height/100.0));
- _views[name]->getCamera()->setViewport(absoluteVp);
+void CompositeDisplay::moveView(const std::string& name, osg::Viewport* v) {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ const osg::GraphicsContext::Traits* traits = _gc->getTraits();
+ osg::Viewport* absoluteVp = new osg::Viewport(v->x() * (traits->width/100.0),
+ v->y() * (traits->height/100.0),
+ v->width() * (traits->width/100.0),
+ v->height() * (traits->height/100.0));
+ _views[name]->getCamera()->setViewport(absoluteVp);
}
void CompositeDisplay::removeView(const std::string& name) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
-
- _views[name]->getCamera()->setGraphicsContext(NULL);
- _views[name]->getCamera()->setViewport(NULL);
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+
+ _views[name]->getCamera()->setGraphicsContext(NULL);
+ _views[name]->getCamera()->setViewport(NULL);
CompositeViewer::removeView(_views[name]);
-
+
if (_views.find(name) != _views.end()) {
_views.erase(name);
- }
+ }
if (_viewports.find(name) != _viewports.end())
_viewports.erase(name);
}
osg::GraphicsContext::WindowingSystemInterface* CompositeDisplay::wsi = NULL;
void CompositeDisplay::getResolution(unsigned int& width, unsigned int& height, int screenId) {
- if (!wsi)
- wsi = osg::GraphicsContext::getWindowingSystemInterface();
+ if (!wsi)
+ wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (wsi) {
- wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(screenId), width, height);
+ wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(screenId), width, height);
} else {
width = 800;
height = 600;
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/CompositeDisplay.h b/src/uscxml/plugins/invoker/graphics/openscenegraph/CompositeDisplay.h
index 0d08c7f..b524777 100644
--- a/src/uscxml/plugins/invoker/graphics/openscenegraph/CompositeDisplay.h
+++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/CompositeDisplay.h
@@ -11,36 +11,40 @@
#include <iostream>
class CompositeDisplay : public osgViewer::CompositeViewer {
-public:
- CompositeDisplay(unsigned int x,
- unsigned int y,
- unsigned int width,
- unsigned int height,
- int screenId);
+public:
+ CompositeDisplay(unsigned int x,
+ unsigned int y,
+ unsigned int width,
+ unsigned int height,
+ int screenId);
virtual ~CompositeDisplay();
-
+
virtual void addView(const std::string& name, osg::Viewport* v, osgViewer::View* view);
- virtual void moveView(const std::string& name, osg::Viewport* v);
+ virtual void moveView(const std::string& name, osg::Viewport* v);
virtual void removeView(const std::string& name);
-
- virtual void frame(double simulationTime);
- virtual bool checkNeedToDoFrame();
-
- int getWidth() { return _width; }
- int getHeight() { return _height; }
-
- static void getResolution(unsigned int& width, unsigned int& height, int screenId);
-
+
+ virtual void frame(double simulationTime);
+ virtual bool checkNeedToDoFrame();
+
+ int getWidth() {
+ return _width;
+ }
+ int getHeight() {
+ return _height;
+ }
+
+ static void getResolution(unsigned int& width, unsigned int& height, int screenId);
+
protected:
- tthread::recursive_mutex _mutex;
- tthread::condition_variable _monitor;
- bool _waitForViewOp;
+ tthread::recursive_mutex _mutex;
+ tthread::condition_variable _monitor;
+ bool _waitForViewOp;
std::map<std::string, osgViewer::View*> _views;
std::map<std::string, osg::Viewport*> _viewports;
- osg::ref_ptr<osg::GraphicsContext> _gc;
+ osg::ref_ptr<osg::GraphicsContext> _gc;
- static osg::GraphicsContext::WindowingSystemInterface* wsi;
- int _width, _height;
+ static osg::GraphicsContext::WindowingSystemInterface* wsi;
+ int _width, _height;
};
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
index 08fc1f3..9e584c3 100644
--- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
+++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
@@ -7,7 +7,7 @@
#endif
namespace uscxml {
-
+
#ifdef BUILD_AS_PLUGINS
PLUMA_CONNECTOR
bool connect(pluma::Host& host) {
@@ -15,7 +15,7 @@ bool connect(pluma::Host& host) {
return true;
}
#endif
-
+
OSGInvoker::OSGInvoker() {
}
@@ -43,288 +43,288 @@ void OSGInvoker::sendToParent(const SendRequest& req) {
}
void OSGInvoker::invoke(const InvokeRequest& req) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
-
- // register default event handlers
- Arabica::DOM::Events::EventTarget<std::string> evTarget = Arabica::DOM::Events::EventTarget<std::string>(req.dom);
- evTarget.addEventListener("DOMSubtreeModified", *this, false);
- evTarget.addEventListener("DOMNodeInserted", *this, false);
- evTarget.addEventListener("DOMNodeRemoved", *this, false);
- evTarget.addEventListener("DOMAttrModified", *this, false);
-
- Arabica::XPath::NodeSet<std::string> content = Interpreter::filterChildElements("content", req.dom);
-
- std::set<std::string> validChilds;
- validChilds.insert("display");
- processChildren(validChilds, content[0]);
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+
+ // register default event handlers
+ Arabica::DOM::Events::EventTarget<std::string> evTarget = Arabica::DOM::Events::EventTarget<std::string>(req.dom);
+ evTarget.addEventListener("DOMSubtreeModified", *this, false);
+ evTarget.addEventListener("DOMNodeInserted", *this, false);
+ evTarget.addEventListener("DOMNodeRemoved", *this, false);
+ evTarget.addEventListener("DOMAttrModified", *this, false);
+
+ Arabica::XPath::NodeSet<std::string> content = Interpreter::filterChildElements("content", req.dom);
+
+ std::set<std::string> validChilds;
+ validChilds.insert("display");
+ processChildren(validChilds, content[0]);
}
void OSGInvoker::runOnMainThread() {
- _displays_t::iterator dispIter = _displays.begin();
- if (_mutex.try_lock()) {
- while(dispIter != _displays.end()) {
- dispIter->second->osgViewer::ViewerBase::frame();
- dispIter++;
- }
- _mutex.unlock();
- }
+ _displays_t::iterator dispIter = _displays.begin();
+ if (_mutex.try_lock()) {
+ while(dispIter != _displays.end()) {
+ dispIter->second->osgViewer::ViewerBase::frame();
+ dispIter++;
+ }
+ _mutex.unlock();
+ }
}
void OSGInvoker::handleEvent(Arabica::DOM::Events::Event<std::string>& event) {
// std::cout << "Handling Event!" << std::endl;
- Arabica::DOM::Node<std::string> node(event.getTarget());
- if (_nodes.find(node) != _nodes.end()) {
- osg::Node* osgNode = _nodes[node];
- if (false) {
- } else if (boost::iequals(LOCALNAME(node), "rotation")) {
- updateRotation(osgNode, event);
- }
- }
+ Arabica::DOM::Node<std::string> node(event.getTarget());
+ if (_nodes.find(node) != _nodes.end()) {
+ osg::Node* osgNode = _nodes[node];
+ if (false) {
+ } else if (boost::iequals(LOCALNAME(node), "rotation")) {
+ updateRotation(osgNode, event);
+ }
+ }
}
void OSGInvoker::processDisplay(const Arabica::DOM::Node<std::string>& element) {
// std::cout << element << std::endl;
- if (_displays.find(element) == _displays.end()) {
-
- int screenId = 0;
- unsigned int actualX = 0;
- unsigned int actualY = 0;
- unsigned int actualWidth = 0;
- unsigned int actualHeight = 0;
- getViewport(element, actualX, actualY, actualWidth, actualHeight, screenId);
-
- CompositeDisplay* compDisp = new CompositeDisplay(actualX, actualY, actualWidth, actualHeight, screenId);
- _displays[element] = compDisp;
-
- std::set<std::string> validChilds;
- validChilds.insert("viewport");
- processChildren(validChilds, element);
- }
+ if (_displays.find(element) == _displays.end()) {
+
+ int screenId = 0;
+ unsigned int actualX = 0;
+ unsigned int actualY = 0;
+ unsigned int actualWidth = 0;
+ unsigned int actualHeight = 0;
+ getViewport(element, actualX, actualY, actualWidth, actualHeight, screenId);
+
+ CompositeDisplay* compDisp = new CompositeDisplay(actualX, actualY, actualWidth, actualHeight, screenId);
+ _displays[element] = compDisp;
+
+ std::set<std::string> validChilds;
+ validChilds.insert("viewport");
+ processChildren(validChilds, element);
+ }
}
void OSGInvoker::processViewport(const Arabica::DOM::Node<std::string>& element) {
- if (_displays.find(element.getParentNode()) == _displays.end())
- return;
-
- CompositeDisplay* compDisp = _displays[element.getParentNode()];
- osgViewer::View* sceneView = new osgViewer::View();
- _views[element] = sceneView;
-
- osg::Group* group = new osg::Group();
- _nodes[element] = group;
- sceneView->setSceneData(group);
-
- std::string name = (HAS_ATTR(element, "id") ? ATTR(element, "id") : Interpreter::getUUID());
-
- unsigned int actualX = 0;
- unsigned int actualY = 0;
- unsigned int actualWidth = 0;
- unsigned int actualHeight = 0;
- getViewport(element, actualX, actualY, actualWidth, actualHeight, compDisp);
-
- osg::Viewport* viewPort = new osg::Viewport(actualX, actualY, actualWidth, actualHeight);
- compDisp->addView(name, viewPort, sceneView);
-
- std::set<std::string> validChilds;
- validChilds.insert("camera");
- validChilds.insert("translation");
- validChilds.insert("rotation");
- validChilds.insert("scale");
- validChilds.insert("node");
- processChildren(validChilds, element);
+ if (_displays.find(element.getParentNode()) == _displays.end())
+ return;
+
+ CompositeDisplay* compDisp = _displays[element.getParentNode()];
+ osgViewer::View* sceneView = new osgViewer::View();
+ _views[element] = sceneView;
+
+ osg::Group* group = new osg::Group();
+ _nodes[element] = group;
+ sceneView->setSceneData(group);
+
+ std::string name = (HAS_ATTR(element, "id") ? ATTR(element, "id") : Interpreter::getUUID());
+
+ unsigned int actualX = 0;
+ unsigned int actualY = 0;
+ unsigned int actualWidth = 0;
+ unsigned int actualHeight = 0;
+ getViewport(element, actualX, actualY, actualWidth, actualHeight, compDisp);
+
+ osg::Viewport* viewPort = new osg::Viewport(actualX, actualY, actualWidth, actualHeight);
+ compDisp->addView(name, viewPort, sceneView);
+
+ std::set<std::string> validChilds;
+ validChilds.insert("camera");
+ validChilds.insert("translation");
+ validChilds.insert("rotation");
+ validChilds.insert("scale");
+ validChilds.insert("node");
+ processChildren(validChilds, element);
}
void OSGInvoker::processCamera(const Arabica::DOM::Node<std::string>& element) {}
void OSGInvoker::updateCamera(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event) {}
void OSGInvoker::processTranslation(const Arabica::DOM::Node<std::string>& element) {
- assert(_nodes.find(element.getParentNode()) != _nodes.end());
- osg::Node* node = _nodes[element.getParentNode()];
-
- double x = 0, y = 0, z = 0;
- if (HAS_ATTR(element, "x"))
- x = strTo<float>(ATTR(element, "x"));
- if (HAS_ATTR(element, "y"))
- y = strTo<float>(ATTR(element, "y"));
- if (HAS_ATTR(element, "z"))
- z = strTo<float>(ATTR(element, "z"));
-
- osg::Matrix translate;
- translate.makeTranslate(x, y, z);
-
- osg::MatrixTransform* transform = new osg::MatrixTransform();
- transform->setMatrix(translate);
- node->asGroup()->addChild(transform);
- _nodes[element] = transform;
-
- std::set<std::string> validChilds;
- validChilds.insert("translation");
- validChilds.insert("rotation");
- validChilds.insert("scale");
- validChilds.insert("node");
- processChildren(validChilds, element);
+ assert(_nodes.find(element.getParentNode()) != _nodes.end());
+ osg::Node* node = _nodes[element.getParentNode()];
+
+ double x = 0, y = 0, z = 0;
+ if (HAS_ATTR(element, "x"))
+ x = strTo<float>(ATTR(element, "x"));
+ if (HAS_ATTR(element, "y"))
+ y = strTo<float>(ATTR(element, "y"));
+ if (HAS_ATTR(element, "z"))
+ z = strTo<float>(ATTR(element, "z"));
+
+ osg::Matrix translate;
+ translate.makeTranslate(x, y, z);
+
+ osg::MatrixTransform* transform = new osg::MatrixTransform();
+ transform->setMatrix(translate);
+ node->asGroup()->addChild(transform);
+ _nodes[element] = transform;
+
+ std::set<std::string> validChilds;
+ validChilds.insert("translation");
+ validChilds.insert("rotation");
+ validChilds.insert("scale");
+ validChilds.insert("node");
+ processChildren(validChilds, element);
}
void OSGInvoker::processRotation(const Arabica::DOM::Node<std::string>& element) {
- assert(_nodes.find(element.getParentNode()) != _nodes.end());
- osg::Node* node = _nodes[element.getParentNode()];
-
- osg::Matrix rotation = rotationFromElement(element);
- osg::MatrixTransform* transform = new osg::MatrixTransform();
- transform->setMatrix(rotation);
- node->asGroup()->addChild(transform);
- _nodes[element] = transform;
-
- std::set<std::string> validChilds;
- validChilds.insert("translation");
- validChilds.insert("rotation");
- validChilds.insert("scale");
- validChilds.insert("node");
- processChildren(validChilds, element);
+ assert(_nodes.find(element.getParentNode()) != _nodes.end());
+ osg::Node* node = _nodes[element.getParentNode()];
+
+ osg::Matrix rotation = rotationFromElement(element);
+ osg::MatrixTransform* transform = new osg::MatrixTransform();
+ transform->setMatrix(rotation);
+ node->asGroup()->addChild(transform);
+ _nodes[element] = transform;
+
+ std::set<std::string> validChilds;
+ validChilds.insert("translation");
+ validChilds.insert("rotation");
+ validChilds.insert("scale");
+ validChilds.insert("node");
+ processChildren(validChilds, element);
}
void OSGInvoker::updateRotation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event) {
- osg::MatrixTransform* transform = static_cast<osg::MatrixTransform*>(node);
- if (false) {
- } else if (boost::iequals(event.getType(), "DOMAttrModified")) {
- osg::Matrix rotation = rotationFromElement(Arabica::DOM::Node<std::string>(event.getTarget()));
- transform->setMatrix(rotation);
- }
+ osg::MatrixTransform* transform = static_cast<osg::MatrixTransform*>(node);
+ if (false) {
+ } else if (boost::iequals(event.getType(), "DOMAttrModified")) {
+ osg::Matrix rotation = rotationFromElement(Arabica::DOM::Node<std::string>(event.getTarget()));
+ transform->setMatrix(rotation);
+ }
}
osg::Matrix OSGInvoker::rotationFromElement(const Arabica::DOM::Node<std::string>& element) {
- double pitch = 0, roll = 0, yaw = 0;
- if (HAS_ATTR(element, "pitch")) {
- NumAttr pitchAttr = NumAttr(ATTR(element, "pitch"));
- if (boost::iequals(pitchAttr.unit, "deg")) {
- pitch = osg::DegreesToRadians(strTo<float>(pitchAttr.value));
- } else if (boost::iequals(pitchAttr.unit, "%")) {
- pitch = osg::DegreesToRadians((strTo<float>(pitchAttr.value) * 360) / 100);
- } else {
- pitch = strTo<float>(pitchAttr.value);
- }
- }
- if (HAS_ATTR(element, "roll")) {
- NumAttr rollAttr = NumAttr(ATTR(element, "roll"));
- if (boost::iequals(rollAttr.unit, "deg")) {
- roll = osg::DegreesToRadians(strTo<float>(rollAttr.value));
- } else if (boost::iequals(rollAttr.unit, "%")) {
- roll = osg::DegreesToRadians((strTo<float>(rollAttr.value) * 360) / 100);
- } else {
- roll = strTo<float>(rollAttr.value);
- }
- }
- if (HAS_ATTR(element, "yaw")) {
- NumAttr yawAttr = NumAttr(ATTR(element, "yaw"));
- if (boost::iequals(yawAttr.unit, "deg")) {
- yaw = osg::DegreesToRadians(strTo<float>(yawAttr.value));
- } else if (boost::iequals(yawAttr.unit, "%")) {
- yaw = osg::DegreesToRadians((strTo<float>(yawAttr.value) * 360) / 100);
- } else {
- yaw = strTo<float>(yawAttr.value);
- }
- }
-
- osg::Matrix rotation;
- rotation.makeRotate(roll, osg::Vec3(0,1,0), // roll
- pitch, osg::Vec3(1,0,0) , // pitch
- yaw, osg::Vec3(0,0,1) ); // heading
-
- return rotation;
+ double pitch = 0, roll = 0, yaw = 0;
+ if (HAS_ATTR(element, "pitch")) {
+ NumAttr pitchAttr = NumAttr(ATTR(element, "pitch"));
+ if (boost::iequals(pitchAttr.unit, "deg")) {
+ pitch = osg::DegreesToRadians(strTo<float>(pitchAttr.value));
+ } else if (boost::iequals(pitchAttr.unit, "%")) {
+ pitch = osg::DegreesToRadians((strTo<float>(pitchAttr.value) * 360) / 100);
+ } else {
+ pitch = strTo<float>(pitchAttr.value);
+ }
+ }
+ if (HAS_ATTR(element, "roll")) {
+ NumAttr rollAttr = NumAttr(ATTR(element, "roll"));
+ if (boost::iequals(rollAttr.unit, "deg")) {
+ roll = osg::DegreesToRadians(strTo<float>(rollAttr.value));
+ } else if (boost::iequals(rollAttr.unit, "%")) {
+ roll = osg::DegreesToRadians((strTo<float>(rollAttr.value) * 360) / 100);
+ } else {
+ roll = strTo<float>(rollAttr.value);
+ }
+ }
+ if (HAS_ATTR(element, "yaw")) {
+ NumAttr yawAttr = NumAttr(ATTR(element, "yaw"));
+ if (boost::iequals(yawAttr.unit, "deg")) {
+ yaw = osg::DegreesToRadians(strTo<float>(yawAttr.value));
+ } else if (boost::iequals(yawAttr.unit, "%")) {
+ yaw = osg::DegreesToRadians((strTo<float>(yawAttr.value) * 360) / 100);
+ } else {
+ yaw = strTo<float>(yawAttr.value);
+ }
+ }
+
+ osg::Matrix rotation;
+ rotation.makeRotate(roll, osg::Vec3(0,1,0), // roll
+ pitch, osg::Vec3(1,0,0) , // pitch
+ yaw, osg::Vec3(0,0,1) ); // heading
+
+ return rotation;
}
void OSGInvoker::processScale(const Arabica::DOM::Node<std::string>& element) {
- assert(_nodes.find(element.getParentNode()) != _nodes.end());
- osg::Node* node = _nodes[element.getParentNode()];
-
- double x = 1, y = 1, z = 1;
- if (HAS_ATTR(element, "x"))
- x = strTo<float>(ATTR(element, "x"));
- if (HAS_ATTR(element, "y"))
- y = strTo<float>(ATTR(element, "y"));
- if (HAS_ATTR(element, "z"))
- z = strTo<float>(ATTR(element, "z"));
-
- osg::Matrix scale;
- scale.makeScale(x, y, z);
-
- osg::MatrixTransform* transform = new osg::MatrixTransform();
- transform->setMatrix(scale);
- node->asGroup()->addChild(transform);
- _nodes[element] = transform;
-
- std::set<std::string> validChilds;
- validChilds.insert("translation");
- validChilds.insert("rotation");
- validChilds.insert("scale");
- validChilds.insert("node");
- processChildren(validChilds, element);
+ assert(_nodes.find(element.getParentNode()) != _nodes.end());
+ osg::Node* node = _nodes[element.getParentNode()];
+
+ double x = 1, y = 1, z = 1;
+ if (HAS_ATTR(element, "x"))
+ x = strTo<float>(ATTR(element, "x"));
+ if (HAS_ATTR(element, "y"))
+ y = strTo<float>(ATTR(element, "y"));
+ if (HAS_ATTR(element, "z"))
+ z = strTo<float>(ATTR(element, "z"));
+
+ osg::Matrix scale;
+ scale.makeScale(x, y, z);
+
+ osg::MatrixTransform* transform = new osg::MatrixTransform();
+ transform->setMatrix(scale);
+ node->asGroup()->addChild(transform);
+ _nodes[element] = transform;
+
+ std::set<std::string> validChilds;
+ validChilds.insert("translation");
+ validChilds.insert("rotation");
+ validChilds.insert("scale");
+ validChilds.insert("node");
+ processChildren(validChilds, element);
}
void OSGInvoker::processNode(const Arabica::DOM::Node<std::string>& element) {
- _nodes_t::iterator nodeIter = _nodes.find(element.getParentNode());
- assert(nodeIter != _nodes.end());
-
- assert(_nodes.find(element.getParentNode()) != _nodes.end());
- osg::Node* parent = _nodes[element.getParentNode()];
-
- std::string filename;
- if (HAS_ATTR(element, "src")) {
- filename = ATTR(element, "src");
-
- if (filename.length() > 0) {
- std::string extension;
- size_t extensionStart = filename.find_last_of(".");
- if (extensionStart != std::string::npos) {
- extension = filename.substr(extensionStart);
- }
-
- URL srcURI(filename);
- if (!srcURI.toAbsolute(_interpreter->getBaseURI())) {
- LOG(ERROR) << "invoke element has relative src URI with no baseURI set.";
- return;
- }
- filename = srcURI.asLocalFile(extension);
- osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(filename);
- if (model.get())
- parent->asGroup()->addChild(model);
-
- }
- }
+ _nodes_t::iterator nodeIter = _nodes.find(element.getParentNode());
+ assert(nodeIter != _nodes.end());
+
+ assert(_nodes.find(element.getParentNode()) != _nodes.end());
+ osg::Node* parent = _nodes[element.getParentNode()];
+
+ std::string filename;
+ if (HAS_ATTR(element, "src")) {
+ filename = ATTR(element, "src");
+
+ if (filename.length() > 0) {
+ std::string extension;
+ size_t extensionStart = filename.find_last_of(".");
+ if (extensionStart != std::string::npos) {
+ extension = filename.substr(extensionStart);
+ }
+
+ URL srcURI(filename);
+ if (!srcURI.toAbsolute(_interpreter->getBaseURI())) {
+ LOG(ERROR) << "invoke element has relative src URI with no baseURI set.";
+ return;
+ }
+ filename = srcURI.asLocalFile(extension);
+ osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(filename);
+ if (model.get())
+ parent->asGroup()->addChild(model);
+
+ }
+ }
}
void OSGInvoker::processChildren(const std::set<std::string>& validChildren, const Arabica::DOM::Node<std::string>& element) {
- Arabica::DOM::NodeList<std::string> childs = element.getChildNodes();
- for (int i = 0; i < childs.getLength(); ++i) {
- if (childs.item(i).getNodeType() != Arabica::DOM::Node_base::ELEMENT_NODE)
- continue;
- if (false) {
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "node") &&
- validChildren.find("node") != validChildren.end()) {
- processNode(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "translation") &&
- validChildren.find("translation") != validChildren.end()) {
- processTranslation(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "rotation") &&
- validChildren.find("rotation") != validChildren.end()) {
- processRotation(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "scale") &&
- validChildren.find("scale") != validChildren.end()) {
- processScale(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "viewport") &&
- validChildren.find("viewport") != validChildren.end()) {
- processViewport(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "camera") &&
- validChildren.find("camera") != validChildren.end()) {
- processCamera(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "display") &&
- validChildren.find("display") != validChildren.end()) {
- processDisplay(childs.item(i));
- } else {
- LOG(INFO) << "Unknown XML element " << TAGNAME(childs.item(i));
- }
- }
+ Arabica::DOM::NodeList<std::string> childs = element.getChildNodes();
+ for (int i = 0; i < childs.getLength(); ++i) {
+ if (childs.item(i).getNodeType() != Arabica::DOM::Node_base::ELEMENT_NODE)
+ continue;
+ if (false) {
+ } else if (boost::iequals(LOCALNAME(childs.item(i)), "node") &&
+ validChildren.find("node") != validChildren.end()) {
+ processNode(childs.item(i));
+ } else if (boost::iequals(LOCALNAME(childs.item(i)), "translation") &&
+ validChildren.find("translation") != validChildren.end()) {
+ processTranslation(childs.item(i));
+ } else if (boost::iequals(LOCALNAME(childs.item(i)), "rotation") &&
+ validChildren.find("rotation") != validChildren.end()) {
+ processRotation(childs.item(i));
+ } else if (boost::iequals(LOCALNAME(childs.item(i)), "scale") &&
+ validChildren.find("scale") != validChildren.end()) {
+ processScale(childs.item(i));
+ } else if (boost::iequals(LOCALNAME(childs.item(i)), "viewport") &&
+ validChildren.find("viewport") != validChildren.end()) {
+ processViewport(childs.item(i));
+ } else if (boost::iequals(LOCALNAME(childs.item(i)), "camera") &&
+ validChildren.find("camera") != validChildren.end()) {
+ processCamera(childs.item(i));
+ } else if (boost::iequals(LOCALNAME(childs.item(i)), "display") &&
+ validChildren.find("display") != validChildren.end()) {
+ processDisplay(childs.item(i));
+ } else {
+ LOG(INFO) << "Unknown XML element " << TAGNAME(childs.item(i));
+ }
+ }
}
void OSGInvoker::getViewport(const Arabica::DOM::Node<std::string>& element,
@@ -333,7 +333,7 @@ void OSGInvoker::getViewport(const Arabica::DOM::Node<std::string>& element,
unsigned int& width,
unsigned int& height,
CompositeDisplay* display) {
- getViewport(element, x, y, width, height, display->getWidth(), display->getHeight());
+ getViewport(element, x, y, width, height, display->getWidth(), display->getHeight());
}
@@ -342,15 +342,14 @@ void OSGInvoker::getViewport(const Arabica::DOM::Node<std::string>& element,
unsigned int& y,
unsigned int& width,
unsigned int& height,
- int& screenId)
-{
-
- screenId = (HAS_ATTR(element, "screenId") ? strTo<int>(ATTR(element, "screenId")) : 0);
-
- unsigned int fullWidth = 0;
- unsigned int fullHeight = 0;
- CompositeDisplay::getResolution(fullWidth, fullHeight, screenId);
- getViewport(element, x, y, width, height, fullWidth, fullHeight);
+ int& screenId) {
+
+ screenId = (HAS_ATTR(element, "screenId") ? strTo<int>(ATTR(element, "screenId")) : 0);
+
+ unsigned int fullWidth = 0;
+ unsigned int fullHeight = 0;
+ CompositeDisplay::getResolution(fullWidth, fullHeight, screenId);
+ getViewport(element, x, y, width, height, fullWidth, fullHeight);
}
void OSGInvoker::getViewport(const Arabica::DOM::Node<std::string>& element,
@@ -359,43 +358,42 @@ void OSGInvoker::getViewport(const Arabica::DOM::Node<std::string>& element,
unsigned int& width,
unsigned int& height,
unsigned int fullWidth,
- unsigned int fullHeight)
-{
- if (HAS_ATTR(element, "x")) {
- NumAttr xAttr = NumAttr(ATTR(element, "x"));
- x = strTo<float>(xAttr.value);
- if (boost::iequals(xAttr.unit, "%"))
- x = (x * fullWidth) / 100;
- }
- if (HAS_ATTR(element, "y")) {
- NumAttr yAttr = NumAttr(ATTR(element, "y"));
- y = strTo<float>(yAttr.value);
- if (boost::iequals(yAttr.unit, "%"))
- y = (y * fullHeight) / 100;
- }
- if (HAS_ATTR(element, "width")) {
- NumAttr widthAttr = NumAttr(ATTR(element, "width"));
- width = strTo<float>(widthAttr.value);
- if (boost::iequals(widthAttr.unit, "%"))
- width = (width * fullWidth) / 100;
- }
- if (HAS_ATTR(element, "height")) {
- NumAttr heightAttr = NumAttr(ATTR(element, "height"));
- height = strTo<float>(heightAttr.value);
- if (boost::iequals(heightAttr.unit, "%"))
- height = (height * fullHeight) / 100;
- }
+ unsigned int fullHeight) {
+ if (HAS_ATTR(element, "x")) {
+ NumAttr xAttr = NumAttr(ATTR(element, "x"));
+ x = strTo<float>(xAttr.value);
+ if (boost::iequals(xAttr.unit, "%"))
+ x = (x * fullWidth) / 100;
+ }
+ if (HAS_ATTR(element, "y")) {
+ NumAttr yAttr = NumAttr(ATTR(element, "y"));
+ y = strTo<float>(yAttr.value);
+ if (boost::iequals(yAttr.unit, "%"))
+ y = (y * fullHeight) / 100;
+ }
+ if (HAS_ATTR(element, "width")) {
+ NumAttr widthAttr = NumAttr(ATTR(element, "width"));
+ width = strTo<float>(widthAttr.value);
+ if (boost::iequals(widthAttr.unit, "%"))
+ width = (width * fullWidth) / 100;
+ }
+ if (HAS_ATTR(element, "height")) {
+ NumAttr heightAttr = NumAttr(ATTR(element, "height"));
+ height = strTo<float>(heightAttr.value);
+ if (boost::iequals(heightAttr.unit, "%"))
+ height = (height * fullHeight) / 100;
+ }
}
osgViewer::View* OSGInvoker::getView(const Arabica::DOM::Node<std::string>& element) {
- Arabica::DOM::Node<std::string> curr = element;
- while(curr && !boost::iequals(LOCALNAME(curr), "viewport")) {
- curr = curr.getParentNode();
- }
- if (curr && _views.find(curr) != _views.end())
- return _views[curr];
- return NULL;
+ Arabica::DOM::Node<std::string> curr = element;
+ while(curr && !boost::iequals(LOCALNAME(curr), "viewport")) {
+ curr = curr.getParentNode();
+ }
+ if (curr && _views.find(curr) != _views.end())
+ return _views[curr];
+ return NULL;
}
-
+
} \ No newline at end of file
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h
index aca54ec..e65bff8 100644
--- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h
+++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h
@@ -35,64 +35,64 @@ public:
virtual void cancel(const std::string sendId);
virtual void invoke(const InvokeRequest& req);
virtual void sendToParent(const SendRequest& req);
- virtual void handleEvent(Arabica::DOM::Events::Event<std::string>& event);
+ virtual void handleEvent(Arabica::DOM::Events::Event<std::string>& event);
- virtual void runOnMainThread();
+ virtual void runOnMainThread();
protected:
- void processDisplay(const Arabica::DOM::Node<std::string>& element);
- void updateDisplay(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
- void processViewport(const Arabica::DOM::Node<std::string>& element);
- void updateViewport(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
- void processCamera(const Arabica::DOM::Node<std::string>& element);
- void updateCamera(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
-
- void processTranslation(const Arabica::DOM::Node<std::string>& element);
- void updateTranslation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
-
- void processRotation(const Arabica::DOM::Node<std::string>& element);
- void updateRotation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
- static osg::Matrix rotationFromElement(const Arabica::DOM::Node<std::string>& element);
-
- void processScale(const Arabica::DOM::Node<std::string>& element);
- void updateScale(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
- void processNode(const Arabica::DOM::Node<std::string>& element);
- void updateNode(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
-
- void processChildren(const std::set<std::string>& validChildren, const Arabica::DOM::Node<std::string>& element);
-
- void getViewport(const Arabica::DOM::Node<std::string>& element,
- unsigned int& x,
- unsigned int& y,
- unsigned int& width,
- unsigned int& height,
- int& screenId);
-
- void getViewport(const Arabica::DOM::Node<std::string>& element,
- unsigned int& x,
- unsigned int& y,
- unsigned int& width,
- unsigned int& height,
- CompositeDisplay* display);
-
- void getViewport(const Arabica::DOM::Node<std::string>& element,
- unsigned int& x,
- unsigned int& y,
- unsigned int& width,
- unsigned int& height,
- unsigned int fullWidth,
- unsigned int fullHeight);
-
- osgViewer::View* getView(const Arabica::DOM::Node<std::string>& element);
-
- std::map<Arabica::DOM::Node<std::string>, CompositeDisplay*> _displays;
- typedef std::map<Arabica::DOM::Node<std::string>, CompositeDisplay*> _displays_t;
-
- std::map<Arabica::DOM::Node<std::string>, osgViewer::View*> _views;
- typedef std::map<Arabica::DOM::Node<std::string>, osgViewer::View*> _views_t;
-
- std::map<Arabica::DOM::Node<std::string>, osg::Node*> _nodes;
- typedef std::map<Arabica::DOM::Node<std::string>, osg::Node*> _nodes_t;
+ void processDisplay(const Arabica::DOM::Node<std::string>& element);
+ void updateDisplay(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+ void processViewport(const Arabica::DOM::Node<std::string>& element);
+ void updateViewport(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+ void processCamera(const Arabica::DOM::Node<std::string>& element);
+ void updateCamera(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+
+ void processTranslation(const Arabica::DOM::Node<std::string>& element);
+ void updateTranslation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+
+ void processRotation(const Arabica::DOM::Node<std::string>& element);
+ void updateRotation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+ static osg::Matrix rotationFromElement(const Arabica::DOM::Node<std::string>& element);
+
+ void processScale(const Arabica::DOM::Node<std::string>& element);
+ void updateScale(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+ void processNode(const Arabica::DOM::Node<std::string>& element);
+ void updateNode(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+
+ void processChildren(const std::set<std::string>& validChildren, const Arabica::DOM::Node<std::string>& element);
+
+ void getViewport(const Arabica::DOM::Node<std::string>& element,
+ unsigned int& x,
+ unsigned int& y,
+ unsigned int& width,
+ unsigned int& height,
+ int& screenId);
+
+ void getViewport(const Arabica::DOM::Node<std::string>& element,
+ unsigned int& x,
+ unsigned int& y,
+ unsigned int& width,
+ unsigned int& height,
+ CompositeDisplay* display);
+
+ void getViewport(const Arabica::DOM::Node<std::string>& element,
+ unsigned int& x,
+ unsigned int& y,
+ unsigned int& width,
+ unsigned int& height,
+ unsigned int fullWidth,
+ unsigned int fullHeight);
+
+ osgViewer::View* getView(const Arabica::DOM::Node<std::string>& element);
+
+ std::map<Arabica::DOM::Node<std::string>, CompositeDisplay*> _displays;
+ typedef std::map<Arabica::DOM::Node<std::string>, CompositeDisplay*> _displays_t;
+
+ std::map<Arabica::DOM::Node<std::string>, osgViewer::View*> _views;
+ typedef std::map<Arabica::DOM::Node<std::string>, osgViewer::View*> _views_t;
+
+ std::map<Arabica::DOM::Node<std::string>, osg::Node*> _nodes;
+ typedef std::map<Arabica::DOM::Node<std::string>, osg::Node*> _nodes_t;
tthread::recursive_mutex _mutex;
std::string _invokeId;
diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
index 65eed78..a983d58 100644
--- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
+++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
@@ -36,58 +36,58 @@ void HeartbeatInvoker::send(const SendRequest& req) {
}
void HeartbeatInvoker::cancel(const std::string sendId) {
- HeartbeatDispatcher::getInstance()->cancelEvent(toStr(this));
+ HeartbeatDispatcher::getInstance()->cancelEvent(toStr(this));
}
void HeartbeatInvoker::sendToParent(const SendRequest& req) {
}
void HeartbeatInvoker::invoke(const InvokeRequest& req) {
- _invokeId = req.invokeid;
- _event.invokeid = _invokeId;
- std::string intervalStr;
- double interval = 0;
- unsigned long intervalMs = 0;
- InvokeRequest::params_t::const_iterator paramIter = req.params.begin();
- while(paramIter != req.params.end()) {
- if (boost::iequals(paramIter->first, "interval")) {
- intervalStr = paramIter->second;
- NumAttr intervalAttr(paramIter->second);
- interval = strTo<double>(intervalAttr.value);
- if (false) {
- } else if (boost::iequals(intervalAttr.unit, "s")) {
- intervalMs = interval * 1000;
- } else if (boost::iequals(intervalAttr.unit, "ms")) {
- intervalMs = interval;
- } else {
- intervalMs = interval;
- }
- }
- if (boost::iequals(paramIter->first, "eventname")) {
- _event.name = paramIter->second;
- }
- paramIter++;
- }
- if (_event.name.length() == 0)
- _event.name = std::string("heartbeat." + intervalStr);
-
- if (intervalMs > 0) {
- HeartbeatDispatcher::getInstance()->addEvent(toStr(this), HeartbeatInvoker::dispatch, intervalMs, this, true);
- }
+ _invokeId = req.invokeid;
+ _event.invokeid = _invokeId;
+ std::string intervalStr;
+ double interval = 0;
+ unsigned long intervalMs = 0;
+ InvokeRequest::params_t::const_iterator paramIter = req.params.begin();
+ while(paramIter != req.params.end()) {
+ if (boost::iequals(paramIter->first, "interval")) {
+ intervalStr = paramIter->second;
+ NumAttr intervalAttr(paramIter->second);
+ interval = strTo<double>(intervalAttr.value);
+ if (false) {
+ } else if (boost::iequals(intervalAttr.unit, "s")) {
+ intervalMs = interval * 1000;
+ } else if (boost::iequals(intervalAttr.unit, "ms")) {
+ intervalMs = interval;
+ } else {
+ intervalMs = interval;
+ }
+ }
+ if (boost::iequals(paramIter->first, "eventname")) {
+ _event.name = paramIter->second;
+ }
+ paramIter++;
+ }
+ if (_event.name.length() == 0)
+ _event.name = std::string("heartbeat." + intervalStr);
+
+ if (intervalMs > 0) {
+ HeartbeatDispatcher::getInstance()->addEvent(toStr(this), HeartbeatInvoker::dispatch, intervalMs, this, true);
+ }
}
void HeartbeatInvoker::dispatch(void* instance, std::string name) {
- HeartbeatInvoker* invoker = (HeartbeatInvoker*)instance;
- invoker->_interpreter->receive(invoker->_event);
+ HeartbeatInvoker* invoker = (HeartbeatInvoker*)instance;
+ invoker->_interpreter->receive(invoker->_event);
}
-
+
HeartbeatDispatcher* HeartbeatDispatcher::_instance = NULL;
HeartbeatDispatcher* HeartbeatDispatcher::getInstance() {
- if (_instance == NULL) {
- _instance = new HeartbeatDispatcher();
- _instance->start();
- }
- return _instance;
+ if (_instance == NULL) {
+ _instance = new HeartbeatDispatcher();
+ _instance->start();
+ }
+ return _instance;
}
HeartbeatDispatcher::HeartbeatDispatcher() {}
diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h
index 4b230c1..a7f3cbd 100644
--- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h
+++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h
@@ -28,22 +28,22 @@ public:
virtual void invoke(const InvokeRequest& req);
virtual void sendToParent(const SendRequest& req);
- static void dispatch(void* instance, std::string name);
-
+ static void dispatch(void* instance, std::string name);
+
protected:
std::string _invokeId;
- Event _event;
-
+ Event _event;
+
};
class HeartbeatDispatcher : public DelayedEventQueue {
public:
- static HeartbeatDispatcher* getInstance();
+ static HeartbeatDispatcher* getInstance();
protected:
- static HeartbeatDispatcher* _instance;
- HeartbeatDispatcher();
+ static HeartbeatDispatcher* _instance;
+ HeartbeatDispatcher();
};
-
+
#ifdef BUILD_AS_PLUGINS
PLUMA_INHERIT_PROVIDER(HeartbeatInvoker, InvokerImpl);
#endif
diff --git a/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp b/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp
index f115c25..3678cc3 100644
--- a/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp
+++ b/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp
@@ -42,7 +42,7 @@ void SampleInvoker::sendToParent(SendRequest& req) {
}
void SampleInvoker::invoke(InvokeRequest& req) {
- _invokeId = req.invokeid;
+ _invokeId = req.invokeid;
}
} \ No newline at end of file
diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
index 85f2963..bcdf2d4 100644
--- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
+++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
@@ -43,7 +43,7 @@ void USCXMLInvoker::cancel(const std::string sendId) {
}
void USCXMLInvoker::sendToParent(const SendRequest& req) {
- SendRequest parentReq = req;
+ SendRequest parentReq = req;
parentReq.invokeid = _invokeId;
_parentInterpreter->receive(parentReq);
}
@@ -55,10 +55,10 @@ void USCXMLInvoker::invoke(const InvokeRequest& req) {
if (dataModel) {
}
- if (_invokedInterpreter) {
- _invokedInterpreter->setInvoker(boost::static_pointer_cast<InvokerImpl>(shared_from_this()));
- _invokedInterpreter->start();
- }
+ if (_invokedInterpreter) {
+ _invokedInterpreter->setInvoker(boost::static_pointer_cast<InvokerImpl>(shared_from_this()));
+ _invokedInterpreter->start();
+ }
}
} \ No newline at end of file
diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
index 2957078..c269869 100644
--- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
+++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
@@ -20,12 +20,12 @@ UmundoInvoker::UmundoInvoker() : _node(NULL), _pub(NULL), _sub(NULL) {
}
UmundoInvoker::~UmundoInvoker() {
- if (_node) {
- if (_sub)
- _node->removeSubscriber(*_sub);
- if (_pub)
- _node->removePublisher(*_pub);
- }
+ if (_node) {
+ if (_sub)
+ _node->removeSubscriber(*_sub);
+ if (_pub)
+ _node->removePublisher(*_pub);
+ }
};
boost::shared_ptr<IOProcessorImpl> UmundoInvoker::create(Interpreter* interpreter) {
@@ -127,37 +127,37 @@ void UmundoInvoker::invoke(const InvokeRequest& req) {
return;
}
if (req.params.find("domain") != req.params.end()) {
- domain = req.params.find("domain")->second;
- }
+ domain = req.params.find("domain")->second;
+ }
_node = getNode(_interpreter, domain);
// add type from .proto or .desc files
if (req.params.find("type") != req.params.end()) {
std::pair<InvokeRequest::params_t::const_iterator, InvokeRequest::params_t::const_iterator> typeRange = req.params.equal_range("types");
for (InvokeRequest::params_t::const_iterator it = typeRange.first; it != typeRange.second; it++) {
- URL typeURI(it->second);
- if (typeURI.toAbsolute(_interpreter->getBaseURI())) {
- std::string filename = typeURI.asLocalFile(".proto");
- umundo::PBSerializer::addProto(filename);
- } else {
- LOG(ERROR) << "umundo invoker has relative type src but nor baseURI set with interpreter.";
- }
+ URL typeURI(it->second);
+ if (typeURI.toAbsolute(_interpreter->getBaseURI())) {
+ std::string filename = typeURI.asLocalFile(".proto");
+ umundo::PBSerializer::addProto(filename);
+ } else {
+ LOG(ERROR) << "umundo invoker has relative type src but nor baseURI set with interpreter.";
+ }
}
}
- // add directory with .proto or .desc files
- if (req.params.find("types") != req.params.end()) {
+ // add directory with .proto or .desc files
+ if (req.params.find("types") != req.params.end()) {
std::pair<InvokeRequest::params_t::const_iterator, InvokeRequest::params_t::const_iterator> typeRange = req.params.equal_range("types");
for (InvokeRequest::params_t::const_iterator it = typeRange.first; it != typeRange.second; it++) {
- URL typeURI(it->second);
- if (typeURI.toAbsolute(_interpreter->getBaseURI()) && typeURI.scheme().compare("file") == 0) {
- umundo::PBSerializer::addProto(typeURI.path());
- } else {
- LOG(ERROR) << "invoke element has relative src URI with no baseURI set.";
- }
+ URL typeURI(it->second);
+ if (typeURI.toAbsolute(_interpreter->getBaseURI()) && typeURI.scheme().compare("file") == 0) {
+ umundo::PBSerializer::addProto(typeURI.path());
+ } else {
+ LOG(ERROR) << "invoke element has relative src URI with no baseURI set.";
+ }
}
- }
-
+ }
+
if (!_isService) {
// use umundo to publish objects on a channel
_pub = new umundo::TypedPublisher(channelName);
@@ -257,15 +257,15 @@ void UmundoInvoker::changed(umundo::ServiceDescription desc) {
std::multimap<std::string, std::pair<std::string, umundo::Node*> > UmundoInvoker::_nodes;
umundo::Node* UmundoInvoker::getNode(Interpreter* interpreter, const std::string& domain) {
- std::pair<_nodes_t::iterator, _nodes_t::iterator> range = _nodes.equal_range(interpreter->getName());
- for (_nodes_t::iterator it = range.first; it != range.second; it++) {
- if (it->second.first.compare(domain) == 0)
- return it->second.second;
- }
- umundo::Node* node = new umundo::Node(domain);
- std::pair<std::string, std::pair<std::string, umundo::Node*> > pair = std::make_pair(interpreter->getName(), std::make_pair(domain, node));
- _nodes.insert(pair);
- return node;
+ std::pair<_nodes_t::iterator, _nodes_t::iterator> range = _nodes.equal_range(interpreter->getName());
+ for (_nodes_t::iterator it = range.first; it != range.second; it++) {
+ if (it->second.first.compare(domain) == 0)
+ return it->second.second;
+ }
+ umundo::Node* node = new umundo::Node(domain);
+ std::pair<std::string, std::pair<std::string, umundo::Node*> > pair = std::make_pair(interpreter->getName(), std::make_pair(domain, node));
+ _nodes.insert(pair);
+ return node;
}
bool UmundoInvoker::protobufToData(Data& data, const google::protobuf::Message& msg) {
diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h
index d54160e..58fa5d8 100644
--- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h
+++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h
@@ -58,7 +58,7 @@ protected:
std::map<umundo::ServiceDescription, umundo::ServiceStub*> _svcs;
static std::multimap<std::string, std::pair<std::string, umundo::Node*> > _nodes;
- typedef std::multimap<std::string, std::pair<std::string, umundo::Node*> > _nodes_t;
+ typedef std::multimap<std::string, std::pair<std::string, umundo::Node*> > _nodes_t;
static umundo::Node* getNode(Interpreter* interpreter, const std::string& domain);
};