Package org.onebusaway.transit_data_federation.services.realtime

Examples of org.onebusaway.transit_data_federation.services.realtime.VehicleLocationCacheElements


    cache.setBlockLocationRecordCacheWindowSize(20);

    List<VehicleLocationCacheElements> records = cache.getRecordsForBlockInstance(blockInstance);
    assertEquals(0, records.size());

    VehicleLocationCacheElements cacheRecord = cache.getRecordForVehicleId(aid("vehicleA"));
    assertNull(cacheRecord);

    cache.addRecord(blockInstance,
        record(20, "blockA", serviceDate, "vehicleA", 10.0), null, null);

    records = cache.getRecordsForBlockInstance(blockInstance);
    assertEquals(1, records.size());
    cacheRecord = records.get(0);
    VehicleLocationRecord record = cacheRecord.getLastElement().getRecord();
    assertEquals(20, record.getTimeOfRecord());
    assertEquals(blockInstance, cacheRecord.getBlockInstance());
    assertEquals(aid("vehicleA"), record.getVehicleId());

    VehicleLocationCacheElements cacheRecord2 = cache.getRecordForVehicleId(aid("vehicleA"));
    assertSame(cacheRecord, cacheRecord2);

    cache.addRecord(blockInstance,
        record(30, "blockA", serviceDate, "vehicleA", 20.0), null, null);
View Full Code Here


    cache.addRecord(instanceB,
        record(50, "blockB", serviceDate, "vehicleD", 20.0), null, null);

    cache.clearStaleRecords(System.currentTimeMillis() - 150);

    VehicleLocationCacheElements cacheRecord = cache.getRecordForVehicleId(aid("vehicleA"));
    assertNull(cacheRecord);

    cacheRecord = cache.getRecordForVehicleId(aid("vehicleB"));
    assertNull(cacheRecord);

    cacheRecord = cache.getRecordForVehicleId(aid("vehicleC"));
    assertEquals(aid("vehicleC"),
        cacheRecord.getLastElement().getRecord().getVehicleId());

    cacheRecord = cache.getRecordForVehicleId(aid("vehicleD"));
    assertEquals(aid("vehicleD"),
        cacheRecord.getLastElement().getRecord().getVehicleId());

    List<VehicleLocationCacheElements> records = cache.getRecordsForBlockInstance(instanceA);
    assertEquals(1, records.size());

    records = cache.getRecordsForBlockInstance(instanceB);
View Full Code Here

        r.setTimeOfRecord(i * 1000);

        _cache.addRecord(_blockInstance, r, null, null);

        List<VehicleLocationCacheElements> records = _cache.getRecordsForBlockInstance(_blockInstance);
        VehicleLocationCacheElements cacheRecord = getCollectionForVehicleId(records);
        if (cacheRecord == null)
          fail();

        VehicleLocationRecord record = cacheRecord.getLastElement().getRecord();

        assertEquals(i * 1000L, record.getTimeOfRecord());
        assertEquals(_blockInstance, cacheRecord.getBlockInstance());
        assertEquals(_vehicleId, record.getVehicleId());

        Thread.yield();
      }
    }
View Full Code Here

      TargetTime time) {

    List<VehicleLocationCacheElements> records = getBlockLocationRecordCollectionForBlock(
        blockInstance, time);

    VehicleLocationCacheElements record = null;
    if (!records.isEmpty())
      record = records.get(0);

    // TODO : find a better way to pick?
    return getBlockLocation(blockInstance, record, null, time.getTargetTime());
View Full Code Here

      VehicleLocationRecord record,
      ScheduledBlockLocation scheduledBlockLocation,
      ScheduleDeviationSamples samples) {

    // Cache the result
    VehicleLocationCacheElements elements = _cache.addRecord(blockInstance,
        record, scheduledBlockLocation, samples);

    if (!CollectionsLibrary.isEmpty(_blockLocationListeners)) {

      /**
 
View Full Code Here

      vlr.setTimeOfRecord(record.getTime());
      vlr.setVehicleId(record.getVehicleId());

      VehicleLocationCacheElement element = new VehicleLocationCacheElement(
          vlr, null, null);
      VehicleLocationCacheElements elements = new VehicleLocationCacheElements(
          blockInstance, element);
      results.add(elements);
    }

    return results;
View Full Code Here

    public VehicleIdRecordStrategy(AgencyAndId vehicleId) {
      _vehicleId = vehicleId;
    }

    public List<VehicleLocationCacheElements> getRecordsFromCache() {
      VehicleLocationCacheElements elementsForVehicleId = _cache.getRecordForVehicleId(_vehicleId);
      if (elementsForVehicleId == null)
        return Collections.emptyList();
      return Arrays.asList(elementsForVehicleId);
    }
View Full Code Here

    VehicleLocationRecord record = _vehicleRecordsById.get(vehicleId);
    if (record == null)
      return null;

    List<VehicleLocationRecord> records = new ArrayList<VehicleLocationRecord>();
    VehicleLocationCacheElements elements = _vehicleLocationRecordCache.getRecordForVehicleId(vehicleId);
    if (elements != null) {
      for (VehicleLocationCacheElement element : elements.getElements())
        records.add(element.getRecord());
    }

    VehicleStatus status = new VehicleStatus();
    status.setRecord(record);
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.realtime.VehicleLocationCacheElements

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.