当属性设置为生成相关代码时,为每个反应的类将生成以下公共虚拟成员函数:
注: 对于 C 函数,前缀
<class name> 是指模型中为其创建了状态图的“类”。
- virtual
int getStatechartSize() 用于 C++
int <class name>_getStatechartSize(<class
name>* me) 用于 C
返回状态图使用的变量数。使用此函数可分配传递给函数 getStatechartStates 的状态向量。
- virtual void getStatechartStates(int stateVector[],
unsigned long& oxfReactiveState) const 用于 C++
void <class name>_getStatechartStates(const <class
name>* const me, int stateVector[], unsigned long* oxfReactiveState) 用于 C
使用当前状态图的状态填充 stateVector,并根据 OMReactive 内部状态设置 oxfReactiveState。
oxfReactiveState 的类型取自 [C][CPP]_CG::Framework::ReactiveStateType 属性。
stateVector 的类型取自 CG::Statechart::FlatStateType(缺省值为 int)属性。
在 WithoutReactive 方式中,最后一个参数被清除,且函数原型变为:
- virtual void getStatechartStates(int stateVector[])
用于 C++
- void <class name>_getStatechartStates(const <class
name>* const me, int stateVector[]) 用于 C
- virtual void setStatechartStates(int
stateVector[],
unsigned long* oxfReactiveState) 用于 C++
void <class
name>_setStatechartStates(<class name>*
const me, int stateVector[], unsigned long* oxfReactiveState) 用于 C
设置反应实例状态以及 OMReactive 内部状态。
oxfReactiveState 的类型取自 [C][CPP]_CG::Framework::ReactiveStateType 属性。
stateVector 的类型取自 CG::Statechart::FlatStateType(缺省值为 int)属性。
注: 如果在动画期间使用
setStatechartState,那么实例状态图将不显示新状态。要“刷新”状态图,您可以切换至“静默”动画方式运行动画,然后切换回“观察”动画方式。