You can define separate transitions for different origin states leading to the same state.
You can define separate transitions for different origin states leading to the same state.
That could be a solution but it would highly increase the number of states of my system, and, unfortunately, my state machine already has around 40 states. If there is no other choice I will do it but I prefer to ask a bit more to find a better solution.
My system starts from a initial state that only waits for different commands from the user (for example, start process1, start process2, start process3...). Every time this state receives a command, the workflow is more or less the same, the statemachine jumps to a new state called "waiting Ack", and there, a ping is sent (via socket) to the system in charge of executing the selected process. Once an ack answer is received from the system pinged, the statemachine jumps to the state associated to execute the process selected and once finished it returns to the initial state. According to your solution I should have as many "waiting ack" states as types of process are, but if I could know what transition lead to the single "waiting Ack" state, I could unify all the "waiting Ack" small states in only one by inserting a switch in the entered state slot.
Any idea or suggestion to design my system?
No, not really.
Qt Code:
QState *s1 = ...; QState *s2 = ...; QSignalTransition *t1 = s1->addTransition(obj1, SIGNAL(signal1()), s2); QSignalTransition *t2 = s1->addTransition(obj2, SIGNAL(signal2()), s2); connect(t1, &QAbstractTransition::triggered, []() { qDebug() << "t1 fired"; }); // C++11 connect(t2, &QAbstractTransition::triggered, []() { qDebug() << "t1 fired"; }); // C++11To copy to clipboard, switch view to plain text mode
Alternatively you could have separete "start process" states, each using assignProperty to set the correct recipient for the ACK step, e.g. network address and port number.
Then you transition into a single waiting ACK state which uses the previously set value.
Cheers,
_
That looks promissing! I'm going to try it. Thank you!
Bookmarks