Single‑track railway timetable & dispatching prototype for Turkish State Railways (TCDD).
Contents
- Overview
- Key Features
- Repository / Solution Structure
- Tech Stack & Framework
- Requirements
- Quick Start
- Data Model (CSV) & File Formats
- Excel Import (Single workbook)
- Import Steps (visuals)
- Scheduling & Conflict Rules
- Keyboard Shortcuts
- KPI Examples
- Roadmap
- Contributing
- License
- Türkçe (TR) açıklama
SingleTrainTrackScheduler is a Windows desktop prototype (C#/.NET) that assists planners in building conflict‑free timetables on single‑track corridors. It models stations, blocks/segments, and trains, checks headways and clearances, finds meet/pass points at loops, and supports both manual and automatic adjustments to resolve conflicts.
Typical workflow:
- Define/import a line (stations + single‑track segments)
- Import a draft plan of passenger/freight trains
- Detect meets/follows and headway violations
- Auto‑place or nudge trains to feasible slots while minimizing delay
- Export a timetable and KPIs for reporting
Note: The prototype focuses on single‑track planning; double‑track segments can be represented but are not the primary target yet.
- Line & assets modeling: Stations (with/without passing loops), segments/blocks, gradients/lengths, operating speeds.
- Train plan modeling: Train classes (passenger/freight), directions, priorities, planned dwell times.
- Conflict detection: Same‑direction headway, opposing‑direction meet/pass, clearance at block boundaries and stations.
- Interactive timetable tools: Distance–time (stringline) and grid views; manual adjust (drag/offset) plus rule‑based auto‑placement.
- KPIs: Total delay, max delay, number of conflicts, on‑time %.
- Import/Export: CSV/JSON for stations, segments, runtimes, and trains. Optional Excel export.
- Project files: Save/Load a complete scenario as a JSON “project”.
Screenshots placeholder – add when available:
docs/img/stringline.pngdocs/img/conflict-list.png
SingleTrainTrackScheduler-TCDD-Prototype/
├─ SingleTrainTrackScheduler.sln # Visual Studio solution
├─ SingleTrainTrackScheduler/ # Desktop app (UI + logic)
└─ SingleTrainTrackScheduler.Setup/ # Installer project (optional)
Suggested layering inside SingleTrainTrackScheduler/:
Domain/ # Core entities (Station, Segment, Train, Stop, BlockOccupancy, etc.)
Services/ # ConflictChecker, Scheduler, RuntimeCalculator, Importers/Exporters
UI/ # Views, ViewModels (WPF/WinForms), Commands, Behaviors
Data/ # Repositories, Project persistence (JSON)
Config/ # AppSettings, default headways/clearances
Utils/ # Time helpers, validation, logging
If your
.csprojdiffers, adjust this section accordingly.
- UI Framework: WPF or Windows Forms (current prototype targets WPF)
- Target Framework: .NET 8.0 for Windows (
net8.0-windows) - Output Type:
WinExe - Project SDK:
Microsoft.NET.Sdk - Installer: Visual Studio Installer Projects (Setup) (optional)
Sample .csproj (WPF, .NET 8):
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>NuGet packages (used/recommended):
| Package | Why |
|---|---|
| Newtonsoft.Json | Save/Load project JSON; flexible serialization |
| CsvHelper | Robust CSV import/export for stations/segments/runtimes/trains |
| (optional) CommunityToolkit.Mvvm | Lightweight MVVM (INotifyPropertyChanged, RelayCommand) |
| (optional) ScottPlot.WPF or LiveChartsCore.SkiaSharpView.WPF | Stringline & KPI charts |
Install via CLI:
# From the project folder
dotnet add package Newtonsoft.Json
dotnet add package CsvHelper
# optional
dotnet add package CommunityToolkit.Mvvm
# choose one charting lib
# dotnet add package ScottPlot.WPF
# dotnet add package LiveChartsCore.SkiaSharpView.WPF- Windows 10/11
- Visual Studio 2019/2022 with .NET desktop workload
- (Optional) Excel installed for direct
.xlsxexport
- Clone the repository:
git clone https://github.com/mertrone/SingleTrainTrackScheduler-TCDD-Prototype.git
- Open
SingleTrainTrackScheduler.slnin Visual Studio. - Set startup project to
SingleTrainTrackScheduler. - Restore NuGet packages and Build.
- Run the app and create a new project or Import CSV/Excel.
Tip: Start with the supplied demo data (below) – small corridor, 5 stations, 6 trains – to get used to conflict messages and resolution tools.
The app reads/writes simple CSV/JSON files. Suggested CSV schemas:
| column | type | required | notes |
|---|---|---|---|
| station_id | string | ✓ | unique key |
| name | string | ✓ | display name |
| km | number | ✓ | cumulative distance (km) along line |
| has_passing_loop | 0/1 | bool | ✓ |
| dwell_default_s | integer | default dwell seconds |
| column | type | required | notes |
|---|---|---|---|
| segment_id | string | ✓ | unique key |
| from_station | string | ✓ | station_id |
| to_station | string | ✓ | station_id |
| length_km | number | ✓ | segment length |
| single_track | 0/1 | bool | ✓ |
| vmax_kmh | number | operating speed limit |
| column | type | required | notes |
|---|---|---|---|
| segment_id | string | ✓ | |
| train_class | enum | ✓ | e.g., PASSENGER, FREIGHT |
| run_time_s | int | ✓ | traversal time for that class |
| column | type | required | notes |
|---|---|---|---|
| train_id | string | ✓ | unique key |
| class | enum | ✓ | PASSENGER/FREIGHT |
| priority | integer | lower = more priority (e.g., 1..5) | |
| origin_station | string | ✓ | station_id |
| destination | string | ✓ | station_id |
| dep_time | datetime | ✓ | YYYY-MM-DD HH:MM:SS |
| planned_stops | json | [{"station_id":"S2","dwell_s":45}, ...] |
{
"meta": { "name": "Kavak–Yaman demo", "created": "2025-09-09" },
"line": {
"stations": [ { "station_id": "S1", "name": "Kavak", "km": 0, "has_passing_loop": true }, ... ],
"segments": [ { "segment_id": "B1", "from_station": "S1", "to_station": "S2", "single_track": true, "length_km": 7.5 } ]
},
"runtimes": [
{ "segment_id": "B1", "train_class": "PASSENGER", "run_time_s": 300 }
],
"trains": [
{ "train_id": "P101", "class": "PASSENGER", "origin_station": "S1", "destination": "S5", "dep_time": "2025-09-10 08:00:00" }
]
}You can import an all‑in‑one Excel instead of separate CSV files. A template matching the schema above is provided.
Expected Sheets
- Stations:
station_id, name, km, has_passing_loop (0/1), dwell_default_s - Segments:
segment_id, from_station, to_station, length_km, single_track (0/1), vmax_kmh - Runtimes:
segment_id, train_class (PASSENGER/FREIGHT), run_time_s - Trains:
train_id, class, priority, origin_station, destination, dep_time (YYYY-MM-DD HH:MM:SS), planned_stops (JSON)
Downloads
- Demo workbook (single file):
docs/demo/SingleTrack_Example_Demo.xlsx - Alternative sample you shared:
docs/demo/SingleTrack_Example_Easy.xlsx
Place the files under
docs/demo/in the repo (or import directly from disk). Date/time cells should be real Excel datetimes or text inYYYY-MM-DD HH:MM:SS. Avoid merged cells and fancy formatting in headers so parsers map columns reliably.
Add these images under docs/img/ and reference them in the repo:
Block occupancy is enforced on each single‑track segment and platform block. Conflicts the checker should detect:
- Follow (same direction): Train B enters a block too soon after Train A.
Rule:enter_B ≥ exit_A + HEADWAY_follow. - Meet (opposing direction) on single‑track: Trains must cross at a passing loop.
Rule: opposing trains may only occupy the same segment if one is fully clear, or both are held at loop stations. - Station/platform clearance: Protects turn‑arounds and dwell‑overlap.
Rule:depart_next ≥ arrive_prev + DWELL + CLEARANCE_platform.
Auto‑scheduling (prototype heuristics):
- Insert/shift trains to the earliest feasible times that satisfy rules.
- Priority‑aware (e.g., passenger > freight) and EDD/CR tie‑breakers.
- Optional minimize total delay objective for batched placement.
Wire these to commands (WPF InputBindings or WinForms equivalents):
| Shortcut | Action |
|---|---|
| Ctrl+N | New project |
| Ctrl+O | Open project |
| Ctrl+I | Import CSV/Excel |
| Ctrl+S | Save project |
| Ctrl+E | Export timetable/KPIs |
| Ctrl+G | Run Conflict Check |
| Ctrl+R | Auto‑Schedule selected/all |
| Ctrl+Z / Ctrl+Y | Undo / Redo |
| Del | Delete selected train |
| ←/→ | Nudge selected train ±1 min |
| Shift+←/→ | Nudge selected train ±5 min |
| F1 | Help / README |
Example (XAML):
<Window.InputBindings>
<KeyBinding Modifiers="Control" Key="N" Command="{Binding NewProjectCommand}"/>
<KeyBinding Modifiers="Control" Key="O" Command="{Binding OpenProjectCommand}"/>
<KeyBinding Modifiers="Control" Key="I" Command="{Binding ImportCsvCommand}"/>
<KeyBinding Modifiers="Control" Key="S" Command="{Binding SaveProjectCommand}"/>
<KeyBinding Modifiers="Control" Key="G" Command="{Binding CheckConflictsCommand}"/>
<KeyBinding Modifiers="Control" Key="R" Command="{Binding AutoScheduleCommand}"/>
</Window.InputBindings>#conflictsΣ delaymax delay% on‑time#meets at loops
- Export distance–time (stringline) PDF and conflict reports
- Automated meet/pass placement improvements (loop selection)
- Exact optimization via Google OR‑Tools (CP‑SAT) or MILP for selected windows
- Multi‑line / junction support
- Scenario diff and KPIs dashboard
- TR/EN localization and printing layouts
Contributions are welcome!
- Fork and create a feature branch.
- Follow C# coding conventions; prefer MVVM if WPF.
- Add unit tests for conflict rules and a small sample dataset.
- Submit a PR with screenshots/GIFs and a short design note.
Released under the MIT License. See LICENSE.txt.
SingleTrainTrackScheduler, tek hat demiryolu hatlarında (TCDD) çatışmasız tren çizelgesi oluşturmayı amaçlayan bir masaüstü prototiptir (C#/.NET). İstasyonlar, hat/bloklar ve trenleri modeller; takip baş mesafesi, karşılıklı tren karşılaşmaları (meet/pass) ve temizlik süreleri gibi kurallara göre çatışmaları bulur; manuel veya otomatik düzenleme ile çözer.
Tipik akış: Hat/istasyon tanımı → Tren planı içe aktarımı → Çatışma tespiti → Otomatik/manuel yerleştirme → KPI’lar ve dışa aktarma.
- Hat modelleme: İstasyon, blok/segment, makas/yan yol (passing loop)
- Tren planı: Yolcu/Yük sınıfları, yön, öncelik, duruş/dwell
- Çatışma kuralları: Aynı yönde takip baş mesafesi, karşı yönde meet/pass, istasyon/peron temizlikleri
- Etkileşimli görünüm: Zaman‑mesafe (stringline) diyagramı ve tablo
- İçe/dışa aktarma: CSV/JSON veya tek dosya Excel
- KPI’lar: Toplam gecikme, en büyük gecikme, on‑time %, meet sayısı
- Windows 10/11 + Visual Studio 2019/2022 (.NET desktop iş yükü)
- Depoyu klonlayın,
SingleTrainTrackScheduler.sln’i açın - Başlangıç projesini SingleTrainTrackScheduler yapın → NuGet geri yükle → Build → Çalıştırın
- CSV/Excel ile içe aktarım yapın
stations.csv:station_id,name,km,has_passing_loop,dwell_default_ssegments.csv:segment_id,from_station,to_station,length_km,single_track,vmax_kmhruntimes.csv:segment_id,train_class,run_time_strains.csv:train_id,class,priority,origin_station,destination,dep_time,planned_stops
- Sayfalar:
Stations,Segments,Runtimes,Trains - İndirme:
docs/demo/SingleTrack_Example_Demo.xlsx(tek dosya demo)
Alternatif örnek:docs/demo/SingleTrack_Example_Easy.xlsx
Tarih/saat hücreleri gerçek Excel datetime veya
YYYY-MM-DD HH:MM:SSformatında metin olmalı. Başlıklarda birleşik hücre kullanmayın.
- Ctrl+N: Yeni proje, Ctrl+O: Aç, Ctrl+I: İçe aktar, Ctrl+S: Kaydet
- Ctrl+G: Çatışma kontrolü, Ctrl+R: Otomatik çizelgele
- Ctrl+Z / Ctrl+Y: Geri al / İleri al, Del: Sil
- ←/→: 1 dk kaydır, Shift+←/→: 5 dk kaydır, F1: Yardım
- PDF çıktı (stringline) ve çatışma raporları
- Meet/pass yer seçimi iyileştirmeleri
- OR‑Tools CP‑SAT veya MILP ile seçili pencerede optimizasyon
- Çok hatlı/junction’lı senaryolar
- TR/EN yerelleştirme ve yazdırma şablonları
Credits: Project owner/maintainer: @mertrone.


