Boost MSM parallel behavior with delayed self-transitions?

Hi community, This is my first post, so I'm sorry for any mistakes in style. I have also posted this question on StackOverflow: http://stackoverflow.com/questions/42920777/boost-msm-parallel-behavior-with.... I am using Boost MSM (basic and functor front-ends) and am trying to implement the following state machine (https://i.stack.imgur.com/K79qk.png): enter image description here I am using Boost MSM (basic and functor front-ends) and am trying to implement the following state machine: enter image description here In words: 1. Enter state State1 2. Enter state A and execute action_A. After 2 seconds, print "Trying again..." and re-execute state A (i.e. call its entry action). This loops forever... 3. At the same time as 2 (i.e. "in parallel"), enter state B and execute action_B. After 5 seconds, print "Trying again..." and re-execute state B (i.e. call its entry action). This loops forever... I would like to know the way to create this state machine in Boost MSM. There are two tricks here which I cannot figure out how to do: - Execution in parallel (i.e. running action_A does not stop running action_B at the same time) - Delayed transition (i.e. the transitions which happen after 2 seconds for state A and after 5 seconds for state B). Neither delay should be blocking! The transitions should just "fire" after this time. Thank you very much for helping, Danylo.

On 21 March 2017 at 01:37, Danylo Malyuta via Boost
1. Enter state State1 2. Enter state A and execute action_A. After 2 seconds, print "Trying again..." and re-execute state A (i.e. call its entry action). This loops forever... 3. At the same time as 2 (i.e. "in parallel"), enter state B and execute action_B. After 5 seconds, print "Trying again..." and re-execute state B (i.e. call its entry action). This loops forever...
I'm not an expert on SM's, but 1 state machine with two active states seems to be contary tot the basic idea of a SM. Hierarchical state machines could work, or instead, you could just implement a (one) loop (the AB-state) that uses one clock and 2 times: a_triggered and b_triggered. Work with one second intervals, put thread to sleep for one second (you don't want to spin on this, 1 second is an eternity in CPU terms). After one second thread will wake up and check whether A and/or B should trigger. If yes, execute action A and/or B and update the relevant a_triggered and/or b_triggered time respectively (set to current time), or, if neither triggers, do nothing and put thread to sleep again (for 1 second), and so on and so on. I realize this does not answer the question: "How to do this with Boost.MSM". The above, on the oher hand, is simple to implement, while Boost.MSM seems overkill to me (if your description of the problem is comprehensive, that is). degski
participants (2)
-
Danylo Malyuta
-
degski