com.github.rinde.rinsim.event.Event.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中com.github.rinde.rinsim.event.Event.<init>()方法的一些代码示例,展示了Event.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.<init>()方法的具体详情如下:
包路径:com.github.rinde.rinsim.event.Event
类名称:Event
方法名:<init>

Event.<init>介绍

[英]Create a new event without a issuer.
[中]创建没有颁发者的新事件。

代码示例

代码示例来源:origin: com.github.rinde/rinlog

@Override
public void receiveParcel(Auctioneer<T> auctioneer, Parcel p,
  long auctionStartTime) {
 LOGGER.info("{} receiveParcel {}", this, p);
 assignedParcels.add(p);
 eventDispatcher
  .dispatchEvent(new Event(CommunicatorEventType.CHANGE, this));
}

代码示例来源:origin: com.github.rinde/rinlog

/**
 * Notifies this blackboard user of a change in the environment.
 */
public void update() {
 eventDispatcher
  .dispatchEvent(new Event(CommunicatorEventType.CHANGE, this));
}

代码示例来源:origin: com.github.rinde/rinlog

protected void dispatchChangeEvent() {
 eventDispatcher.dispatchEvent(
  new Event(RoutePlannerEventType.CHANGE, this));
}

代码示例来源:origin: rinde/RinSim

void close() {
 if (!shell.isDisposed()) {
  display.asyncExec(new Runnable() {
   @Override
   public void run() {
    shell.close();
   }
  });
 }
 if (builder.callback().isPresent()) {
  builder.callback().get()
   .handleEvent(new Event(Clock.ClockEventType.STOPPED, null));
 }
}

代码示例来源:origin: rinde/RinSim

/**
 * Start the simulation.
 */
@Override
public final void start() {
 checkState(!isTicking(), "Time is already ticking.");
 isTicking = true;
 eventDispatcher.dispatchEvent(new Event(ClockEventType.STARTED, this));
 doStart();
 eventDispatcher.dispatchEvent(new Event(ClockEventType.STOPPED, this));
}

代码示例来源:origin: com.github.rinde/rinlog

@Override
public boolean releaseParcel(Parcel p) {
 checkArgument(!pdpModel.get().getParcelState(p).isPickedUp()
  && !pdpModel.get().getParcelState(p).isTransitionState());
 LOGGER.info("{} releaseParcel {}", this, p);
 checkArgument(assignedParcels.contains(p));
 assignedParcels.remove(p);
 checkState(!assignedParcels.contains(p));
 eventDispatcher
  .dispatchEvent(new Event(CommunicatorEventType.CHANGE, this));
 return true;
}

代码示例来源:origin: rinde/RinSim

@Override
 public void handleEvent(Event e) {
  @SuppressWarnings("unchecked")
  final StateTransitionEvent<Trigger, RealtimeModel> event =
   (StateTransitionEvent<Trigger, RealtimeModel>) e;
  LOGGER.debug("{} {}", timeLapse, event);
  if ((event.newState == realtimeState || event.newState == INIT_RT)
   && eventDispatcher.hasListenerFor(SWITCH_TO_REAL_TIME)) {
   eventDispatcher.dispatchEvent(new Event(SWITCH_TO_REAL_TIME, ref));
  } else if ((event.newState == st || event.newState == INIT_ST)
   && eventDispatcher.hasListenerFor(SWITCH_TO_SIM_TIME)) {
   eventDispatcher.dispatchEvent(new Event(SWITCH_TO_SIM_TIME, ref));
  }
 }
}, StateMachineEvent.values());

代码示例来源:origin: rinde/RinSim

@OverridingMethodsMustInvokeSuper
void cleanUpAfterException() {
 eventDispatcher.dispatchEvent(new Event(ClockEventType.STOPPED, this));
}

代码示例来源:origin: rinde/RinSim

@Override
public void doneForNow() {
 try {
  checkState(solveCount.decrementAndGet() >= 0);
  if (solveCount.get() == 0) {
   LOGGER.trace("doneForNow");
   eventDispatcher.safeDispatchEvent(
    new Event(EventType.DONE_COMPUTING, reference));
   simSolverEventDispatcher.safeDispatchEvent(
    new SolverEvent(RtSimSolver.EventType.DONE,
     currentSchedule, currentState));
  }
 } catch (final RuntimeException e) {
  reportException(e);
 }
}

代码示例来源:origin: rinde/RinSim

void handleFailure(Throwable t) {
 if (t instanceof CancellationException
  || t instanceof InterruptedException) {
  LOGGER.info("RealtimeSolver execution got cancelled/interrupted");
  try {
   eventDispatcher.dispatchEvent(
    new Event(RtSimSolverSchedulerBridge.EventType.DONE_COMPUTING,
     reference));
  } catch (final RuntimeException e) {
   simSolversManager.addException(e);
  }
 } else {
  simSolversManager.addException(t);
 }
}

代码示例来源:origin: rinde/RinSim

eventDispatcher.dispatchEvent(new Event(
 RtSimSolverSchedulerBridge.EventType.START_COMPUTING, reference));

代码示例来源:origin: rinde/RinSim

private void dispatchEvents(TimeLapse timeLapse) {
 TimedEvent e = null;
 while ((e = scenarioQueue.peek()) != null
  && e.getTime() <= timeLapse.getTime()) {
  scenarioQueue.poll();
  if (status == null) {
   LOGGER.info("scenario started at virtual time:" + timeLapse.getTime());
   status = EventType.SCENARIO_STARTED;
   disp.dispatchEvent(new Event(status, this));
  }
  dispatch(e);
 }
 if ((e = scenarioQueue.peek()) != null
  && e.getTime() <= timeLapse.getTime() + timeLapse.getTickLength()
  && clock instanceof RealtimeClockController) {
  LOGGER.trace("Found an event in next tick, switch to RT");
  ((RealtimeClockController) clock).switchToRealTime();
 }
 if (e == null && status != EventType.SCENARIO_FINISHED) {
  status = EventType.SCENARIO_FINISHED;
  disp.dispatchEvent(new Event(status, this));
 }
}

代码示例来源:origin: rinde/RinSim

@Override
public void show() {
 shell.open();
 for (final Listener l : listeners) {
  l.handleEvent(new Event(EventType.SHOW, this));
 }
 if (!builder.viewOptions().contains(ViewOption.ASYNC)) {
  while (!shell.isDisposed()) {
   if (!display.readAndDispatch()) {
    display.sleep();
   }
  }
  if (shell.isDisposed()) {
   clockController.stop();
  }
 }
}

代码示例来源:origin: com.github.rinde/rinsim-scenario

private void dispatchEvents(TimeLapse timeLapse) {
 TimedEvent e = null;
 while ((e = scenarioQueue.peek()) != null
  && e.getTime() <= timeLapse.getTime()) {
  scenarioQueue.poll();
  if (status == null) {
   LOGGER.info("scenario started at virtual time:" + timeLapse.getTime());
   status = EventType.SCENARIO_STARTED;
   disp.dispatchEvent(new Event(status, this));
  }
  dispatch(e);
 }
 if ((e = scenarioQueue.peek()) != null
  && e.getTime() <= timeLapse.getTime() + timeLapse.getTickLength()
  && clock instanceof RealtimeClockController) {
  LOGGER.trace("Found an event in next tick, switch to RT");
  ((RealtimeClockController) clock).switchToRealTime();
 }
 if (e == null && status != EventType.SCENARIO_FINISHED) {
  status = EventType.SCENARIO_FINISHED;
  disp.dispatchEvent(new Event(status, this));
 }
}

代码示例来源:origin: rinde/RinSim

@Test(expected = IllegalArgumentException.class)
public void dispatchEventFail2() {
 dispatcher.dispatchEvent(new Event(OTHER_EVENT1));
}

代码示例来源:origin: com.github.rinde/rinlog

routePlannerChanged = new AtomicBoolean();
eventDispatcher = new EventDispatcher(TruckEvent.values());
routeChangedEvent = new Event(TruckEvent.ROUTE_CHANGE, this);
LOGGER.trace("Truck constructor, {}, {}, {}, {}.", rp, c, ra,
 lazyRouteComp);

代码示例来源:origin: com.github.rinde/rinsim-pdptw

clock.getCurrentTime());
if (totalVehicles == lastArrivalTimeAtDepot.size()) {
 eventDispatcher.dispatchEvent(new Event(
  StatsProvider.EventTypes.ALL_VEHICLES_AT_DEPOT, this));

代码示例来源:origin: rinde/RinSim

clock.getCurrentTime());
if (totalVehicles == lastArrivalTimeAtDepot.size()) {
 eventDispatcher.dispatchEvent(new Event(
  StatsProvider.EventTypes.ALL_VEHICLES_AT_DEPOT, this));

代码示例来源:origin: rinde/RinSim

assertFalse(dispatcher.hasListenerFor(OTHER_EVENT1));
dispatcher.dispatchEvent(new Event(EVENT2));
assertEquals(asList(), l1.getEventTypeHistory());
assertEquals(asList(EVENT2), l2.getEventTypeHistory());
assertEquals(asList(EVENT2), l3.getEventTypeHistory());
dispatcher.dispatchEvent(new Event(EVENT3));
assertEquals(asList(), l1.getEventTypeHistory());
assertEquals(asList(EVENT2), l2.getEventTypeHistory());
assertEquals(asList(EVENT2, EVENT3), l3.getEventTypeHistory());
dispatcher.dispatchEvent(new Event(EVENT1));
assertEquals(asList(EVENT1), l1.getEventTypeHistory());
assertEquals(asList(EVENT2, EVENT1), l2.getEventTypeHistory());
assertEquals(asList(EVENT2, EVENT3, EVENT1), l3.getEventTypeHistory());
dispatcher.dispatchEvent(new Event(EVENT3));
assertEquals(asList(EVENT1), l1.getEventTypeHistory());
assertEquals(asList(EVENT2, EVENT1), l2.getEventTypeHistory());

相关文章