Package org.onebusaway.transit_data_federation.services.blocks

Examples of org.onebusaway.transit_data_federation.services.blocks.BlockInstance


      if (record.getBlock() == 0) {
        _recordsWithoutBlockId++;
        return;
      }

      BlockInstance blockInstance = getBlockInstanceForRecord(record);
      if (blockInstance == null) {
        _recordsWithoutServiceDate++;
        return;
      }

      BlockConfigurationEntry blockConfig = blockInstance.getBlock();
      BlockEntry block = blockConfig.getBlock();
      AgencyAndId blockId = block.getId();

      VehicleLocationRecord message = new VehicleLocationRecord();

      message.setBlockId(blockId);

      message.setServiceDate(blockInstance.getServiceDate());
      message.setTimeOfRecord(record.getTime() * 1000);
      message.setTimeOfLocationUpdate(message.getTimeOfRecord());
     
      // In Orbcad, +scheduleDeviation means the bus is early and -schedule
      // deviation means bus is late, which is opposite the
      // ScheduleAdherenceRecord convention
      message.setScheduleDeviation(-record.getScheduleDeviation());

      message.setVehicleId(new AgencyAndId(blockId.getAgencyId(),
          Integer.toString(record.getVehicleId())));

      if (record.hasLat() && record.hasLon()) {
        message.setCurrentLocationLat(record.getLat());
        message.setCurrentLocationLon(record.getLon());
      }

      int effectiveScheduleTime = (int) (record.getTime() - blockInstance.getServiceDate() / 1000);
      int adjustedScheduleTime = effectiveScheduleTime
          - record.getScheduleDeviation();

      ScheduledBlockLocation location = _scheduledBlockLocationService.getScheduledBlockLocationFromScheduledTime(
          blockConfig, adjustedScheduleTime);
View Full Code Here


    double epsilon = 0.001;

    TargetTime target = new TargetTime(t(
        serviceDate, 0, 0), System.currentTimeMillis());

    BlockInstance blockInstance = new BlockInstance(blockConfig, serviceDate);
    BlockLocation location = _service.getLocationForBlockInstance(
        blockInstance, target);

    assertNull(location);
View Full Code Here

      // TODO : We currently assume that a block won't overlap with itself
      if (instances.size() != 1)
        continue;

      BlockInstance instance = instances.get(0);

      VehicleLocationRecord r = new VehicleLocationRecord();
      r.setTimeOfRecord(time.getTime());
      r.setServiceDate(instance.getServiceDate());
      r.setBlockId(block.getId());

      String agencyId = block.getId().getAgencyId();
      r.setVehicleId(new AgencyAndId(agencyId, vehicleRef.getValue()));
View Full Code Here

    List<BlockInstance> instances = _service.getActiveBlocksInTimeRange(blocks,
        layoverIndices, frequencyIndices, time, time);

    assertEquals(1, instances.size());

    BlockInstance instance = instances.get(0);
    assertEquals(bcA_A_B, instance.getBlock());
    assertEquals(serviceDateA.getTime(), instance.getServiceDate());

    /****
     *
     ****/

    time = timeFromString("2010-09-07 010:15");

    instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices,
        frequencyIndices, time, time);

    assertEquals(1, instances.size());

    instance = instances.get(0);
    assertEquals(bcB_A_B, instance.getBlock());
    assertEquals(serviceDateA.getTime(), instance.getServiceDate());

    /****
     *
     ****/

    /*
     * time = timeFromString("2010-09-07 011:15");
     *
     * instances = _service.getActiveBlocksInTimeRange(blocks, frequencyIndices,
     * time, time);
     *
     * assertEquals(1, instances.size());
     *
     * instance = instances.get(0); assertEquals(bcB_A_B, instance.getBlock());
     * assertEquals(serviceDateA.getTime(), instance.getServiceDate());
     */

    /****
     *
     ****/

    time = timeFromString("2010-09-07 012:15");

    instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices,
        frequencyIndices, time, time);

    assertEquals(1, instances.size());

    instance = instances.get(0);
    assertEquals(bcB_A_B, instance.getBlock());
    assertEquals(serviceDateA.getTime(), instance.getServiceDate());

    /****
     *
     ****/

    time = timeFromString("2010-09-08 09:15");

    instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices,
        frequencyIndices, time, time);

    assertEquals(1, instances.size());

    instance = instances.get(0);
    assertEquals(bcA_AB, instance.getBlock());
    assertEquals(serviceDateB.getTime(), instance.getServiceDate());

    /****
     *
     ****/

    time = timeFromString("2010-09-08 10:15");

    instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices,
        frequencyIndices, time, time);

    Collections.sort(instances, new BlockInstanceComparator());

    assertEquals(2, instances.size());

    instance = instances.get(0);
    assertEquals(bcA_AB, instance.getBlock());
    assertEquals(serviceDateB.getTime(), instance.getServiceDate());

    instance = instances.get(1);
    assertEquals(bcB_AB, instance.getBlock());
    assertEquals(serviceDateB.getTime(), instance.getServiceDate());

    /****
     *
     ****/

    time = timeFromString("2010-09-08 11:15");

    instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices,
        frequencyIndices, time, time);

    assertEquals(1, instances.size());

    instance = instances.get(0);
    assertEquals(bcB_AB, instance.getBlock());
    assertEquals(serviceDateB.getTime(), instance.getServiceDate());

    /****
     *
     ****/

    time = timeFromString("2010-09-08 12:15");

    instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices,
        frequencyIndices, time, time);

    assertEquals(1, instances.size());

    instance = instances.get(0);
    assertEquals(bcB_AB, instance.getBlock());
    assertEquals(serviceDateB.getTime(), instance.getServiceDate());

    /****
     *
     ****/

    time = timeFromString("2010-09-09 09:15");

    instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices,
        frequencyIndices, time, time);

    assertEquals(0, instances.size());

    /****
     *
     ****/

    time = timeFromString("2010-09-09 10:15");

    instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices,
        frequencyIndices, time, time);

    assertEquals(1, instances.size());

    instance = instances.get(0);
    assertEquals(bcA_B_A, instance.getBlock());
    assertEquals(serviceDateC.getTime(), instance.getServiceDate());

    /****
     *
     ****/

    time = timeFromString("2010-09-09 11:15");

    instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices,
        frequencyIndices, time, time);

    assertEquals(1, instances.size());

    instance = instances.get(0);
    assertEquals(bcB_B_A, instance.getBlock());
    assertEquals(serviceDateC.getTime(), instance.getServiceDate());
  }
View Full Code Here

      throw new ServiceException("no arrival-departure found");

    /**
     * We group alarms by block instance
     */
    BlockInstance blockInstance = instance.getBlockInstance();

    /**
     * Retrieve the alarms for the block instance
     */
    AlarmsForBlockInstance alarms = getAlarmsForBlockInstance(blockInstance);
View Full Code Here

    /**
     * If we have new real-time info for a block, we need to update the alarms
     * attached to the block instance
     */
    BlockInstance blockInstance = blockLocation.getBlockInstance();
    AlarmsForBlockInstance alarms = _alarmsByBlockInstance.get(blockInstance);
    if (alarms != null)
      alarms.updateBlockLocation(blockLocation);
  }
View Full Code Here

    if (b.getBlockTripInstanceFrom() == null) {

      BlockEntry block = trip.getBlock();

      BlockInstance blockInstance = _blockCalendarService.getBlockInstance(
          block.getId(), serviceDate);
      BlockTripInstance tripInstance = BlockTripInstanceLibrary.getBlockTripInstance(
          blockInstance, trip.getId());
      b.setBlockTripInstanceFrom(tripInstance);
    }
View Full Code Here

    if (obaState.getMaxBlockSequence() >= 0 && v instanceof AbstractBlockVertex) {

      AbstractBlockVertex abv = (AbstractBlockVertex) v;
      ArrivalAndDepartureInstance instance = abv.getInstance();

      BlockInstance blockInstance = instance.getBlockInstance();
      BlockConfigurationEntry blockConfig = blockInstance.getBlock();
      List<BlockStopTimeEntry> stopTimes = blockConfig.getStopTimes();
      int maxBlockSequence = Math.min(obaState.getMaxBlockSequence(),
          stopTimes.size());

      BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
View Full Code Here

  private BlockStatusBean bean(BlockLocation blockLocation) {

    if (blockLocation == null)
      return null;

    BlockInstance instance = blockLocation.getBlockInstance();
    BlockConfigurationEntry block = instance.getBlock();
    long serviceDate = instance.getServiceDate();

    BlockStatusBean bean = new BlockStatusBean();

    bean.setBlock(_blockBeanService.getBlockForId(block.getBlock().getId()));
View Full Code Here

          record.getBlockId(), timeFrom, timeTo);
      // TODO : We currently assume that a block won't overlap with itself
      if (instances.size() != 1)
        continue;

      BlockInstance instance = instances.get(0);
      record.setServiceDate(instance.getServiceDate());

      records.add(record);
    }

    _vehicleLocationListener.handleVehicleLocationRecords(records);
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.blocks.BlockInstance

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.