2016-12-13 95 views
0

有沒有一種方法可以在助力器狀態機的仿真器前端結合多個衛兵?在Boost Metastate機器中結合使用多個衛兵

我想做到以下幾點:

struct transition_table : mpl::vector< 
// Start  Event  Target  Action      Guard 
// +---------+------------+-----------+---------------------------+----------------------------+ 
Row < Stopped , play  , Playing , start_playback   , guard1 && guard2    >   
// +---------+------------+-----------+---------------------------+----------------------------+ 
> {}; 

guard1guard2都是布爾表達式。但是,這不能編譯。 Boost SML很容易實現。

用下面的代碼:

struct actions_guards { 
    auto operator()() noexcept { 
    using namespace sml; 
    return make_transition_table(
     *"idle"_s + event<e1> = "s1"_s 
     , "s1"_s + event<e2> [ guard1 && guard2 ]/action1 = X 
    ); 
    } 

回答

0
#include <boost/msm/front/euml/euml.hpp> 
using namespace euml; 

struct transition_table : mpl::vector< 
// Start  Event  Target  Action      Guard 
// +---------+------------+-----------+---------------------------+----------------------------+ 
Row < Stopped , play  , Playing , start_playback   , And_<guard1, guard2>    >   
// +---------+------------+-----------+---------------------------+----------------------------+ 
> {};