Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15
-
None
Description
According to SCXML Standard 5.10.1 The Internal Structure of Events event.origin is a URI, equivalent to the 'target' attribute on the <send> element. For external events, the SCXML Processor should set this field to a value which, when used as the value of 'target', will allow the receiver of the event to <send> a response back to the originating entity via the Event I/O Processor specified in 'origintype'.
Simply:
event.origin == #_scxml_ + sessionid
for external events with SCXML I/O Processor
Minimal example
The example is test for external event origin which successfully runs on USCXML or SCION.
Expected
scxml.statemachine: "Source origin" : "#_scxml_cd83043b..." scxml.statemachine: "Outcome" : "pass"
Current result
scxml.statemachine: "Source origin" : "#_parent" scxml.statemachine: "Outcome" : "fail" ERROR: I must not fail here!
#include <QCoreApplication> #include <QScxmlStateMachine> #include <QBuffer> #include <QLoggingCategory> namespace Scxml { static const char *chScxml = "<scxml datamodel=\"ecmascript\" initial=\"s1\" name=\"ScxmlTestInvokeEventOrigin\" version=\"1.0\" xmlns=\"http://www.w3.org/2005/07/scxml\">" " <state id=\"s1\">" " <invoke id=\"ID_SUB\">" " <content>" " <scxml datamodel=\"ecmascript\" initial=\"Register\" name=\"ScxmlChild\" version=\"1.0\" xmlns=\"http://www.w3.org/2005/07/scxml\">" " <state id=\"Register\">" " <onentry>" " <send event=\"register\" target=\"#_parent\"/>" " </onentry>" " <transition event=\"parent.confirm\" target=\"quit\"/>" " </state>" " <final id=\"quit\"/>" " </scxml>" " </content>" " </invoke>" " <onentry>" " <send delay=\"1s\" event=\"timeout\" id=\"ID.timeout\"/>" " </onentry>" " <onexit>" " <cancel sendid=\"ID.timeout\"/>" " </onexit>" " <transition event=\"register\">" " <log expr=\"_event.origin\" label=\"Source origin\"/>" " <send event=\"parent.confirm\" targetexpr=\"_event.origin\"/>" " </transition>" " <transition event=\"done.invoke.ID_SUB\" target=\"pass\"/>" " <transition event=\"timeout\" target=\"fail\"/>" " </state>" " <final id=\"pass\">" " <onentry>" " <log expr=\"'pass'\" label=\"Outcome\"/>" " </onentry>" " </final>" " <final id=\"fail\">" " <onentry>" " <log expr=\"'fail'\" label=\"Outcome\"/>" " </onentry>" " </final>" "</scxml>"; } // end namespace: Scxml int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QBuffer buffer; buffer.open(QBuffer::ReadWrite); buffer.write(Scxml::chScxml); buffer.seek(0); auto machine = QScxmlStateMachine::fromData(&buffer); machine->connectToState("fail",[](bool active){ if (active) { qCritical() << "ERROR: I must not fail here!"; QCoreApplication::exit(-1); } }); machine->start(); return a.exec(); }