In fact it is worst, I exchanged the management of the do behavior between the entry and exit cases. Considering that state machine (the transitions from a state to itself are internal) :
和主要的
int main()
{
MM mm;
mm.create();
cout << endl << "fire taa" << endl;
mm.taa();
cout << endl << "fire tab" << endl;
mm.tab();
cout << endl << "fire tbb" << endl;
mm.tbb();
cout << endl << "fire tba" << endl;
mm.tba();
cout << endl << "fire tdone" << endl;
mm.tdone();
}
编译(不定义VERBOSE_STATE_MACHINE)和执行:
pi@raspberrypi:~/sm/src $ g++ -Wall -g MM.cpp mmain.cpp
pi@raspberrypi:~/sm/src $ ./a.out
a entry
fire taa
a do
taa
fire tab
a do
a exit
tab expr
b entry
fire tbb
b do
tbb
fire tba
b do
b exit
tba expr
a entry
fire tdone
a do
a exit
tdone
pi@raspberrypi:~/sm/src $
So the 做行为为内部转换执行,退出状态时错误,进入状态时丢失。
请注意状态机发电机是plug-out它的定义是 BoUML 通过项目交付的一部分sm_生成器,它是用 C++(而不是 Java)实现的。这样就可以加载项目了sm_生成器,保存为您有写入权限的地方,更正它,生成C++代码,编译它并用您的新版本替换官方生成器或声明您的新版本plug-out并将其关联到状态机将其添加到菜单中。
我修改了我的状态机发生器,上一次是在2011年!
The 做行为退出状态时不再执行,包括通过自我外部转换,现在在可能的情况之后执行do entry。我还在自我内部转换的可能转换行为之后(而不是之前)执行此操作,这样可以避免两次连续执行,而在转换具有行为的情况下,中间没有任何内容。
请注意,已经可以执行可能的操作做行为通过操作当前状态做活动定义在与机器关联的类上。这允许在过渡触发之间进行此操作。
与之前的状态机稍微修改一下添加一个自我外部转变 :
然后main
#include "MM.h"
#include <iostream>
using namespace std;
int main()
{
MM mm;
mm.create();
cout << endl << "fire taa" << endl;
mm.taa();
cout << endl << "fire ta_a" << endl;
mm.ta_a();
cout << endl << "fire tab" << endl;
mm.tab();
cout << endl << "fire tbb" << endl;
mm.tbb();
cout << endl << "fire tba" << endl;
mm.tba();
cout << endl << "fire tdone" << endl;
mm.tdone();
}
编译(不定义VERBOSE_STATE_MACHINE)和执行:
pi@raspberrypi:~/sm/src $ g++ -Wall MM.cpp mmain.cpp
pi@raspberrypi:~/sm/src $ ./a.out
a entry
a do
fire taa
taa expr
a do
fire ta_a
a exit
ta_a expr
a entry
a do
fire tab
a exit
tab expr
b entry
b do
fire tbb
tbb expr
b do
fire tba
b exit
tba expr
a entry
a do
fire tdone
a exit
tdone expr
pi@raspberrypi:~/sm/src $
BoUML 7.10 https://www.bouml.fr/historic.html可用并解决问题