Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with QScxmlStateMachine and boolean data type in SCXML transition condition

Problem with QScxmlStateMachine and boolean data type in SCXML transition condition

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 226 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr_Gruber
    wrote on last edited by Mr_Gruber
    #1

    Hi,

    i have the problem that if there is a boolean data type in the condition part of the scxml file, the QScxmlStateMachine::submitEvent(const QString &eventName, const QVariant &data) function does not work as i expect.

    This is my simple scxml file

    <?xml version="1.0" encoding="UTF-8"?>
    <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" datamodel="ecmascript" name="default" initial="ViewA">
        <state id="MainWindow">
            <state id="ViewA">
                <transition event="switch1" cond="_event.data == true" target="ViewB"/>
                <transition event="switch1" cond="_event.data == false" target="ViewC"/>
            </state>
            <state id="ViewB">
                <transition event="switch2" cond="_event.data == false" target="ViewA"/>
                <transition event="switch2" cond="_event.data == true" target="ViewC"/>
            </state>
            <state id="ViewC">
                <transition event="switch3" cond="_event.data == true" target="ViewA"/>
                <transition event="switch3" cond="_event.data == false" target="ViewB"/>
            </state>
        </state>
    </scxml>
    

    So it's all about this part:

    cond="_event.data == true"
    

    When I call

    submitEvent("switch1", true)
    

    the view is not changing.

    But, if I put there an integer, for example

    cond="_event.data == 5"
    

    the view changes after calling:

    submitEvent("switch1", 5)
    

    Does somebody has any idea?
    Thank you!

    Pablo J. RoginaP 1 Reply Last reply
    0
    • M Mr_Gruber

      Hi,

      i have the problem that if there is a boolean data type in the condition part of the scxml file, the QScxmlStateMachine::submitEvent(const QString &eventName, const QVariant &data) function does not work as i expect.

      This is my simple scxml file

      <?xml version="1.0" encoding="UTF-8"?>
      <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" datamodel="ecmascript" name="default" initial="ViewA">
          <state id="MainWindow">
              <state id="ViewA">
                  <transition event="switch1" cond="_event.data == true" target="ViewB"/>
                  <transition event="switch1" cond="_event.data == false" target="ViewC"/>
              </state>
              <state id="ViewB">
                  <transition event="switch2" cond="_event.data == false" target="ViewA"/>
                  <transition event="switch2" cond="_event.data == true" target="ViewC"/>
              </state>
              <state id="ViewC">
                  <transition event="switch3" cond="_event.data == true" target="ViewA"/>
                  <transition event="switch3" cond="_event.data == false" target="ViewB"/>
              </state>
          </state>
      </scxml>
      

      So it's all about this part:

      cond="_event.data == true"
      

      When I call

      submitEvent("switch1", true)
      

      the view is not changing.

      But, if I put there an integer, for example

      cond="_event.data == 5"
      

      the view changes after calling:

      submitEvent("switch1", 5)
      

      Does somebody has any idea?
      Thank you!

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @Mr_Gruber said in Problem with QScxmlStateMachine and boolean data type in SCXML transition condition:

      scxml

      What if you use the approach suggested in this answer (part #2)?
      Simply checking for 0 or 1 in your SCXML "cond" property

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mr_Gruber
        wrote on last edited by
        #3

        Thank you for your reply. By the way, I'm using QT 5.15.2
        Unfortunately it doesn't work with 0 and 1. It works if I write it as a string

        cond="_event.data == 'true'"
        

        even if I leave the boolean in the code.

        And there is one more thing, my scxml file is auto-generated by a statechart tool (yakindu), so the program should work with this scxml syntax.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved