Last active
May 29, 2024 14:54
-
-
Save kaat0/f056c9b56db91c459f9fb54f6abcafc0 to your computer and use it in GitHub Desktop.
TikZ drawing of blocking times in railways
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%!TEX TS-program = pdflatexmk | |
% Copyright 2022 Martin Scheidt, ORCID: 0000-0002-9384-8945 (ISC license) | |
% Permission to use, copy, modify, and/or distribute this file for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. | |
\documentclass[tikz,border=2,preview=true,convert]{standalone} | |
\usepackage[prefix=]{xcolor-solarized} | |
\usepackage{lmodern,microtype,mathptmx,courier} | |
\usepackage[main=english,ngerman]{babel} | |
\usepackage{iflang} % needs babel | |
\newcommand{\IfLanguage}[2]{\IfLanguageName{#1}{#2}{}} | |
\usepackage{etoolbox} | |
\newtoggle{topology} | |
\newtoggle{time-distance-diagram} | |
\newtoggle{background-fill} | |
\newtoggle{fixed-block-time} | |
\newtoggle{moving-block-time} | |
\newtoggle{DEBUG} | |
\tikzset{DEBUG/.style={magenta,thin}} | |
\usetikzlibrary{intersections,calc,backgrounds} | |
\usetikzlibrary{trackschematic}% | |
\definecolor{darkblue}{RGB}{37,64,97} | |
\tikzset{background=darkblue,foreground=white} | |
\colorlet{highlight}{white} | |
\colorlet{foreground}{white} | |
\colorlet{background}{darkblue} | |
\colorlet{degrade}{foreground!50!background} | |
\makeatletter | |
% source from: \url{http://tex.stackexchange.com/q/26382/86} | |
% TODO: switch to tikz package spath3 | |
\tikzset{ | |
use path for main/.code={% | |
\tikz@addmode{% | |
\expandafter\pgfsyssoftpath@setcurrentpath\csname tikz@intersect@path@name@#1\endcsname | |
}% | |
}, | |
use path for actions/.code={% | |
\expandafter\def\expandafter\tikz@preactions\expandafter{\tikz@preactions\expandafter\let\expandafter\tikz@actions@path\csname tikz@intersect@path@name@#1\endcsname}% | |
}, | |
use path/.style={% | |
use path for main=#1, | |
use path for actions=#1, | |
} | |
} | |
\makeatother | |
\begin{document} | |
\settoggle{DEBUG}{false} | |
\settoggle{topology}{true} | |
\settoggle{time-distance-diagram}{true} | |
\settoggle{background-fill}{false} | |
\settoggle{fixed-block-time}{true} | |
\settoggle{moving-block-time}{false} | |
\selectlanguage{ngerman} | |
\begin{tikzpicture}[font=\sffamily,background rectangle/.style={fill=background},show background rectangle] | |
% \tikzset{every node/.style={anchor=base}}; | |
\newlength{\trainlength}\setlength{\trainlength}{3cm} | |
\newlength{\speedspace}\setlength{\speedspace}{10cm} | |
\newlength{\cleartime}\setlength{\cleartime}{0.4cm} | |
\newlength{\releasetime}\setlength{\releasetime}{0.4cm} | |
%% coordinates | |
\coordinate (A) at ( 0, 0); | |
\coordinate (B) at (23, 0); | |
\coordinate (VP1) at ( 5, 0); % view point | |
\coordinate (DS1) at ( 6, 0); % distant signal | |
\coordinate (BS1) at ( 9, 0); % block signal | |
\coordinate (EoA1) at (15, 0); % end of movement authority = BS1 | |
\coordinate (CP1) at (16.5, 0); % clearing point | |
\coordinate (VP2) at (11, 0); | |
\coordinate (DS2) at (12, 0); | |
\coordinate (BS2) at (15, 0); | |
\coordinate (EoA2) at (21, 0); | |
\coordinate (CP2) at (22.5, 0); | |
\coordinate (T) at ( 4, 0); % train head | |
\coordinate (gT) at (20, 0); % ghost train head | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%% description | |
\tikzset{every path/.style={line width=0.75pt,>=latex}}; | |
% help line for coordinates | |
\path[name path=pos-RoT] ([shift={(-\trainlength,-2)}] T) -- ++(0,-1.2\speedspace); % rear of train | |
\path[name path=pos-T] ([shift={(0,-2)}] T) -- ++(0,-1.2\speedspace); % head of train | |
\path[name path=pos-VP1] ([shift={(0,-2)}] VP1) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-DS1] ([shift={(0,-2)}] DS1) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-BS1] ([shift={(0,-2)}] BS1) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-EoA1] ([shift={(0,-2)}] EoA1) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-CP1] ([shift={(0,-2)}] CP1) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-VP2] ([shift={(0,-2)}] VP2) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-DS2] ([shift={(0,-2)}] DS2) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-BS2] ([shift={(0,-2)}] BS2) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-CP2] ([shift={(0,-2)}] CP2) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-EoA2] ([shift={(0,-2)}] EoA2) -- ++(0,-1.2\speedspace); | |
% coordinates along train run head | |
\coordinate (trainrun-head-A) at ([shift={(0,-2)}] A); | |
\coordinate (trainrun-head-B) at ($([shift={(0,-2)}] B) + (0,-\speedspace)$); | |
\path[name path=trainrun-head] (trainrun-head-A) -- (trainrun-head-B); | |
\path[name intersections={of=trainrun-head and pos-T ,by=current-head-pos}]; | |
\path[name intersections={of=trainrun-head and pos-RoT,by=rear-pos-help}]; | |
\path[name intersections={of=trainrun-head and pos-VP1,by=coord-head-VP1}]; | |
\path[name intersections={of=trainrun-head and pos-DS1,by=coord-head-DS1}]; | |
\path[name intersections={of=trainrun-head and pos-BS1,by=coord-head-BS1}]; | |
\path[name intersections={of=trainrun-head and pos-EoA1,by=coord-head-EoA1}]; | |
\path[name intersections={of=trainrun-head and pos-VP2,by=coord-head-VP2}]; | |
\path[name intersections={of=trainrun-head and pos-DS2,by=coord-head-DS2}]; | |
\path[name intersections={of=trainrun-head and pos-BS2,by=coord-head-BS2}]; | |
\path[name intersections={of=trainrun-head and pos-EoA2,by=coord-head-EoA2}]; | |
% coordinates along train run rear | |
\path[name path=trainlength-at-current-pos] (current-head-pos) -- ++(-\trainlength,0); | |
\path[name intersections={of=pos-RoT and trainlength-at-current-pos,by=current-rear-pos}]; | |
\coordinate (time-for-trainlength) at ($(current-rear-pos)-(rear-pos-help)$); | |
\coordinate (trainrun-rear-A) at ($(trainrun-head-A)+(time-for-trainlength)$); | |
\coordinate (trainrun-rear-B) at ($(trainrun-head-B)+(time-for-trainlength)$); | |
\path[name path=trainrun-rear] (trainrun-rear-A) -- (trainrun-rear-B); | |
\path[name intersections={of=trainrun-rear and pos-EoA1,by=coord-rear-EoA1}]; | |
\path[name intersections={of=trainrun-rear and pos-CP1,by=coord-rear-CP1}]; | |
\path[name intersections={of=trainrun-rear and pos-EoA2,by=coord-rear-EoA2}]; | |
\path[name intersections={of=trainrun-rear and pos-CP2,by=coord-rear-CP2}]; | |
% distances | |
\coordinate (sighting-distance1) at ($(DS1)-(VP1)$); | |
\coordinate (approach-distance1) at ($(BS1)-(DS1)$); | |
\coordinate (block1-length) at ($(EoA1)-(BS1)$); | |
\coordinate (overlap1) at ($(CP1)-(EoA1)$); | |
\coordinate (sighting-distance2) at ($(DS2)-(VP2)$); | |
\coordinate (approach-distance2) at ($(BS2)-(DS2)$); | |
\coordinate (block2-length) at ($(EoA2)-(BS2)$); | |
\coordinate (overlap2) at ($(CP2)-(EoA2)$); | |
\path[name path=trainlength-at-coord-head-DS2] (coord-head-DS2) -- ++(-\trainlength,0) coordinate (coord-rear-DS2) -- ++($-1*(overlap1)$) coordinate (coord-rear-margin-DS2) -- ++(0,-0.2\speedspace); | |
% coordinates blocking time | |
\path[name path=begin-signal-watch-time1] (coord-head-VP1) -- ++($(sighting-distance1)+(approach-distance1)+(block1-length)$); | |
\path[name path=begin-approach-time1] (coord-head-DS1) -- ++($(approach-distance1)+(block1-length)$); | |
\path[name path=begin-time-between-signals1] (coord-head-BS1) -- ++($(block1-length)$); | |
\path[name path=head-leaves-block1] (coord-head-EoA1) -- ++($-1*(block1-length)$); | |
\path[name path=end-time-between-signals1] (coord-rear-EoA1) -- ++($-1*(block1-length)$); | |
\path[name path=begin-release-time1] (coord-rear-CP1) -- ++($-1*(overlap1)-(block1-length)$); | |
\path[name intersections={of=begin-signal-watch-time1 and pos-BS1,by=coord-signal-watch-time1}]; | |
\path[name intersections={of=begin-approach-time1 and pos-BS1,by=coord-approach-time1}]; | |
\path[name intersections={of=head-leaves-block1 and pos-BS1,by=coord-head-leaves-block1}]; | |
\path[name intersections={of=end-time-between-signals1 and pos-BS1,by=coord-end-between-signals1}]; | |
\path[name intersections={of=begin-release-time1 and pos-BS1,by=coord-release-time1}]; | |
\path[name intersections={of=begin-release-time1 and pos-BS2,by=coord-release-time1-BS2}]; | |
\coordinate (coord-signal-clearing-timeA1) at ($(coord-signal-watch-time1)+(0,\cleartime)$); | |
\coordinate (coord-signal-clearing-timeB1) at ($(coord-signal-clearing-timeA1)+(block1-length)$); | |
\coordinate (coord-end-release-timeA1) at ($(coord-release-time1)-(0,\releasetime)$); | |
\coordinate (coord-end-release-timeB1) at ($(coord-end-release-timeA1)+(block1-length)$); | |
% | |
\path[name path=begin-signal-watch-time2] (coord-head-VP2) -- ++($(sighting-distance2)+(approach-distance2)+(block2-length)$); | |
\path[name path=begin-approach-time2] (coord-head-DS2) -- ++($(approach-distance2)+(block2-length)$); | |
\path[name path=begin-time-between-signals2] (coord-head-BS2) -- ++($(block2-length)$); | |
\path[name path=head-leaves-block2] (coord-head-EoA2) -- ++($-1*(block2-length)$); | |
\path[name path=end-time-between-signals2] (coord-rear-EoA2) -- ++($-1*(block2-length)$); | |
\path[name path=begin-release-time2] (coord-rear-CP2) -- ++($-1*(overlap2)-(block2-length)$); | |
\path[name intersections={of=begin-signal-watch-time2 and pos-BS2,by=coord-signal-watch-time2}]; | |
\path[name intersections={of=begin-approach-time2 and pos-BS2,by=coord-approach-time2}]; | |
\path[name intersections={of=head-leaves-block2 and pos-BS2,by=coord-head-leaves-block2}]; | |
\path[name intersections={of=end-time-between-signals2 and pos-BS2,by=coord-end-between-signals2}]; | |
\path[name intersections={of=begin-release-time2 and pos-BS2,by=coord-release-time2}]; | |
\coordinate (coord-signal-clearing-timeA2) at ($(coord-signal-watch-time2)+(0,\cleartime)$); | |
\coordinate (coord-signal-clearing-timeB2) at ($(coord-signal-clearing-timeA2)+(block2-length)$); | |
\coordinate (coord-end-release-timeA2) at ($(coord-release-time2)-(0,\releasetime)$); | |
\coordinate (coord-end-release-timeB2) at ($(coord-end-release-timeA2)+(block2-length)$); | |
% moving block line | |
\path let \p1=(coord-signal-clearing-timeA1), \p2=(coord-signal-clearing-timeA2), \p3=(A) in | |
\pgfextra{\pgfmathsetmacro{\y}{(\y1-\y2)/(\x1-\x2)*(\x3-\x2)+\y2}} | |
(A |- 0,\y pt) coordinate (begin-moving-block-A); | |
\path let \p1=(coord-signal-clearing-timeA1), \p2=(coord-signal-clearing-timeA2), \p3=(B) in | |
\pgfextra{\pgfmathsetmacro{\y}{(\y1-\y2)/(\x1-\x2)*(\x3-\x2)+\y2}} | |
(B |- 0,\y pt) coordinate (begin-moving-block-B); | |
\path let \p1=(coord-end-release-timeB1), \p2=(coord-end-release-timeB2), \p3=(A) in | |
\pgfextra{\pgfmathsetmacro{\y}{(\y1-\y2)/(\x1-\x2)*(\x3-\x2)+\y2}} | |
(A |- 0,\y pt) coordinate (end-moving-block-A); | |
\path let \p1=(coord-end-release-timeB1), \p2=(coord-end-release-timeB2), \p3=(B) in | |
\pgfextra{\pgfmathsetmacro{\y}{(\y1-\y2)/(\x1-\x2)*(\x3-\x2)+\y2}} | |
(B |- 0,\y pt) coordinate (end-moving-block-B); | |
\path[name path=begin-moving-block] (begin-moving-block-A) -- (begin-moving-block-B); | |
\path[name path=end-moving-block] (end-moving-block-A) -- (end-moving-block-B); | |
\path[name intersections={of=begin-moving-block and pos-EoA2,by=coord-signal-clearing-time3}]; | |
\path[name intersections={of=end-moving-block and pos-BS1, by=coord-end-release-timeB0}]; | |
\path[name intersections={of=end-moving-block and trainlength-at-coord-head-DS2,by=coord-release-moving-block}]; | |
% | |
\iftoggle{DEBUG}{ | |
% help lines and points | |
\foreach \name in {pos-RoT,pos-T,pos-VP1,pos-DS1,pos-BS1,pos-EoA1,pos-CP1,pos-VP2,pos-DS2,pos-BS2,pos-EoA2,pos-CP2,trainrun-head,trainrun-rear,trainlength-at-current-pos,trainlength-at-coord-head-DS2,begin-signal-watch-time1,begin-approach-time1,begin-time-between-signals1,head-leaves-block1,end-time-between-signals1,begin-release-time1,begin-signal-watch-time2,begin-approach-time2,begin-time-between-signals2,head-leaves-block2,end-time-between-signals2,begin-release-time2,begin-moving-block,end-moving-block} | |
\draw[use path=\name,DEBUG]; | |
\foreach \point in {trainrun-head-A,trainrun-head-B,current-head-pos,current-rear-pos,rear-pos-help,trainrun-rear-A,trainrun-rear-B,coord-head-VP1,coord-head-DS1,coord-head-BS1,coord-head-VP2,coord-head-DS2,coord-rear-DS2,coord-rear-margin-DS2,coord-head-BS2,coord-head-EoA2,coord-rear-EoA1,coord-rear-CP1,coord-release-moving-block,coord-rear-EoA2,coord-rear-CP2,coord-signal-watch-time1,coord-approach-time1,coord-head-leaves-block1,coord-end-between-signals1,coord-release-time1,coord-release-time1-BS2,coord-signal-clearing-timeA1,coord-signal-clearing-timeB1,coord-signal-clearing-timeB2,coord-end-release-timeA1,coord-end-release-timeB1,coord-signal-watch-time2,coord-approach-time2,coord-head-leaves-block2,coord-end-between-signals2,coord-release-time2,coord-signal-clearing-timeA2,coord-end-release-timeA2,coord-end-release-timeB2,begin-moving-block-A,begin-moving-block-B,end-moving-block-A,end-moving-block-B,coord-signal-clearing-time3,coord-end-release-timeB0} | |
\fill[DEBUG] (\point) circle (0.05) node[above=1] {\tiny \point}; | |
}{} | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% draw time distance diagram | |
\iftoggle{background-fill}{ | |
\fill[foreground!10] (begin-moving-block-A) -- (begin-moving-block-B) -- (end-moving-block-B) --(end-moving-block-A) -- cycle; | |
\fill[degrade] (coord-signal-clearing-timeA1) -- (coord-signal-clearing-timeB1) -- (coord-signal-clearing-timeA2) -- cycle; | |
\fill[degrade] (coord-signal-clearing-timeA2) -- (coord-signal-clearing-timeB2) -- (coord-signal-clearing-time3) -- cycle; | |
\fill[degrade] (coord-end-release-timeB0) -- (coord-end-release-timeA1) -- (coord-end-release-timeB1) -- cycle; | |
\fill[degrade] (coord-end-release-timeB1) -- (coord-end-release-timeA2) -- (coord-end-release-timeB2) -- cycle; | |
}{} | |
\iftoggle{time-distance-diagram}{ | |
\begin{scope}[shift={(-0.2,0.3)}] | |
\path[draw=foreground,->,>=latex] (0,0) -- ++(1,0) node [right,text=foreground] {\footnotesize $s$}; | |
\path[draw=foreground,->,>=latex] (0,0) -- ++(0,-1) node [below,text=foreground] {\footnotesize $t$}; | |
\end{scope} | |
% help lines | |
\iftoggle{fixed-block-time}{ | |
\path[draw=foreground,dotted] ([shift={(0,-1)}] BS1) -- ++(0,-1.2\speedspace); | |
\path[draw=foreground,dotted] ([shift={(0,-1)}] BS2) -- ++(0,-1.2\speedspace); | |
\path[draw=foreground,dotted] ([shift={(0,-1)}] EoA2) -- ++(0,-1.2\speedspace); | |
}{} | |
\iftoggle{moving-block-time}{ | |
\path[draw=foreground,dotted] ([shift={(0,-1)}] EoA1) -- ++(0,-1.2\speedspace); | |
}{} | |
% train | |
\path[draw=foreground] (trainrun-head-A) -- (trainrun-head-B) node[sloped,very near start,fill=background,text=foreground] {% | |
\IfLanguage{english}{train head} | |
\IfLanguage{ngerman}{Zugspitze} | |
}; | |
\path[draw=foreground,dashed] (trainrun-rear-A) -- (trainrun-rear-B) node[sloped,very near start,fill=background,text=foreground] {% | |
\IfLanguage{english}{rear of train} | |
\IfLanguage{ngerman}{Zugschluss} | |
}; | |
}{} | |
% draw moving block time | |
\iftoggle{moving-block-time}{ | |
\path[draw=foreground] (begin-moving-block-A) -- (begin-moving-block-B) node[sloped,very near start,above,text=foreground] {% | |
\IfLanguage{english}{begin moving block time} | |
\IfLanguage{ngerman}{Sperrzeitbeginn} | |
}; | |
\path[draw=foreground] (end-moving-block-A) -- (end-moving-block-B) node[sloped,very near start,below,text=foreground] {% | |
\IfLanguage{english}{end moving block time} | |
\IfLanguage{ngerman}{Sperrzeitende} | |
}; | |
% legende | |
\draw[highlight,->] (coord-signal-watch-time2) -- (coord-signal-clearing-timeA2) node[midway,right=3pt,align=left,fill=\iftoggle{background-fill}{foreground!10}{background},inner sep=0pt,text=foreground] {% | |
\IfLanguage{english}{time for clearing the signal} | |
\IfLanguage{ngerman}{Fahrstraßenbildezeit} | |
}; | |
\draw[highlight,->] (coord-approach-time2) -- (coord-signal-watch-time2) node[midway,right=3pt,align=left,fill=\iftoggle{background-fill}{foreground!10}{background},inner sep=0pt,text=foreground] {% | |
\IfLanguage{english}{signal watch time} | |
\IfLanguage{ngerman}{Sichtzeit} | |
}; | |
\draw[highlight,->] (coord-head-DS2) -- (coord-approach-time2) node[midway,above,text=foreground] {% | |
\IfLanguage{english}{breaking distance} | |
\IfLanguage{ngerman}{Bremsweg} | |
}; | |
\fill[highlight] (coord-head-DS2) circle (0.05); | |
\draw[highlight,->] (coord-head-DS2) -- (coord-rear-DS2) node[midway,above=3pt,fill=\iftoggle{background-fill}{foreground!10}{background},inner sep=0pt,text=foreground] {% | |
\IfLanguage{english}{train length} | |
\IfLanguage{ngerman}{Zuglänge} | |
}; | |
\draw[highlight,->] (coord-rear-DS2) -- (coord-rear-margin-DS2) node[midway,above=3pt,fill=\iftoggle{background-fill}{foreground!10}{background},inner sep=0pt,text=foreground] {% | |
\IfLanguage{english}{safety margin} | |
\IfLanguage{ngerman}{Sicherheitsabstand} | |
}; | |
\draw[highlight,->] (coord-rear-margin-DS2) -- (coord-release-moving-block) node[midway,left=3pt,align=right,fill=\iftoggle{background-fill}{foreground!10}{background},inner sep=1pt,text=foreground] {% | |
\IfLanguage{english}{release time} | |
\IfLanguage{ngerman}{Fahrstraßenauflösezeit} | |
}; | |
\draw[degrade,->] (coord-approach-time2) -- (coord-head-BS2) node[midway,right,align=left,text=foreground] {% | |
\IfLanguage{english}{approach time} | |
\IfLanguage{ngerman}{Annäherungsfahrzeit} | |
}; | |
\draw[degrade,->] (coord-head-BS2) -- (coord-rear-EoA1) node[midway,right=3pt,align=left,fill=\iftoggle{background-fill}{foreground!10}{background},inner sep=0pt,text=foreground] {% | |
\IfLanguage{english}{clearing time - part 1} | |
\IfLanguage{ngerman}{Räumfahrzeit - Teil 1} | |
}; | |
\draw[degrade,->] (coord-rear-EoA1) -- (coord-release-time1-BS2) node[midway,right=3pt,align=left,fill=\iftoggle{background-fill}{foreground!10}{background},inner sep=0pt,text=foreground] {% | |
\IfLanguage{english}{clearing time - part 2} | |
\IfLanguage{ngerman}{Räumfahrzeit - Teil 2} | |
}; | |
\draw[degrade,->] (coord-release-time1-BS2) -- (coord-end-release-timeB1) node[midway,right=3pt,align=left,fill=\iftoggle{background-fill}{foreground!10}{background},inner sep=0pt,text=foreground] {% | |
\IfLanguage{english}{release time} | |
\IfLanguage{ngerman}{Fahrstraßenauflösezeit} | |
}; | |
}{} | |
\iftoggle{background-fill}{ | |
\draw[foreground] (begin-moving-block-A) -- (begin-moving-block-B) node[sloped,very near start,above] {% | |
\IfLanguage{english}{begin moving block time} | |
\IfLanguage{ngerman}{Sperrzeitanfang} | |
}; | |
\draw[foreground] (end-moving-block-A) -- (end-moving-block-B) node[sloped,very near start,below] {% | |
\IfLanguage{english}{end moving block time} | |
\IfLanguage{ngerman}{Sperrzeitende} | |
}; | |
\draw[foreground] (coord-signal-clearing-timeA1) rectangle (coord-end-release-timeB1); | |
\draw[foreground] (coord-signal-clearing-timeA2) rectangle (coord-end-release-timeB2); | |
\node[above] at ($(coord-signal-clearing-timeA1)!0.5!(coord-signal-clearing-timeB1)$) {% | |
\IfLanguage{english}{begin fixed block time} | |
\IfLanguage{ngerman}{Sperrzeitanfang} | |
}; | |
\node[below] at ($(coord-end-release-timeA1)!0.5!(coord-end-release-timeB1)$) {% | |
\IfLanguage{english}{end fixed block time} | |
\IfLanguage{ngerman}{Sperrzeitende} | |
}; | |
}{} | |
% draw fixed blocking time | |
\iftoggle{fixed-block-time}{ | |
\iftoggle{background-fill}{}{ | |
% blocking time block 2 | |
\path[draw=foreground] (coord-signal-clearing-timeA2) rectangle ($(block2-length)+(coord-signal-watch-time2)$); | |
\path[draw=foreground] (coord-signal-watch-time2) rectangle ($(block2-length)+(coord-approach-time2)$); | |
\path[draw=foreground] (coord-approach-time2) rectangle ($(block2-length)+(coord-head-BS2)$); | |
\path[draw=foreground] (coord-head-BS2) rectangle (coord-head-EoA2); | |
\path[draw=foreground] (coord-head-leaves-block2) rectangle (coord-rear-EoA2); | |
\path[draw=foreground] (coord-rear-EoA2) rectangle (coord-release-time2); | |
\path[draw=foreground] (coord-release-time2) rectangle (coord-end-release-timeB2); | |
% blocking time block 1 | |
\draw[highlight] (coord-signal-clearing-timeA1) rectangle ($(block1-length)+(coord-signal-watch-time1)$); | |
\path[draw=highlight] (coord-signal-watch-time1) rectangle ($(block1-length)+(coord-approach-time1)$); | |
\path[draw=highlight] (coord-approach-time1) rectangle ($(block1-length)+(coord-head-BS1)$); | |
\path[draw=highlight] (coord-head-BS1) rectangle (coord-head-EoA1); | |
\path[draw=highlight] (coord-head-leaves-block1) rectangle (coord-rear-EoA1); | |
\path[draw=highlight] (coord-rear-EoA1) rectangle (coord-release-time1); | |
\path[draw=highlight] (coord-release-time1) rectangle (coord-end-release-timeB1); | |
% legende | |
\node[highlight,right,align=left] at ([shift={(0.75,-0.2)}] coord-signal-clearing-timeA1) {% | |
\IfLanguage{english}{time for clearing the signal} | |
\IfLanguage{ngerman}{Fahrstraßenbildezeit} | |
}; | |
\node[highlight,right,align=left] at ([shift={(0.75,-0.2)}] coord-signal-watch-time1) {% | |
\IfLanguage{english}{signal watch time} | |
\IfLanguage{ngerman}{Sichtzeit} | |
}; | |
\node[highlight,right,align=left] at ([shift={(0.75,-0.2)}] coord-approach-time1) {% | |
\IfLanguage{english}{approach time} | |
\IfLanguage{ngerman}{Annäherungsfahrzeit} | |
}; | |
\node[highlight,right,align=left] at ([shift={(0.75,-0.2)}] coord-head-BS1) {% | |
\IfLanguage{english}{time between block signals} | |
\IfLanguage{ngerman}{Fahrzeit im Block} | |
}; | |
\node[highlight,right,align=left,fill=\iftoggle{background-fill}{foreground!10}{background},inner sep=0pt] at ([shift={(0.85,-0.2)}] coord-head-leaves-block1) {% | |
\IfLanguage{english}{clearing time - part 1} | |
\IfLanguage{ngerman}{Räumfahrzeit - Teil 1} | |
}; | |
\node[highlight,right,align=left] at ([shift={(0.75,-0.2)}] coord-end-between-signals1) {% | |
\IfLanguage{english}{clearing time - part 2} | |
\IfLanguage{ngerman}{Räumfahrzeit - Teil 2} | |
}; | |
\node[highlight,right,align=left] at ([shift={(0.75,-0.2)}] coord-release-time1) {% | |
\IfLanguage{english}{release time} | |
\IfLanguage{ngerman}{Fahrstraßenauflösezeit} | |
}; | |
} | |
}{} | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% draw topology | |
\iftoggle{topology}{ | |
%% tracks | |
\maintrack ([shift={(0,1)}] A) -- ([shift={(0,1)}] B); | |
%% objects | |
\train[run=normal,forward,length=\trainlength] at ([shift={(0,1)}] T) (); | |
% \pic at ([shift={(0,1)}] gT) {ghost_train_direction_forward=\trainlength}; | |
\iftoggle{fixed-block-time}{ | |
\viewpoint[forward] at ([shift={(0,1)}] VP1); | |
\viewpoint[forward] at ([shift={(0,1)}] VP2); | |
% \node[below=0.6cm,rotate=-90,right] at ([shift={(0,1)}] VP1) { | |
% \IfLanguage{english}{view point} | |
% \IfLanguage{ngerman}{Sichtpunkt} | |
% }; | |
\distantsignal[forward] at ([shift={(0,1)}] DS1) label (); | |
\distantsignal[forward] at ([shift={(0,1)}] DS2) label (); | |
% \node[below=0.6cm,rotate=-90,right] at ([shift={(0,1)}] DS1) { | |
% \IfLanguage{english}{distant signal} | |
% \IfLanguage{ngerman}{Vorsignal} | |
% }; | |
\blocksignal[forward] at ([shift={(0,1)}] BS1) label (); | |
\blocksignal[forward] at ([shift={(0,1)}] BS2) label (); | |
% \node[below=0.6cm,rotate=-90,right,fill=background] at ([shift={(0,1)}] BS1) { | |
% \IfLanguage{english}{block signal} | |
% \IfLanguage{ngerman}{Blocksignal} | |
% }; | |
\blocksignal[forward] at ([shift={(0,1)}] EoA2) label (); | |
% \node[below=0.7cm,rotate=-90,right,fill=background] at ([shift={(0,1)}] EoA1) { | |
% \IfLanguage{english}{end of movement authority} | |
% \IfLanguage{ngerman}{Ende der Fahrterlaubis} | |
% }; | |
\blockclearing[forward] at ([shift={(0,1)}] CP1) label (); | |
\blockclearing[forward] at ([shift={(0,1)}] CP2) label (); | |
% \node[below=0.5cm,rotate=-90,right] at ([shift={(0,1)}] CP1) { | |
% \IfLanguage{english}{block clearing point} | |
% \IfLanguage{ngerman}{Signalzugschlussstelle} | |
% }; | |
}{} | |
\iftoggle{moving-block-time}{ | |
\brakingpoint[forward] at ([shift={(0,1)}] DS1) label (); | |
% \node[below=0.6cm,rotate=-90,right] at ([shift={(0,1)}] DS1) { | |
% \IfLanguage{english}{distant signal} | |
% \IfLanguage{ngerman}{Vorsignal} | |
% }; | |
\movementauthority[forward] at ([shift={(0,1)}] EoA1) label (); | |
% \node[below=0.7cm,rotate=-90,right,fill=background] at ([shift={(0,1)}] EoA1) { | |
% \IfLanguage{english}{end of movement authority} | |
% \IfLanguage{ngerman}{Ende der Fahrterlaubis} | |
% }; | |
\dangerpoint[forward] at ([shift={(0,1)}] CP1) label (); | |
% \node[below=0.5cm,rotate=-90,right] at ([shift={(0,1)}] CP1) { | |
% \IfLanguage{english}{block clearing point} | |
% \IfLanguage{ngerman}{Signalzugschlussstelle} | |
% }; | |
}{} | |
}{} | |
\end{tikzpicture} | |
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%!TEX TS-program = pdflatexmk | |
% Copyright 2022 Martin Scheidt, ORCID: 0000-0002-9384-8945 (ISC license) | |
% Permission to use, copy, modify, and/or distribute this file for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. | |
\documentclass[tikz,border=2,preview=true,convert]{standalone} | |
\usepackage[prefix=]{xcolor-solarized} | |
\usepackage{lmodern,microtype,mathptmx,courier} | |
\usepackage[main=english,ngerman]{babel} | |
\usepackage{iflang} % needs babel | |
\newcommand{\IfLanguage}[2]{\IfLanguageName{#1}{#2}{}} | |
\usepackage{etoolbox} | |
\newtoggle{topology} | |
\newtoggle{time-distance-diagram} | |
% \newtoggle{background-fill} | |
\newtoggle{fixed-block-time} | |
\newtoggle{moving-block-time} | |
\newtoggle{DEBUG} | |
\tikzset{DEBUG/.style={magenta,thin}} | |
\usetikzlibrary{intersections,calc,backgrounds} | |
\usetikzlibrary{trackschematic}% | |
\definecolor{darkblue}{RGB}{37,64,97} | |
\tikzset{background=darkblue,foreground=white} | |
\colorlet{highlight}{white} | |
\colorlet{foreground}{white} | |
\colorlet{background}{darkblue} | |
\colorlet{degrade}{foreground!20!background} | |
\makeatletter | |
% source from: \url{http://tex.stackexchange.com/q/26382/86} | |
% TODO: switch to tikz package spath3 | |
\tikzset{ | |
use path for main/.code={% | |
\tikz@addmode{% | |
\expandafter\pgfsyssoftpath@setcurrentpath\csname tikz@intersect@path@name@#1\endcsname | |
}% | |
}, | |
use path for actions/.code={% | |
\expandafter\def\expandafter\tikz@preactions\expandafter{\tikz@preactions\expandafter\let\expandafter\tikz@actions@path\csname tikz@intersect@path@name@#1\endcsname}% | |
}, | |
use path/.style={% | |
use path for main=#1, | |
use path for actions=#1, | |
} | |
} | |
\makeatother | |
\begin{document} | |
\settoggle{DEBUG}{false} | |
\settoggle{topology}{true} | |
\settoggle{time-distance-diagram}{true} | |
\settoggle{fixed-block-time}{true} | |
\settoggle{moving-block-time}{false} | |
\selectlanguage{ngerman} | |
\begin{tikzpicture}[font=\sffamily,background rectangle/.style={fill=background},show background rectangle] | |
% \tikzset{every node/.style={anchor=base}}; | |
\newlength{\trainlength}\setlength{\trainlength}{3cm} | |
\newlength{\speedspace}\setlength{\speedspace}{10cm} | |
\newlength{\cleartime}\setlength{\cleartime}{0.4cm} | |
\newlength{\releasetime}\setlength{\releasetime}{0.4cm} | |
%% coordinates | |
\coordinate (A) at ( 0, 0); | |
\coordinate (B) at (23, 0); | |
\coordinate (VP1) at ( 5, 0); % view point | |
\coordinate (DS1) at ( 6, 0); % distant signal | |
\coordinate (BS1) at ( 8, 0); % block signal | |
\coordinate (CP0) at (9.5, 0); % clearing point | |
\coordinate (Y) at (10.5, 0); % turnout | |
\coordinate (RCP) at (12, 0); % routeclearing point | |
\coordinate (VP2) at (13, 0); | |
\coordinate (DS2) at (14, 0); | |
\coordinate (EoA1) at (16, 0); % end of movement authority = BS1 | |
\coordinate (BS2) at (16, 0); | |
\coordinate (CP1) at (17.5, 0); % clearing point | |
\coordinate (EoA2) at (21, 0); | |
\coordinate (CP2) at (22.5, 0); | |
\coordinate (T) at ( 4, 0); % train head | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%% description | |
\tikzset{every path/.style={line width=0.75pt,>=latex}}; | |
% help line for coordinates | |
\path[name path=pos-T] ([shift={(0,-2)}] T) -- ++(0,-1.2\speedspace); % head of train | |
\path[name path=pos-RoT] ([shift={(-\trainlength,-2)}] T) -- ++(0,-1.2\speedspace); % rear of train | |
\path[name path=pos-VP1] ([shift={(0,-2)}] VP1) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-DS1] ([shift={(0,-2)}] DS1) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-BS1] ([shift={(0,-2)}] BS1) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-CP0] ([shift={(0,-2)}] CP0) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-Y] ([shift={(0,-2)}] Y) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-RCP] ([shift={(0,-2)}] RCP) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-VP2] ([shift={(0,-2)}] VP2) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-DS2] ([shift={(0,-2)}] DS2) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-BS2] ([shift={(0,-2)}] BS2) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-CP1] ([shift={(0,-2)}] CP1) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-EoA2] ([shift={(0,-2)}] EoA2) -- ++(0,-1.2\speedspace); | |
\path[name path=pos-CP2] ([shift={(0,-2)}] CP2) -- ++(0,-1.2\speedspace); | |
% coordinates along train run head | |
\coordinate (trainrun-head-A) at ([shift={(0,-2)}] A); | |
\coordinate (trainrun-head-B) at ($([shift={(0,-2)}] B) + (0,-\speedspace)$); | |
\path[name path=trainrun-head] (trainrun-head-A) -- (trainrun-head-B); | |
\path[name intersections={of=trainrun-head and pos-T ,by=current-head-pos}]; | |
\path[name intersections={of=trainrun-head and pos-RoT,by=rear-pos-help}]; | |
\path[name path=trainrun-head] (trainrun-head-A) -- (trainrun-head-B); | |
\path[name intersections={of=trainrun-head and pos-VP1,by=coord-head-VP1}]; | |
\path[name intersections={of=trainrun-head and pos-DS1,by=coord-head-DS1}]; | |
\path[name intersections={of=trainrun-head and pos-BS1,by=coord-head-BS1A}]; | |
\path[name intersections={of=trainrun-head and pos-RCP,by=coord-head-RCP}]; | |
\path[name intersections={of=trainrun-head and pos-BS2,by=coord-head-EoA1}]; | |
\path[name intersections={of=trainrun-head and pos-VP2,by=coord-head-VP2}]; | |
\path[name intersections={of=trainrun-head and pos-DS2,by=coord-head-DS2}]; | |
\path[name intersections={of=trainrun-head and pos-BS2,by=coord-head-BS2}]; | |
\path[name intersections={of=trainrun-head and pos-EoA2,by=coord-head-EoA2}]; | |
% coordinates along train run rear | |
\path[name path=trainlength-at-current-pos] (current-head-pos) -- ++(-\trainlength,0); | |
\path[name intersections={of=pos-RoT and trainlength-at-current-pos,by=current-rear-pos}]; | |
\coordinate (time-for-trainlength) at ($(current-rear-pos)-(rear-pos-help)$); | |
\coordinate (trainrun-rear-A) at ($(trainrun-head-A)+(time-for-trainlength)$); | |
\coordinate (trainrun-rear-B) at ($(trainrun-head-B)+(time-for-trainlength)$); | |
\path[name path=trainrun-rear] (trainrun-rear-A) -- (trainrun-rear-B); | |
\path[name intersections={of=trainrun-rear and pos-BS1,by=coord-rear-BS1}]; | |
\path[name intersections={of=trainrun-rear and pos-RCP,by=coord-rear-RCP}]; | |
\path[name intersections={of=trainrun-rear and pos-BS2,by=coord-rear-EoA1}]; | |
\path[name intersections={of=trainrun-rear and pos-CP1,by=coord-rear-CP1}]; | |
\path[name intersections={of=trainrun-rear and pos-EoA2,by=coord-rear-EoA2}]; | |
\path[name intersections={of=trainrun-rear and pos-CP2,by=coord-rear-CP2}]; | |
% distances | |
\coordinate (sighting-distance1) at ($(DS1)-(VP1)$); | |
\coordinate (approach-distance1) at ($(BS1)-(DS1)$); | |
\coordinate (block1-length) at ($(EoA1)-(BS1)$); | |
\coordinate (overlap1) at ($(CP1)-(EoA1)$); | |
\coordinate (sighting-distance2) at ($(DS2)-(VP2)$); | |
\coordinate (approach-distance2) at ($(BS2)-(DS2)$); | |
\coordinate (block2-length) at ($(EoA2)-(BS2)$); | |
\coordinate (overlap2) at ($(CP2)-(EoA2)$); | |
% | |
% coordinates blocking time | |
\path[name path=begin-signal-watch-time1] (coord-head-VP1) -- ++($(sighting-distance1)+(approach-distance1)+(block1-length)$); | |
\path[name path=begin-approach-time1] (coord-head-DS1) -- ++($(approach-distance1)+(block1-length)$); | |
\path[name path=begin-time-between-signals1] (coord-head-BS1A) -- ++($(block1-length)$) coordinate (coord-head-BS1B); | |
\path[name path=head-leaves-block1] (coord-head-EoA1) -- ++($-1*(block1-length)$); | |
\path[name path=end-time-route-lock] (coord-rear-RCP) -- ++($-1*(block1-length)$); | |
\path[name path=begin-time-route-clearing] (coord-head-RCP) -- ++($-1*(block1-length)$); | |
\path[name path=end-time-between-signals1] (coord-rear-EoA1) -- ++($-1*(block1-length)$); | |
\path[name path=begin-release-time1] (coord-rear-CP1) -- ++($-1*(overlap1)-(block1-length)$); | |
\path[name intersections={of=begin-signal-watch-time1 and pos-BS1,by=coord-signal-watch-time1}]; | |
\path[name intersections={of=begin-approach-time1 and pos-BS1,by=coord-approach-time1}]; | |
\path[name intersections={of=head-leaves-block1 and pos-RCP,by=coord-head-leaves-block1}]; | |
\path[name intersections={of=begin-time-route-clearing and pos-BS1,by=coord-head-leaves-route}]; | |
\path[name intersections={of=end-time-route-lock and pos-BS1,by=coord-end-route-lock}]; | |
\path[name intersections={of=end-time-between-signals1 and pos-RCP,by=coord-end-between-signals1}]; | |
\path[name intersections={of=begin-release-time1 and pos-RCP,by=coord-release-time1}]; | |
\path[name intersections={of=begin-release-time1 and pos-BS2,by=coord-release-time1-BS2}]; | |
\coordinate (coord-signal-clearing-timeA1) at ($(coord-signal-watch-time1)+(0,\cleartime)$); | |
\coordinate (coord-signal-clearing-timeB1) at ($(coord-signal-clearing-timeA1)+(block1-length)$); | |
\coordinate (coord-end-release-timeA1) at ($(coord-release-time1)-(0,\releasetime)$); | |
\coordinate (coord-end-route-release) at ($(coord-end-route-lock)-(0,\releasetime)$); | |
\coordinate (coord-end-release-timeB1) at ($(coord-release-time1-BS2)-(0,\releasetime)$); | |
% | |
\path[name path=begin-signal-watch-time2] (coord-head-VP2) -- ++($(sighting-distance2)+(approach-distance2)+(block2-length)$); | |
\path[name path=begin-approach-time2] (coord-head-DS2) -- ++($(approach-distance2)+(block2-length)$); | |
\path[name path=begin-time-between-signals2] (coord-head-BS2) -- ++($(block2-length)$); | |
\path[name path=head-leaves-block2] (coord-head-EoA2) -- ++($-1*(block2-length)$); | |
\path[name path=end-time-between-signals2] (coord-rear-EoA2) -- ++($-1*(block2-length)$); | |
\path[name path=begin-release-time2] (coord-rear-CP2) -- ++($-1*(overlap2)-(block2-length)$); | |
\path[name intersections={of=begin-signal-watch-time2 and pos-BS2,by=coord-signal-watch-time2}]; | |
\path[name intersections={of=begin-approach-time2 and pos-BS2,by=coord-approach-time2}]; | |
\path[name intersections={of=head-leaves-block2 and pos-BS2,by=coord-head-leaves-block2}]; | |
\path[name intersections={of=end-time-between-signals2 and pos-BS2,by=coord-end-between-signals2}]; | |
\path[name intersections={of=begin-release-time2 and pos-BS2,by=coord-release-time2}]; | |
\coordinate (coord-signal-clearing-timeA2) at ($(coord-signal-watch-time2)+(0,\cleartime)$); | |
\coordinate (coord-signal-clearing-timeB2) at ($(coord-signal-clearing-timeA2)+(block2-length)$); | |
\coordinate (coord-end-release-timeA2) at ($(coord-release-time2)-(0,\releasetime)$); | |
\coordinate (coord-end-release-timeB2) at ($(coord-end-release-timeA2)+(block2-length)$); | |
% moving block line | |
\path let \p1=(coord-signal-clearing-timeA1), \p2=(coord-signal-clearing-timeA2), \p3=(A) in | |
\pgfextra{\pgfmathsetmacro{\y}{(\y1-\y2)/(\x1-\x2)*(\x3-\x2)+\y2}} | |
(A |- 0,\y pt) coordinate (begin-moving-block-A); | |
\path let \p1=(coord-signal-clearing-timeA1), \p2=(coord-signal-clearing-timeA2), \p3=(B) in | |
\pgfextra{\pgfmathsetmacro{\y}{(\y1-\y2)/(\x1-\x2)*(\x3-\x2)+\y2}} | |
(B |- 0,\y pt) coordinate (begin-moving-block-B); | |
\path let \p1=(coord-end-release-timeB1), \p2=(coord-end-release-timeB2), \p3=(A) in | |
\pgfextra{\pgfmathsetmacro{\y}{(\y1-\y2)/(\x1-\x2)*(\x3-\x2)+\y2}} | |
(A |- 0,\y pt) coordinate (end-moving-block-A); | |
\path let \p1=(coord-end-release-timeB1), \p2=(coord-end-release-timeB2), \p3=(B) in | |
\pgfextra{\pgfmathsetmacro{\y}{(\y1-\y2)/(\x1-\x2)*(\x3-\x2)+\y2}} | |
(B |- 0,\y pt) coordinate (end-moving-block-B); | |
\path[name path=begin-moving-block] (begin-moving-block-A) -- (begin-moving-block-B); | |
\path[name path=end-moving-block] (end-moving-block-A) -- (end-moving-block-B); | |
\path[name intersections={of=begin-signal-watch-time1 and pos-RCP,by=coord-signal-watch-time1-RCP}]; | |
\path[name intersections={of=begin-time-between-signals1 and pos-RCP,by=coord-between-signals1-RCP}]; | |
\path[name intersections={of=begin-moving-block and pos-RCP,by=begin-moving-block-RCP}]; | |
\path[name intersections={of=end-moving-block and pos-BS1,by=end-moving-block-RCP-A}]; | |
\path[name path=end-route-release] (coord-end-route-release) -- ++(block1-length); | |
\path[name intersections={of=end-moving-block and end-route-release,by=end-moving-block-RCP-B}]; | |
\iftoggle{DEBUG}{ | |
% help lines and points | |
\foreach \name in {pos-RoT,pos-T,pos-VP1,pos-DS1,pos-BS1,pos-CP0,pos-Y,pos-RCP,pos-VP2,pos-DS2,pos-BS2,pos-CP1,pos-EoA2,pos-CP2,trainrun-head,trainlength-at-current-pos,trainrun-rear,begin-signal-watch-time1,begin-approach-time1,begin-time-between-signals1,head-leaves-block1,end-time-route-lock,begin-time-route-clearing,end-time-between-signals1,begin-release-time1,begin-signal-watch-time2,begin-approach-time2,begin-time-between-signals2,head-leaves-block2,end-time-between-signals2,begin-release-time2,begin-moving-block,end-moving-block} | |
\draw[use path=\name,DEBUG]; | |
\foreach \point in {trainrun-head-A,trainrun-head-B,current-head-pos,rear-pos-help,current-rear-pos,trainrun-rear-A,trainrun-rear-B,coord-head-VP1,coord-head-DS1,coord-head-BS1A,coord-head-RCP,coord-head-BS1B,coord-head-VP2,coord-head-DS2,coord-head-BS2,coord-head-EoA2,coord-rear-BS1,coord-rear-RCP,coord-rear-EoA1,coord-rear-CP1,coord-rear-EoA2,coord-rear-CP2,coord-signal-watch-time1,coord-signal-watch-time1-RCP,coord-between-signals1-RCP,coord-approach-time1,coord-end-route-lock,coord-end-route-release,coord-head-leaves-route,coord-head-leaves-block1,coord-end-between-signals1,coord-release-time1,coord-release-time1-BS2,coord-signal-clearing-timeA1,coord-signal-clearing-timeB1,coord-end-release-timeA1,coord-end-release-timeB1,coord-signal-watch-time2,coord-approach-time2,coord-head-leaves-block2,coord-end-between-signals2,coord-release-time2,coord-signal-clearing-timeA2,coord-signal-clearing-timeB2,coord-end-release-timeA2,coord-end-release-timeB2,begin-moving-block-A,begin-moving-block-B,begin-moving-block-RCP,end-moving-block-RCP-A,end-moving-block-RCP-B,end-moving-block-A,end-moving-block-B} | |
\fill[DEBUG] (\point) circle (0.05) node[above=1] {\tiny \point}; | |
}{} | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% draw time distance diagram | |
\iftoggle{time-distance-diagram}{ | |
\begin{scope}[shift={(-0.2,0.3)}] | |
\path[draw=foreground] [->,>=latex] (0,0) -- ++(1,0) node [right,text=foreground] {\footnotesize $s$}; | |
\path[draw=foreground] [->,>=latex] (0,0) -- ++(0,-1) node [below,text=foreground] {\footnotesize $t$}; | |
\end{scope} | |
% help lines | |
\iftoggle{fixed-block-time}{ | |
\path[draw=foreground,dotted] ([shift={(0,-1)}] BS1) -- ++(0,-1.2\speedspace); | |
\path[draw=foreground,dotted] ([shift={(0,-1)}] RCP) -- ++(0,-1.2\speedspace); | |
\path[draw=foreground,dotted] ([shift={(0,-1)}] BS2) -- ++(0,-1.2\speedspace); | |
\path[draw=foreground,dotted] ([shift={(0,-1)}] EoA2) -- ++(0,-1.2\speedspace); | |
}{} | |
\iftoggle{moving-block-time}{ | |
\path[draw=foreground,dotted] ([shift={(0,-1)}] BS2) -- ++(0,-1.2\speedspace); | |
}{} | |
% train | |
\path[draw=foreground] (trainrun-head-A) -- (trainrun-head-B) node[sloped,very near start,fill=background,text=foreground] {% | |
\IfLanguage{english}{train head} | |
\IfLanguage{ngerman}{Zugspitze} | |
}; | |
\path[draw=foreground,dashed] (trainrun-rear-A) -- (trainrun-rear-B) node[sloped,very near start,fill=background,text=foreground] {% | |
\IfLanguage{english}{rear of train} | |
\IfLanguage{ngerman}{Zugschluss} | |
}; | |
}{} | |
% draw moving block time | |
\iftoggle{moving-block-time}{ | |
% run | |
\path[draw=foreground] (begin-moving-block-A) -- (coord-signal-clearing-timeA1) node[sloped,near start,right=1cm,above,align=left,text=foreground] {% | |
\IfLanguage{english}{begin moving block time} | |
\IfLanguage{ngerman}{Sperrzeitbeginn absoluter Bremswegabstand} | |
}; | |
\path[draw=foreground] (begin-moving-block-RCP) -- (begin-moving-block-B) node[sloped,near end,above,text=foreground] {% | |
\IfLanguage{english}{begin moving block time} | |
\IfLanguage{ngerman}{Sperrzeitbeginn} | |
}; | |
\path[draw=degrade] (coord-signal-clearing-timeA1) -- (begin-moving-block-RCP); | |
\path[draw=foreground] (end-moving-block-A) -- (end-moving-block-RCP-A) node[sloped,near start,right=1cm,below,align=left,text=foreground] {% | |
\IfLanguage{english}{end moving block time} | |
\IfLanguage{ngerman}{Sperrzeitende absoluter Bremswegabstand} | |
}; | |
\path[draw=foreground] (end-moving-block-RCP-B) -- (end-moving-block-B) node[sloped,near end,below,text=foreground] {% | |
\IfLanguage{english}{end moving block time} | |
\IfLanguage{ngerman}{Sperrzeitende} | |
}; | |
\path[draw=degrade] (end-moving-block-RCP-A) -- (end-moving-block-RCP-B); | |
% route | |
\path[draw=highlight] (coord-signal-clearing-timeA1) rectangle (coord-signal-watch-time1-RCP); | |
\path[draw=highlight] (coord-approach-time1) rectangle (coord-signal-watch-time1-RCP); | |
\path[draw=highlight] (coord-approach-time1) rectangle (coord-between-signals1-RCP); | |
\path[draw=highlight] (coord-head-leaves-route) rectangle (coord-between-signals1-RCP); | |
\path[draw=highlight] (coord-head-leaves-route) rectangle (coord-rear-RCP); | |
\path[draw=highlight] (coord-end-route-release) rectangle (coord-rear-RCP); | |
% legende | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(0.1,0.2)}] coord-signal-clearing-timeA1) {% | |
\IfLanguage{english}{begin route block time} | |
\IfLanguage{ngerman}{Fahrstraßensperrzeit} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(0.1,-0.2)}] coord-signal-clearing-timeA1) {% | |
\IfLanguage{english}{clearing the signal} | |
\IfLanguage{ngerman}{Fahrstraßenbildezeit} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(0.1,-0.2)}] coord-signal-watch-time1) {% | |
\IfLanguage{english}{signal watch time} | |
\IfLanguage{ngerman}{Sichtzeit} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(0.1,-0.2)}] coord-approach-time1) {% | |
\IfLanguage{english}{approach time} | |
\IfLanguage{ngerman}{Annäherungsfahrzeit} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(0.1,-0.2)}] coord-head-BS1A) {% | |
\IfLanguage{english}{time on route} | |
\IfLanguage{ngerman}{Fahrzeit durch die Fahrstraße} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(0.1,-0.2)}] coord-head-leaves-route) {% | |
\IfLanguage{english}{clearing time} | |
\IfLanguage{ngerman}{Räumfahrzeit} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(0.1,-0.2)}] coord-end-route-lock) {% | |
\IfLanguage{english}{route release time} | |
\IfLanguage{ngerman}{Fahrstraßenauflösezeit} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(0.1,-0.2)}] coord-end-route-release) {% | |
\IfLanguage{english}{end route block time} | |
\IfLanguage{ngerman}{} | |
}; | |
}{} | |
% draw fixed blocking time | |
\iftoggle{fixed-block-time}{ | |
% blocking time block 2 | |
\path[draw=foreground] (coord-signal-clearing-timeA2) rectangle ($(block2-length)+(coord-signal-watch-time2)$); | |
\path[draw=foreground] (coord-signal-watch-time2) rectangle ($(block2-length)+(coord-approach-time2)$); | |
\path[draw=foreground] (coord-approach-time2) rectangle ($(block2-length)+(coord-head-BS2)$); | |
\path[draw=foreground] (coord-head-BS2) rectangle (coord-head-EoA2); | |
\path[draw=foreground] (coord-head-leaves-block2) rectangle (coord-rear-EoA2); | |
\path[draw=foreground] (coord-rear-EoA2) rectangle (coord-release-time2); | |
\path[draw=foreground] (coord-release-time2) rectangle (coord-end-release-timeB2); | |
% blocking time block 1 | |
\path[draw=highlight] (coord-signal-clearing-timeA1) rectangle ($(block1-length)+(coord-signal-watch-time1)$); | |
\path[draw=highlight] (coord-signal-watch-time1) rectangle ($(block1-length)+(coord-approach-time1)$); | |
\path[draw=highlight] (coord-approach-time1) rectangle ($(block1-length)+(coord-head-BS1A)$); | |
\path[draw=highlight] (coord-head-BS1A) -- (coord-end-route-lock) -- (coord-rear-RCP) -- (coord-end-between-signals1) -- (coord-rear-EoA1) -- (coord-head-BS1B) -- cycle; | |
\path[draw=highlight] (coord-end-route-release) rectangle (coord-rear-RCP); | |
\path[draw=highlight] (coord-head-RCP) rectangle (coord-end-route-lock); | |
\path[draw=highlight] (coord-head-leaves-block1) rectangle (coord-rear-EoA1); | |
\path[draw=highlight] (coord-rear-EoA1) rectangle (coord-release-time1); | |
\path[draw=highlight] (coord-end-release-timeA1) rectangle (coord-release-time1-BS2); | |
% legende | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(1.75,-0.2)}] coord-signal-clearing-timeA1) {% | |
\IfLanguage{english}{time for clearing the signal} | |
\IfLanguage{ngerman}{Fahrstraßenbildezeit} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(1.75,-0.2)}] coord-signal-watch-time1) {% | |
\IfLanguage{english}{signal watch time} | |
\IfLanguage{ngerman}{Sichtzeit} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(1.75,-0.2)}] coord-approach-time1) {% | |
\IfLanguage{english}{approach time} | |
\IfLanguage{ngerman}{Annäherungsfahrzeit} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(1.75,-0.2)}] coord-head-BS1A) {% | |
\IfLanguage{english}{time between block signals} | |
\IfLanguage{ngerman}{Fahrzeit auf der Fahrstraße und im Block} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(0.6,-0.2)}] coord-head-leaves-route) {% | |
\IfLanguage{english}{clearing time - part 1} | |
\IfLanguage{ngerman}{Räumfahrzeit - Teil 1} | |
}; | |
\node[highlight,right,align=left,fill=background,inner sep=0pt] at ([shift={(0.6,-0.2)}] coord-head-leaves-block1) {% | |
\IfLanguage{english}{clearing time - part 2} | |
\IfLanguage{ngerman}{Räumfahrzeit - Teil 2} | |
}; | |
\node[highlight,right,align=left] at ([shift={(0.5,-0.2)}] coord-end-between-signals1) {% | |
\IfLanguage{english}{clearing time - part 3} | |
\IfLanguage{ngerman}{Räumfahrzeit - Teil 3} | |
}; | |
\node[highlight,right,align=left] at ([shift={(0.5,-0.2)}] coord-release-time1) {% | |
\IfLanguage{english}{block release time} | |
\IfLanguage{ngerman}{Fahrstraßenauflösezeit} | |
}; | |
\node[highlight,right,align=left] at ([shift={(0.5,-0.2)}] coord-end-route-lock) {% | |
\IfLanguage{english}{route release time} | |
\IfLanguage{ngerman}{Fahrstraßenauflösezeit} | |
}; | |
}{} | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% draw topology | |
\iftoggle{topology}{ | |
\iftoggle{fixed-block-time}{ | |
\viewpoint[forward] at ([shift={(0,1)}] VP1); | |
\viewpoint[forward] at ([shift={(0,1)}] VP2); | |
% \node[below=0.6cm,rotate=-90,right] at ([shift={(0,1)}] VP1) { | |
% \IfLanguage{english}{view point} | |
% \IfLanguage{ngerman}{Sichtpunkt} | |
% }; | |
\distantsignal[forward] at ([shift={(0,1)}] DS1) label (); | |
\distantsignal[forward] at ([shift={(0,1)}] DS2) label (); | |
% \node[below=0.6cm,rotate=-90,right] at ([shift={(0,1)}] DS1) { | |
% \IfLanguage{english}{distant signal} | |
% \IfLanguage{ngerman}{Vorsignal} | |
% }; | |
\signal[block,route,forward] at ([shift={(0,1)}] BS1) label (); | |
\blocksignal[forward] at ([shift={(0,1)}] BS2) label (); | |
% \node[below=0.6cm,rotate=-90,right,fill=background] at ([shift={(0,1)}] BS1) { | |
% \IfLanguage{english}{block signal} | |
% \IfLanguage{ngerman}{Blocksignal} | |
% }; | |
\blocksignal[forward] at ([shift={(0,1)}] EoA2) label (); | |
% \node[below=0.7cm,rotate=-90,right,fill=background] at ([shift={(0,1)}] EoA1) { | |
% \IfLanguage{english}{end of movement authority} | |
% \IfLanguage{ngerman}{Ende der Fahrterlaubis} | |
% }; | |
\blockclearing[forward] at ([shift={(0,1)}] CP0) label (); | |
\routeclearing[forward] at ([shift={(0,1)}] RCP) label (); | |
\blockclearing[forward] at ([shift={(0,1)}] CP1) label (); | |
\blockclearing[forward] at ([shift={(0,1)}] CP2) label (); | |
% \node[below=0.5cm,rotate=-90,right] at ([shift={(0,1)}] CP1) { | |
% \IfLanguage{english}{block clearing point} | |
% \IfLanguage{ngerman}{Signalzugschlussstelle} | |
% }; | |
}{} | |
\iftoggle{moving-block-time}{ | |
\movementauthority[forward] at ([shift={(0,1)}] EoA1) label (); | |
% \node[below=0.7cm,rotate=-90,right,fill=background] at ([shift={(0,1)}] EoA1) { | |
% \IfLanguage{english}{end of movement authority} | |
% \IfLanguage{ngerman}{Ende der Fahrterlaubis} | |
% }; | |
\brakingpoint[forward] at ([shift={(0,1)}] DS1) label (); | |
\routesignal[forward] at ([shift={(0,1)}] BS1) label (); | |
\blockclearing[forward] at ([shift={(0,1)}] CP0) label (); | |
\dangerpoint[forward] at ([shift={(0,1)}] CP1) label (); | |
\routeclearing[forward] at ([shift={(0,1)}] RCP) label (); | |
}{} | |
%% tracks | |
\maintrack ([shift={(0,1)}] A) -- ([shift={(0,1)}] B); | |
\turnout[forward,branch=left,points=right] at ([shift={(0,1)}] Y) label (); | |
\maintrack ([shift={(0,1)}] Y) -- ++(1,1); | |
%% objects | |
\train[run=normal,forward,length=\trainlength] at ([shift={(0,1)}] T) (); | |
% \pic at ([shift={(0,1)}] gT) {ghost_train_direction_forward=\trainlength}; | |
}{} | |
\end{tikzpicture} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment