Skip to content
/ uscxml Public
forked from tklab-tud/uscxml

SCXML interpreter written in C++

Notifications You must be signed in to change notification settings

enricop/uscxml

 
 

Repository files navigation

uSCXML ReadMe

Build Status

uSCXML is a SCXML interpreter written in C/C++. It is mostly feature-complete and to a large extend standards compliant. It runs on Linux, Windows and MacOSX, each 32- as well as 64Bits as well as iOS. There are still a few rough edges though, especially with the plugins and custom extensions.

  • Datamodels
  • Invokers
    • scxml: Invoke a nested scxml interpreter
    • dirmon: Watches a directory for changes to files
    • scenegraph: Simplified 3D scenegraphs with custom markup
    • heartbeat: Periodically sends events
    • umundo: Subscribe to channels and publish events
  • DOM
    • DOM Core Level 2 + XPath extensions available for ecmascript datamodel
    • Namespace aware to embed custom markup for special invokers
  • Communication
    • Features the standard basichttp io-processor
    • Features the required SCXML io-processor
    • No DOM io-processor
    • Early support for WebSockets
    • Can actually respond to HTTP requests with data via <response>
  • Language Bindings
    • PHP module for apache and cli interpreter
    • Java bindings

Test Reports

  • We continuously run the W3C IRP tests for SCXML.
  • Have a look at the result for the various platforms.
  • The manual and XPath specific tests are excluded.

uSCXML still fails the following ecmascript tests:

Test#StatusDescriptionComment
329 Failed "test that none of the system variables can be modified" uSCXML allows writing to _event. This is very useful to have a scope that vanishes when processing an event is finished. I raised the issue on the ML and it might make it into a later draft
346 Failed "test that any attempt to change the value of a system variable causes error.execution to be raised" Same issue as above: we allow writing to _event.
519 520 531 534 Failed Tests contain non-standard ECMAScript.

License

uSCXML itself is distributed under the Simplified BSD license as in, do not sue us and do not misrepresent authorship. Please have a look at the licenses of the libraries we depend upon as well.

Download

We do not yet feature installers. Please download the source and have a look at the build instructions.

Usage

In order to use the interpreter, you need to #include "uscxml/Interpreter.h" and instantiate objects of uscxml::Interpreter.

Non-Blocking Interpretation with SCXML from URL

Interpreter scxml = Interpreter::fromURL("http://www.example.com/fancy.scxml");
scxml.start(); // non-blocking

There are some cases, i.e. with graphical invokers, where the main thread is required in order to react to UI events. You will have to deligate control flow from the main thread into the interpreter every now and then:

interpreter.runOnMainThread(25);

This will perform a single iteration on the invoked components with a maximum of 25 frames per seconds or return immediately. You will have to call this method every now and then if you are using e.g. the scenegraph invoker.

Blocking Interpretation with inline SCXML

Interpreter scxml = Interpreter::fromXML("<scxml><final id="exit"/></scxml>");
scxml.interpret(); // blocking

Callbacks for an Interpreter

You can register an InterpreterMonitor prior to start in order to receive control-flow upon various events in the Interpreter.

class StatusMonitor : public uscxml::InterpreterMonitor {
	void onStableConfiguration(Interpreter) {}
	void beforeCompletion(Interpreter) {}
	void afterCompletion(Interpreter) {}
	void beforeMicroStep(Interpreter) {}
	void beforeTakingTransitions(Interpreter, const Arabica::XPath::NodeSet<std::string>&) {}
	void beforeEnteringStates(Interpreter, const Arabica::XPath::NodeSet<std::string>&) {}
	void afterEnteringStates(Interpreter) {}
	void beforeExitingStates(Interpreter, const Arabica::XPath::NodeSet<std::string>&) {}
	void afterExitingStates(Interpreter) {}
};

StatusMonitor statMon;
Interpreter scxml = Interpreter::fromXML("<scxml><final id="exit"/></scxml>");
scxml.addMonitor(&statMon);
scxml.start();

This will cause the interpreter to invoke the callbacks from the monitor whenever the corresponding internal phase is reached.

Extending uSCXML

The uSCXML interpreter can be extended by introducing new

  1. DataModels as embedded scripting languages (e.g. ECMAScript, Prolog and XPath)
  2. Invokers to represent external components that deliver and accept events (e.g. iCal, SceneGraph, DirectoryMonitor)
  3. I/O-Processors to provide communication with external systems (e.g. BasicHTTP, SCXML).
  4. Elements for Executable Content (e.g. <respond>, <fetch>, <postpone>).

The basic approach to extend the interpreter is the same in all cases:

  1. Write a class inheriting the abstract base class (e.g. DataModelImpl, InvokerImpl, IOProcessorImpl, ExecutableContentImpl).
  2. Instantiate your class and register it as a prototype at the Factory via one of its static register* methods.
    1. You can register at the global Factory Singleton via Factory::register*(prototypeInstance)
    2. Or provide a new Factory instance to selected interpreters as an in-between.
  3. Write an interpreter using your new functionality.

Acknowledgments

This SCXML interpreter is developed at the Telekooperation Group of the Technical University of Darmstadt as part of the SmartVortex project funded by the 7th European framework program.

About

SCXML interpreter written in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 73.8%
  • Perl 9.4%
  • C 6.1%
  • JavaScript 4.2%
  • Shell 2.1%
  • XSLT 1.9%
  • Other 2.5%