Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 39 additions & 18 deletions src/app/services/data/node.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,7 @@
// update the number of stops
trainrunSection1.setNumberOfStops(
trainrunSection2.getNumberOfStops() +
trainrunSection1.getNumberOfStops() +
(isNonStop ? 0 : 1),
trainrunSection1.getNumberOfStops()
);

// update the time Locks
Expand Down Expand Up @@ -494,32 +493,48 @@
return false;
}

toggleNonStop(nodeId: number, transitionId: number) {
propagateIfNonStop(nodeId : number, transitionId: number, isForward : boolean){
const node = this.getNodeFromId(nodeId);
node.toggleNonStop(transitionId);
const trainrunSections = node.getTrainrunSections(transitionId);
const node1 = node.getOppositeNode(trainrunSections.trainrunSection1);
const node2 = node.getOppositeNode(trainrunSections.trainrunSection2);
const isForwardPathLocked = this.hasPathAnyDepartureOrArrivalTimeLock(
node1,
node,
trainrunSections.trainrunSection1,
);
const isBackwardPathLocked = this.hasPathAnyDepartureOrArrivalTimeLock(
node2,
node,
trainrunSections.trainrunSection2,
);

if (!isForwardPathLocked) {
this.trainrunSectionService.iterateAlongTrainrunUntilEndAndPropagateTime(
node1,
trainrunSections.trainrunSection1.getId(),
);
);
if(isForward){
if (!isBackwardPathLocked) {
this.trainrunSectionService.iterateAlongTrainrunUntilEndAndPropagateTime(
node1,
trainrunSections.trainrunSection1.getId(),
);
}
if (!isForwardPathLocked) {
this.trainrunSectionService.iterateAlongTrainrunUntilEndAndPropagateTime(
node2,
trainrunSections.trainrunSection2.getId(),
);
}
}
if (!isBackwardPathLocked) {
this.trainrunSectionService.iterateAlongTrainrunUntilEndAndPropagateTime(
node2,
trainrunSections.trainrunSection2.getId(),
);
else{
if (!isForwardPathLocked) {
this.trainrunSectionService.iterateAlongTrainrunUntilEndAndPropagateTime(
node2,
trainrunSections.trainrunSection2.getId(),
);
}

if (!isBackwardPathLocked) {
this.trainrunSectionService.iterateAlongTrainrunUntilEndAndPropagateTime(
node1,
trainrunSections.trainrunSection1.getId(),
);
}

}

if (isForwardPathLocked && isBackwardPathLocked) {
Expand Down Expand Up @@ -547,6 +562,12 @@
);
}

toggleNonStop(nodeId: number, transitionId: number) {
const node = this.getNodeFromId(nodeId);
node.toggleNonStop(transitionId);
this.propagateIfNonStop(nodeId, transitionId, true)

Check failure on line 568 in src/app/services/data/node.service.ts

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
}

checkExistsNoCycleTrainrunAfterFreePortsConnecting(
node: Node,
port1: Port,
Expand Down
10 changes: 7 additions & 3 deletions src/app/services/data/trainrun.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -839,9 +839,13 @@ export class TrainrunService {

let halteZeit = 0;
if (!nextPair.node.isEndNode(nextPair.trainrunSection)) {
const oldArrival = nextPair.node.getArrivalTime(nextPair.trainrunSection);
const trs = nextPair.node.getNextTrainrunSection(nextPair.trainrunSection);
const nextDeparture = nextPair.node.getDepartureTime(trs);
const oldArrival = nextPair.node.getArrivalTime(
nextPair.trainrunSection,
);
const trs = nextPair.node.getNextTrainrunSection(
nextPair.trainrunSection,
);
const nextDeparture = nextPair.node.isNonStop(nextPair.trainrunSection) ? oldArrival : nextPair.node.getDepartureTime(trs);
halteZeit =
nextDeparture < oldArrival ? nextDeparture + 60 - oldArrival : nextDeparture - oldArrival;
}
Expand Down
14 changes: 13 additions & 1 deletion src/app/services/data/trainrunsection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,19 @@
trainrunSection.setTargetDeparture(targetDeparture);
trainrunSection.setTravelTime(travelTime);
TrainrunSectionValidator.validateOneSection(trainrunSection);
const sourceNode = trainrunSection.getSourceNode();
const sourceTransition = sourceNode.getTransition(trsId)

Check failure on line 313 in src/app/services/data/trainrunsection.service.ts

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
const sourceNonStop = sourceTransition !== undefined ? sourceTransition.getIsNonStopTransit() : false;
if(sourceNonStop){
this.nodeService.propagateIfNonStop(sourceNode.getId(),sourceTransition.getId(), false)

Check failure on line 316 in src/app/services/data/trainrunsection.service.ts

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
}

const targetNode = trainrunSection.getTargetNode();
const targetTransition = targetNode.getTransition(trsId)

Check failure on line 320 in src/app/services/data/trainrunsection.service.ts

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
const targetNonStop = targetTransition !== undefined ? targetTransition.getIsNonStopTransit() : false;
if(targetNonStop){
this.nodeService.propagateIfNonStop(targetNode.getId(),targetTransition.getId(), true)

Check failure on line 323 in src/app/services/data/trainrunsection.service.ts

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
}
this.trainrunService.propagateConsecutiveTimesForTrainrun(trainrunSection.getId());
this.nodeService.validateConnections(trainrunSection.getSourceNode());
this.nodeService.validateConnections(trainrunSection.getTargetNode());
Expand Down Expand Up @@ -526,7 +539,6 @@

while (iterator.hasNext()) {
const pair = iterator.next();

const isNonStop = previousPair.node.isNonStop(pair.trainrunSection);
const halteZeit = previousPair.node.getTrainrunCategoryHaltezeit();
const previousNodeArrival = previousPair.node.getArrivalTime(previousPair.trainrunSection);
Expand Down
Loading