Skip to content
  • 0 Votes
    1 Posts
    175 Views
    No one has replied
  • 0 Votes
    2 Posts
    650 Views
    R

    By writing a small demo to complete my post, I found the issue. As it might be helpful to somebody else, here it is:

    demo.scxml:

    <?xml version="1.0" encoding="UTF-8"?> <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" binding="early" xmlns:qt="http://www.qt.io/2015/02/scxml-ext" name="plop.scxml" qt:editorversion="4.7.1"> <state id="State_1"> <qt:editorinfo scenegeometry="144.50;162.05;84.50;112.05;120;100" geometry="144.50;162.05;-60;-50;120;100"/> </state> </scxml>

    demo.py:

    #!/usr/bin/env python import sys from PySide2.QtCore import QObject, QCoreApplication, SLOT, Slot from PySide2.QtScxml import QScxmlStateMachine class Backend_1(QObject): def __init__(self, machine): super(Backend_1, self).__init__() self.machine = machine self.machine.connectToState("State_1", self, SLOT("s1_active(bool)")) @Slot(bool) def s1_active(self, active): if active: print('Backend_1::State_1: enter') self.submachine = QScxmlStateMachine.fromFile('demo.scxml') b = Backend_2(self.submachine) self.submachine.start() else: print('Backend_1::State_1: exit') class Backend_2(QObject): def __init__(self, machine): super(Backend_2, self).__init__() self.machine = machine self.machine.connectToState("State_1", self, SLOT("s1_active(bool)")) @Slot(bool) def s1_active(self, active): if active: print('Backend_2::State_1: enter') else: print('Backend_2::State_1: exit') if __name__ == '__main__': app = QCoreApplication(sys.argv) machine = QScxmlStateMachine.fromFile('demo.scxml') b = Backend_1(machine) machine.start() sys.exit(app.exec_())

    If you run this, you expect to see:
    Backend_1::State_1: enter
    Backend_2::State_1: enter

    But, the second statemachine does not seem to start. To fix it, you need to store the instance of Backend_2 (eg: self.b = Backend_2(self.submachine)). I guess it was garbage collected, so all the states/events connections were broken.

    Meanwhile, if you think my design patter is bad, I'm willing to learn :)

  • 0 Votes
    1 Posts
    437 Views
    No one has replied
  • 0 Votes
    4 Posts
    805 Views
    Pablo J. RoginaP

    @nurettin I see, gettting the scxml + js outside the application seems more versatile

    I got a hint on stackoverflow

    Could it be possible you provide a link to such Q&A for anybody interested? Thanks

  • 0 Votes
    2 Posts
    849 Views
    SGaistS

    Hi,

    The QtSCXML module being currently a technical preview, you should bring your questions to the interest mailing list. You'll find there QtSCXML's developers/maintainers. This forum is more user oriented and there's likely less people having already used that module here.

  • 0 Votes
    2 Posts
    906 Views
    SGaistS

    Hi and welcome to devnet,

    The QtSCXML module being currently a technical preview, you should bring your questions to the interest mailing list. You'll find there QtSCXML's developers/maintainers. This forum is more user oriented and there's likely less people having already used that module here.

  • 0 Votes
    2 Posts
    918 Views
    PhrogzP

    Answered on StackOverflow. The key is that there are many functions hidden from the documentation that need to be overridden, like evaluateToString().