Skip to content

Commit ecbf005

Browse files
committed
ST6RI-405 Added exclusiveStates feature to States library model.
- Removed validation check that substates of non-parallel states must have an incoming transition.
1 parent 4892b5c commit ecbf005

5 files changed

Lines changed: 32 additions & 15 deletions

File tree

org.omg.sysml.xpect.tests/src/org/omg/sysml/xpect/tests/validation/invalid/TransitionUsage_invalid.sysml.xt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ package TransitionUsage_invalid {
4848
then S2_2;
4949
state S2_2;
5050
}
51-
51+
5252
state def S3 {
53-
entry; then S3_1;
5453
state S3_1;
55-
// XPECT warnings ---> "Should have an incoming transition." at "state S3_2;"
5654
state S3_2;
5755
}
5856

@@ -64,17 +62,13 @@ package TransitionUsage_invalid {
6462
then s2_2;
6563
state s2_2;
6664
}
67-
65+
6866
state s3 {
69-
entry; then s3_1;
7067
state s3_1;
71-
// XPECT warnings ---> "Should have an incoming transition." at "state s3_2 { state s3_2_1; state s3_2_2; }"
7268
state s3_2 {
7369
state s3_2_1;
7470
state s3_2_2;
7571
}
76-
transition first s3_1 then s3_2.s3_2_1;
77-
succession first s3_2 then s3_2.s3_2_2;
7872
}
7973

8074
}

org.omg.sysml.xtext/src/org/omg/sysml/xtext/validation/SysMLValidator.xtend

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,12 @@ class SysMLValidator extends KerMLValidator {
366366

367367
@Check
368368
def checkStateUsage(StateUsage usg) {
369-
val owningType = usg.owningType
370-
if (owningType !== null && !owningType.isAbstract && usg.isComposite &&
371-
UsageUtil.isNonParallelState(owningType) && !UsageUtil.hasIncomingTransitions(usg)
372-
) {
373-
warning(INVALID_STATEUSAGE_TRANSITIONS_MSG, usg, null, INVALID_STATEUSAGE_TRANSITIONS)
374-
}
369+
// val owningType = usg.owningType
370+
// if (owningType !== null && !owningType.isAbstract && usg.isComposite &&
371+
// UsageUtil.isNonParallelState(owningType) && !UsageUtil.hasIncomingTransitions(usg)
372+
// ) {
373+
// warning(INVALID_STATEUSAGE_TRANSITIONS_MSG, usg, null, INVALID_STATEUSAGE_TRANSITIONS)
374+
// }
375375
checkStateSubactions(usg)
376376
}
377377

org.omg.sysml/src/org/omg/sysml/adapter/StateUsageAdapter.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.omg.sysml.lang.sysml.StateDefinition;
2525
import org.omg.sysml.lang.sysml.StateUsage;
2626
import org.omg.sysml.lang.sysml.Type;
27+
import org.omg.sysml.util.UsageUtil;
2728

2829
public class StateUsageAdapter extends ActionUsageAdapter {
2930

@@ -38,7 +39,14 @@ public StateUsage getTarget() {
3839

3940
@Override
4041
protected String getSubactionType() {
41-
return isSubstate()? "substate": super.getSubactionType();
42+
return isExclusiveState()? "exclusiveState":
43+
isSubstate()? "substate":
44+
super.getSubactionType();
45+
}
46+
47+
public boolean isExclusiveState() {
48+
Type owningType = getTarget().getOwningType();
49+
return !UsageUtil.isParallelState(owningType);
4250
}
4351

4452
public boolean isSubstate() {

org.omg.sysml/src/org/omg/sysml/util/ImplicitGeneralizationMap.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ protected ImplicitGeneralizationMap() {
231231
put(StateDefinitionImpl.class, "base", "States::StateAction");
232232
put(StateUsageImpl.class, "base", "States::stateActions");
233233
put(StateUsageImpl.class, "substate", "States::StateAction::substates");
234+
put(StateUsageImpl.class, "exclusiveState", "States::StateAction::exclusiveStates");
234235

235236
put(SuccessionAsUsageImpl.class, "base", "Links::links");
236237
put(SuccessionAsUsageImpl.class, "binary", "Occurrences::happensBeforeLinks");

sysml.library/Systems Library/States.sysml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ package States {
1111
private import Actions::transitionActions;
1212
private import Actions::AcceptAction;
1313
private import Actions::actions;
14+
private import SequenceFunctions::notEmpty;
15+
private import SequenceFunctions::size;
1416

1517
/**
1618
* A StateAction is a kind of Action that is also a StatePerformance. It is the base type for all
@@ -38,10 +40,22 @@ package States {
3840
*/
3941
abstract state substates: StateAction[0..*] :> stateActions, subactions;
4042

43+
/**
44+
* The substates of this state that are mutually exclusive, that is, whose performances do not
45+
* overlap in time.
46+
*/
47+
abstract state exclusiveStates: StateAction[0..*] :> substates;
48+
4149
/**
4250
* The transitions of this state that are state transitions.
4351
*/
4452
abstract action stateTransitions: StateTransitionAction[0..*] :> transitions;
53+
54+
/**
55+
* Exclusive states cannot overlap, so it must be possible to strictly sequence them in time.
56+
*/
57+
succession stateSequencing first exclusiveStates[0..1] then exclusiveStates[0..1];
58+
assert constraint {notEmpty(exclusiveStates) implies size(stateSequencing) == size(exclusiveStates) - 1}
4559
}
4660

4761
/**

0 commit comments

Comments
 (0)