use of net.parostroj.timetable.model.LineTrack in project grafikon by jub77.
the class LSTrain method createTrain.
public DelayedAttributes<Train> createTrain(TrainDiagram diagram) throws LSException {
Train train = diagram.getPartFactory().createTrain(id);
train.setNumber(number);
train.setDescription(desc);
train.setTopSpeed(topSpeed);
train.setType(diagram.getTrainTypes().getById(type));
// build time interval list
TrainIntervalsBuilder builder = new TrainIntervalsBuilder(train, start);
if (this.route != null) {
for (Object routePart : this.route) {
if (routePart instanceof LSTrainRoutePartNode) {
LSTrainRoutePartNode nodePart = (LSTrainRoutePartNode) routePart;
Node node = diagram.getNet().getNodeById(nodePart.getNodeId());
NodeTrack nodeTrack = node.getTrackById(nodePart.getTrackId());
builder.addNode(nodePart.getIntervalId(), node, nodeTrack, nodePart.getStop(), nodePart.getAttributes().createAttributes(diagram::getObjectById));
} else {
LSTrainRoutePartLine linePart = (LSTrainRoutePartLine) routePart;
Line line = diagram.getNet().getLineById(linePart.getLineId());
LineTrack lineTrack = line.getTrackById(linePart.getTrackId());
builder.addLine(linePart.getIntervalId(), line, lineTrack, linePart.getSpeed(), linePart.getAddedTime() != null ? linePart.getAddedTime() : 0, linePart.getAttributes().createAttributes(diagram::getObjectById));
}
}
}
builder.finish();
// set technological time
train.setTimeBefore(this.timeBefore);
train.setTimeAfter(this.timeAfter);
return new DelayedAttributes<>(train, attributes, diagram::getObjectById);
}
Aggregations