use of de.hpi.bpt.scylla.logger.ProcessNodeInfo in project scylla by bptlab.
the class BPMNEvent method addToLogAsCanceled.
public void addToLogAsCanceled(ProcessInstance processInstance) {
long timestamp = Math.round(getModel().presentTime().getTimeRounded(DateTimeUtils.getReferenceTimeUnit()));
String taskName = displayName;
Set<String> resources = new HashSet<String>();
SimulationModel model = (SimulationModel) getModel();
ProcessModel processModel = processInstance.getProcessModel();
String processScopeNodeId = SimulationUtils.getProcessScopeNodeId(processModel, nodeId);
ProcessNodeInfo info;
info = new ProcessNodeInfo(nodeId, processScopeNodeId, source, timestamp, taskName, resources, ProcessNodeTransitionType.CANCEL);
model.addNodeInfo(processModel, processInstance, info);
}
use of de.hpi.bpt.scylla.logger.ProcessNodeInfo in project scylla by bptlab.
the class TaskCancelEvent method addToLog.
@Override
protected void addToLog(ProcessInstance processInstance) {
long timestamp = Math.round(getModel().presentTime().getTimeRounded(DateTimeUtils.getReferenceTimeUnit()));
String taskName = displayName;
Set<String> resources = new HashSet<String>();
Set<ResourceObject> resourceObjects = processInstance.getAssignedResources().get(source).getResourceObjects();
for (ResourceObject res : resourceObjects) {
String resourceName = res.getResourceType() + "_" + res.getId();
resources.add(resourceName);
}
ProcessNodeTransitionType transition = ProcessNodeTransitionType.CANCEL;
SimulationModel model = (SimulationModel) getModel();
ProcessModel processModel = processInstance.getProcessModel();
String processScopeNodeId = SimulationUtils.getProcessScopeNodeId(processModel, nodeId);
ProcessNodeInfo info = new ProcessNodeInfo(nodeId, processScopeNodeId, source, timestamp, taskName, resources, transition);
model.addNodeInfo(processModel, processInstance, info);
}
use of de.hpi.bpt.scylla.logger.ProcessNodeInfo in project scylla by bptlab.
the class TaskEnableEvent method addToLog.
@Override
protected void addToLog(ProcessInstance processInstance) {
long timestamp = Math.round(getModel().presentTime().getTimeRounded(DateTimeUtils.getReferenceTimeUnit()));
String taskName = displayName;
Set<String> resources = new HashSet<String>();
ProcessNodeTransitionType transition = ProcessNodeTransitionType.ENABLE;
SimulationModel model = (SimulationModel) getModel();
ProcessModel processModel = processInstance.getProcessModel();
String processScopeNodeId = SimulationUtils.getProcessScopeNodeId(processModel, nodeId);
ProcessNodeInfo info = new ProcessNodeInfo(nodeId, processScopeNodeId, getName(), timestamp, taskName, resources, transition);
model.addNodeInfo(processModel, processInstance, info);
}
use of de.hpi.bpt.scylla.logger.ProcessNodeInfo in project scylla by bptlab.
the class TaskTerminateEvent method addToLog.
@Override
protected void addToLog(ProcessInstance processInstance) {
long timestamp = Math.round(getModel().presentTime().getTimeRounded(DateTimeUtils.getReferenceTimeUnit()));
String taskName = displayName;
Set<String> resources = new HashSet<String>();
Set<ResourceObject> resourceObjects = processInstance.getAssignedResources().get(source).getResourceObjects();
for (ResourceObject res : resourceObjects) {
String resourceName = res.getResourceType() + "_" + res.getId();
resources.add(resourceName);
}
ProcessNodeTransitionType transition = ProcessNodeTransitionType.TERMINATE;
SimulationModel model = (SimulationModel) getModel();
if (!alreadyCanceled(model)) {
ProcessModel processModel = processInstance.getProcessModel();
String processScopeNodeId = SimulationUtils.getProcessScopeNodeId(processModel, nodeId);
ProcessNodeInfo info = new ProcessNodeInfo(nodeId, processScopeNodeId, source, timestamp, taskName, resources, transition);
model.addNodeInfo(processModel, processInstance, info);
}
}
use of de.hpi.bpt.scylla.logger.ProcessNodeInfo in project scylla by bptlab.
the class DateTimeUtils method getTaskTerminationTime.
/**
* Calculates the relative end time of a task. Consideres timetables of resources instances. If any resource
* instance is idle, the duration is extended by the idle time.
*
* @param timeSpan
* the original duration of the task without any interruptions
* @param presentTime
* current simulation time
* @param tuple
* resource instances assigned to the task
* @param event
* source event (for logging purposes)
* @return the end time of the task
*/
public static TimeInstant getTaskTerminationTime(TimeSpan timeSpan, TimeInstant presentTime, ResourceObjectTuple tuple, ScyllaEvent event) {
SimulationModel model = (SimulationModel) event.getModel();
ProcessInstance processInstance = event.getProcessInstance();
ProcessModel processModel = processInstance.getProcessModel();
String source = event.getSource();
String taskName = event.getDisplayName();
int nodeId = event.getNodeId();
String processScopeNodeId = SimulationUtils.getProcessScopeNodeId(processModel, nodeId);
Set<String> resources = new HashSet<String>();
Set<ResourceObject> resourceObjects = tuple.getResourceObjects();
for (ResourceObject res : resourceObjects) {
String resourceName = res.getResourceType() + "_" + res.getId();
resources.add(resourceName);
}
// start
long duration = timeSpan.getTimeRounded(timeUnit);
if (duration == 0) {
return presentTime;
}
ZonedDateTime dateTime = DateTimeUtils.getDateTime(presentTime);
List<TimetableItem> timetable = tuple.getSharedTimetable();
if (timetable == null) {
return new TimeInstant(presentTime.getTimeRounded(timeUnit) + duration);
}
Integer index = null;
for (int i = 0; i < timetable.size(); i++) {
TimetableItem item = timetable.get(i);
if (isWithin(dateTime, item)) {
index = i;
break;
}
}
long timePassed = 0;
while (timePassed < duration) {
TimetableItem item = timetable.get(index);
DayOfWeek untilWeekday = item.getWeekdayTo();
LocalTime untilTime = item.getEndTime();
ZonedDateTime dateTimeUntilEnd = getNextOrSameZonedDateTime(dateTime, untilWeekday, untilTime);
long durationUntilEnd = chronoUnit.between(dateTime, dateTimeUntilEnd);
long amountToAdd;
if (timePassed + durationUntilEnd >= duration) {
// task completes in current timetable item
amountToAdd = duration - timePassed;
} else {
// until end of timetable item
amountToAdd = durationUntilEnd;
}
timePassed += amountToAdd;
dateTime = dateTime.plus(amountToAdd, chronoUnit);
if (timePassed + durationUntilEnd < duration) {
// task is not completed in current timetable item, so jump to the start of the next timetable item
if (model.isOutputLoggingOn()) {
// log idle during use
ResourceStatus status = ResourceStatus.IN_USE_IDLE;
long timeRelativeToStart = getTimeInstant(dateTime).getTimeRounded(timeUnit);
ResourceInfo info = new ResourceInfo(timeRelativeToStart, status, processInstance, nodeId);
for (ResourceObject obj : tuple.getResourceObjects()) {
String resourceType = obj.getResourceType();
String resourceId = obj.getId();
model.addResourceInfo(resourceType, resourceId, info);
}
ProcessNodeTransitionType transition = ProcessNodeTransitionType.PAUSE;
ProcessNodeInfo nodeInfo = new ProcessNodeInfo(nodeId, processScopeNodeId, source, timeRelativeToStart, taskName, resources, transition);
model.addNodeInfo(processModel, processInstance, nodeInfo);
}
index++;
if (index == timetable.size()) {
index = 0;
}
TimetableItem nextItem = timetable.get(index);
untilWeekday = nextItem.getWeekdayFrom();
untilTime = nextItem.getBeginTime();
dateTime = getNextZonedDateTime(dateTime, untilWeekday, untilTime);
if (model.isOutputLoggingOn()) {
// log back to work
ResourceStatus status = ResourceStatus.IN_USE;
long timeRelativeToStart = getTimeInstant(dateTime).getTimeRounded(timeUnit);
ResourceInfo info = new ResourceInfo(timeRelativeToStart, status, processInstance, nodeId);
for (ResourceObject obj : tuple.getResourceObjects()) {
String resourceType = obj.getResourceType();
String resourceId = obj.getId();
model.addResourceInfo(resourceType, resourceId, info);
}
ProcessNodeTransitionType transition = ProcessNodeTransitionType.RESUME;
ProcessNodeInfo nodeInfo = new ProcessNodeInfo(nodeId, processScopeNodeId, source, timeRelativeToStart, taskName, resources, transition);
model.addNodeInfo(processModel, processInstance, nodeInfo);
}
}
}
TimeInstant timeInstant = getTimeInstant(dateTime);
return timeInstant;
}
Aggregations