本文整理了Java中com.github.rinde.rinsim.event.Event.getEventType()
方法的一些代码示例,展示了Event.getEventType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.getEventType()
方法的具体详情如下:
包路径:com.github.rinde.rinsim.event.Event
类名称:Event
方法名:getEventType
暂无
代码示例来源:origin: rinde/RinSim
public void safeDispatchEvent(Event e) {
dispatching.incrementAndGet();
final Set<Listener> targetListeners;
synchronized (listeners) {
checkCanDispatchEventType(e.getEventType());
targetListeners = ImmutableSet.copyOf(listeners.get(e.getEventType()));
}
for (final Listener l : targetListeners) {
l.handleEvent(e);
}
dispatching.decrementAndGet();
update();
}
代码示例来源:origin: com.github.rinde/rinsim-event
public void safeDispatchEvent(Event e) {
dispatching.incrementAndGet();
final Set<Listener> targetListeners;
synchronized (listeners) {
checkCanDispatchEventType(e.getEventType());
targetListeners = ImmutableSet.copyOf(listeners.get(e.getEventType()));
}
for (final Listener l : targetListeners) {
l.handleEvent(e);
}
dispatching.decrementAndGet();
update();
}
代码示例来源:origin: com.github.rinde/rinsim-event
/**
* Dispatch an event. Notifies all listeners that are listening for this type
* of event.
* @param e The event to be dispatched, only events with a supported type can
* be dispatched.
*/
public void dispatchEvent(Event e) {
synchronized (listeners) {
dispatching.incrementAndGet();
checkCanDispatchEventType(e.getEventType());
for (final Listener l : listeners.get(e.getEventType())) {
l.handleEvent(e);
}
dispatching.decrementAndGet();
}
update();
}
代码示例来源:origin: rinde/RinSim
/**
* Dispatch an event. Notifies all listeners that are listening for this type
* of event.
* @param e The event to be dispatched, only events with a supported type can
* be dispatched.
*/
public void dispatchEvent(Event e) {
synchronized (listeners) {
dispatching.incrementAndGet();
checkCanDispatchEventType(e.getEventType());
for (final Listener l : listeners.get(e.getEventType())) {
l.handleEvent(e);
}
dispatching.decrementAndGet();
}
update();
}
代码示例来源:origin: rinde/RinSim
void doHandleEvent(Event e) {
synchronized (computingSimSolvers) {
final boolean isComputingBefore = isComputing();
LOGGER.trace("receive: {}, computing: {}, clock is ticking: {}, {}", e,
isComputingBefore, clock.isTicking(), computingSimSolvers);
if (e.getEventType() == EventType.START_COMPUTING) {
if (!isComputingBefore) {
LOGGER.debug("start computing -> switch to real time");
clock.switchToRealTime();
}
computingSimSolvers.add((RtSimSolverSchedulerBridge) e.getIssuer());
} else if (e.getEventType() == EventType.DONE_COMPUTING) {
// done computing
checkState(computingSimSolvers.remove(e.getIssuer()));
// if (!isComputing()) {
// stop();
// }
} else {
throw new IllegalArgumentException("Unexpected event: " + e);
}
}
}
代码示例来源:origin: rinde/RinSim
@Override
public void handleEvent(Event e) {
if (e
.getEventType() == ScenarioController.EventType.SCENARIO_FINISHED) {
sim.stop();
}
}
});
代码示例来源:origin: com.github.rinde/rinsim-example
@Override
public void handleEvent(Event e) {
verify(e instanceof PDPModelEvent);
final PDPModelEvent event = (PDPModelEvent) e;
final Box box = (Box) verifyNotNull(event.parcel);
if (e.getEventType() == PDPModelEventType.END_PICKUP) {
occupiedPositions.remove(box.getPickupLocation());
}
if (e.getEventType() == PDPModelEventType.END_DELIVERY) {
final long duration = DoubleMath.roundToLong(
FactoryExample.SERVICE_DURATION / 2d
+ rng.nextDouble() * FactoryExample.SERVICE_DURATION,
RoundingMode.CEILING);
simulator.get().unregister(box);
final BoxHandle bh = box.boxHandle;
bh.wordIndex = (bh.wordIndex + 1) % points.size();
final Point dest;
if (bh.index >= points.get(bh.wordIndex).size()) {
dest = rndBorder();
} else {
dest = points.get(bh.wordIndex).get(bh.index);
occupiedPositions.add(dest);
}
final Box newBox = new Box(box.getDeliveryLocation(),
dest, duration, bh);
bh.box = newBox;
simulator.get().register(newBox);
}
}
代码示例来源:origin: rinde/RinSim
@Override
public void handleEvent(Event e) {
verify(e instanceof PDPModelEvent);
final PDPModelEvent event = (PDPModelEvent) e;
final Box box = (Box) verifyNotNull(event.parcel);
if (e.getEventType() == PDPModelEventType.END_PICKUP) {
occupiedPositions.remove(box.getPickupLocation());
}
if (e.getEventType() == PDPModelEventType.END_DELIVERY) {
final long duration = DoubleMath.roundToLong(
FactoryExample.SERVICE_DURATION / 2d
+ rng.nextDouble() * FactoryExample.SERVICE_DURATION,
RoundingMode.CEILING);
simulator.get().unregister(box);
final BoxHandle bh = box.boxHandle;
bh.wordIndex = (bh.wordIndex + 1) % points.size();
final Point dest;
if (bh.index >= points.get(bh.wordIndex).size()) {
dest = rndBorder();
} else {
dest = points.get(bh.wordIndex).get(bh.index);
occupiedPositions.add(dest);
}
final Box newBox = new Box(box.getDeliveryLocation(),
dest, duration, bh);
bh.box = newBox;
simulator.get().register(newBox);
}
}
代码示例来源:origin: rinde/RinSim
@Override
public void handleEvent(Event e) {
log.add(LogEntry.create(clock.getCurrentTime(),
clock.getCurrentTime() + clock.getTickLength(),
clock.getClockMode(), e.getEventType()));
}
}, SWITCH_TO_REAL_TIME, SWITCH_TO_SIM_TIME, STARTED, STOPPED);
代码示例来源:origin: com.github.rinde/rinsim-pdptw
@Override
public void handleEvent(Event e) {
if (e.getEventType() == PDPModelEventType.NEW_PARCEL) {
verify(e instanceof PDPModelEvent);
final PDPModelEvent event = (PDPModelEvent) e;
timeline.addParcel(new ParcelInfo(event.time,
verifyNotNull(event.parcel)));
}
}
}, PDPModelEventType.NEW_PARCEL);
代码示例来源:origin: rinde/RinSim
@Override
public void handleEvent(Event e) {
if (e.getEventType() == PDPModelEventType.NEW_PARCEL) {
verify(e instanceof PDPModelEvent);
final PDPModelEvent event = (PDPModelEvent) e;
timeline.addParcel(new ParcelInfo(event.time,
verifyNotNull(event.parcel)));
}
}
}, PDPModelEventType.NEW_PARCEL);
代码示例来源:origin: rinde/RinSim
@Override
public void handleEvent(Event e) {
log.add(logEntry(clock.getCurrentTime(), e.getEventType()));
}
}, RtClockEventType.values());
代码示例来源:origin: rinde/RinSim
@Override
public void handleEvent(Event e) {
verify(e instanceof CommModelEvent);
final CommModelEvent event = (CommModelEvent) e;
if (e.getEventType() == CommModel.EventTypes.ADD_COMM_USER) {
addUIObject(event.getUser(), event.getDevice());
} else {
removeUIObject(event.getUser());
}
}
}, CommModel.EventTypes.ADD_COMM_USER,
代码示例来源:origin: com.github.rinde/rinsim-pdptw
@Override
public void handleEvent(Event e) {
if (e.getEventType() == ClockEventType.STARTED) {
startTimeReal = System.currentTimeMillis();
startTimeSim = clock.getCurrentTime();
computationTime = 0;
} else if (e.getEventType() == ClockEventType.STOPPED) {
computationTime = System.currentTimeMillis() - startTimeReal;
simulationTime = clock.getCurrentTime() - startTimeSim;
} else if (e.getEventType() == RoadEventType.MOVE) {
verify(e instanceof MoveEvent);
final MoveEvent me = (MoveEvent) e;
} else if (e.getEventType() == PDPModelEventType.START_PICKUP) {
verify(e instanceof PDPModelEvent);
final PDPModelEvent pme = (PDPModelEvent) e;
} else if (e.getEventType() == PDPModelEventType.END_PICKUP) {
totalPickups++;
} else if (e.getEventType() == PDPModelEventType.START_DELIVERY) {
final PDPModelEvent pme = (PDPModelEvent) e;
} else if (e.getEventType() == PDPModelEventType.END_DELIVERY) {
totalDeliveries++;
} else if (e.getEventType() == SCENARIO_EVENT) {
final ScenarioEvent se = (ScenarioEvent) e;
if (se.getTimedEvent() instanceof AddParcelEvent) {
} else if (e.getEventType() == NEW_PARCEL) {
代码示例来源:origin: rinde/RinSim
@Override
public void handleEvent(Event e) {
if (e.getEventType() == ClockEventType.STARTED) {
startTimeReal = System.currentTimeMillis();
startTimeSim = clock.getCurrentTime();
computationTime = 0;
} else if (e.getEventType() == ClockEventType.STOPPED) {
computationTime = System.currentTimeMillis() - startTimeReal;
simulationTime = clock.getCurrentTime() - startTimeSim;
} else if (e.getEventType() == RoadEventType.MOVE) {
verify(e instanceof MoveEvent);
final MoveEvent me = (MoveEvent) e;
} else if (e.getEventType() == PDPModelEventType.START_PICKUP) {
verify(e instanceof PDPModelEvent);
final PDPModelEvent pme = (PDPModelEvent) e;
} else if (e.getEventType() == PDPModelEventType.END_PICKUP) {
totalPickups++;
} else if (e.getEventType() == PDPModelEventType.START_DELIVERY) {
final PDPModelEvent pme = (PDPModelEvent) e;
} else if (e.getEventType() == PDPModelEventType.END_DELIVERY) {
totalDeliveries++;
} else if (e.getEventType() == SCENARIO_EVENT) {
final ScenarioEvent se = (ScenarioEvent) e;
if (se.getTimedEvent() instanceof AddParcelEvent) {
} else if (e.getEventType() == NEW_PARCEL) {
代码示例来源:origin: com.github.rinde/rinlog
if (e.getEventType() == CommunicatorEventType.CHANGE) {
changed = true;
if (!lazyRouteComputing) {
代码示例来源:origin: rinde/RinSim
@Test
public void followPathEventIssuerType() {
final MovingRoadUser user = new TestRoadUser();
model.addObjectAt(user, SW);
final ListenerEventHistory list = new ListenerEventHistory();
model.getEventAPI().addListener(list, RoadEventType.MOVE);
assertTrue(list.getHistory().isEmpty());
model.followPath(user, newLinkedList(asList(SW, SE, NE, NW)),
TimeLapseFactory.create(0, 10));
assertEquals(1, list.getHistory().size());
assertEquals(RoadEventType.MOVE, list.getHistory().get(0).getEventType());
assertEquals(model, list.getHistory().get(0).getIssuer());
}
代码示例来源:origin: rinde/RinSim
@Test
public void moveToEventIssuerType() {
final MovingRoadUser user = new TestRoadUser();
model.addObjectAt(user, SW);
final ListenerEventHistory list = new ListenerEventHistory();
model.getEventAPI().addListener(list, RoadEventType.MOVE);
assertTrue(list.getHistory().isEmpty());
model.moveTo(user, NW, TimeLapseFactory.create(0, 10));
assertEquals(1, list.getHistory().size());
assertEquals(RoadEventType.MOVE, list.getHistory().get(0).getEventType());
assertEquals(model, list.getHistory().get(0).getIssuer());
}
代码示例来源:origin: rinde/RinSim
assertThat(events.get(0).getEventType()).isEqualTo(EventType.NEW_SCHEDULE);
assertThat(events.get(1).getEventType()).isEqualTo(EventType.DONE);
代码示例来源:origin: rinde/RinSim
@Override
public void handleEvent(Event e) {
GraphEvent ge = (GraphEvent) e;
if (e.getEventType() == ADD_CONNECTION) {
assertTrue(ge.getGraph().hasConnection(ge.getConnection()));
assertEquals(
ge.getConnection(),
ge.getGraph().getConnection(ge.getConnection().from(),
ge.getConnection().to()));
} else if (e.getEventType() == REMOVE_CONNECTION) {
assertFalse(ge.getGraph().hasConnection(ge.getConnection().from(),
ge.getConnection().to()));
} else if (e.getEventType() == CHANGE_CONNECTION_DATA) {
assertTrue(ge.getGraph().hasConnection(ge.getConnection().from(),
ge.getConnection().to()));
assertEquals(
ge.getConnection().data(),
ge.getGraph()
.getConnection(ge.getConnection().from(),
ge.getConnection().to())
.data());
}
}
}
内容来源于网络,如有侵权,请联系作者删除!