Search in sources :

Example 6 with LineTrack

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);
}
Also used : NodeTrack(net.parostroj.timetable.model.NodeTrack) Line(net.parostroj.timetable.model.Line) TrainIntervalsBuilder(net.parostroj.timetable.actions.TrainIntervalsBuilder) Node(net.parostroj.timetable.model.Node) Train(net.parostroj.timetable.model.Train) LineTrack(net.parostroj.timetable.model.LineTrack)

Aggregations

LineTrack (net.parostroj.timetable.model.LineTrack)6 NodeTrack (net.parostroj.timetable.model.NodeTrack)4 Line (net.parostroj.timetable.model.Line)3 Node (net.parostroj.timetable.model.Node)3 TrainIntervalsBuilder (net.parostroj.timetable.actions.TrainIntervalsBuilder)2 Train (net.parostroj.timetable.model.Train)2 ParseException (java.text.ParseException)1 LocalizedString (net.parostroj.timetable.model.LocalizedString)1 Net (net.parostroj.timetable.model.Net)1 TimeInterval (net.parostroj.timetable.model.TimeInterval)1 Track (net.parostroj.timetable.model.Track)1