Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ <h2 class="SummaryTitle">
"app.view.editor-side-view.editor-tools-view-component.export-trainruns-as-csv-excel"
| translate
}}</sbb-tooltip>
{{ 'app.view.editor-side-view.editor-tools-view-component.export-trainruns-as-csv' | translate }}
<sbb-tooltip
>{{ 'app.view.editor-side-view.editor-tools-view-component.export-trainruns-as-csv-excel' | translate }}</sbb-tooltip
>

<br />
<button
(click)="onTrainrunDetailDataAsCSVData()"
[title]="'app.view.editor-side-view.editor-tools-view-component.export-trainruns-detail' | translate"
class="TrainrunDialog EditorToolButton"
>
<sbb-icon svgIcon="download-large-data-small"></sbb-icon>
</button>
{{ 'app.view.editor-side-view.editor-tools-view-component.export-trainruns-detail-as-csv' | translate }}
<sbb-tooltip
>{{ 'app.view.editor-side-view.editor-tools-view-component.export-trainruns-detail-as-csv-excel' | translate }}</sbb-tooltip
>
<br />
<button
(click)="onExportOriginDestination()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {TrainrunSectionValidator} from "../../services/util/trainrunsection.vali
import {OriginDestinationService} from "src/app/services/analytics/origin-destination/components/origin-destination.service";
import {EditorMode} from "../editor-menu/editor-mode";
import {NODE_TEXT_AREA_HEIGHT, RASTERING_BASIC_GRID_SIZE} from "../rastering/definitions";
import {GeneralViewFunctions} from "../util/generalViewFunctions";
import {TrainrunSection} from "../../models/trainrunsection.model";

interface ContainertoExportData {
documentToExport: HTMLElement;
Expand Down Expand Up @@ -204,6 +206,12 @@ export class EditorToolsViewComponent {
this.onExport(filename, csvData);
}

onTrainrunDetailDataAsCSVData() {
const filename = $localize`:@@app.view.editor-side-view.editor-tools-view-component.trainrunExportFile:trainrunExportFile` + ".csv";
const csvData = this.createTrainrunDetailDataAsCSVData();
this.onExport(filename, csvData);
}

onExportOriginDestination() {
const filename =
$localize`:@@app.view.editor-side-view.editor-tools-view-component.originDestinationFile:originDestination` +
Expand Down Expand Up @@ -526,6 +534,181 @@ export class EditorToolsViewComponent {
}
}

private createTrainrunDetailDataAsCSVData(): string {
/*
This prompt can be uses to test with any LLM

---- start ----
Build agent that can process, analyze, and compare timetable data. In order to do this, data with trainruns is required.
A timetable consists of at least one or an unlimited number of trainruns. Each trainrun is described with attributes
such as Name, Frequency, Direction, and PathTime.

Name: The name indicates the train journey, which usually consists of one forward and one backward trainrun.
If a train journey only travels in one direction, then the train journey consists only of a forward trainrun.

Frequency: Each train journey has a frequency attribute that indicates how often the train runs.
For example, a frequency of 15 means that a single train departs from the starting point every 15 minutes,
resulting in 4 trains per hour. A frequency of 30 means a new train starts every half hour,
and 60 means once per hour. The trains of the train journey consist solely of a master train.
Using the frequency, all train run of a timetable can be infinitely rolled out or unfolded from the train
journey and its journeys. This leads to a full-day timetable that is suitable for planning problems and also
for complex timetable analyses.

PathTime: This attribute describes the temporal and spatial sequence of the travel route.
PathTime is a vector that consists of the following elements:

- Node: Name of the place or city.
- ArrivalTime: Consecutive Arrival time at the node: The time in minutes at which the train arrives at the node.
- DepartureTime: Consecutive Departure time at the node: The time in minutes at which the train leaves the node.
- Stop: True if the train stops so that passengers can board or alight and possibly take a connecting journey at the same node.
False if the train does not stop and passengers cannot board or alight.
- ArrivalMinute: Arrival time at the node: The time in minutes at which the train arrives at the node - just the minute - 0..60
- DepatureMinute: Departure time at the node: The time in minutes at which the train leaves the node - just the minute - 0..60

Additional Information:
Within a train journey, all trainruns in opposite direction have a symmetric counterpart, expect there is just a one-way trainrun.
Symmetrical means that forward (F) and backward (B)
always have symmetrical times. The travel times are symmetrical to zero minutes, i.e., 60 minus the arrival
time corresponds to the departure time in the opposite direction.

Build the agent. Then ask the user if they can upload timetable data. Every time timetable data is uploaded,
create a new variant. Use only the timetable data that has been uploaded. Once a new variant is uploaded,
output in a table for the new data of the new variant how many trains were loaded and how many journes there are.
Only this should be output. Once everything is loaded, also output, "I am waiting for new instructions."

Output: Ask for the language the user would like to receive the response in. And write: "Please load the data by uploading CSV files."
Comment on lines +542 to +579
Copy link
Contributor Author

@aiAdrian aiAdrian Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(1) http://copilot.microsoft.com/
(2) Change deep thinker
(3) Copy this "promp"

---- end ----

Prompt
---- start ----
Please compare the variants and provide feedback on the differences you observe in the variants,
including route deviations, ArrivalMinute or DepatureMinute deviations, frequencies, ... .
The results should be visualized. For example, you could use a table with the variants and the
analysis results in the columns and the topic in the rows.
Comment on lines +584 to +587
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After you have uploaded at least two different trainrunExportFile.csv

Enter this prompt to first insights from copilot

---- end ----

*/
const sep = ",";
const headers: string[] = [];
const rows: string[][] = [];

//headers.push("ID");
headers.push("Name");
headers.push("Frequency");
headers.push("Direction");
headers.push("PathTime");

const direction = ["F", "B"];

this.trainrunService
.getTrainruns()
.filter((trainrun) => this.filterService.filterTrainrun(trainrun))
.forEach((trainrun) => {
const freqsUnroll: number[] = [0];

direction.forEach(dir => {

let alltrainrunsections = this.trainrunSectionService.getAllTrainrunSectionsForTrainrun(trainrun.getId());
while (alltrainrunsections.length > 0) {

const bothEndNodes =
this.trainrunService.getBothEndNodesFromTrainrunPart(alltrainrunsections[0]);

const startNodeTmp =
GeneralViewFunctions.getLeftOrTopNode(
bothEndNodes.endNode1,
bothEndNodes.endNode2,
);

// forward / backward
const startNode = dir === "F" ? startNodeTmp :
startNodeTmp.getId() === bothEndNodes.endNode1.getId() ?
bothEndNodes.endNode2 : bothEndNodes.endNode1;


const startTrainrunSection = startNode.getStartTrainrunSection(trainrun.getId());

const visitedTrainrunSections: TrainrunSection[] = [];
visitedTrainrunSections.push(startTrainrunSection);
const iterator = this.trainrunService.getIterator(startNode, startTrainrunSection);
let nodes: string = "Path=[" + startNode.getBetriebspunktName();

// calc start time
const startTime = startTrainrunSection.getSourceNodeId() === iterator.current().node.getId() ?
startTrainrunSection.getTargetDepartureConsecutiveTime() :
startTrainrunSection.getSourceDepartureConsecutiveTime();
const startTimeMinute = startTrainrunSection.getSourceNodeId() === iterator.current().node.getId() ?
startTrainrunSection.getTargetDeparture() :
startTrainrunSection.getSourceDeparture();

let pathTime: string = "PathTime=[(" + startNode.getBetriebspunktName() + ", null " + "," + startTime + "," + true + ", null, " + startTimeMinute +")";

while (iterator.hasNext()) {
iterator.next();
nodes += sep + iterator.current().node.getBetriebspunktName();
const ts = iterator.current().trainrunSection;

// calc time a
const timeA = ts.getSourceNodeId() === iterator.current().node.getId() ?
ts.getSourceArrivalConsecutiveTime() :
ts.getTargetArrivalConsecutiveTime();
const timeAMinute = ts.getSourceNodeId() === iterator.current().node.getId() ?
ts.getSourceArrival() :
ts.getTargetArrival();

const node = iterator.current().node;
const bpName = node.getBetriebspunktName();
const trans = node.getTransition(iterator.current().trainrunSection.getId());

const nonStop = trans === undefined ? false : !trans.getIsNonStopTransit();

if (iterator.hasNext()) {
const tsNext = iterator.current().node.getNextTrainrunSection(iterator.current().trainrunSection);

// calc time D
const timeD = tsNext.getSourceNodeId() === iterator.current().node.getId() ?
tsNext.getSourceDepartureConsecutiveTime() :
tsNext.getTargetDepartureConsecutiveTime();
const timeDMinute = tsNext.getSourceNodeId() === iterator.current().node.getId() ?
tsNext.getSourceDeparture() :
tsNext.getTargetDeparture();

pathTime += sep + "(" + bpName + "," + timeA + "," + timeD + "," + nonStop + "," + timeAMinute + "," + timeDMinute + ")";
} else {
pathTime += sep + "(" + bpName + "," + timeA + ", null" + "," + true + ", " + timeAMinute + ", null)";
}

visitedTrainrunSections.push(iterator.current().trainrunSection);
}
visitedTrainrunSections.push(iterator.current().trainrunSection);

// create row data to push to rows
const row: string[] = [];
//row.push("" + trainrun.getId());
row.push("" + trainrun.getCategoryShortName() + trainrun.getTitle());
row.push("" + trainrun.getTrainrunFrequency().frequency);
row.push(dir);
//row.push(nodes + "]");
row.push(pathTime + "]");

// to storage
rows.push(row);

// filter all still visited trainrun sections
alltrainrunsections = alltrainrunsections.filter(ts =>
visitedTrainrunSections.indexOf(ts) === -1
);
}
}); // each direction F : forward / B : backward

}); // each trainrun


return this.buildCSVString(headers, rows);
}



private convertToZuglaufCSV(): string {
const comma = ",";
const headers: string[] = [];
Expand Down
4 changes: 4 additions & 0 deletions src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@
"export-trainruns-as-csv-excel": "In Excel: Daten -> Aus Text/CSV -> Filename ... importieren",
"export-origin-destination": "Export origin-destination",
"export-origin-destination-as-csv": "Export origin-destination as CSV",
"export-trainruns-detail": "Zugfahrten detailiert exportieren",
"export-trainruns-detail-as-csv": "Zugfahrten detailiert exportieren als CSV",
"export-trainruns-detail-as-csv-excel": "In Excel: Daten -> Aus Text/CSV -> Filename ... importieren",
"base-data": "Stammdaten",
"import-base-data": "Stammdaten importieren",
"help-csv-data": "Hilfe: CSV - Datei",
Expand All @@ -518,6 +521,7 @@
"spaceTimeChartFile": "streckengrafik",
"baseDataFile": "stammdaten",
"trainrunFile": "zuglauf",
"trainrunExportFile": "trainrunExportFile",
"originDestinationFile": "originDestination",
"trainCategory": "Zugkategorie",
"trainName": "Zugname",
Expand Down
4 changes: 4 additions & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@
"export-trainruns-as-csv-excel": "In Excel: Data -> From Text/CSV -> Import ... filename",
"export-origin-destination": "Export origin-destination",
"export-origin-destination-as-csv": "Export origin-destination as CSV",
"export-trainruns-detail": "Export alls trainruns (details)",
"export-trainruns-detail-as-csv": "Export alls trainruns (details) as CSV",
"export-trainruns-detail-as-csv-excel": "In Export: Data -> From Text/CSV -> Import ... filename",
"base-data": "Base data",
"import-base-data": "Import base data",
"help-csv-data": "Help: CSV - Data",
Expand All @@ -518,6 +521,7 @@
"spaceTimeChartFile": "spaceTimeChart",
"baseDataFile": "baseData",
"trainrunFile": "trainrun",
"trainrunExportFile": "trainrunExportFile",
"originDestinationFile": "originDestination",
"trainCategory": "Train category",
"trainName": "Train name",
Expand Down
4 changes: 4 additions & 0 deletions src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,9 @@
"export-trainruns-as-csv-excel": "Dans Excel : Données -> txt/CSV -> Importer ... nom de fichier",
"export-origin-destination": "Exporter origine-destination",
"export-origin-destination-as-csv": "Exporter origine-destination au format CSV",
"export-trainruns-detail": "Exporter les details des trajets de train",
"export-trainruns-detail-as-csv": "Exporter les details des trajets de train au format CSV",
"export-trainruns-detail-as-csv-excel": "export-trainruns-detail-as-csv-excel",
"base-data": "Données de base",
"import-base-data": "Importer les données de base",
"help-csv-data": "Aide: CSV - Données",
Expand All @@ -517,6 +520,7 @@
"spaceTimeChartFile": "graphiqueEspaceTemps",
"baseDataFile": "baseData",
"trainrunFile": "trains",
"trainrunExportFile": "trainrunExportFile",
"originDestinationFile": "origineDestination",
"trainCategory": "Catégorie du train",
"trainName": "Nom du train",
Expand Down
4 changes: 4 additions & 0 deletions src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,9 @@
"export-trainruns-as-csv-excel": "In Excel: Data -> From Text/CSV -> Import ... filename",
"export-origin-destination": "Export origin-destination",
"export-origin-destination-as-csv": "Export origin-destination as CSV",
"export-trainruns-detail": "Export alls trainruns (details)",
"export-trainruns-detail-as-csv": "Export alls trainruns (details) as CSV",
"export-trainruns-detail-as-csv-excel": "In Export: Data -> From Text/CSV -> Import ... filename",
"base-data": "Base data",
"import-base-data": "Import base data",
"help-csv-data": "Help: CSV - Data",
Expand All @@ -517,6 +520,7 @@
"spaceTimeChartFile": "spaceTimeChart",
"baseDataFile": "baseData",
"trainrunFile": "trainrun",
"trainrunExportFile": "trainrunExportFile",
"originDestinationFile": "originDestination",
"trainCategory": "Train category",
"trainName": "Train name",
Expand Down
Loading