Code Monkey home page Code Monkey logo

tklab-tud / uscxml Goto Github PK

View Code? Open in Web Editor NEW
103.0 15.0 54.0 108.92 MB

SCXML interpreter and transformer/compiler written in C/C++ with bindings to Java, C#, Python and Lua

License: Other

CMake 1.11% Shell 0.21% Perl 0.95% C++ 88.29% Visual Basic 0.09% C 4.68% Makefile 0.03% XSLT 1.70% Batchfile 0.01% C# 0.01% Java 0.34% PHP 0.71% HTML 1.82% Lex 0.03% Tcl 0.01% Python 0.01% Objective-C++ 0.02% JavaScript 0.01% Lua 0.01% Gnuplot 0.01%
scxml interpreter c-plus-plus lua transformer embedded ecmascript w3c c java

uscxml's People

Contributors

1anam avatar abhi18av avatar alexzhornyak avatar c64zottel avatar gabm avatar magnusfant avatar mathiasjohanson avatar sradomski avatar sterad avatar vogelsgesang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uscxml's Issues

Forward declaration instead of include?

Hello,
I guess, it's still necessary to use the Factory when creating IOProcessors.
but Factory.h includes:

include "uscxml/InterpreterInfo.h"

which further needs XPath.hpp

but the include is not necessary in Factory.h, forward decl would be sufficient.

usr/local/include/uscxml -I. -o ustatemachine.o ../bitbucket/libs/uscxmlManager/ustatemachine.cpp
In file included from /usr/local/include/uscxml/Factory.h:24:0,
from ../bitbucket/libs/uscxmlManager/ustatemachine.cpp:4:
/usr/local/include/uscxml/InterpreterInfo.h:28:27: fatal error: XPath/XPath.hpp: No such file or directory
compilation terminated.

[Lua Datamodel] Sending "error.execution" event causes unhandled exception when LOM is not assigned.

During execution of $(USCXML_ROOT)\test\w3c\lua\test194.scxml I've got unhandled exception.

I understood why is it so. We generate "error.execution" and when lua object model is not supported we produce "error.execution" again.

LuaDataModel.cpp

void LuaDataModel::setEvent(const Event& event) {
        ...
    if (event.dom) {
        if (_luaHasXMLParser) {
            const luabridge::LuaRef& luaLom = luabridge::getGlobal(_luaState, "lxp.lom");
            const luabridge::LuaRef& luaLomParse = luaLom["parse"];
            assert(luaLomParse.isFunction());
            std::stringstream luaXMLSS;
            luaXMLSS << event.dom;
            try {
                luaEvent["data"] = luaLomParse(luaXMLSS.str());
            } catch (luabridge::LuaException e) {
                ERROR_EXECUTION_THROW(e.what());
            }
        } else {
// WE COME HERE AND PRODUCE AGAIN "error.execution"
// AND IT'S SEEM TO BE A DEADLOCK           
ERROR_EXECUTION_THROW("No DOM support in Lua datamodel");
        }
    } else if (event.content.length() > 0) {
...

So I offer to set a condition, that we did not come from "error.execution" event

void LuaDataModel::setEvent(const Event& event) {
        ...
    if (event.dom && event.name!="error.execution") {

test_194.cpp

#include "uscxml/Interpreter.h"
#include "glog/logging.h"

using namespace uscxml;

static const char *chScxml =

    "<scxml datamodel=\"lua\" initial=\"s0\" name=\"ScxmlShape1\" version=\"1.0\" xmlns=\"http://www.w3.org/2005/07/scxml\">"
    "   <state id=\"s0\">"
    "       <onentry>"
    "           <send event=\"event2\" target=\"xxxxxxxxx\"/>"
    "           <send event=\"timeout\"/>"
    "       </onentry>"
    "       <transition event=\"error.execution\" target=\"pass\"/>"
    "       <transition event=\"*\" target=\"fail\"/>"
    "   </state>"
    "   <final id=\"pass\"/>"
    "   <final id=\"fail\"/>"
    "</scxml>"
    ;

int main(int argc, char** argv) {
    google::LogToStderr();
    google::InitGoogleLogging(argv[0]);

    uscxml::Interpreter scxml = uscxml::Interpreter::fromXML(chScxml, "");    
    scxml.addMonitor(new  StateTransitionMonitor());

    uscxml::InterpreterState state;    
    // assume initial stable configuration
    do {
        state = scxml.step();
    } while(state > 0);

    while(state != uscxml::USCXML_FINISHED) {
        do {
            state = scxml.step();
        } while(state > 0);
    }

    return EXIT_SUCCESS;    
}

Syntax error in 'BuildXercesC.cmake'

On string 57 and 72 we need slash in copy destination directory. Otherwise cmake creates file with such name

Wrong variant:
${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/deps/xerces-c/lib/xerces-c_3_1.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}

Correct variant
${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/deps/xerces-c/lib/xerces-c_3_1.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/

P.S. And please, look at issue 75. It needs more correction.

XPathDataModel.cpp:501: data element has no content [fail initializing datamodel with XML nodes]

Hi,
we receive the following error when starting the scxml interpreter:

E0925 09:56:37.048688  8641 XPathDataModel.cpp:501] data element has no content

the scxml file we are using:
https://gist.github.com/enricop/1a7fe33e05f35ff7a42c
The problem is that 'TIM' data element is not initialized.
(We tried changing the data element with simpler ones, but nothing changes)

Debugging this problem i can see that

'const Node<std::string>& node'  at XPathDataModel.cpp:453 

is passed correctly to

XPathDataModel::init at XPathDataModel.cpp:452

with the complete XML tree of the XML nodes.

However the check

'if (node) {' at XPathDataModel.cpp:464

fails without a reason.

If i try to force the execution of the block:

  Node<std::string> data = node;
        while (data) {
         Node<std::string> dataClone = _doc.importNode(data, true);
         container.appendChild(dataClone);
             data = data.getNextSibling();
    }

i have no errors, but the data element is not correctly initialized in memory,
resulting in the following errors (related to an assign command)

E0925 10:10:13.249907  8746 Interpreter.cpp:1138] Assigning to undeclared location '$TIM/frame/data[@index='17']/item/nestedData' not allowed.

And if i print the content of
an event sending the TIM namelist:

  {
    "TIM": undefined
  }

We would like to know what are the parts of the XPath datamodel implementation that are currently working, and if it possible to find a workaround for this problem if it is confirmed.
We need the XPath datamodel since we can send directly data elements in XML format to external listeners.

We are using the latest revision on USCXML (commit be3c180) on Linux x86_64

We tried replacing contrib/prebuild/libarabica.a with our revision compiled locally.
USCXML compiles correctly but the error above does not change.

Thanks for your thoughts and suggestions, I'll really appreciate them!

Enrico

Cannot build on Windows

I followed the instructions for Windows but all it did is to generate empty project files which do not build the source code itself. Any ideas how to proceed?

Arabica Memory Leaks when usinx xpath datamodel

Hi,
we are stress testing our software based on uscxml.

We notice that a large amount of memory is acquired by the process as the interpreter processes large amount of XML data. (almost 1M every 20sec)
We use heavily a '< send > ' element nested into a '< foreach >' element in our SCXML.

We tried switching our arabica backend to Expat, but the memory leaks are still there.
We know that arabica manages the memory 'automagically' and should free any node that is not referenced any more by some objects.
We think in some parts of the XPathDataModel.cpp file nodes are cloned or imported in a wrong way. So that references are never going to be 0 even when the corresponding object is destroyed.

What about the coexisting _doc and _datamodel objects? These two objects seems to be used almost interchangeably. The first is used to create new elements and the second to maintain the current datamodel.

We tried using valgrind but it crashes while examining the process.

Our XPathDataModel:
https://github.com/enricop/uscxml/blob/master/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp

Can you provide some suggestion to find out these problems in the datamodel code?

For example, how could the nodes, returned by the resolveVariable function, be freed? The are allocated to a new NodeSetValue every time the XPath engine resolves a variable.
https://github.com/enricop/uscxml/blob/master/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp#L829

Thank you for your support.
Best Regards,
Enrico

Can not gently destroy unfinished Interpeter with blocking steps

In issue 62 it was recommended to use blocking steps to prevent assertion on destroying of invoked components. Ok, it's work for that. But now I can not understand how gently stop unfinished main interpreter. I've got such assertion in the sample below.

#include "uscxml/Interpreter.h"
#include "glog/logging.h"

#include <boost/thread.hpp>
#include <boost/bind.hpp>

using namespace uscxml;

void InterpreterInThread(Interpreter *AInterpreter) {
    InterpreterState state;
    do {
        state = AInterpreter->step(true);
    } while(state != uscxml::USCXML_FINISHED);  
}

int main(int argc, char** argv) {
    google::LogToStderr();
    google::InitGoogleLogging(argv[0]);

    const char *chScxml =
        "<scxml initial=\"Start\" name=\"root\" version=\"1.0\" xmlns=\"http://www.w3.org/2005/07/scxml\">"
        "   <state id=\"Start\">"
        "       <transition event=\"block\" target=\"Fail\"/>"
        "   </state>"
        "   <final id=\"Fail\"/>"
        "</scxml>";


    uscxml::Interpreter scxml = uscxml::Interpreter::fromXML(chScxml, "");
    scxml.addMonitor(new StateTransitionMonitor());

    boost::thread t(boost::bind(&InterpreterInThread,&scxml));

    boost::this_thread::sleep(boost::posix_time::seconds(1));

    scxml.reset();

    t.join();

    std::cout << "************************************" << std::endl;
    std::cout << "Successfully finished state machine!" << std::endl;

    return EXIT_SUCCESS;

}

Assertion failed: false, file ..\src\uscxml\Interpreter.cpp, line 1323

P.S. I'm sorry, just now have seen a new version. I will download latest and check again.

Can not build 'libcurl' win 7 64 VS2013

CMake Error at libcurl-stamp/download-libcurl.cmake:9 (file):
file DOWNLOAD HASH mismatch
for file: [G:/SDK/uscxml_2_0/vc12/deps/libcurl/src/curl-7.48.0.tar.gz]
expected hash: [b2cac71029d28cb989150bac72aafab5]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [51;"SSL peer certificate was not ok"]

P.S. It's a pity that you did not support more VS2010

Element <finalize> with no executable content do not update model data.

According to standard in the chapter 6.5.2 of element is written

If no executable content is specified, the SCXML Processor must update the data model each time an event is received from the child process that was created by the parent element. Specifically if the parent element contains a 'namelist' attribute or one or more children containing 'location' attributes, then for each item in the 'namelist' attribute and each such element, the Processor must update the corresponding location as if by with any return value that has a name that matches the 'namelist' item or the 'name' of the element. Thus the effect of an with an empty element and either a 'namelist' attribute or a element with a 'location' attribute is first to send the part of the data model specified by 'namelist' or 'location' to the invoked component and then to update that part of the data model with any returned values that have the same name. Note that the automatic update does not take place if the element is absent as opposed to empty.

So the next scxml fails

<scxml datamodel="lua" initial="main" name="root" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <datamodel>
        <data expr="1" id="i_GLOBAL_VAR"/>
    </datamodel>
    <state id="main" initial="start">
        <transition event="error.*" target="Fail"/>
        <transition cond="i_GLOBAL_VAR==2" event="completed" target="Pass"/>
        <transition event="completed" target="Fail"/>
        <state id="start">
            <invoke id="test_invoke" namelist="i_GLOBAL_VAR" type="scxml">
                <content>
                    <scxml datamodel="lua" initial="InvokeStart" name="scxml_invoke" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
                        <datamodel>
                            <data expr="0" id="i_GLOBAL_VAR"/>
                        </datamodel>
                        <final id="InvokeEnd">
                            <onentry>
                                <send event="completed" namelist="i_GLOBAL_VAR" target="#_parent"/>
                            </onentry>
                        </final>
                        <state id="InvokeStart">
                            <onentry>
                                <assign expr="i_GLOBAL_VAR*2" location="i_GLOBAL_VAR"/>
                                <log expr="i_GLOBAL_VAR" label="INVOKE-i_GLOBAL_VAR"/>
                            </onentry>
                            <transition target="InvokeEnd"/>
                        </state>
                    </scxml>
                </content>
                <finalize/>
            </invoke>
        </state>
    </state>
    <final id="Fail"/>
    <final id="Pass"/>
</scxml>

Fatal error with duplicating names in invokable scxml placed in content.

When scxml is placed inside invoke content it causes fatal error with duplicating names.

main.scxml

<scxml datamodel="lua" initial="start" name="root" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <final id="end"/>
    <state id="start">
        <invoke id="test_invoke" type="scxml">
            <content>
                <scxml datamodel="lua" name="scxml_invoke" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
                    <state id="start">
                        <transition target="end"/>
                    </state>
                    <final id="end"/>
                </scxml>
            </content>
        </invoke>
        <transition event="done.invoke.test_invoke" target="end"/>
    </state>
</scxml>

Output:

E0423 11:09:52.799 742 4 712 uscxml_tester.cpp:124] Issue (FATAL) at //state[@id="start"]: State with id 'start' is unreachable
E0423 11:09:52.807 742 4 712 uscxml_tester.cpp:124] Issue (FATAL) at //state[@id="start"]: Duplicate state with id 'start'
E0423 11:09:52.810 742 4 712 uscxml_tester.cpp:124] Issue (FATAL) at //final[@id="end"]: State with id 'end' is unreachable
E0423 11:09:52.812 742 4 712 uscxml_tester.cpp:124] Issue (FATAL) at //final[@id="end"]: Duplicate state with id 'end'

But, when scxml is placed in extern file, everything works fine.

main.scxml

<scxml datamodel="lua" initial="start" name="root" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <final id="end"/>
    <state id="start">
        <invoke id="test_invoke" src="file:///c:/TSServices/Test/invoke1.scxml" type="scxml"/>
        <transition event="done.invoke.test_invoke" target="end"/>
    </state>
</scxml>

invoke1.scxml

<scxml datamodel="lua" initial="start" name="scxml_invoke" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <state id="start">
        <transition target="end"/>
    </state>
    <final id="end"/>
</scxml>

Output:

I0423 11:08:28.610 743 3 408 uscxml_tester.cpp:61] After enter:start
I0423 11:08:28.612 742 3 408 uscxml_tester.cpp:72] After enter:start
I0423 11:08:28.628 742 3 408 Interpreter.cpp:2 298] Added invoker scxml at test_invoke
I0423 11:08:28.641 742 3 408 uscxml_tester.cpp:37] After exit:start
I0423 11:08:28.665 742 3 408 uscxml_tester.cpp:49] After exit:start
I0423 11:08:28.669 742 3 408 Interpreter.cpp:2 351] Removed invoker at test_invoke
I0423 11:08:28.679 743 3 408 uscxml_tester.cpp:61] After enter:end
I0423 11:08:28.682 742 3 408 uscxml_tester.cpp:72] After enter:end
I0423 11:08:28.687 742 3 408 uscxml_tester.cpp:276] *********************************
I0423 11:08:28.691 742 3 408 uscxml_tester.cpp:277] Successfully ended state machine!
I0423 11:08:28.693 742 3 408 uscxml_tester.cpp:278] *********************************

'getopt.c' not included in uscxml.lib (Win 7.1)

That's why during compiling app we get errors

uscxml.lib(Interpreter.obj) : error LNK2001: unresolved external symbol _getopt_long_only
uscxml.lib(Interpreter.obj) : error LNK2001: unresolved external symbol _optind
uscxml.lib(Interpreter.obj) : error LNK2001: unresolved external symbol _opterr
uscxml.lib(Interpreter.obj) : error LNK2001: unresolved external symbol _optarg

Syntax errors in 'BuildLibEvent.cmake'

Lines 28-31

${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/deps/libevent/lib && 
${CMAKE_COMMAND} -E copy libevent.lib libevent_core.lib libevent_extras.lib ${CMAKE_BINARY_DIR}/deps/libevent/lib/ && 
${CMAKE_COMMAND} -E copy_directory include ${CMAKE_BINARY_DIR}/deps/libevent/include
${CMAKE_COMMAND} -E copy Win32-Code/event2 ${CMAKE_BINARY_DIR}/deps/libevent/include/event2

should be replaced by

${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/deps/libevent/lib && 
${CMAKE_COMMAND} -E copy libevent.lib libevent_core.lib libevent_extras.lib ${CMAKE_BINARY_DIR}/deps/libevent/lib/ && 
${CMAKE_COMMAND} -E copy libevent_core.lib ${CMAKE_BINARY_DIR}/deps/libevent/lib/ &&
${CMAKE_COMMAND} -E copy libevent_extras.lib ${CMAKE_BINARY_DIR}/deps/libevent/lib/ &&
${CMAKE_COMMAND} -E copy_directory include ${CMAKE_BINARY_DIR}/deps/libevent/include &&
${CMAKE_COMMAND} -E copy_directory Win32-Code/event2 ${CMAKE_BINARY_DIR}/deps/libevent/include/event2

Ubuntu 15.10: can not be used when making a shared object; recompile with -fPIC

Hello,

i just tried the new version. I get now:
Is there a flag missing?
can not be used when making a shared object; recompile with -fPIC

[ 32%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/interpreter/ContentExecutorImpl.cpp.o
[ 33%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/interpreter/MicroStepFast.cpp.o
[ 35%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/interpreter/EventQueueImpl.cpp.o
[ 37%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/interpreter/InterpreterImpl.cpp.o
[ 39%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/messages/Event.cpp.o
[ 41%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/messages/Blob.cpp.o
[ 43%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/messages/Data.cpp.o
[ 45%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/debug/InterpreterIssue.cpp.o
[ 47%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/util/Convenience.cpp.o
[ 49%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/util/DOM.cpp.o
[ 50%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/util/Predicates.cpp.o
[ 52%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/util/URL.cpp.o
[ 54%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/util/UUID.cpp.o
[ 56%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/util/String.cpp.o
[ 58%] Building C object CMakeFiles/uscxml.dir/src/uscxml/util/MD5.c.o
[ 60%] Building C object CMakeFiles/uscxml.dir/src/uscxml/util/Base64.c.o
[ 62%] Building C object CMakeFiles/uscxml.dir/src/uscxml/util/SHA1.c.o
[ 64%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/server/HTTPServer.cpp.o
[ 66%] Building C object CMakeFiles/uscxml.dir/contrib/src/jsmn/jsmn.c.o
[ 67%] Building C object CMakeFiles/uscxml.dir/contrib/src/evws/evws.c.o
[ 69%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/Interpreter.cpp.o
[ 71%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/plugins/Factory.cpp.o
[ 73%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp.o
[ 75%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp.o
[ 77%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp.o
[ 79%] Building CXX object CMakeFiles/uscxml.dir/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp.o
Linking CXX shared library lib/libuscxml.so
/usr/bin/ld: deps/uriparser/lib/liburiparser.a(UriFile.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
deps/uriparser/lib/liburiparser.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
CMakeFiles/uscxml.dir/build.make:718: recipe for target 'lib/libuscxml.so.2.0.0' failed
make[2]: *** [lib/libuscxml.so.2.0.0] Error 1
CMakeFiles/Makefile2:95: recipe for target 'CMakeFiles/uscxml.dir/all' failed
make[1]: *** [CMakeFiles/uscxml.dir/all] Error 2
Makefile:85: recipe for target 'all' failed
make: *** [all] Error 2
orko@battlecat:~/study/t

[Lua datamodel] Unpredictable behaviour in <assign> element using variables in location

Hello, I'm trying to use variables in location during assigning the data
<assign expr="1" location="VarArray[Var1]"/>
and I neither get the data changed nor any errors from interpreter.

So, can we use variables in location?
If not why we don't have any warnings or errors?
P.S. If I use <script> element for assigning the data, everything works fine.

<scxml datamodel="lua" initial="StateShape1" name="ScxmlShape1" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<datamodel>
		<data id="VarArray">{ 0, 0, 0 }</data>
		<data expr="1" id="Var1"/>
	</datamodel>
	<state id="StateShape1">
		<onentry>
			<assign expr="555" location="VarArray[Var1]"/>
		</onentry>
		<transition cond="VarArray[1]~=0" target="Pass"/>
		<transition event="error.*" target="Fail"/>
		<transition cond="VarArray[1]==0" target="Unknown"/>
	</state>
	<final id="Pass"/>
	<final id="Fail"/>
	<final id="Unknown"/>
</scxml>

[Lua datamodel] Data is not isolated in invokable session

Hello, according to scxml standard

The invoked external resource is logically separated from the state machine that invokes it and does not share data with it unless the author explicitly requests this with the <param> or <content> elements and/or the 'src' and 'namelist' attributes

but in present version all data is in global scope. I transformed test244 by removing namelist attribute and declared a variable inside of invokable session and I pass the test instead of getting error.

<scxml datamodel="lua" initial="s0" name="ScxmlShape1" version="1.0" xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance">
	<datamodel>
		<data expr="1" id="Var1"/>
	</datamodel>
	<state id="s0">
		<onentry>
			<send delay="2000" event="timeout" xmlns:scxml="http://www.w3.org/2005/07/scxml"/>
		</onentry>
		<invoke type="http://www.w3.org/TR/scxml/">
			<content>
				<scxml datamodel="lua" initial="sub0" name="ScxmlShape1" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
					<datamodel>
						<data expr="555" id="VarXXX"/>
					</datamodel>
					<final id="subFinal"/>
					<state id="sub0">
						<transition cond="Var1==1" target="subFinal">
							<send target="#_parent" event="success"/>
						</transition>
						<transition target="subFinal">
							<send target="#_parent" event="failure"/>
						</transition>
					</state>
				</scxml>
			</content>
		</invoke>
		<transition event="success" target="pass"/>
		<transition event="*" target="fail"/>
	</state>
	<final id="pass" xmlns:scxml="http://www.w3.org/2005/07/scxml">
		<onentry>
			<log expr="'pass'" label="Outcome"/>
			<log expr="VarXXX" label="We mustn't see VarXXX here"/>
		</onentry>
	</final>
	<final id="fail" xmlns:scxml="http://www.w3.org/2005/07/scxml">
		<onentry>
			<log expr="'fail'" label="Outcome"/>
		</onentry>
	</final>
</scxml>

Makefile:85: recipe for target 'install' failed

Hello,

I am probably a bit fast, but I saw you checked in the documentation. So, I tried... ;)

CMake Error at docs/cmake_install.cmake:36 (file):
file INSTALL cannot find "/home/orko/study/thesis/uscxml-build/docs/html".
Call Stack (most recent call first):
cmake_install.cmake:287 (include)

Makefile:85: recipe for target 'install' failed
make: *** [install] Error 1

How apply ActionLanguage to invokers?

Hello,
I created my custom DelayedEventQueue and passed it through the ActionLanguage class

AviaDelayedEventQueue *aviaqueue = new AviaDelayedEventQueue(g_intepreter.getImpl().get());
aviaqueue->getElapsed = std::bind(&Timer::getElapsed,&g_Timer);
ActionLanguage lang;
lang.delayedQueue = DelayedEventQueue(std::shared_ptr<DelayedEventQueueImpl>(aviaqueue));
g_intepreter.setActionLanguage(lang);

It works fine but affect only on top level interpreter.
How override delayed event queue in invokers?

I tried to register custom invoker as written in the code below

namespace uscxml {

	class ScxmlDelayInvoker :
		public USCXMLInvoker
	{
		ActionLanguage *lang_;
	public:
		ScxmlDelayInvoker(ActionLanguage *ALang);
		virtual ~ScxmlDelayInvoker();

		std::shared_ptr<InvokerImpl> ScxmlDelayInvoker::create(InterpreterImpl* interpreter) {
		// variant 1
		/*AviaDelayedEventQueue *aviaqueue = new AviaDelayedEventQueue(interpreter);
		aviaqueue->getElapsed = std::bind(&Timer::getElapsed, _pTimer);
		
		ActionLanguage lang;
		lang.delayedQueue =
			DelayedEventQueue(std::shared_ptr<DelayedEventQueueImpl>(aviaqueue));*/
		
		// variant 2
		interpreter->setActionLanguage(*lang_);

		std::shared_ptr<ScxmlDelayInvoker> invoker(new ScxmlDelayInvoker(lang_));
		invoker->_interpreter = interpreter;

		return invoker;
	}

		virtual std::list<std::string> getNames() {
			std::list<std::string> names;
			names.push_back("delay_scxml");
			return names;
		}
	};

}

ScxmlDelayInvoker *delayinvoker = new ScxmlDelayInvoker(&lang);
Factory::getInstance()->registerInvoker(delayinvoker);

But during invoke I've got fatal error (AccessViolation) and I think that I'm not doing it correctly.
So, where is my mistake?

XPathDatamodel: cannot resolve external namespace functions

When the xpath expression speficied in the array tag below is resolved:

<foreach array="fn:tokenize($_event/data/text(), ',')" item="itemCurr" index="numr">
                    <assign location="XPATH_LOCATION" xpr="$itemCurr"/>
</foreach>

I get the following exception:

terminate called after throwing an instance of 'Arabica::XPath::UndefinedFunctionException'
  what():  The function '{http://www.w3.org/2005/xpath-functions}tokenize' is undefined.

This happens after I've added

    dm->_xpath.setNamespaceContext(interpreter->getNSContext());

to XPathDatamodel.cpp:55. (bofere this the 'fn' namespace wasn't even resolved).

However this fix is not enough since the string "{http://www.w3.org/2005/xpath-functions}tokenize" is not a correct function identifier.

I am really new in this area. I don't know how resolved functions should be returned from the interpreter to Arabica, but I need to find a solution quickly.

Are changes required to the validNames() and resolveFunction() methods?
Any suggestion?

Thank you for your precious support.
Regards,
Enrico

EDIT:
Among the scmxl element tags i have:
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns="http://www.w3.org/2005/07/scxml"

Lua porting

give advice, please, how to bind uscxml with language Lua?

Function 'resortStates' in 'void FastMicroStep::init' executes in 50 sec with some scxml

Hi, now I continue testing history in inline invokes, but have a trouble with huge time (50 sec) of initialization. In version 1.0 the same code worked immediately.

<scxml datamodel="lua" initial="Work" name="Simulator" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <datamodel>
        <data id="PauseTimers">{
    test = 'a',
    b = 25,
    t_test = {
        xxx = '23',
        zzz = 45
    }
}
        </data>
    </datamodel>
    <final id="Pass"/>
    <final id="Fail"/>
    <state id="Work" initial="Init">
        <onentry>
            <log expr="'Hello from work'"/>
        </onentry>
        <transition event="error.*" target="Fail"/>
        <transition event="quit" target="Pass"/>
        <state id="Init">
            <onentry>
                <log expr="'Hello from init'"/>
            </onentry>
            <transition event="StartExercise" target="Training"/>
        </state>
        <parallel id="Training">
            <transition event="StopExercise" target="Init"/>
            <state id="APU">
                <invoke type="scxml">
                    <content>
                        <scxml datamodel="lua" initial="StateShape1" name="ScxmlShape1" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
                            <final id="Fail"/>
                            <state id="StateShape1" initial="Flash">
                                <transition event="error" target="Fail"/>
                                <transition event="StopExercise" target="Pass"/>
                                <state id="Flash">
                                    <datamodel>
                                        <data id="t_ApuOff">{
    dDiff = 0,
    dEnter = os.clock(),
    dInterval = 2000
}
                                        </data>
                                        <data id="t_ApuOn">{
    dDiff = 0,
    dEnter = os.clock(),
    dInterval = 2000
}
                                        </data>
                                        <data expr="'xxx'" id="FlashName"/>
                                    </datamodel>
                                    <transition event="Pause" target="OnPause"/>
                                    <state id="ApuOn">
                                        <onentry>
                                            <send delayexpr="tostring(t_ApuOn.dInterval-t_ApuOn.dDiff)..'ms'" event="DoApuOff" id="ID_DoApuOff"/>
                                            <assign expr="os.clock()" location="t_ApuOn.dEnter"/>
                                            <log expr="string.format('%s=%d',FlashName,t_ApuOn.dInterval-t_ApuOn.dDiff)" label="Delay[On]"/>
                                        </onentry>
                                        <onexit>
                                            <cancel sendid="ID_DoApuOff"/>
                                            <assign expr="t_ApuOn.dDiff + (os.clock() - t_ApuOn.dEnter)*1000" location="t_ApuOn.dDiff"/>
                                            <log expr="string.format('%s=%d',FlashName,t_ApuOn.dDiff)" label="Elapsed[On]"/>
                                        </onexit>
                                        <transition event="DoApuOff" target="ApuOff">
                                            <assign location="t_ApuOn.dDiff" expr="0"/>
                                        </transition>
                                    </state>
                                    <initial>
                                        <transition target="ApuOff">
                                            <assign location="t_ApuOff.dDiff" expr="0"/>
                                            <assign location="t_ApuOn.dDiff" expr="0"/>
                                        </transition>
                                    </initial>
                                    <state id="ApuOff">
                                        <onentry>
                                            <send delayexpr="tostring(t_ApuOff.dInterval-t_ApuOff.dDiff)..'ms'" event="DoApuOn" id="ID_DoApuOn"/>
                                            <assign expr="os.clock()" location="t_ApuOff.dEnter"/>
                                            <log expr="string.format('%s=%d',FlashName,t_ApuOff.dInterval-t_ApuOff.dDiff)" label="Delay[Off]"/>
                                        </onentry>
                                        <onexit>
                                            <cancel sendid="ID_DoApuOn"/>
                                            <assign expr="t_ApuOff.dDiff + (os.clock() - t_ApuOff.dEnter)*1000" location="t_ApuOff.dDiff"/>
                                            <log expr="string.format('%s=%d',FlashName,t_ApuOff.dDiff)" label="Elapsed[Off]"/>
                                        </onexit>
                                        <transition event="DoApuOn" target="ApuOn">
                                            <assign location="t_ApuOff.dDiff" expr="0"/>
                                        </transition>
                                    </state>
                                    <history id="HistoryShape1" type="deep">
                                        <transition target="ApuOff"/>
                                    </history>
                                </state>
                                <state id="OnPause">
                                    <transition event="Resume" target="HistoryShape1"/>
                                </state>
                            </state>
                            <final id="Pass"/>
                        </scxml>
                    </content>
                    <param expr="'APU'" name="FlashName"/>
                </invoke>
            </state>
            <state id="StateShape3">
                <state id="OnResume">
                    <transition event="Pause" target="OnPause"/>
                </state>
                <state id="OnPause">
                    <transition event="Resume" target="OnResume"/>
                </state>
            </state>
            <state id="ENGINES">
                <invoke type="scxml">
                    <content>
                        <scxml datamodel="lua" initial="StateShape1" name="ScxmlShape1" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
                            <final id="Fail"/>
                            <state id="StateShape1" initial="Flash">
                                <transition event="error" target="Fail"/>
                                <transition event="StopExercise" target="Pass"/>
                                <state id="Flash">
                                    <datamodel>
                                        <data id="t_ApuOff">{
    dDiff = 0,
    dEnter = os.clock(),
    dInterval = 2000
}
                                        </data>
                                        <data id="t_ApuOn">{
    dDiff = 0,
    dEnter = os.clock(),
    dInterval = 2000
}
                                        </data>
                                        <data expr="'xxx'" id="FlashName"/>
                                    </datamodel>
                                    <transition event="Pause" target="OnPause"/>
                                    <state id="ApuOn">
                                        <onentry>
                                            <send delayexpr="tostring(t_ApuOn.dInterval-t_ApuOn.dDiff)..'ms'" event="DoApuOff" id="ID_DoApuOff"/>
                                            <assign expr="os.clock()" location="t_ApuOn.dEnter"/>
                                            <log expr="string.format('%s=%d',FlashName,t_ApuOn.dInterval-t_ApuOn.dDiff)" label="Delay[On]"/>
                                        </onentry>
                                        <onexit>
                                            <cancel sendid="ID_DoApuOff"/>
                                            <assign expr="t_ApuOn.dDiff + (os.clock() - t_ApuOn.dEnter)*1000" location="t_ApuOn.dDiff"/>
                                            <log expr="string.format('%s=%d',FlashName,t_ApuOn.dDiff)" label="Elapsed[On]"/>
                                        </onexit>
                                        <transition event="DoApuOff" target="ApuOff">
                                            <assign location="t_ApuOn.dDiff" expr="0"/>
                                        </transition>
                                    </state>
                                    <initial>
                                        <transition target="ApuOff">
                                            <assign location="t_ApuOff.dDiff" expr="0"/>
                                            <assign location="t_ApuOn.dDiff" expr="0"/>
                                        </transition>
                                    </initial>
                                    <state id="ApuOff">
                                        <onentry>
                                            <send delayexpr="tostring(t_ApuOff.dInterval-t_ApuOff.dDiff)..'ms'" event="DoApuOn" id="ID_DoApuOn"/>
                                            <assign expr="os.clock()" location="t_ApuOff.dEnter"/>
                                            <log expr="string.format('%s=%d',FlashName,t_ApuOff.dInterval-t_ApuOff.dDiff)" label="Delay[Off]"/>
                                        </onentry>
                                        <onexit>
                                            <cancel sendid="ID_DoApuOn"/>
                                            <assign expr="t_ApuOff.dDiff + (os.clock() - t_ApuOff.dEnter)*1000" location="t_ApuOff.dDiff"/>
                                            <log expr="string.format('%s=%d',FlashName,t_ApuOff.dDiff)" label="Elapsed[Off]"/>
                                        </onexit>
                                        <transition event="DoApuOn" target="ApuOn">
                                            <assign location="t_ApuOff.dDiff" expr="0"/>
                                        </transition>
                                    </state>
                                    <history id="HistoryShape1" type="deep">
                                        <transition target="ApuOff"/>
                                    </history>
                                </state>
                                <state id="OnPause">
                                    <transition event="Resume" target="HistoryShape1"/>
                                </state>
                            </state>
                            <final id="Pass"/>
                        </scxml>
                    </content>
                    <param expr="'ENGINES'" name="FlashName"/>
                </invoke>
            </state>
        </parallel>
    </state>
</scxml>

[Lua datamodel] Table data with string key values can not be evaluated

Hi, I'm trying to assigning table to data element.
This code works correctly

<scxml datamodel="lua" initial="Start" name="Root" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <datamodel>
        <data id="testTable">{
    555,777,888
}
        </data>
    </datamodel>
    <final id="Pass"/>
    <final id="Fail"/>
    <state id="Start">
        <onentry>
            <script>print('*************************')
print(type(testTable))
for k,v in pairs(testTable) do
    print(string.format(&quot;key=%s,value=%s&quot;,tostring(k),tostring(v)))
end
            </script>
        </onentry>
        <transition target="Pass"/>
        <transition event="error.*" target="Fail"/>
    </state>
</scxml>

But, when elements in table have string keys they can not be interpretated into Lua variables

<scxml datamodel="lua" initial="Start" name="Root" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <datamodel>
        <data id="testTable">{
    a=555,b=777,c=888
}
        </data>
    </datamodel>
    <final id="Pass"/>
    <final id="Fail"/>
    <state id="Start">
        <onentry>
            <script>print('*************************')
print(type(testTable))
for k,v in pairs(testTable) do
    print(string.format(&quot;key=%s,value=%s&quot;,tostring(k),tostring(v)))
end
            </script>
        </onentry>
        <transition target="Pass"/>
        <transition event="error.*" target="Fail"/>
    </state>
</scxml>

And I've got exception in 'LuaDataModel.cpp' in the line 87
data.compound[luaKey.tostring()] = getLuaAsData(_luaState, luaVal);

During converting luaKey to string I get NULL instead of 'a','b','c'

No make rule to install your gem...

Hello,

compiling works now, but there is no make-rule to install uscxml:

orko@battlecat:~/study/thesis/uscxml$ sudo make install
make: *** No rule to make target 'install'. Stop.

Can't compile on ubuntu 15.10

Hello,

I just updated to Ubuntu 15.10 and can't compile uscxml:

[ 73%] Built target uscxml
[ 73%] Built target uscxml_transform
Scanning dependencies of target uscxml-analyze
[ 73%] Building CXX object CMakeFiles/uscxml-analyze.dir/apps/uscxml-analyze.cpp.o
Linking CXX executable bin/uscxml-analyze
CMakeFiles/uscxml-analyze.dir/apps/uscxml-analyze.cpp.o: In function main': uscxml-analyze.cpp:(.text.startup+0x41c): undefined reference toArabica::io::URI::as_stringabi:cxx11 const'
lib/libuscxml64.so: undefined reference to Arabica::io::URI::URI(Arabica::io::URI const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' lib/libuscxml64.so: undefined reference togoogle::LogSink::ToString[abi:cxx11](int, char const*, int, tm const*, char const*, unsigned long)'
lib/libuscxml64.so: undefined reference to Arabica::io::URI::URI(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' lib/libuscxml64.so: undefined reference toArabica::SAX::InputSourceResolver::open(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::_cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::istream)'
lib/libuscxml64.so: undefined reference to `Arabica::io::URI::portabi:cxx11 const'
collect2: error: ld returned 1 exit status
CMakeFiles/uscxml-analyze.dir/build.make:126: recipe for target 'bin/uscxml-analyze' failed
make[2]: *_* [bin/uscxml-analyze] Error 1
CMakeFiles/Makefile2:189: recipe for target 'CMakeFiles/uscxml-analyze.dir/all' failed
make[1]: *** [CMakeFiles/uscxml-analyze.dir/all] Error 2
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2

I can't even find the place in uscxml where Arabica::io::URI::URI is even used.
The error is not in the application, it is somewhere inside uscxml.

I appreciate any help.

Andreas

Can not resolve URL (Win 7.1 MSVC2013)

During executing 'test-validating.cpp' in line Interpreter interpreter = Interpreter::fromXML(xml, "")
I've got exception in 'url.cpp' function 'resolve'

Cannot resolve <> with <file%3A%2F%2FG%3A/SDK/uscxml_2_0/vc12/test/>

XML Character escaping entity '&quot;' is ignored by xml parser (Lua datamodel)

Suppose we have some variants of text in script:

  1. "<script> print('Hello, World!') </script>"
    Output>>print('Hello, World!') Ok.

  2. "<script> print("Hello, World!") </script>"
    Output>>print("Hello, World!") Ok.

  3. "<script><![CDATA[ print('Hello, \"World\"') ]]> </script>"
    Output>>:print('Hello, "World!"') Ok.

  4. "<script> print('Hello, &quot;World&quot;') </script>"
    Output>>:print('Hello, World!') Error!
    Description: missing double quotes around 'World'!

  5. "<script> print(&quot;Hello, world!&quot;) </script>"
    Output>>: print(Hello, world!) Fatal!
    Description: missing double quotes and of course Lua syntax error

As far as you know a lot of parsers enclose double quotes in attributes and text with entity "&quot". And after creating scxml text we have all double quotes escaped. What is the correct way to manage with text attributes, that contains such entities?

source code for testing

[Lua datamodel] Script content is evaluated with 'return' that causes error

Hello, script code seems to be evaluated as data.

<scxml datamodel="lua" initial="Start" name="Root" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <state id="Start">
        <onentry>
            <script>x = 15
print(string.format(&quot;x=%d&quot;,x))
            </script>
        </onentry>
        <transition target="Pass"/>
    </state>
    <final id="Pass"/>
</scxml>

On version 1.0 it works normally, but now I've got syntax error.

2016-06-13 15:53:17,176 ERROR [default] name: error.execution
data:
{
"cause": "[string "return(x = 15..."]:1: ')' expected near '='"
}

Wrong URL causes crash on VC2010 Windows 7.1 64

During executing test-url.exe application crashes on lines
absURLs.push_back(URL("file:/"));
relURLs.push_back(URL("file:"));

Exact place in URL.cpp
_uri = Arabica::io::URI(url);

And on lines

URL relURL(*relIter);
relURL.toAbsolute(*absIter);

when relURL=="file://"

Thus, for example, I can not pass test216.scxml.

<scxml datamodel="lua" initial="s0" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <datamodel>
        <data expr="'foo'" id="testvar1"/>
    </datamodel>
    <state id="s0">
        <onentry>
            <send delay="5s" event="timeout"/>
            <assign expr="'file:test216sub1.scxml'" location="testvar1"/>
        </onentry>
        <invoke srcexpr="testvar1" type="http://www.w3.org/TR/scxml"/>
        <transition event="done.invoke" target="pass"/>
        <transition event="*" target="fail"/>
    </state>
    <final id="pass"/>
    <final id="fail"/>
</scxml>

expr="'file:test216sub1.scxml'" - CRASH
expr="'test216sub1.scxml'" - CRASH
expr="'file:///test216sub1.scxml'" - Error>"Failed to create interpreter from file:///test216sub1.scxml"

expr="'g:\\SDK\\uscxml_git\\test\\w3c\\lua\\test216sub1.scxml'"

  • Error>"Failed to create interpreter from file://g/SDK/uscxml_git/test/w3c/lua/test216sub1.scxml"

expr="'g:/SDK/uscxml_git/test/w3c/lua/test216sub1.scxml'"

  • Error>"Failed to create interpreter from file://g/SDK/uscxml_git/test/w3c/lua/test216sub1.scxml"

expr="'file:///g:/SDK/uscxml_git/test/w3c/lua/test216sub1.scxml'" - WORKS

Processing of invoked component does not stop after parent's transition out

According to spec 6.4.2

If the invoking session takes a transition out of the state containing the before it receives the 'done.invoke.id' event, the SCXML Processor must automatically cancel the invoked component and stop its processing.

1 issue:
In the example below we see that invoked component is cancelled only on final transition

2 issue
During cancelling of invoked component internal 'onexit' handlers do not work

<scxml datamodel="lua" initial="Level_1" name="Simulator" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <state id="Level_1" initial="Level_2_a">
        <transition event="error.*" target="Fail"/>
        <transition event="Quit" target="Pass"/>
        <state id="Level_2_a" initial="FlashProcess">
            <transition event="Stop" target="Level_2_b"/>
            <state id="FlashProcess">
                <invoke autoforward="true" type="scxml">
                    <content>
                        <scxml datamodel="lua" initial="Flash" name="Flasher" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
                            <state id="Flash">
                                <onexit>
                                    <log expr="'Why onexit does not work?'"/>
                                </onexit>
                                <transition event="error" target="Fail"/>
                                <initial>
                                    <transition target="Off"/>
                                </initial>
                                <state id="Off">
                                    <onentry>
                                        <send delay="500ms" event="DoOn"/>
                                        <log expr="'Flash off'"/>
                                    </onentry>
                                    <transition event="DoOn" target="On"/>
                                </state>
                                <state id="On">
                                    <onentry>
                                        <send delay="500ms" event="DoOff"/>
                                        <log expr="'Flash on'"/>
                                    </onentry>
                                    <transition event="DoOff" target="Off"/>
                                </state>
                            </state>
                            <final id="Fail"/>
                        </scxml>
                    </content>
                </invoke>
                <onentry>
                    <send delay="3s" event="Pause"/>
                </onentry>
                <transition event="Pause" target="OnPause"/>
            </state>
            <state id="OnPause">
                <onentry>
                    <send delay="3s" event="Stop"/>
                </onentry>
            </state>
        </state>
        <state id="Level_2_b">
            <onentry>
                <send delay="3s" event="Quit"/>
            </onentry>
        </state>
    </state>
    <final id="Pass"/>
    <final id="Fail"/>
</scxml>

Assertion in case of using send with id

I'm testing of canceling events. And I've got assertion

Assertion failed: _sendIds.find(sendReq.sendid) == _sendIds.end(), file ..\src\uscxml\Interpreter.cpp, line 2117

in scxml below

<scxml datamodel="lua" initial="work" name="root" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <datamodel>
        <data expr="0" id="testvar1"/>
    </datamodel>
    <state id="work" initial="act1">
        <transition event="OnTimer" target="fail"/>
        <transition cond="testvar1&gt;3" target="Pass"/>
        <state id="act1">
            <onentry>
                <send delay="3000ms" event="OnTimer" id="ID_OnTimer"/>
                <send delay="300ms" event="OnDone"/>
                <assign expr="testvar1 + 1" location="testvar1"/>
            </onentry>
            <onexit>
                <cancel sendid="ID_OnTimer"/>
            </onexit>
            <transition event="OnDone" target="act2"/>
        </state>
        <state id="act2">
            <onentry>
                <send delay="1000ms" event="Back"/>
            </onentry>
            <transition event="Back" target="act1"/>
        </state>
    </state>
    <final id="fail"/>
    <final id="Pass"/>
</scxml>

uscxml/Convenience.h does not build on linux

[I'm not using the includes provided with the uscxml package]
adding the following includes fixes the compile errors

#include <stdint.h>
#include <limits>
#include <climits>
#include <cwchar>
#include <limits>
#include <boost/static_assert.hpp>
#include <boost/detail/endian.hpp>
#include <boost/type_traits/is_arithmetic.hpp>

Lua version for datamodel >= 5.2

Dear Stefan !

Function call "lua_pcall ()" (in the module "Lua Data Model.cpp") has expired.
In Lua since version 5.2 of this function in lua library no more. Therefore, an error occurs when using datamodel.

Instead, use "lua_pcallk ()"

After commit 89947b3 execution of delayed events is broken in invokers

Hello, after latest commit I've got an assertion. Previously the code worked fine.
InterpreterImpl.cpp: line 336
assert(_delayedEventTargets.find(eventUUID) != _delayedEventTargets.end());

Please, check the code below

#include "uscxml/config.h"
#include "uscxml/Interpreter.h"
#include "uscxml/interpreter/InterpreterMonitor.h"

using namespace uscxml;

namespace Scxmlsample1 {
	static const char *chScxml =
		"<scxml initial=\"StateShape1\" name=\"ScxmlShape1\" version=\"1.0\" xmlns=\"http://www.w3.org/2005/07/scxml\">"
		"	<state id=\"StateShape1\" initial=\"StateShape2\">"
		"		<transition event=\"Quit\" target=\"FinalShape1\"/>"
		"		<transition event=\"error.*\" target=\"FinalShape1\"/>"
		"		<state id=\"StateShape2\">"
		"			<onentry>"
		"				<send delay=\"3000ms\" event=\"OnTimer\"/>"
		"			</onentry>"
		"			<transition event=\"OnTimer\" target=\"StateShape3\"/>"
		"		</state>"
		"		<state id=\"StateShape3\">"
		"			<invoke autoforward=\"true\" type=\"scxml\">"
		"				<content>"
		"					<scxml initial=\"StateShape1\" name=\"Include\" version=\"1.0\" xmlns=\"http://www.w3.org/2005/07/scxml\">"
		"						<state id=\"StateShape1\">"
		"							<transition event=\"error.*\" target=\"FinalShape1\"/>"
		"							<state id=\"Step1\">"
		"								<onentry>"
		"									<send delay=\"1700ms\" event=\"Timer2\"/>"
		"									<log expr=\"'Hello from step1'\"/>"
		"								</onentry>"
		"								<transition event=\"Timer2\" target=\"Step2\"/>"
		"							</state>"
		"							<state id=\"Step2\">"
		"								<onentry>"
		"									<send delay=\"1500ms\" event=\"Timer2\"/>"
		"									<log expr=\"'Hello from step2'\"/>"
		"								</onentry>"
		"								<transition event=\"Timer2\" target=\"Step1\"/>"
		"							</state>"
		"						</state>"
		"						<final id=\"FinalShape1\"/>"
		"					</scxml>"
		"				</content>"
		"			</invoke>"
		"		</state>"
		"	</state>"
		"	<final id=\"FinalShape1\"/>"
		"</scxml>";
} // end namespace: Scxmlsample1

int _tmain(int argc, _TCHAR* argv[])
{
	Interpreter intepreter = Interpreter::fromXML(Scxmlsample1::chScxml, "");

	StateTransitionMonitor mon;
	intepreter.addMonitor(&mon);

	InterpreterState state = InterpreterState::USCXML_UNDEF;

	while (state != USCXML_FINISHED)
	{
		state = intepreter.step(true);
	}

	return 0;
}

Assertion failed in Interpreter destructor after testing <invoke> element

I'm trying to test procedure according to standard as described here If the invoking session takes a transition out of the state containing the before it receives the 'done.invoke.id' event, the SCXML Processor must automatically cancel the invoked component and stop its processing

main.scxml

invoke content scxml

full source code

So, the problem is that, when invoke content finished normally and we finished after 'done.invoke.id' event, Inerpreter object can be deleted without any problems. But, when we are in some middle state inside invoke content scxml and then we receive transition out, after finishing state machine in InterpreterImpl::~InterpreterImpl() we get assertion.

Screenshot of problem

whether is uscxml reetrantnym code?

whether is uscxml reetrantnym code? I can run at the same time a lot of interpreters uscxml, each with its own file interpretetor * .scxml?

[Lua datamodel] Table data can not be assigned using <assign> element

I can not assign any value to table data using element. Can do it only using <script>

<scxml datamodel="lua" initial="Start" name="Root" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <datamodel>
        <data id="Var1">{
    testInt=0,
    testDouble=0.0,
    testString='message'
}
        </data>
    </datamodel>
    <final id="Pass">
        <onentry>
            <script>for k,v in pairs(Var1) do
    print(string.format('key=%s,value=%s',tostring(k),tostring(v)))
end
            </script>
        </onentry>
    </final>
    <state id="Start">
        <onentry>
            <assign expr="555" location="Var1.testInt"/>
            <assign expr="555.555" location="Var1.testDouble"/>
            <assign expr="'modified message'" location="Var1.testString"/>
        </onentry>
        <transition target="Pass">
            <assign location="Var1.testInt" expr="111"/>
            <assign location="Var1.testDouble" expr="111.111"/>
            <assign location="Var1.testString" expr="'modified message in transition'"/>
        </transition>
    </state>
</scxml>

And this for comparison

<scxml datamodel="lua" initial="Start" name="Root" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <datamodel>
        <data id="Var1">{
    testInt=0,
    testDouble=0.0,
    testString='message'
}
        </data>
    </datamodel>
    <final id="Pass">
        <onentry>
            <script>for k,v in pairs(Var1) do
    print(string.format('key=%s,value=%s',tostring(k),tostring(v)))
end
            </script>
        </onentry>
    </final>
    <state id="Start">
        <onentry>
            <script>Var1.testInt=555
Var1.testDouble=555.555
Var1.testString='modified using script'
            </script>
        </onentry>
        <transition target="Pass">
            <assign location="Var1.testInt" expr="111"/>
            <assign location="Var1.testDouble" expr="111.111"/>
            <assign location="Var1.testString" expr="'modified message in transition'"/>
        </transition>
    </state>
</scxml>

Problem: Debouncing through step(blockMS) with blockMs = numerical_limits<size_t>::max doesnt work

Debouncing step with the default value of step(std::numerical_limits<size_t>::max()) doesn't work.

The reason is because size_t is an unsigned long while the representation of std::chrono::milliseconds is int64 on my system. So we basically get an overflow while calculating the endTime which probably lies in the past. This corrupted value of unsigned long is then used straight away in BasicEventQueue.cpp`:

auto endTime = std::chrono::system_clock::now() + std::chrono::milliseconds(blockMs);
while (endTime > std::chrono::system_clock::now() && _queue.empty()) {
    _cond.wait_until(_mutex, endTime);
}

Possible Solutions:

  • define a sane max value (1e6 msec or more). That would work in any case..
  • make the max value dependent on the representation of std::chrono::system_clock (that would introduce chrono dependency)
  • use std::chrono::system_clock::duration::max() right away as default value

I'd go with the last option, what do you think @sradomski ?

Alternative way for pause in uscxml interpreter

Hello,
USCXML is a great library for supporting scxml standard, but there is a real problem for modelling difficult systems, especially during some simulations. Because we need pause/resume mode.
SCXML offers history states for this purposes. But modelling in such case becomes redundant and difficult.
Let's take a look at simple example.

<scxml initial="Flash" name="ScxmlShape1" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <state id="Flash" initial="ApuOff">
        <transition event="error.*" target="Fail"/>
        <transition event="StopExercise" target="Pass"/>
        <state id="ApuOn">
            <onentry>
                <send delay="2000ms" event="DoApuOff" id="ID_DoApuOff"/>
            </onentry>
            <transition event="DoApuOff" target="ApuOff"/>
        </state>
        <state id="ApuOff">
            <onentry>
                <send delay="2000ms" event="DoApuOn" id="ID_DoApuOn"/>
            </onentry>
            <transition event="DoApuOn" target="ApuOn"/>
        </state>
    </state>
    <final id="Fail"/>
    <final id="Pass"/>
</scxml>

What we should do if we needed pause/resume?

<scxml datamodel="lua" initial="StateShape1" name="ScxmlShape1" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <final id="Fail"/>
    <state id="StateShape1" initial="Flash">
        <transition event="error" target="Fail"/>
        <transition event="StopExercise" target="Pass"/>
        <state id="Flash">
            <datamodel>
                <data id="t_ApuOff">{
    dDiff = 0,
    dEnter = os.clock(),
    dInterval = 2000
}
                </data>
                <data id="t_ApuOn">{
    dDiff = 0,
    dEnter = os.clock(),
    dInterval = 2000
}
                </data>
                <data expr="'xxx'" id="FlashName"/>
            </datamodel>
            <transition event="Pause" target="OnPause"/>
            <state id="ApuOn">
                <onentry>
                    <send delayexpr="tostring(t_ApuOn.dInterval-t_ApuOn.dDiff)..'ms'" event="DoApuOff" id="ID_DoApuOff"/>
                    <assign expr="os.clock()" location="t_ApuOn.dEnter"/>
                    <log expr="string.format('%s=%d',FlashName,t_ApuOn.dInterval-t_ApuOn.dDiff)" label="Delay[On]"/>
                </onentry>
                <onexit>
                    <cancel sendid="ID_DoApuOff"/>
                    <assign expr="t_ApuOn.dDiff + (os.clock() - t_ApuOn.dEnter)*1000" location="t_ApuOn.dDiff"/>
                    <log expr="string.format('%s=%d',FlashName,t_ApuOn.dDiff)" label="Elapsed[On]"/>
                </onexit>
                <transition event="DoApuOff" target="ApuOff">
                    <assign location="t_ApuOn.dDiff" expr="0"/>
                </transition>
            </state>
            <initial>
                <transition target="ApuOff">
                    <assign location="t_ApuOff.dDiff" expr="0"/>
                    <assign location="t_ApuOn.dDiff" expr="0"/>
                </transition>
            </initial>
            <state id="ApuOff">
                <onentry>
                    <send delayexpr="tostring(t_ApuOff.dInterval-t_ApuOff.dDiff)..'ms'" event="DoApuOn" id="ID_DoApuOn"/>
                    <assign expr="os.clock()" location="t_ApuOff.dEnter"/>
                    <log expr="string.format('%s=%d',FlashName,t_ApuOff.dInterval-t_ApuOff.dDiff)" label="Delay[Off]"/>
                </onentry>
                <onexit>
                    <cancel sendid="ID_DoApuOn"/>
                    <assign expr="t_ApuOff.dDiff + (os.clock() - t_ApuOff.dEnter)*1000" location="t_ApuOff.dDiff"/>
                    <log expr="string.format('%s=%d',FlashName,t_ApuOff.dDiff)" label="Elapsed[Off]"/>
                </onexit>
                <transition event="DoApuOn" target="ApuOn">
                    <assign location="t_ApuOff.dDiff" expr="0"/>
                </transition>
            </state>
            <history id="HistoryShape1" type="deep">
                <transition target="ApuOff"/>
            </history>
        </state>
        <state id="OnPause">
            <transition event="Resume" target="HistoryShape1"/>
        </state>
    </state>
    <final id="Pass"/>
</scxml>

Our simple example becomes a monster and if we will use invokable processes we need to send event 'Pause' to all timers and to create a lot of conditions.

So what is my offer?
If I'm not mistaken, uscxml uses libevent library for events and for timers it use 'evutils_gettimeofday' function. That's why the simpliest way is to give an opportunity for user to override global time with custom global timer.

It would be very great to have some function of pause/resume in uscxml interpreter.

why replaced Arabica DOM implementation with Xerces-C

b62e797
I find you replaced Arabica DOM implementation with Xerces-C,this is a giant work. I am curious why you did it?At the beginning the perfermance of this interpreter was affected by the arabica mybe the dynamic_cast the pointer of dom. Now the Xerces-C is efficient in perfermace?

[Lua datamodel] Data is not initialized in invokable session

Sorry for new issue, but can not go further in testing.

First of all issue code

<scxml datamodel="lua" initial="Start" name="Root" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
    <state id="Start">
        <invoke id="ID_DATA_ISSUE">
            <content>
                <scxml datamodel="lua" initial="StateShape1" name="ScxmlShape1" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
                    <datamodel>
                        <data id="Timestamp">{
    iSec = 1
}
                        </data>
                    </datamodel>
                    <final id="Pass"/>
                    <final id="Fail">
                        <onentry>
                            <send event="error.execution" target="#_parent"/>
                        </onentry>
                    </final>
                    <state id="StateShape1">
                        <onentry>
                            <script>print(Timestamp)
print(Timestamp.iSec)
                            </script>
                            <send delayexpr="tostring(Timestamp.iSec) .. 's'" event="step_1"/>
                        </onentry>
                        <transition event="step_1" target="Pass"/>
                        <transition event="error.*" target="Fail"/>
                    </state>
                </scxml>
            </content>
        </invoke>
        <transition event="done.invoke.ID_DATA_ISSUE" target="Pass"/>
        <transition event="error.*" target="Fail"/>
    </state>
    <final id="Pass"/>
    <final id="Fail"/>
</scxml>

1 part of issue: I can not initialize data in datamodel section in invokable element.

2 part of issue: We have 'error.execution' event inside invokable element. I expect that this element will be stopped in processing and I will get this error event outside. But now I need to rethrow this error event outside. I think this is redundantly. I'm in doubt. May be your variant is more logically and I'm wrong. How do you think?

Syntax error in 'test\CMakeLists.txt'

Error on string 72:
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/headers/${USCXML_REL_HEADER}.cpp ${HEADER_TEST})

CMake Error at test/CMakeLists.txt:72 (FILE):
file Internal CMake error when trying to open file:
G:/SDK/uscxml_2_0/vc12/test/headers/G:/SDK/uscxml_2_0/src/uscxml/uscxml.h.cpp
for writing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.