use of net.parostroj.timetable.model.Train in project grafikon by jub77.
the class PreviousNextTrainValidator method checkAndUpdateTimeAfter.
private void checkAndUpdateTimeAfter(Train currentTrain) {
Train nextTrain = currentTrain.getNextJoinedTrain();
if (nextTrain != null) {
int startTime = currentTrain.getEndTime();
int endTime = nextTrain.getStartTime();
int length = TimeUtil.difference(startTime, endTime);
if (length != currentTrain.getTimeAfter()) {
currentTrain.setTimeAfter(length);
}
if (nextTrain.getTimeBefore() != 0) {
nextTrain.setTimeBefore(0);
}
}
}
use of net.parostroj.timetable.model.Train in project grafikon by jub77.
the class TrainDiagramBuilder method setFreightNet.
public void setFreightNet(LSFreightNet lsFreightNet) throws LSException {
FreightNet net = lsFreightNet.createFreightNet(diagram);
this.diagram.setFreightNet(net);
for (LSFreightConnection lsConnection : lsFreightNet.getConnections()) {
Train from = diagram.getTrains().getById(lsConnection.getTrainFrom());
Train to = diagram.getTrains().getById(lsConnection.getTrainTo());
TimeInterval iFrom = from.getIntervalById(lsConnection.getIntervalFrom());
TimeInterval iTo = to.getIntervalById(lsConnection.getIntervalTo());
FNConnection connection = diagram.getFreightNet().addConnection(iFrom, iTo);
connection.merge(lsConnection.getAttributes().createAttributes(diagram::getObjectById));
}
}
use of net.parostroj.timetable.model.Train in project grafikon by jub77.
the class TrainDiagramBuilder method setTrain.
public void setTrain(LSTrain lsTrain) throws LSException {
DelayedAttributes<Train> delayedAttributes = lsTrain.createTrain(diagram);
delayedAttributesList.add(delayedAttributes);
Train train = delayedAttributes.getObject();
Train foundTrain = null;
if ((foundTrain = diagram.getTrains().getById(train.getId())) != null) {
diagram.getTrains().remove(foundTrain);
}
diagram.getTrains().add(train);
}
use of net.parostroj.timetable.model.Train in project grafikon by jub77.
the class LSTrain method createTrain.
public Train createTrain(TrainDiagram diagram) {
Train train = diagram.getPartFactory().createTrain(id);
train.setNumber(number);
train.getAttributes().add(attributes.createAttributes());
train.setDescription(desc);
train.setTopSpeed(topSpeed);
train.setType(diagram.getTrainTypes().getById(type));
// build time interval list
TrainIntervalsBuilder builder = new TrainIntervalsBuilder(train, start);
for (Object routePart : getRoute()) {
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());
} 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(), 0, linePart.getAttributes().createAttributes());
}
}
builder.finish();
// set technological time
train.setTimeBefore(this.timeBefore);
train.setTimeAfter(this.timeAfter);
return train;
}
use of net.parostroj.timetable.model.Train in project grafikon by jub77.
the class LSTrainsCycleItem method createTrainsCycleItem.
public TrainsCycleItem createTrainsCycleItem(TrainsCycle cycle, TrainDiagram diagram) {
Train modelTrain = diagram.getTrains().getById(train);
TrainsCycleItem item = new TrainsCycleItem(cycle, modelTrain, LocalizedString.fromString(comment), modelTrain.getIntervalById(from), modelTrain.getIntervalById(to));
return item;
}
Aggregations