Transit 10 functions in sequence based on a timer using State Machine Framework
-
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. -
//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]
-
Hi,
What are function1 and friends ?
-
I understood why you wanted to do, however you didn't answer my question
@QState *state1= new Qstate(function1); << what is function1 ?@
-
So, what was the problem ?