Search in sources :

Example 1 with Event

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<>();
}
Also used : BEvent(de.prob.model.representation.BEvent) Event(de.prob.model.eventb.Event)

Example 2 with Event

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);
}
Also used : BEvent(de.prob.model.representation.BEvent) AEvent(de.be4.eventbalg.core.parser.node.AEvent) Event(de.prob.model.eventb.Event) MachineModifier(de.prob.model.eventb.MachineModifier)

Example 3 with Event

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);
}
Also used : Event(de.prob.model.eventb.Event)

Example 4 with Event

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;
}
Also used : EventParameter(de.prob.model.eventb.EventParameter) AbstractElement(de.prob.model.representation.AbstractElement) ClassicalBMachine(de.prob.model.classicalb.ClassicalBMachine) ArrayList(java.util.ArrayList) Event(de.prob.model.eventb.Event) EventBMachine(de.prob.model.eventb.EventBMachine) Operation(de.prob.model.classicalb.Operation)

Example 5 with Event

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);
}
Also used : Event(de.prob.model.eventb.Event)

Aggregations

Event (de.prob.model.eventb.Event)7 ArrayList (java.util.ArrayList)3 EventBGuard (de.prob.model.eventb.EventBGuard)2 EventParameter (de.prob.model.eventb.EventParameter)2 BEvent (de.prob.model.representation.BEvent)2 AEvent (de.be4.classicalb.core.parser.node.AEvent)1 AEventsModelClause (de.be4.classicalb.core.parser.node.AEventsModelClause)1 AWitness (de.be4.classicalb.core.parser.node.AWitness)1 PEvent (de.be4.classicalb.core.parser.node.PEvent)1 PExpression (de.be4.classicalb.core.parser.node.PExpression)1 PPredicate (de.be4.classicalb.core.parser.node.PPredicate)1 PSubstitution (de.be4.classicalb.core.parser.node.PSubstitution)1 PWitness (de.be4.classicalb.core.parser.node.PWitness)1 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)1 AEvent (de.be4.eventbalg.core.parser.node.AEvent)1 ClassicalBMachine (de.prob.model.classicalb.ClassicalBMachine)1 Operation (de.prob.model.classicalb.Operation)1 EventBAction (de.prob.model.eventb.EventBAction)1 EventBMachine (de.prob.model.eventb.EventBMachine)1 MachineModifier (de.prob.model.eventb.MachineModifier)1