use of de.hpi.bpt.scylla.simulation.event.TaskCancelEvent in project scylla by bptlab.
the class BatchTCPlugin method eventRoutine.
@Override
public void eventRoutine(TaskCancelEvent event, ProcessInstance processInstance) throws ScyllaRuntimeException {
BatchPluginUtils pluginInstance = BatchPluginUtils.getInstance();
pluginInstance.logTaskEventForNonResponsiblePI(event, processInstance);
ProcessInstance parentProcessInstance = processInstance.getParent();
if (parentProcessInstance != null) {
ProcessModel processModel = processInstance.getProcessModel();
int parentNodeId = processModel.getNodeIdInParent();
BatchCluster cluster = pluginInstance.getRunningCluster(parentProcessInstance, parentNodeId);
if (cluster != null) {
List<TaskTerminateEvent> parentalEndEvents = cluster.getParentalEndEvents();
for (TaskTerminateEvent pee : parentalEndEvents) {
TaskCancelEvent cancelEvent = new TaskCancelEvent(pee.getModel(), pee.getSource(), pee.getSimulationTimeOfSource(), pee.getDesmojObjects(), pee.getProcessInstance(), pee.getNodeId());
cancelEvent.schedule(pee.getProcessInstance());
}
parentalEndEvents.clear();
pluginInstance.setClusterToTerminated(parentProcessInstance, parentNodeId);
}
}
}
use of de.hpi.bpt.scylla.simulation.event.TaskCancelEvent 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);
}
}
use of de.hpi.bpt.scylla.simulation.event.TaskCancelEvent in project scylla by bptlab.
the class SubprocessTCPlugin method eventRoutine.
@Override
public void eventRoutine(TaskCancelEvent desmojEvent, ProcessInstance processInstance) throws ScyllaRuntimeException {
ProcessModel processModel = processInstance.getProcessModel();
if (processModel.getParent() != null) {
int nodeIdInParent = processModel.getNodeIdInParent();
ProcessInstance parentProcessInstance = processInstance.getParent();
String parentProcessInstanceName = parentProcessInstance.getName();
SubprocessPluginUtils pluginInstance = SubprocessPluginUtils.getInstance();
Map<Integer, TaskTerminateEvent> eventsOnHoldMap = pluginInstance.getEventsOnHold().get(parentProcessInstanceName);
TaskTerminateEvent event = eventsOnHoldMap.get(nodeIdInParent);
if (event != null) {
SimulationModel model = (SimulationModel) event.getModel();
String source = event.getSource();
TaskCancelEvent cancelEvent = new TaskCancelEvent(model, source, event.getSimulationTimeOfSource(), event.getDesmojObjects(), event.getProcessInstance(), event.getNodeId());
cancelEvent.schedule(parentProcessInstance, new TimeSpan(0));
eventsOnHoldMap.remove(nodeIdInParent);
}
}
}
Aggregations