Package rinde.sim.core.model.pdp

Examples of rinde.sim.core.model.pdp.Vehicle


          final int y = vp.toCoordY(pos.y);
          offsetX = (int) img.atSiteOffset.x + x - image.getBounds().width / 2;
          offsetY = (int) img.atSiteOffset.y + y - image.getBounds().height / 2;
        } else if (ps == ParcelState.PICKING_UP || ps == ParcelState.DELIVERING) {

          final Vehicle v = mapping.get(p);
          final PDPModel.VehicleParcelActionInfo vpai = pdpModel.get()
              .getVehicleActionInfo(v);
          final Point pos = roadModel.get().getPosition(v);
          final int x = vp.toCoordX(pos.x);
          final int y = vp.toCoordY(pos.y);
View Full Code Here


    assertTrue(model.getSupportedType().equals(PDPObject.class));
  }
  @Test
  public void testDrop(){
      final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
      model.register(truck);
      rm.register(truck);

      final Parcel pack = new TestParcel(new Point(2, 2), 100, 100, 2);
      model.register(pack);
View Full Code Here

      assertEquals(VehicleState.IDLE, model.getVehicleState(truck));
           
  }
  @Test
  public void testPickupAfterDrop(){
      final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
      model.register(truck);
      rm.register(truck);

      final Parcel pack2 = new TestParcel(new Point(2, 2), 100, 100, 2);
      model.register(pack2);
      rm.register(pack2);
      rm.addObjectAt(pack2, new Point(1, 2));

      rm.followPath(truck, newLinkedList(asList(new Point(1, 2))),
          TimeLapseFactory.create(0, 3600000));
      model.pickup(truck, pack2, TimeLapseFactory.create(0, 40));
      model.continuePreviousActions(truck, TimeLapseFactory.create(0, 40));

      final TimeLapse tl = TimeLapseFactory.create(0, 40);
      model.continuePreviousActions(truck, tl);
      assertFalse(model.getContents(truck).isEmpty());
      assertEquals(ParcelState.IN_CARGO, model.getParcelState(pack2));
      assertEquals(VehicleState.IDLE, model.getVehicleState(truck));
     
      //riding to other spot to drop
      rm.followPath(truck, newLinkedList(asList(new Point(2, 2))),
            TimeLapseFactory.create(0, 3600000));
     
      model.drop(truck, pack2, TimeLapseFactory.create(0, 100));
     
      final Vehicle truck2 = new TestVehicle(new Point(2, 2), 10.0, 1.0);
      model.register(truck2);
      rm.register(truck2);
     
      model.pickup(truck2, pack2, TimeLapseFactory.create(0, 40));
      model.continuePreviousActions(truck2, TimeLapseFactory.create(0, 40));
View Full Code Here

}
 
  @Test
  public void testPickup() {
    final Parcel pack1 = new TestParcel(new Point(2, 2), 0, 0, 2);
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    model.register(pack1);
    model.register(truck);
    rm.register(pack1);
    rm.register(truck);
    rm.addObjectAt(pack1, new Point(1, 1));

    // nothing should happen
    truck.tick(TimeLapseFactory.create(0, 10000));

    assertEquals(0, model.getContentsSize(truck), EPSILON);
    assertTrue(model.getContents(truck).isEmpty());
    assertEquals(ParcelState.AVAILABLE, model.getParcelState(pack1));
    assertEquals(VehicleState.IDLE, model.getVehicleState(truck));
View Full Code Here

  @Test
  public void testDelayedPickup() {

    final Parcel pack1 = new TestParcel(new Point(2, 2), 10, 10, 2);
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    model.register(pack1);
    model.register(truck);
    rm.register(pack1);
    rm.register(truck);
    rm.addObjectAt(pack1, new Point(1, 1));

    model.pickup(truck, pack1, TimeLapseFactory.create(0, 1));
    assertTrue(model.getContents(truck).isEmpty());
    assertEquals(model.getContentsSize(truck), 0, EPSILON);

    truck.tick(TimeLapseFactory.create(1, 10));
    assertFalse(model.getContents(truck).isEmpty());
    assertTrue(model.getContents(truck).contains(pack1));
    assertEquals(model.getContentsSize(truck), 2, EPSILON);
  }
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void testPickupFail1() {
    // truck not in roadmodel
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    model.pickup(truck, null, TimeLapseFactory.create(0, 1));
  }
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void testPickupFail2() {
    // package not in roadmodel
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    rm.register(truck);
    final Parcel pack1 = new TestParcel(new Point(2, 2), 0, 0, 2.0);
    model.pickup(truck, pack1, TimeLapseFactory.create(0, 1));
  }
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void testPickupFail3A() {
    // package not in available state (it is already been picked up)
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    rm.register(truck);
    model.register(truck);
    final Parcel pack1 = new TestParcel(new Point(2, 2), 10, 10, 2.0);
    rm.register(pack1);
    model.register(pack1);
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void testPickupFail3B() {
    // package is not registered
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    rm.register(truck);
    final Parcel pack1 = new TestParcel(new Point(2, 2), 0, 0, 2.0);
    rm.register(pack1);
    rm.addObjectAtSamePosition(pack1, truck);
    model.pickup(truck, pack1, TimeLapseFactory.create(0, 1));
View Full Code Here

    model.pickup(truck, pack1, TimeLapseFactory.create(0, 1));
  }

  @Test(expected = IllegalArgumentException.class)
  public void testPickupFail4() {
    final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
    rm.register(truck);
    final Parcel pack1 = new TestParcel(new Point(2, 2), 0, 0, 2.0);
    rm.register(pack1);
    rm.addObjectAtSamePosition(pack1, truck);
    model.register(pack1);
View Full Code Here

TOP

Related Classes of rinde.sim.core.model.pdp.Vehicle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.