Note that there are some explanatory texts on larger screens.

plurals
  1. POQStatemachine and parallel states
    primarykey
    data
    text
    <p>I'm going crazy with QStateMachine wth ParallelState. I've a main state (sequential) which contain a first state, a second state which contains a group of parallel states, and another state that is again sequential. The first state represent a process which create N input files, the second represents N threads which works over each input (one thread for one file) and the last state represents a process which generates a report of the overall process (need to wait that second state has completely finished). Well, the problem is just when I need to create a barrier between the second state and the third one. I need some barrier in order to complete all the threads and I'm not able to do it. Following documentation it is said that the composite state which is parallel, call finished when all its children enter in the final state. First of all what does it mean in this case, entering in a final state? May I need to create a final state for each state inside my parallel state? Anyway I try this but nothing. The result is that when the first thread finishes, the final state of my container is called.</p> <p>This is a snippet:</p> <pre><code>QState *mainState = new QState(QState::ExclusiveStates); // Create the first state associated to the first process QState *firstState = new QState(mainState); QObject::connect(firstState, SIGNAL(entered()), this, SLOT(executeFirstProcess())); // parallel container state QState *parallelContainerState = new QState(QState::ParallelStates, mainState); firstState-&gt;addTransition(this, SIGNAL(goToNextStep()), parallelContainerState); QFinalState *parallelFinalState = new QFinalState(parallelContainerState); int parallelStepCounter = 0; for(;parallelStepCounter &lt; 5; parallelStepCounter++) { QState *pState = new QState(parallelContainerState); QObject::connect(pState, SIGNAL(entered()), this, SLOT(executePState())); pState-&gt;addTransition(pState, SIGNAL(finished()), parallelFinalState); } QState *reportState = new QState(mainState); QObject::connect(reportState, SIGNAL(entered()), this, SLOT(generateReport())); parallelContainerState-&gt;addTransition(parallelContainerState, SIGNAL(finished()), reportState); ... set initial state, start machine bla bla... </code></pre> <p>How can wait that second state has completely finished? I also try to use QObject::connect with finished signal of each pState, but it is not called.</p> <p>thank you, best</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload