use of de.hpi.bpt.scylla.simulation.event.ProcessSimulationStopEvent in project scylla by bptlab.
the class SimulationModel method doInitialSchedules.
@Override
public void doInitialSchedules() {
TimeUnit timeUnit = DateTimeUtils.getReferenceTimeUnit();
for (String processId : pSimMap.keySet()) {
ProcessSimulationComponents desmojObj = pSimMap.get(processId);
// schedule for end of simulation (if defined), aligned to global start time
ZonedDateTime endDateOfSimulationConf = desmojObj.getSimulationConfiguration().getEndDateTime();
Long endTimeRelativeToGlobalStart = Long.MAX_VALUE;
if (endDateOfSimulationConf != null) {
endTimeRelativeToGlobalStart = DateTimeUtils.getDuration(startDateTime, endDateOfSimulationConf);
ProcessSimulationStopEvent endEvent = new ProcessSimulationStopEvent(this, processId, traceIsOn());
// java.util.Date getTime() returns milliseconds
endEvent.schedule(new TimeSpan(endTimeRelativeToGlobalStart, timeUnit));
}
// schedule for start of simulation, aligned to global start time
ZonedDateTime startDateOfSimulationConf = desmojObj.getSimulationConfiguration().getStartDateTime();
long startTimeRelativeToGlobalStart = DateTimeUtils.getDuration(startDateTime, startDateOfSimulationConf);
ProcessModel processModel = desmojObj.getProcessModel();
int processInstanceId = desmojObj.incrementProcessInstancesStarted();
ProcessInstance firstProcessInstance = new ProcessInstance(this, processModel, processInstanceId, traceIsOn());
ProcessInstanceGenerationEvent startEvent = new ProcessInstanceGenerationEvent(this, processId, endTimeRelativeToGlobalStart, traceIsOn());
startEvent.schedule(firstProcessInstance, new TimeSpan(startTimeRelativeToGlobalStart, timeUnit));
}
if (endDateTime != null) {
// / java.util.Date getTime() returns milliseconds
long simulationDuration = DateTimeUtils.getDuration(startDateTime, endDateTime);
TimeInstant timeInstant = new TimeInstant(simulationDuration, DateTimeUtils.getReferenceTimeUnit());
for (String processId : pSimMap.keySet()) {
ProcessSimulationStopEvent abortEvent = new ProcessSimulationStopEvent(this, processId, traceIsOn());
abortEvent.schedule(timeInstant);
}
}
}
Aggregations