我试图通过状态图在模拟中一个一个地执行 2 个模型。伪代码如下。在模型测试中,有两个块,stateA 和 stateB。在模拟开始时,执行 stateA。10 秒后,stateA 停止,而 stateB 执行。停止点 v 的值需要从 stateA 转移到 stateB。有人可以给我一些建议吗?非常感谢!
model test
inner Integer v(start = 1);
block StateA
outer output Integer v;
equation
v = previous(v) + 2;
end StateA;
StateA stateA;
block StateB
outer output Integer v;
equation
v = previous(v) - 1;
end StateB;
StateB stateB;
equation
initialState(stateA);
transition(stateA, stateB, t >= t0, immediate=false);
end test;
另一件事是为什么我无法在 openModelica 中模拟以下简单示例?
model StateMachine1
inner Integer i(start=0);
block State1
outer output Integer i;
equation
i = previous(i) + 2;
end State1;
State1 state1;
block State2
outer output Integer i;
equation
i = previous(i) - 1;
end State2;
State2 state2;
equation
initialState(state1);
transition(state1, state2, i > 10, immediate=false);
transition(state2, state1, i < 1, immediate=false);
end StateMachine1;
错误:在范围 StateMachine1 中找不到类 initialState