Package org.onebusaway.uk.network_rail.cif

Examples of org.onebusaway.uk.network_rail.cif.BasicScheduleElement


        if (existing != null) {
          _log.warn("duplicate insert tiploc=" + insert.getTiploc());
        }
      }
      if (element instanceof BasicScheduleElement) {
        BasicScheduleElement schedule = (BasicScheduleElement) element;
        if (!_schedulesByTrainUid.containsKey(schedule.getTrainUid())) {
          _schedulesByTrainUid.put(schedule.getTrainUid(), schedule);
        }
      }
    }
View Full Code Here


    return event;
  }

  private void handleActivation(TrainInstance trainInstance,
      TrainMovementBody body) {
    BasicScheduleElement schedule = _timetableService.getBestScheduleForTrainUid(body.getTrainUid());
    trainInstance.setSchedule(schedule);
    if (schedule != null) {
      for (TimepointElement timepoint : schedule.getTimepoints()) {
        int stanox = _timetableService.getStanoxForTiploc(timepoint.getTiploc());
        if (stanox != 0) {
          trainInstance.putTimepoint(stanox, timepoint);
        }
      }
View Full Code Here

    }
  }

  private boolean hasPotentialAreaMatch(TrainInstance trainInstance, long time,
      Set<String> stanoxAreaIds) {
    BasicScheduleElement schedule = trainInstance.getSchedule();
    if (schedule == null) {
      return false;
    }

    if (trainInstance.getLastStanox() != 0
        && Math.abs(time - trainInstance.getLastStanoxTime()) < _timepointMatchThreshold
        && hasStanoxAreaMatch(trainInstance.getLastStanox(), stanoxAreaIds)) {
      return true;
    }

    List<TimepointElement> timepoints = schedule.getTimepoints();
    if (timepoints.isEmpty()) {
      return false;
    }

    TimepointElement firstTimepoint = timepoints.get(0);
View Full Code Here

  public StationLocation getStationLocationForTiploc(String tiploc) {
    return _stationLocationsByTiploc.get(tiploc);
  }

  public BasicScheduleElement getBestScheduleForTrainUid(String trainUid) {
    BasicScheduleElement schedule = _schedulesByTrainUid.get(trainUid);
    if (schedule == null) {
      _statisticsService.incrementUnknownTrainUidCount();
    }
    return schedule;
  }
View Full Code Here

          _tiplocsByStanox.put(insert.getStanox(), tiplocs);
        }
        tiplocs.add(insert.getTiploc());
      }
      if (element instanceof BasicScheduleElement) {
        BasicScheduleElement schedule = (BasicScheduleElement) element;
        if (!_schedulesByTrainUid.containsKey(schedule.getTrainUid())) {
          _schedulesByTrainUid.put(schedule.getTrainUid(), schedule);
        }
      }
    }
View Full Code Here

    }
  }

  private void handleActivation(TrainMovementMessage message) {
    TrainMovementBody body = message.getBody();
    BasicScheduleElement schedule = getBestScheduleForTrainUid(body.getTrainUid());
    if (schedule == null) {
      return;
    }
    String trainId = body.getTrainId();
    long timestamp = Long.parseLong(message.getHeader().getMsgQueueTimestamp());
View Full Code Here

    _narrativeService.addMessage(instance.getTrainReportingNumber(), timestamp,
        "activation: trainUid=" + body.getTrainUid() + " trainId=" + trainId);
  }

  private void fillTimepointsForTrainInstance(TrainInstance instance) {
    BasicScheduleElement schedule = instance.getSchedule();
    for (TimepointElement timepoint : schedule.getTimepoints()) {
      TiplocInsertElement insert = _insertsByTiploc.get(timepoint.getTiploc());
      if (insert == null) {
        continue;
      }
      instance.putTimepoint(insert.getStanox(), timepoint);
View Full Code Here

    _narrativeService.addMessage(heartbeat, "berth heartbeat: areaId="
        + heartbeat.getAreaId());
  }

  private BasicScheduleElement getBestScheduleForTrainUid(String trainUid) {
    BasicScheduleElement schedule = _schedulesByTrainUid.get(trainUid);
    if (schedule == null) {
      _statisticsService.incrementUnknownTrainUidCount();
    }
    return schedule;
  }
View Full Code Here

    FeedMessage.Builder tripUpdatesFeed = GtfsRealtimeLibrary.createFeedMessageBuilder();

    for (TrainInstance instance : _trainsById.values()) {

      BasicScheduleElement schedule = instance.getSchedule();

      TripDescriptor.Builder tripDescriptor = TripDescriptor.newBuilder();
      tripDescriptor.setTripId(schedule.getTrainUid());

      VehicleDescriptor.Builder vehicleDescriptor = VehicleDescriptor.newBuilder();
      vehicleDescriptor.setId(instance.getTrainId());

      if (instance.getStopTimeUpdate() != null) {
View Full Code Here

        new FileInputStream(_statePath)));

    try {
      List<TrainState> states = (List<TrainState>) in.readObject();
      for (TrainState state : states) {
        BasicScheduleElement schedule = _schedulesByTrainUid.get(state.getTrainUid());
        if (schedule == null) {
          _log.warn("unknown schedule referenced in saved state: "
              + state.getTrainUid());
          continue;
        }
View Full Code Here

TOP

Related Classes of org.onebusaway.uk.network_rail.cif.BasicScheduleElement

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.