public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance eventNodeInstance = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = eventNodeInstance.getNode().getMetaData(); ProcessInstance pi = eventNodeInstance.getProcessInstance(); Node node = eventNodeInstance.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); SimulationDataProvider provider = context.getDataProvider(); TimeGenerator timeGenerator=TimeGeneratorFactory.newTimeGenerator(provider.getSimulationDataForNode(node)); long duration = timeGenerator.generateTime(); context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new ActivitySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), node.getName(), bpmn2NodeId, duration, startTime, context.getClock().getCurrentTime(), type); }
@Override public long advanceTime(long amount, TimeUnit unit) { return ((org.drools.core.time.SessionPseudoClock)delegateClock).advanceTime(amount, unit); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance nodeInstance = (NodeInstance) activity; ProcessInstance pi = nodeInstance.getProcessInstance(); context.setStartTime(context.getClock().getCurrentTime()); Node node = nodeInstance.getNode(); String bpmn2NodeId = (String) node.getMetaData().get("UniqueId"); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); return new StartSimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), context.getStartTime(), context.getClock().getCurrentTime(), bpmn2NodeId, node.getName()); }
private void tickAtRateUntil(long tickLength, long start, long end) { // Now keep tick'ing at an accelerated rate for another week for (long now = start; now <= end; now += tickLength) { // Tick m_droolsAlarmContext.getClock().advanceTime(tickLength, TimeUnit.MILLISECONDS); m_droolsAlarmContext.tick(); results.addAlarms(now + tickLength, m_transactionTemplate.execute((t) -> { final List<OnmsAlarm> alarms = m_alarmDao.findAll(); alarms.forEach(a -> { Hibernate.initialize(a.getAssociatedAlarms()); }); return alarms; })); } }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance nodeInstance = (NodeInstance) activity; ProcessInstance pi = nodeInstance.getProcessInstance(); context.setStartTime(context.getClock().getCurrentTime()); Node node = nodeInstance.getNode(); String bpmn2NodeId = (String) node.getMetaData().get("UniqueId"); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); return new StartSimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), context.getStartTime(), context.getClock().getCurrentTime(), bpmn2NodeId, node.getName()); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance eventNodeInstance = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = eventNodeInstance.getNode().getMetaData(); ProcessInstance pi = eventNodeInstance.getProcessInstance(); Node node = eventNodeInstance.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); SimulationDataProvider provider = context.getDataProvider(); TimeGenerator timeGenerator=TimeGeneratorFactory.newTimeGenerator(provider.getSimulationDataForNode(node)); long duration = timeGenerator.generateTime(); context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new ActivitySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), node.getName(), bpmn2NodeId, duration, startTime, context.getClock().getCurrentTime(), type); }
m_droolsAlarmContext.getClock().advanceTime(tickLength, TimeUnit.MILLISECONDS); m_droolsAlarmContext.tick(); m_droolsAlarmContext.getClock().advanceTime(tickLength, TimeUnit.MILLISECONDS); m_droolsAlarmContext.tick(); results.addAlarms(now, m_transactionTemplate.execute((t) -> {
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance nodeInstance = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); ProcessInstance pi = nodeInstance.getProcessInstance(); Node node = nodeInstance.getNode(); String bpmn2NodeId = (String) node.getMetaData().get("UniqueId"); String processName = pi.getProcessName(); String processVer = pi.getProcess().getVersion(); if (processVer == null) { processVer = ""; } // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); return new EndSimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), startTime, context.getClock().getCurrentTime(), context.getStartTime(), bpmn2NodeId, node.getName(), processName, processVer); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance gateway = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = gateway.getNode().getMetaData(); ProcessInstance pi = gateway.getProcessInstance(); Node node = gateway.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); // todo long duration = 0; long endTime = startTime + duration; context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); SimulationDataProvider provider = context.getDataProvider(); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new GatewaySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), startTime, endTime, bpmn2NodeId, node.getName(), type); }
@Test public void testExclusiveGatewayProcessSimulation() { PathFinder finder = PathFinderFactory.getInstance(this.getClass().getResourceAsStream("/BPMN2-ExclusiveSplit.bpmn2")); List<SimulationPath> paths = finder.findPaths(new SimulationFilterPathFormatConverter()); SimulationContext context = SimulationContextFactory.newContext(new HardCodedSimulationDataProvider()); for (SimulationPath path : paths) { context.setCurrentPath(path); KieSession session = TestUtils.createSession("BPMN2-ExclusiveSplit.bpmn2"); context.setClock((SessionPseudoClock) session.getSessionClock()); // set start date to current time context.getClock().advanceTime(System.currentTimeMillis(), TimeUnit.MILLISECONDS); session.startProcess("com.sample.test"); System.out.println("#####################################"); } }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance nodeInstance = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); ProcessInstance pi = nodeInstance.getProcessInstance(); Node node = nodeInstance.getNode(); String bpmn2NodeId = (String) node.getMetaData().get("UniqueId"); String processName = pi.getProcessName(); String processVer = pi.getProcess().getVersion(); if (processVer == null) { processVer = ""; } // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); return new EndSimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), startTime, context.getClock().getCurrentTime(), context.getStartTime(), bpmn2NodeId, node.getName(), processName, processVer); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance gateway = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = gateway.getNode().getMetaData(); ProcessInstance pi = gateway.getProcessInstance(); Node node = gateway.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); // todo long duration = 0; long endTime = startTime + duration; context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); SimulationDataProvider provider = context.getDataProvider(); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new GatewaySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), startTime, endTime, bpmn2NodeId, node.getName(), type); }
@Test public void testExclusiveGatewayProcessSimulation() { PathFinder finder = PathFinderFactory.getInstance(this.getClass().getResourceAsStream("/BPMN2-ExclusiveSplit.bpmn2")); List<SimulationPath> paths = finder.findPaths(new SimulationFilterPathFormatConverter()); SimulationContext context = SimulationContextFactory.newContext(new HardCodedSimulationDataProvider()); for (SimulationPath path : paths) { context.setCurrentPath(path); KieSession session = TestUtils.createSession("BPMN2-ExclusiveSplit.bpmn2"); context.setClock((SessionPseudoClock) session.getSessionClock()); // set start date to current time context.getClock().advanceTime(System.currentTimeMillis(), TimeUnit.MILLISECONDS); session.startProcess("com.sample.test"); System.out.println("#####################################"); } }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance stateNode = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = stateNode.getNode().getMetaData(); ProcessInstance pi = stateNode.getProcessInstance(); Node node = stateNode.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); SimulationDataProvider provider = context.getDataProvider(); TimeGenerator timeGenerator=TimeGeneratorFactory.newTimeGenerator(provider.getSimulationDataForNode(node)); long duration = timeGenerator.generateTime(); context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new ActivitySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), node.getName(), bpmn2NodeId, duration, startTime, context.getClock().getCurrentTime(), type); }
@Test public void testParallelGatewayProcessSimulation() { PathFinder finder = PathFinderFactory.getInstance(this.getClass().getResourceAsStream("/BPMN2-ParallelSplit.bpmn2")); List<SimulationPath> paths = finder.findPaths(new SimulationFilterPathFormatConverter()); SimulationContext context = SimulationContextFactory.newContext(new HardCodedSimulationDataProvider()); for (SimulationPath path : paths) { context.setCurrentPath(path); KieSession session = TestUtils.createSession("BPMN2-ParallelSplit.bpmn2"); context.setClock((SessionPseudoClock) session.getSessionClock()); // set start date to current time context.getClock().advanceTime(System.currentTimeMillis(), TimeUnit.MILLISECONDS); session.startProcess("com.sample.test"); System.out.println("#####################################"); } }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance stateNode = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = stateNode.getNode().getMetaData(); ProcessInstance pi = stateNode.getProcessInstance(); Node node = stateNode.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); SimulationDataProvider provider = context.getDataProvider(); TimeGenerator timeGenerator=TimeGeneratorFactory.newTimeGenerator(provider.getSimulationDataForNode(node)); long duration = timeGenerator.generateTime(); context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new ActivitySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), node.getName(), bpmn2NodeId, duration, startTime, context.getClock().getCurrentTime(), type); }
@Test public void testUserTaskProcessSimulation() { PathFinder finder = PathFinderFactory.getInstance(this.getClass().getResourceAsStream("/BPMN2-UserTask.bpmn2")); List<SimulationPath> paths = finder.findPaths(new SimulationFilterPathFormatConverter()); SimulationContext context = SimulationContextFactory.newContext(new HardCodedSimulationDataProvider()); for (SimulationPath path : paths) { context.setCurrentPath(path); KieSession session = TestUtils.createSession("BPMN2-UserTask.bpmn2"); context.setClock((SessionPseudoClock) session.getSessionClock()); // set start date to current time context.getClock().advanceTime(System.currentTimeMillis(), TimeUnit.MILLISECONDS); session.startProcess("UserTask"); System.out.println("#####################################"); } }
public SimulationEvent simulate(Object activity, SimulationContext context) { long startTime = context.getClock().getCurrentTime(); NodeInstance stateNode = (NodeInstance) activity; StaffPool pool = context.getStaffPoolManager().getActivityPool(node.getName()); long waitTime = pool.allocate(context.getClock().getCurrentTime()); double resourceCost = pool.getResourceCost() * durationInUnit; context.getClock().advanceTime((duration), TimeUnit.MILLISECONDS); context.setMaxEndTime(context.getClock().getCurrentTime()); context.getClock().getCurrentTime(), resourceUtilization);
@Test public void testParallelGatewayProcessSimulation() { PathFinder finder = PathFinderFactory.getInstance(this.getClass().getResourceAsStream("/BPMN2-ParallelSplit.bpmn2")); List<SimulationPath> paths = finder.findPaths(new SimulationFilterPathFormatConverter()); SimulationContext context = SimulationContextFactory.newContext(new HardCodedSimulationDataProvider()); for (SimulationPath path : paths) { context.setCurrentPath(path); KieSession session = TestUtils.createSession("BPMN2-ParallelSplit.bpmn2"); context.setClock((SessionPseudoClock) session.getSessionClock()); // set start date to current time context.getClock().advanceTime(System.currentTimeMillis(), TimeUnit.MILLISECONDS); session.startProcess("com.sample.test"); System.out.println("#####################################"); } }
public SimulationEvent simulate(Object activity, SimulationContext context) { long startTime = context.getClock().getCurrentTime(); NodeInstance stateNode = (NodeInstance) activity; StaffPool pool = context.getStaffPoolManager().getActivityPool(node.getName()); long waitTime = pool.allocate(context.getClock().getCurrentTime()); double resourceCost = pool.getResourceCost() * durationInUnit; context.getClock().advanceTime((duration), TimeUnit.MILLISECONDS); context.setMaxEndTime(context.getClock().getCurrentTime()); context.getClock().getCurrentTime(), resourceUtilization);