|
|
|
|
|
|
|
|
|
|
|
|
Re: How to restrict validator to the active working file? [message #1865187 is a reply to message #1865178] |
Sat, 27 April 2024 19:41 |
Ehsan Ahmad Messages: 40 Registered: April 2018 |
Member |
|
|
Yes, the validator runs for one file now, as required.
@Check(CheckType.NORMAL)
public void checkOnlyOneInitialState(BehaviorState behaviorState) {
int initialStateCount = 0;
BehaviorStatesSection bss = (BehaviorStatesSection) behaviorState.eContainer();
for (BehaviorState bs : bss.getBehavior_states()) {
if(bs.getIsInitial().equals("initial"))
initialStateCount = initialStateCount +1;
}
if (initialStateCount > 1)
error(behaviorState.getName(), DevsPackage.Literals.BEHAVIOR_STATE__NAME);
}
But regardless to the size of the bss.getBehavior_states(), it only runs twice. As a result it only checks isInitial for the first and the second state. So, for the following model, it only produces error if the state Test1 and Test2 have 'initial'.
states
Test1: initial 0.0;
Test2: initial 0.0;
Test3: 1.0;
Test4: 2.0;
Test5: initial 3.0;
But does not produce error if the second state Test2 in case does not have initial. For example, no error is produces for the following model
states
Test1: initial 0.0;
Test2: 0.0;
Test3: initial 1.0;
Test4: 2.0;
Test5: initial 3.0;
Global declaration private int initialStateCount = 0; //for number of initial state
was add to tackle this issue as the initialSateCount was reset after 2 iterations but is of no use and still the loop only runs for the first two states.
Regards,
Ehsan
[Updated on: Sat, 27 April 2024 19:43] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04362 seconds