Search in sources :

Example 1 with TaskCancelEvent

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);
        }
    }
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) TaskCancelEvent(de.hpi.bpt.scylla.simulation.event.TaskCancelEvent) ProcessInstance(de.hpi.bpt.scylla.simulation.ProcessInstance) TaskTerminateEvent(de.hpi.bpt.scylla.simulation.event.TaskTerminateEvent)

Example 2 with TaskCancelEvent

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);
    }
}
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)

Example 3 with TaskCancelEvent

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);
        }
    }
}
Also used : TimeSpan(desmoj.core.simulator.TimeSpan) ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) TaskCancelEvent(de.hpi.bpt.scylla.simulation.event.TaskCancelEvent) ProcessInstance(de.hpi.bpt.scylla.simulation.ProcessInstance) TaskTerminateEvent(de.hpi.bpt.scylla.simulation.event.TaskTerminateEvent) SimulationModel(de.hpi.bpt.scylla.simulation.SimulationModel)

Aggregations

TaskCancelEvent (de.hpi.bpt.scylla.simulation.event.TaskCancelEvent)3 ProcessModel (de.hpi.bpt.scylla.model.process.ProcessModel)2 ProcessInstance (de.hpi.bpt.scylla.simulation.ProcessInstance)2 TaskTerminateEvent (de.hpi.bpt.scylla.simulation.event.TaskTerminateEvent)2 TimeSpan (desmoj.core.simulator.TimeSpan)2 ScyllaRuntimeException (de.hpi.bpt.scylla.exception.ScyllaRuntimeException)1 SimulationModel (de.hpi.bpt.scylla.simulation.SimulationModel)1 ScyllaEvent (de.hpi.bpt.scylla.simulation.event.ScyllaEvent)1 TaskEvent (de.hpi.bpt.scylla.simulation.event.TaskEvent)1 EventAbstract (desmoj.core.simulator.EventAbstract)1 ArrayList (java.util.ArrayList)1