use of desmoj.core.simulator.EventAbstract 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);
}
}
Aggregations