model StateInOut4
inner Real value(start=0);
block State1
outer output Real value;
Real a;
equation
a = value;
//a = time;
end State1;
block State2
outer output Real value;
equation
value = 1;
end State2;
State1 state1;
State2 state2;
equation
initialState(state1);
transition(state1,state2,ticksInState()>=5,reset=true,immediate=true);
transition(state2,state1,ticksInState()>=5,reset=true,immediate=true);
state1.a=time;
annotation (experiment(StopTime=7, __Dymola_Algorithm="Dassl"));
end StateInOut4;
In this model, variable state1.a is assigned a value on the outer layer.
I checked the code exported from Dymola for this model, and this equation is not within the state activation control if-statement:
when _Clocks.BaseClock_0.SubClock_1.active then
state1.a := time;
if (_StateMachines.state1.activeState == stateMachine_of_state1.state_state1) then
state1.value := state1.a;
end if;
if (_StateMachines.state1.activeState == stateMachine_of_state1.state_state2) then
state2.value := 1;
end if;
end when;
However, in the direct simulation results in Dymola, it has no value when the state is not activated:

If this model is exported as FMU and then imported into Dymola for simulation, variable state1.a will have a value at all times:

So what should the expected result be? I think even if assigning values on the outer layer, variables in the state should still only be calculated when the state is activated.
In this model, variable
state1.ais assigned a value on the outer layer.I checked the code exported from Dymola for this model, and this equation is not within the state activation control if-statement:
However, in the direct simulation results in Dymola, it has no value when the state is not activated:


If this model is exported as FMU and then imported into Dymola for simulation, variable
state1.awill have a value at all times:So what should the expected result be? I think even if assigning values on the outer layer, variables in the state should still only be calculated when the state is activated.