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. Transit 10 functions in sequence based on a timer using State Machine Framework
Forum Updated to NodeBB v4.3 + New Features

Transit 10 functions in sequence based on a timer using State Machine Framework

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 1.3k Views 1 Watching
  • 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.
  • H Offline
    H Offline
    houmingc
    wrote on last edited by
    #1

    I created a sequence of 10 function
    functionA, functionB, functionC, functionD ...
    that i would like to transit sequencely based on a timer.

    I do not know how to join them together using State machine framework.
    I did many hours of reading and i still don't understand how to link them together. Please kindly help.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      houmingc
      wrote on last edited by
      #2

      //Code i wrote myself, please kindly comment and assist.

      @
      QStateMachine machine;
      QState *group=new QState();
      group->setObjectName("group");
      QTimer timer;
      timer.setInterval(1250);
      timer.setSingleShot(true);
      connect(group,SIGNAL(entered()),&timer,SLOT(start());

      //start at state level
      QState *state1= new Qstate(function1);
      QState *state2= new Qstate(function2);
      QState *state3= new Qstate(function3);
      QState *state4= new Qstate(function4);
      group->setInitialState(state1);

      s2->addTransition(function1,SIGNAL(timeout),function2);
      s3->addTransition(function2,SIGNAL(timeout),function3);
      s4->addTransition(function3,SIGNAL(timeout),function4);

      //end at machine level
      machine.addstate(state1);
      machine.addstate(state2);
      machine.addstate(state3);
      machine.addstate(state4);

      machine.addState(group)
      machine.setInitialState(group);
      machine.start();
      @

      [edit: added missing coding tags @ SGaist]

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        What are function1 and friends ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • H Offline
          H Offline
          houmingc
          wrote on last edited by
          #4

          I like to transit sequentially from function1 to function10. The state Machine framework that i wrote, why is it not correct?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            I understood why you wanted to do, however you didn't answer my question

            @QState *state1= new Qstate(function1); << what is function1 ?@

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • H Offline
              H Offline
              houmingc
              wrote on last edited by
              #6

              function1 is 1st LED blinking
              function2 is 2rd LED blinking.
              function3 is 3 rd LED blinking.

              1 Reply Last reply
              0
              • H Offline
                H Offline
                houmingc
                wrote on last edited by
                #7

                i understand. Problem solved

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  So, what was the problem ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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