Search in sources :

Example 1 with TaskEvent

use of de.hpi.bpt.scylla.simulation.event.TaskEvent in project scylla by bptlab.

the class ProcessInstance method cancel.

// public double getTimeRelativeToSubProcessStart() {
// return timeRelativeToSubProcessStart;
// }
// 
// public void setTimeRelativeToSubProcessStart(double timeRelativeToSubProcessStart) {
// this.timeRelativeToSubProcessStart = timeRelativeToSubProcessStart;
// }
// 
// public Double getEndTimeRelativeToSubProcessStart() {
// return endTimeRelativeToSubProcessStart;
// }
// 
// public void setEndTimeRelativeToSubProcessStart(Double endTimeRelativeToSubProcessStart) {
// this.endTimeRelativeToSubProcessStart = endTimeRelativeToSubProcessStart;
// }
@Override
public void cancel() {
    try {
        Iterator<String> iterator = children.keySet().iterator();
        while (iterator.hasNext()) {
            String name = iterator.next();
            ProcessInstance child = children.get(name);
            child.cancel();
        }
        if (isScheduled()) {
            List<EventAbstract> scheduledEvents = getScheduledEvents();
            List<ScyllaEvent> rescheduledEvents = new ArrayList<ScyllaEvent>();
            for (EventAbstract e : scheduledEvents) {
                if (e instanceof TaskEvent) {
                    TaskEvent event = (TaskEvent) e;
                    TaskCancelEvent cancelEvent = new TaskCancelEvent(event.getModel(), event.getSource(), event.getSimulationTimeOfSource(), event.getDesmojObjects(), this, event.getNodeId());
                    rescheduledEvents.add(cancelEvent);
                }
            }
            super.cancel();
            for (ScyllaEvent event : rescheduledEvents) {
                TimeSpan timeSpan = new TimeSpan(0);
                SimulationUtils.scheduleEvent(event, timeSpan);
            }
        }
        if (parent != null) {
            parent.removeChild(this);
        }
    } catch (ScyllaRuntimeException e) {
        throw new RuntimeException(e);
    }
}
Also used : ScyllaRuntimeException(de.hpi.bpt.scylla.exception.ScyllaRuntimeException) ArrayList(java.util.ArrayList) TaskCancelEvent(de.hpi.bpt.scylla.simulation.event.TaskCancelEvent) ScyllaEvent(de.hpi.bpt.scylla.simulation.event.ScyllaEvent) TimeSpan(desmoj.core.simulator.TimeSpan) ScyllaRuntimeException(de.hpi.bpt.scylla.exception.ScyllaRuntimeException) TaskEvent(de.hpi.bpt.scylla.simulation.event.TaskEvent) EventAbstract(desmoj.core.simulator.EventAbstract)

Aggregations

ScyllaRuntimeException (de.hpi.bpt.scylla.exception.ScyllaRuntimeException)1 ScyllaEvent (de.hpi.bpt.scylla.simulation.event.ScyllaEvent)1 TaskCancelEvent (de.hpi.bpt.scylla.simulation.event.TaskCancelEvent)1 TaskEvent (de.hpi.bpt.scylla.simulation.event.TaskEvent)1 EventAbstract (desmoj.core.simulator.EventAbstract)1 TimeSpan (desmoj.core.simulator.TimeSpan)1 ArrayList (java.util.ArrayList)1