Examples of TrainInstance


Examples of org.onebusaway.uk.network_rail.gtfs_realtime.instance.TrainInstance

    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    long serviceDate = c.getTimeInMillis();

    TrainInstance instance = new TrainInstance(trainId, serviceDate);

    fillTimepointsForTrainInstance(instance);

    _trainsById.put(trainId, instance);
    _narrativeService.addMessage(instance,
        "activation: trainUid=" + body.getTrainUid());
    _narrativeService.addMessage(instance.getTrainReportingNumber(), timestamp,
        "activation: trainUid=" + body.getTrainUid() + " trainId=" + trainId);
  }
View Full Code Here

Examples of org.onebusaway.uk.network_rail.gtfs_realtime.instance.TrainInstance

      instance.putTimepoint(insert.getStanox(), timepoint);
    }
  }

  private void handleCancellation(TrainMovementMessage message) {
    TrainInstance instance = getTrainInstanceForTrainId(message);
    if (instance == null) {
      _statisticsService.incrementUnknownCancelledTrainIdCount();
      return;
    } else {
      /**
       * We don't want to remove the train instance, since it might be
       * reinstated in the future. But we do clear any stop time updates it
       * might have.
       */
      instance.setStopTimeUpdate(null);

      _narrativeService.addMessage(instance, "cancelation");
    }
  }
View Full Code Here

Examples of org.onebusaway.uk.network_rail.gtfs_realtime.instance.TrainInstance

    _narrativeService.addMessage(
        body.getTrainId().substring(2, 6),
        Long.parseLong(message.getHeader().getMsgQueueTimestamp()),
        "movement: trainId=" + body.getTrainId() + " stanox="
            + body.getLocStanox());
    TrainInstance instance = getTrainInstanceForTrainId(message);
    if (instance == null) {
      _statisticsService.incrementUnknownTrainIdCount();
      return;
    }

    Set<TrainInstance> instances = _trainsByShortId.get(instance.getTrainReportingNumber());
    if (instances == null) {
      instances = new HashSet<TrainInstance>();
      _trainsByShortId.put(instance.getTrainReportingNumber(), instances);
    }
    instances.add(instance);

    if (body.getLocStanox() == null) {
      _statisticsService.incrementEmptyLocStanoxCount();
    }
    int stanox = Integer.parseInt(body.getLocStanox());
    TimepointElement timepoint = null; // what?
    if (timepoint == null) {
      _statisticsService.incrementUnknownStanoxCount();
      return;
    }

    if (body.getPlatform() != null) {
      String platform = body.getPlatform().trim();
      if (!platform.isEmpty() && !platform.equals(timepoint.getPlatform())) {
        _statisticsService.incrementPlatformChange();
      }
    }

    _narrativeService.addMessage(instance, "movement: stanox=" + stanox
        + " tiploc=" + timepoint.getTiploc());

    if (body.getActualTimestamp().isEmpty()
        || body.getPlannedTimestamp().isEmpty()) {
      return;
    }

    long actualTimestamp = Long.parseLong(body.getActualTimestamp());
    long plannedTimestamp = Long.parseLong(body.getPlannedTimestamp());
    int delay = (int) ((actualTimestamp - plannedTimestamp) / 1000);

    StopTimeEvent.Builder departure = StopTimeEvent.newBuilder();
    departure.setDelay(delay);

    StopTimeUpdate.Builder stopTimeUpdate = StopTimeUpdate.newBuilder();
    stopTimeUpdate.setStopId(timepoint.getTiploc());
    stopTimeUpdate.setDeparture(departure);

    instance.setStopTimeUpdate(stopTimeUpdate.build());
  }
View Full Code Here

Examples of org.onebusaway.uk.network_rail.gtfs_realtime.instance.TrainInstance

  private void handleUnidentifiedTrain(TrainMovementMessage message) {

  }

  private void handleReinstatement(TrainMovementMessage message) {
    TrainInstance instance = getTrainInstanceForTrainId(message);
    if (instance == null) {
      _statisticsService.incrementUnknownReinstatedTrainIdCount();
      return;
    } else {
      _narrativeService.addMessage(instance, "reinstatement");
View Full Code Here

Examples of org.onebusaway.uk.network_rail.gtfs_realtime.instance.TrainInstance

  private void handleChangeOfOrigin(TrainMovementMessage message) {
    /**
     * I'm not sure what this means in practice.
     */
    TrainInstance instance = getTrainInstanceForTrainId(message);
    if (instance != null) {
      _narrativeService.addMessage(instance, "change-of-origin");
    }
  }
View Full Code Here

Examples of org.onebusaway.uk.network_rail.gtfs_realtime.instance.TrainInstance

     */
    TrainMovementBody body = message.getBody();
    String trainId = body.getTrainId();
    String revisedTrainId = body.getRevisedTrainId();
    if (!trainId.equals(revisedTrainId)) {
      TrainInstance train = _trainsById.remove(trainId);
      if (train != null) {
        throw new UnsupportedOperationException();
       
        /*
        train = new TrainInstance(revisedTrainId, train);
View Full Code Here

Examples of org.onebusaway.uk.network_rail.gtfs_realtime.instance.TrainInstance

        _log.info("berth ids=" + _berthIds.size());
      }
    }
    _narrativeService.addMessage(step, "berth step: areaId=" + step.getAreaId()
        + " from=" + step.getFrom() + " to=" + step.getTo());
    TrainInstance instance = getTrainInstanceForShortTrainId(step,
        step.getFrom(), step.getTo());
    if (instance == null) {
      return;
    }
    _narrativeService.addMessage(instance,
View Full Code Here

Examples of org.onebusaway.uk.network_rail.gtfs_realtime.instance.TrainInstance

  private void processBerthCanelMessage(BerthCancelMessage cancel) {
    _narrativeService.addMessage(
        cancel,
        "berth cancel: areaId=" + cancel.getAreaId() + " from="
            + cancel.getFrom());
    TrainInstance instance = getTrainInstanceForShortTrainId(cancel,
        cancel.getFrom(), null);
    if (instance == null) {
      return;
    }
    _narrativeService.addMessage(
View Full Code Here

Examples of org.onebusaway.uk.network_rail.gtfs_realtime.instance.TrainInstance

  private void processBerthInterposeMessage(BerthInterposeMessage interpose) {
    _narrativeService.addMessage(interpose, "berth interpose: areaId="
        + interpose.getAreaId() + " to=" + interpose.getTo());

    TrainInstance instance = getTrainInstanceForShortTrainId(interpose, null,
        interpose.getTo());
    if (instance == null) {
      return;
    }
    _narrativeService.addMessage(instance, "berth interpose: areaId="
View Full Code Here

Examples of org.onebusaway.uk.network_rail.gtfs_realtime.instance.TrainInstance

    TrainMovementBody body = message.getBody();
    String trainId = body.getTrainId();
    if (trainId == null) {
      return null;
    }
    TrainInstance instance = _trainsById.get(trainId);
    if (instance != null) {
      instance.setLastUpdateTime(Long.parseLong(message.getHeader().getMsgQueueTimestamp()));
    }
    return instance;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.