use of org.osate.ba.aadlba.ActualPortHolder in project osate2 by osate.
the class AadlBaConsistencyRulesChecker method D_3_C4_Check.
/**
* Document: AADL Behavior Annex draft
* Version : 0.94
* Type : Consistency rule
* Section : D.3 Behavior Specification
* Object : Check consistency rule D.3.(C4)
* Keys : complete state mode behavior condition mode transition triggers
*/
public boolean D_3_C4_Check(BehaviorTransition btOwner, Identifier srcState) {
// [OPTIM] -------------------------------------------------------------
// these checking can be moved to the rules driver in order to optimize.
BehaviorState bs = (BehaviorState) srcState.getBaRef();
BehaviorState declaredState = null;
if (bs.getName().equalsIgnoreCase(srcState.getId())) {
declaredState = bs;
}
// with true.
if (declaredState.getBindedMode() == null) {
return true;
}
// ---------------------------------------------------------------------
// At this point, one of the current behavior transtion's src states
// represent a mode.
DispatchTriggerLogicalExpression dtle;
Mode mode = declaredState.getBindedMode();
// trigger logical expression is analyzed.
if (btOwner.getCondition() instanceof DispatchCondition) {
DispatchCondition dc = (DispatchCondition) btOwner.getCondition();
if (dc.getDispatchTriggerCondition() instanceof DispatchTriggerLogicalExpression) {
dtle = (DispatchTriggerLogicalExpression) dc.getDispatchTriggerCondition();
} else {
// At least, there is one mode transition trigger in a mode
// transition. So this transition is not consistency.
reportConsistencyError(srcState, "The behavior transition tries " + "to refine a transition mode but it hasn't got any dispatch " + "trigger logical expression: Behavior Annex D.3.(C4) " + "consistency rule failed");
return false;
}
} else {
// exit with false result.
return false;
}
EList<ModeTransition> lModeTrans = Aadl2Visitors.getElementsInNamespace(_baParentContainer, ModeTransition.class);
// any transition mode.
if (lModeTrans.isEmpty()) {
reportConsistencyError(srcState, "The behavior transition tries to " + "refine a transition mode while " + _baParentContainer.getQualifiedName() + " component hasn't got any transition mode: " + "Behavior Annex D.3.(C4) consistency rule failed");
return false;
}
// At this point preliminary checking has been passed.
List<String> lModeTriggs = new ArrayList<String>();
// Fetches dispatch trigger names in the given behavior transition.
List<String> ldispTriggs = new ArrayList<String>();
for (DispatchTrigger trigg : AadlBaVisitors.getDispatchTriggers(dtle)) {
ActualPortHolder portHolder = (ActualPortHolder) trigg;
ldispTriggs.add(portHolder.getPort().getName());
}
// Otherwise reports an error.
for (ModeTransition mTrans : lModeTrans) {
// If the transition mode contains the considered mode:
if (mTrans.getSource().getName().equalsIgnoreCase(mode.getName())) {
// Fetches mode transition trigger names.
for (ModeTransitionTrigger mtt : mTrans.getOwnedTriggers()) {
lModeTriggs.add(AadlBaUtils.getName(mtt));
}
// considering their order.
if (Aadl2Utils.compareStringList(ldispTriggs, lModeTriggs)) {
return true;
} else {
lModeTriggs.clear();
continue;
}
}
// Else continue to the next transition mode.
}
// Error case : the given behavior transition which is out of a mode
// is not consisting with any transition mode which involves the considered
// mode.
reportConsistencyError(srcState, "The behavior transition tries to " + "refine a transition mode but it is not consisting with any " + "transition mode of " + _baParentContainer.getQualifiedName() + " component: Behavior Annex D.3.(C4) consistency rule failed");
return false;
}
use of org.osate.ba.aadlba.ActualPortHolder in project osate2 by osate.
the class PortDequeueActionImpl method basicSetPort.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetPort(ActualPortHolder newPort, NotificationChain msgs) {
ActualPortHolder oldPort = port;
port = newPort;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AadlBaPackage.PORT_DEQUEUE_ACTION__PORT, oldPort, newPort);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.osate.ba.aadlba.ActualPortHolder in project osate2 by osate.
the class PortSendActionImpl method basicSetPort.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetPort(ActualPortHolder newPort, NotificationChain msgs) {
ActualPortHolder oldPort = port;
port = newPort;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AadlBaPackage.PORT_SEND_ACTION__PORT, oldPort, newPort);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
Aggregations