use of de.prob.model.eventb.Event in project prob2 by bendisposto.
the class MachineXmlHandler method beginEventExtraction.
private void beginEventExtraction(final Attributes attributes) {
String crazyRodinInternalName = attributes.getValue("name");
String name = attributes.getValue("org.eventb.core.label");
String convergence = attributes.getValue("org.eventb.core.convergence");
String extended = attributes.getValue("org.eventb.core.extended");
Event.EventType eventType;
if ("0".equals(convergence)) {
eventType = Event.EventType.ORDINARY;
} else if ("1".equals(convergence)) {
eventType = Event.EventType.CONVERGENT;
} else {
eventType = Event.EventType.ANTICIPATED;
}
event = new Event(name, eventType, Boolean.valueOf(extended));
eventCache.get(machine.getName()).put(crazyRodinInternalName, event);
extractingEvent = true;
refinesForEvent = new ArrayList<>();
guards = new ArrayList<>();
actions = new ArrayList<>();
witnesses = new ArrayList<>();
parameters = new ArrayList<>();
}
use of de.prob.model.eventb.Event in project prob2 by bendisposto.
the class MachineExtractor method caseAEvent.
@Override
public void caseAEvent(final AEvent node) {
EventExtractor eE = new EventExtractor(new Event(node.getName().getText(), EventType.ORDINARY, false), machineM.getMachine().getRefines(), typeEnv, getComment(node.getComments()));
node.apply(eE);
machineM = new MachineModifier(machineM.getMachine().addTo(BEvent.class, eE.getEvent()), typeEnv);
}
use of de.prob.model.eventb.Event in project prob2 by bendisposto.
the class EventExtractor method caseARefinesEventRefinement.
@Override
public void caseARefinesEventRefinement(ARefinesEventRefinement node) {
if (machineRefines.isEmpty()) {
throw new IllegalArgumentException("Could not find machine refinement although event is marked as a refinement");
}
if (node.getNames().size() != 1) {
throw new IllegalArgumentException("The API currently only supports single refinement for events");
}
String name = node.getNames().get(0).getText();
Event event = machineRefines.get(0).getEvent(name);
if (event == null) {
throw new IllegalArgumentException("Could not find refined event with name " + name);
}
eventM = eventM.refines(event, false);
}
use of de.prob.model.eventb.Event in project prob2 by bendisposto.
the class Transition method getParameterPredicates.
/**
* @return a list of string predicates representing the value of the
* parameters for this transition
*/
public List<String> getParameterPredicates() {
if (isArtificialTransition()) {
return Collections.emptyList();
}
evaluate(FormulaExpand.EXPAND);
List<String> predicates = new ArrayList<>();
AbstractElement mainComponent = stateSpace.getMainComponent();
List<String> paramNames = new ArrayList<>();
if (mainComponent instanceof ClassicalBMachine) {
Operation op = ((ClassicalBMachine) mainComponent).getOperation(getName());
paramNames = op.getParameters();
} else if (mainComponent instanceof EventBMachine) {
Event event = ((EventBMachine) mainComponent).getEvent(getName());
for (EventParameter eventParameter : event.getParameters()) {
paramNames.add(eventParameter.getName());
}
}
if (paramNames.size() == this.params.size()) {
for (int i = 0; i < paramNames.size(); i++) {
predicates.add(paramNames.get(i) + " = " + this.params.get(i));
}
}
return predicates;
}
use of de.prob.model.eventb.Event in project prob2 by bendisposto.
the class EventExtractor method caseAExtendedEventRefinement.
@Override
public void caseAExtendedEventRefinement(final AExtendedEventRefinement node) {
if (machineRefines.isEmpty()) {
throw new IllegalArgumentException("Could not find machine refinement although event is marked as a refinement");
}
String name = node.getName().getText();
Event event = machineRefines.get(0).getEvent(name);
if (event == null) {
throw new IllegalArgumentException("Could not find refined event with name " + name);
}
eventM = eventM.refines(event, true);
}
Aggregations