Search in sources :

Example 6 with ProcessModel

use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.

the class BatchPluginUtils method getRunningCluster.

BatchCluster getRunningCluster(ProcessInstance processInstance, int nodeId) {
    ProcessModel processModel = processInstance.getProcessModel();
    String processId = processModel.getId();
    if (batchClusters.containsKey(processId)) {
        Map<Integer, List<BatchCluster>> batchClustersOfProcess = batchClusters.get(processId);
        if (batchClustersOfProcess.containsKey(nodeId)) {
            List<BatchCluster> clusters = batchClustersOfProcess.get(nodeId);
            for (BatchCluster bc : clusters) {
                List<ProcessInstance> clusterProcessInstances = bc.getProcessInstances();
                if (bc.getState() == BatchClusterState.RUNNING && clusterProcessInstances.contains(processInstance)) {
                    return bc;
                }
            }
        }
    }
    return null;
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) ArrayList(java.util.ArrayList) List(java.util.List) ProcessInstance(de.hpi.bpt.scylla.simulation.ProcessInstance)

Example 7 with ProcessModel

use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.

the class BatchPluginUtils method scheduleNextEventInBatchProcess.

// if the execution type is sequential-taskbased, this is responsible for scheduling the same event of the next process instance, if it exists
void scheduleNextEventInBatchProcess(ScyllaEvent event, ProcessInstance processInstance) {
    ProcessInstance parentProcessInstance = processInstance.getParent();
    if (parentProcessInstance != null) {
        ProcessModel processModel = processInstance.getProcessModel();
        int parentNodeId = processModel.getNodeIdInParent();
        BatchPluginUtils pluginInstance = BatchPluginUtils.getInstance();
        BatchCluster cluster = pluginInstance.getRunningCluster(parentProcessInstance, parentNodeId);
        if (cluster != null && cluster.hasExecutionType(BatchClusterExecutionType.SEQUENTIAL_TASKBASED)) {
            // Get the other events or tasks from this batch to be scheduled after the current one...
            Integer nodeId = event.getNodeId();
            Pair<ScyllaEvent, ProcessInstance> eventToSchedule = cluster.getNotPIEvents(nodeId);
            if (eventToSchedule != null) {
                eventToSchedule.getValue0().schedule(eventToSchedule.getValue1());
            // System.out.println("Scheduled " + eventToSchedule.getValue0().getDisplayName() + " for process instance " + eventToSchedule.getValue1());
            }
            if (parentProcessInstance != cluster.getResponsibleProcessInstance()) {
                // ..and save the next events before them getting clered
                ScyllaEvent nextEvent = event.getNextEventMap().get(0);
                Integer nodeIdOfNextElement = nextEvent.getNodeId();
                cluster.addPIEvent(nodeIdOfNextElement, nextEvent, processInstance);
            // System.out.println("Added " + nextEvent.getDisplayName() + " to cluster queue for process instance " + processInstance);
            }
        }
    }
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) ProcessInstance(de.hpi.bpt.scylla.simulation.ProcessInstance)

Example 8 with ProcessModel

use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.

the class BatchTBPlugin method eventRoutine.

@SuppressWarnings("unchecked")
@Override
public void eventRoutine(TaskBeginEvent event, ProcessInstance processInstance) throws ScyllaRuntimeException {
    // System.out.println(event + " with display name " + event.getDisplayName() + " || " + event.getNextEventMap() + " and source " + event.getSource());
    BatchPluginUtils pluginInstance = BatchPluginUtils.getInstance();
    pluginInstance.logTaskEventForNonResponsiblePI(event, processInstance);
    ProcessSimulationComponents desmojObjects = event.getDesmojObjects();
    // SimulationModel model = (SimulationModel) desmojEvent.getModel();
    int nodeId = event.getNodeId();
    ProcessModel processModel = processInstance.getProcessModel();
    ProcessInstance parentProcessInstance = processInstance.getParent();
    if (parentProcessInstance != null) {
        int parentNodeId = processModel.getNodeIdInParent();
        BatchCluster cluster = pluginInstance.getRunningCluster(parentProcessInstance, parentNodeId);
        // If we are the representative (first executed) process instance we add the setUp time for this task
        if (cluster != null && parentProcessInstance == cluster.getResponsibleProcessInstance()) {
            // therefore we fist take a sample of the setUp distribution
            double setUpTimeToAdd = desmojObjects.getSetUpDistributionSample(nodeId);
            TimeUnit unit = desmojObjects.getSetUpDistributionTimeUnit(nodeId);
            TimeSpan setUpTimeToAddAsTimeSpan = new TimeSpan(setUpTimeToAdd, unit);
            // get the old value (this will always be the entry 0 in our map, because it's always the next)
            double standardTime = event.getTimeSpanToNextEventMap().get(0).getTimeAsDouble(TimeUnit.SECONDS);
            // and overwrite the time to the next task in the timeSpanToNextEventMap (=set the calculated time as the new time)
            TimeSpan timeForTaskWithSetUp = new TimeSpan(standardTime + setUpTimeToAddAsTimeSpan.getTimeAsDouble(TimeUnit.SECONDS), TimeUnit.SECONDS);
            event.getTimeSpanToNextEventMap().put(0, timeForTaskWithSetUp);
        }
    }
    // SimulationConfiguration simulationConfiguration = desmojObjects.getSimulationConfiguration();
    /*Map<Integer, BatchActivity> batchActivities = (Map<Integer, BatchActivity>) simulationConfiguration
                .getExtensionValue(getName(), "batchActivities");*/
    Map<Integer, BatchActivity> batchActivities = processModel.getBatchActivities();
    if (batchActivities.containsKey(nodeId) && processModel.getSubProcesses().containsKey(nodeId)) {
        // subprocess plugin wants to schedule BPMNStartEvents for subprocess
        // we prevent it
        Map<Integer, ScyllaEvent> nextEventMap = event.getNextEventMap();
        Map<Integer, TimeSpan> timeSpanToNextEventMap = event.getTimeSpanToNextEventMap();
        for (Integer indexOfSubprocessBPMNStartEvent : nextEventMap.keySet()) {
            ScyllaEvent eventToSchedule = nextEventMap.get(indexOfSubprocessBPMNStartEvent);
            if (eventToSchedule instanceof BPMNStartEvent || eventToSchedule instanceof TaskTerminateEvent) {
                nextEventMap.remove(indexOfSubprocessBPMNStartEvent);
                timeSpanToNextEventMap.remove(indexOfSubprocessBPMNStartEvent);
                break;
            }
        }
    }
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) ScyllaEvent(de.hpi.bpt.scylla.simulation.event.ScyllaEvent) TaskTerminateEvent(de.hpi.bpt.scylla.simulation.event.TaskTerminateEvent) TimeSpan(desmoj.core.simulator.TimeSpan) ProcessSimulationComponents(de.hpi.bpt.scylla.simulation.ProcessSimulationComponents) TimeUnit(java.util.concurrent.TimeUnit) ProcessInstance(de.hpi.bpt.scylla.simulation.ProcessInstance) BPMNStartEvent(de.hpi.bpt.scylla.simulation.event.BPMNStartEvent)

Example 9 with ProcessModel

use of de.hpi.bpt.scylla.model.process.ProcessModel 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 10 with ProcessModel

use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.

the class BatchTEPlugin method eventRoutine.

@SuppressWarnings("unchecked")
@Override
public void eventRoutine(TaskEnableEvent event, ProcessInstance processInstance) throws ScyllaRuntimeException {
    BatchPluginUtils pluginInstance = BatchPluginUtils.getInstance();
    pluginInstance.logTaskEventForNonResponsiblePI(event, processInstance);
    // ProcessSimulationComponents desmojObjects = event.getDesmojObjects();
    // SimulationModel model = (SimulationModel) desmojEvent.getModel();
    int nodeId = event.getNodeId();
    ProcessModel processModel = processInstance.getProcessModel();
    // SimulationConfiguration simulationConfiguration = desmojObjects.getSimulationConfiguration();
    /*Map<Integer, BatchActivity> batchActivities = (Map<Integer, BatchActivity>) simulationConfiguration
                .getExtensionValue(getName(), "batchActivities");*/
    Map<Integer, BatchActivity> batchActivities = processModel.getBatchActivities();
    if (batchActivities.containsKey(nodeId) && processModel.getSubProcesses().containsKey(nodeId)) {
        // in any case: put taskbeginevent of subprocess container on hold
        // String source = desmojEvent.getSource();
        int indexOfSubprocessBeginEvent = 0;
        Map<Integer, ScyllaEvent> nextEventMap = event.getNextEventMap();
        Map<Integer, TimeSpan> timeSpanToNextEventMap = event.getTimeSpanToNextEventMap();
        // Map<String, TaskBeginEvent> subprocessStartEventsOnHold =
        // pluginInstance.getSubprocessStartEventsOnHold();
        TaskBeginEvent subprocessBeginEvent = (TaskBeginEvent) nextEventMap.get(indexOfSubprocessBeginEvent);
        pluginInstance.assignToBatchCluster(processInstance, nodeId, subprocessBeginEvent);
        nextEventMap.remove(indexOfSubprocessBeginEvent);
        timeSpanToNextEventMap.remove(indexOfSubprocessBeginEvent);
    }
}
Also used : TimeSpan(desmoj.core.simulator.TimeSpan) ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) TaskBeginEvent(de.hpi.bpt.scylla.simulation.event.TaskBeginEvent) ScyllaEvent(de.hpi.bpt.scylla.simulation.event.ScyllaEvent)

Aggregations

ProcessModel (de.hpi.bpt.scylla.model.process.ProcessModel)73 SimulationModel (de.hpi.bpt.scylla.simulation.SimulationModel)42 TimeSpan (desmoj.core.simulator.TimeSpan)26 ScyllaValidationException (de.hpi.bpt.scylla.exception.ScyllaValidationException)22 NodeNotFoundException (de.hpi.bpt.scylla.model.process.graph.exception.NodeNotFoundException)19 ScyllaRuntimeException (de.hpi.bpt.scylla.exception.ScyllaRuntimeException)18 ProcessInstance (de.hpi.bpt.scylla.simulation.ProcessInstance)18 ScyllaEvent (de.hpi.bpt.scylla.simulation.event.ScyllaEvent)16 Map (java.util.Map)16 HashMap (java.util.HashMap)14 ProcessNodeInfo (de.hpi.bpt.scylla.logger.ProcessNodeInfo)13 ProcessSimulationComponents (de.hpi.bpt.scylla.simulation.ProcessSimulationComponents)13 Element (org.jdom2.Element)13 TimeInstant (desmoj.core.simulator.TimeInstant)12 HashSet (java.util.HashSet)12 SimulationConfiguration (de.hpi.bpt.scylla.model.configuration.SimulationConfiguration)10 TimeUnit (java.util.concurrent.TimeUnit)10 EventDefinitionType (de.hpi.bpt.scylla.model.process.node.EventDefinitionType)8 ArrayList (java.util.ArrayList)8 Namespace (org.jdom2.Namespace)8