I was trying to execute 2 models one by one in a simulation via state chart. The pseudo-code follows. In model test, there are two blocks, stateA and stateB. At the beginning of the simulation, stateA is executed. 10 seconds later, stateA is stopped while stateB is executed. The value of v at the stop point needs to transfer from stateA to stateB. Could anybody give me some advises? Thanks a lot!
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;
Another thing is why I cannot simulate the following simple example in 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;
Error: Class initialState not found in scope StateMachine1