diff --git a/src/app/services/data/node.service.ts b/src/app/services/data/node.service.ts index 484d77b83..55d7d8bc5 100644 --- a/src/app/services/data/node.service.ts +++ b/src/app/services/data/node.service.ts @@ -418,8 +418,7 @@ export class NodeService implements OnDestroy { // update the number of stops trainrunSection1.setNumberOfStops( trainrunSection2.getNumberOfStops() + - trainrunSection1.getNumberOfStops() + - (isNonStop ? 0 : 1), + trainrunSection1.getNumberOfStops() ); // update the time Locks @@ -494,32 +493,48 @@ export class NodeService implements OnDestroy { 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) { @@ -547,6 +562,12 @@ export class NodeService implements OnDestroy { ); } + toggleNonStop(nodeId: number, transitionId: number) { + const node = this.getNodeFromId(nodeId); + node.toggleNonStop(transitionId); + this.propagateIfNonStop(nodeId, transitionId, true) + } + checkExistsNoCycleTrainrunAfterFreePortsConnecting( node: Node, port1: Port, diff --git a/src/app/services/data/trainrun.service.ts b/src/app/services/data/trainrun.service.ts index 377a40878..156a7a7c7 100644 --- a/src/app/services/data/trainrun.service.ts +++ b/src/app/services/data/trainrun.service.ts @@ -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; } diff --git a/src/app/services/data/trainrunsection.service.ts b/src/app/services/data/trainrunsection.service.ts index 3ed3a2453..606c44921 100644 --- a/src/app/services/data/trainrunsection.service.ts +++ b/src/app/services/data/trainrunsection.service.ts @@ -309,6 +309,19 @@ export class TrainrunSectionService implements OnDestroy { trainrunSection.setTargetDeparture(targetDeparture); trainrunSection.setTravelTime(travelTime); TrainrunSectionValidator.validateOneSection(trainrunSection); + const sourceNode = trainrunSection.getSourceNode(); + const sourceTransition = sourceNode.getTransition(trsId) + const sourceNonStop = sourceTransition !== undefined ? sourceTransition.getIsNonStopTransit() : false; + if(sourceNonStop){ + this.nodeService.propagateIfNonStop(sourceNode.getId(),sourceTransition.getId(), false) + } + + const targetNode = trainrunSection.getTargetNode(); + const targetTransition = targetNode.getTransition(trsId) + const targetNonStop = targetTransition !== undefined ? targetTransition.getIsNonStopTransit() : false; + if(targetNonStop){ + this.nodeService.propagateIfNonStop(targetNode.getId(),targetTransition.getId(), true) + } this.trainrunService.propagateConsecutiveTimesForTrainrun(trainrunSection.getId()); this.nodeService.validateConnections(trainrunSection.getSourceNode()); this.nodeService.validateConnections(trainrunSection.getTargetNode()); @@ -526,7 +539,6 @@ export class TrainrunSectionService implements OnDestroy { 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);