use of org.osate.aadl2.EnumerationLiteral in project osate2 by osate.
the class AadlBaUtils method getDataRepresentation.
/**
* Returns the data representation associated to the given PropertyReference
* object <BR><BR>
* Note : {@link #getDataRepresentation(PropertyType)} and
* {@link #getDataRepresentation(PropertyExpression)} to see restrictions.
* <BR><BR>
* @param pv the given PropertyReference object
* @return the data representation associated to the given
* PropertyReference object
* @exception UnsupportedOperationException for the unsupported types
*/
public static DataRepresentation getDataRepresentation(PropertyReference pr) {
EList<PropertyNameHolder> holders = pr.getProperties();
PropertyNameHolder last = holders.get(holders.size() - 1);
Element el = last.getProperty().getElement();
if (el instanceof PropertyType || el instanceof BasicProperty) {
return getDataRepresentation(((BasicProperty) el).getPropertyType());
} else if (el instanceof PropertyAssociation) {
return getDataRepresentation((PropertyAssociation) el);
} else if (el instanceof PropertyExpression) {
return getDataRepresentation((PropertyExpression) el);
} else if (el instanceof EnumerationLiteral) {
return DataRepresentation.ENUM_LITERAL;
} else {
String errorMsg = "getDataRepresentation: " + el.getClass().getSimpleName() + " is not supported yet.";
System.err.println(errorMsg);
throw new UnsupportedOperationException(errorMsg);
}
}
use of org.osate.aadl2.EnumerationLiteral in project osate2 by osate.
the class AadlBaUtils method getPropertyType.
/**
* Returns the PropertyType object associated to the given PropertyElementHolder
* given object.
* @param holder the PropertyElementHolder given object
* @return the associated PropertyType object
*/
public static PropertyType getPropertyType(PropertyElementHolder holder) {
PropertyType result = null;
Element el = holder.getElement();
if (el instanceof PropertyType) {
result = (PropertyType) el;
} else if (el instanceof BasicProperty) {
result = ((BasicProperty) el).getPropertyType();
} else if (el instanceof PropertyAssociation) {
result = ((PropertyAssociation) el).getProperty().getPropertyType();
} else if (el instanceof PropertyExpression) {
result = PropertyUtils.getContainingProperty((PropertyExpression) el).getPropertyType();
} else if (el instanceof EnumerationLiteral) {
result = (EnumerationType) el.eContainer();
}
return result;
}
use of org.osate.aadl2.EnumerationLiteral in project osate2 by osate.
the class AadlBaLegalityRulesChecker method D_4_L1_Check.
/**
* Document: AADL Behavior Annex draft
* Version : 0.94
* Type : Legality rule and Semantic rule
* Section : D.4 Thread Dispatch Behavior Specification
* Object : Check legality rule D.4.(L1) and semantic rule D.4.(5)
* Keys : dispatch relative timeout condition catch timed thread complete
* state period property
*/
public boolean D_4_L1_Check(DispatchRelativeTimeout tc, DeclarativeBehaviorTransition bt) {
List<Identifier> sourceState = bt.getSrcStates();
if (sourceState.size() == 1) {
BehaviorState bs = (BehaviorState) (sourceState.get(0)).getBaRef();
if (false == _alreadyFoundDispatchRelativeTimeoutTransition.containsKey(bs) && bs.isComplete()) {
// If the ba's parent container is not a Thread, the return value
// list will be empty.
EList<org.osate.aadl2.PropertyExpression> vl;
vl = PropertyUtils.findPropertyExpression(_baParentContainer, ThreadProperties.DISPATCH_PROTOCOL);
if (vl.size() > 0) {
org.osate.aadl2.PropertyExpression value = vl.get(vl.size() - 1);
if (value instanceof NamedValue && ((NamedValue) value).getNamedValue() instanceof EnumerationLiteral) {
EnumerationLiteral el = (EnumerationLiteral) ((NamedValue) value).getNamedValue();
String literal = el.getName();
if (literal.equalsIgnoreCase(DispatchTriggerProperties.TIMED)) {
boolean hasPeriod = false;
Long period = PropertyUtils.getIntValue(_baParentContainer, TimingProperties.PERIOD);
hasPeriod = period != null;
if (hasPeriod) {
_alreadyFoundDispatchRelativeTimeoutTransition.put(bs, bt);
return true;
} else // Error case: period property must be declared in the
// ba's parent container.
{
reportLegalityError(tc, "The dispatch relative timeout" + " and catch statement must declared in timed " + " thread with a period property properly set: " + " Behavior Annex D.4.(5) semantic rule failed");
// Early exit to skip the next error reporting.
return false;
}
}
}
}
// Error case : it must only be declared for timed thread.
this.reportLegalityError(tc, "The dispatch relative timeout and" + " catch statement must only be declared for timed thread: " + "Behavior Annex D.4.(L1) legality rule failed");
} else // Error case : It must be declared in an outgoing transition of
// a complete state.
{
if (false == _alreadyReportedErroneousTransition.contains(bt)) {
this.reportLegalityError(tc, "The dispatch relative timeout and " + "catch statement must be declared in an outgoing transition " + "of a complete state: Behavior Annex" + " D.4.(L1) legality rule failed");
_alreadyReportedErroneousTransition.add(bt);
}
}
} else // Error case : It must be declared in only one transition of the source state.
{
// If transition source states list is > 1, report errors for the
// furthers timeout catch.
this.reportLegalityError(tc, "The dispatch relative timeout and catch" + " statement must be declared in only one transition: " + "Behavior Annex D.4.(L1) legality rule failed");
}
return false;
}
use of org.osate.aadl2.EnumerationLiteral in project osate2 by osate.
the class AadlBaLegalityRulesChecker method D_4_L2_Check.
/**
* Document: AADL Behavior Annex draft
* Version : 0.94
* Type : Legality rule
* Section : D.4 Thread Dispatch Behavior Specification
* Object : Check legality rule D.4.(L2)
* Keys : dispatch completion relative timeout condition catch complete
* state
*/
public Boolean D_4_L2_Check(CompletionRelativeTimeout crtcac, DeclarativeBehaviorTransition bt) {
List<Identifier> sourceState = bt.getSrcStates();
if (!_alreadyFoundCompletionRelativeTimeoutConditionCatchTransition.containsKey(sourceState) && sourceState.size() == 1) {
BehaviorState bs = (BehaviorState) (sourceState.get(0)).getBaRef();
// Positive case.
if (bs.isComplete()) {
_alreadyFoundCompletionRelativeTimeoutConditionCatchTransition.put(bs, bt);
EList<org.osate.aadl2.PropertyExpression> vl;
vl = PropertyUtils.findPropertyExpression(_baParentContainer, ThreadProperties.DISPATCH_PROTOCOL);
if (vl.size() > 0) {
org.osate.aadl2.PropertyExpression value = vl.get(vl.size() - 1);
if (value instanceof NamedValue && ((NamedValue) value).getNamedValue() instanceof EnumerationLiteral) {
EnumerationLiteral el = (EnumerationLiteral) ((NamedValue) value).getNamedValue();
String literal = el.getName();
if (literal.equalsIgnoreCase(DispatchTriggerProperties.TIMED)) {
boolean hasPeriod = false;
Long period = PropertyUtils.getIntValue(_baParentContainer, TimingProperties.PERIOD);
hasPeriod = period != null;
Long timeoutConstantValue = null;
IntegerValue iv = crtcac.getIntegerValue();
if (iv instanceof IntegerLiteral) {
timeoutConstantValue = ((IntegerLiteral) iv).getValue();
}
boolean timeoutIsConstant = timeoutConstantValue != null;
// otherwise it is inconsistent.
if (hasPeriod && timeoutIsConstant && period < timeoutConstantValue) {
this.reportLegalityError(crtcac, "The completion relative timeout" + " condition and catch statement must have a value greater or" + " equal to the Period of the thread it is defined in (otherwise)" + " timeout condition can never occur");
}
}
}
}
return true;
} else // Error case : it must be declared in an outgoing transition of
// a complete state.
{
this.reportLegalityError(crtcac, "The completion relative timeout" + " condition and catch statement must be declared in an " + "outgoing transition of a complete state: Behavior Annex" + " D.4.(L2) legality rule failed");
}
} else // Error case : it must be declared in at most one transition.
{
// furthers completion timeout catch.
if (false == _alreadyReportedErroneousTransition.contains(bt)) {
this.reportLegalityError(crtcac, "The completion relative timeout " + "condition and catch statement must be declared in only one " + "transition: Behavior Annex D.4.(L2) legality rule failed");
_alreadyReportedErroneousTransition.add(bt);
}
}
return false;
}
use of org.osate.aadl2.EnumerationLiteral in project osate2 by osate.
the class AadlBaNameResolver method enumerationTypeResolver.
private boolean enumerationTypeResolver(EnumerationType type, DeclarativePropertyName declPropertyName) {
EnumerationType enumType = type;
for (EnumerationLiteral literal : enumType.getOwnedLiterals()) {
if (literal.getName().equalsIgnoreCase(declPropertyName.getPropertyName().getId())) {
declPropertyName.setOsateRef(literal);
declPropertyName.getPropertyName().setOsateRef(literal);
return true;
}
}
return false;
}
Aggregations