123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511 |
- \NeedsTeXFormat{LaTeX2e}[1995/12/01]
- \ProvidesPackage{rtsched}[2005/01/01]
- \typeout{'rtsched' style for Latex and PSTricks}
- \typeout{Easily draw real-time schedules in TeX/Latex.}
- \typeout{(c) 2005, Giuseppe Lipari, Pisa, Italy (g.lipari@sssup.it)}
- \typeout{Version 1.1}
-
- \RequirePackage{multido}
- \RequirePackage{pstricks}
- \RequirePackage{keyval}
-
- %%
- %% These can be changed at any time
- %%
- \def\RTWindowLength{10cm} % window length
- \def\RTWindowHeight{0cm} % window height
- \def\RTNullWindowHeight{0cm} % nullwindow height
- \def\RTTaskLabelSize{10pt} % Size in pt of the task label
- \def\RTNumberLabelSize{10pt} % Size in pt of the number labels
- \def\RTDefTaskSymbol{\tau}
- \def\RTDefNumberOffset{0}
- \def\RTDefTaskFill{solid}
- \def\RTDefTaskColor{gray}
- \def\RTDefLineColor{black}
- \def\RTDefXScale{1}
- \def\RTDefWriteSymbols{0}
- \def\RTDefGridInvisible{0}
- \def\RTDefNumbersInvisible{0}
- \def\RTDefRowLabelOffset{0pt}
- \def\RTDefAxisInvisible{0}
- \def\RTDefLineWidth{1pt}
- \def\RTDefLineStyle{solid}
-
- \def\RTExecLabel{\ }
- \def\RTTaskSymbol{\RTDefTaskSymbol}
- \def\RTTaskFill{\RTDefTaskFill}
- \def\RTTaskColor{\RTDefTaskColor}
- \def\RTLineColor{\RTDefLineColor}
- \def\RTXScale{\RTDefXScale}
- \def\RTWriteSymbols{\RTDefWriteSymbols}
- \def\RTNumberOffset{\RTDefNumberOffset}
- \def\RTNumberOffset{\RTDefNumberOffset}
- \def\RTGridInvisible{\RTDefGridInvisible}
- \def\RTAxisInvisible{\RTDefAxisInvisible}
- \def\RTNumbersInvisible{\RTDefGridInvisible}
- \def\RTRowLabelOffset{\RTDefRowLabelOffset}
- \def\RTLineWidth{\RTDefLineWidth}
- \def\RTLineStyle{\RTDefLineStyle}
-
- \define@key{RT}{height}[\RTNullWindowHeight]{\def\RTWindowHeight{#1}}
- \define@key{RT}{width}[10cm]{\def\RTWindowLength{#1}}
- \define@key{RT}{labelsize}[10pt]{\def\RTTaskLabelSize{#1}}
- \define@key{RT}{numbersize}[10pt]{\def\RTNumberLabelSize{#1}}
- \define@key{RT}{color}[\RTDefTaskColor]{\def\RTTaskColor{#1}}
- \define@key{RT}{linecolor}[\RTDefLineColor]{\def\RTLineColor{#1}}
- \define@key{RT}{execlabel}[\ ]{\def\RTExecLabel{#1}}
- \define@key{RT}{fillstyle}[\RTDefTaskFill]{\def\RTTaskFill{#1}}
- \define@key{RT}{nocommand}{}
- \define@key{RT}{xscale}[\RTDefXScale]{\def\RTXScale{#1}}
- \define@key{RT}{symbol}[{\tau}]{\def\RTTaskSymbol{#1}}
- \define@key{RT}{nosymbols}[\RTDefWriteSymbols]{\def\RTWriteSymbols{#1}}
- \define@key{RT}{numoffset}[\RTDefNumberOffset]{\def\RTNumberOffset{#1}}
- \define@key{RT}{nogrid}[\RTDefGridInvisible]{\def\RTGridInvisible{#1}}
- \define@key{RT}{nonumbers}[\RTDefNumbersInvisible]{\def\RTNumbersInvisible{#1}}
- \define@key{RT}{labeloffset}[\RTDefRowLabelOffset]{\def\RTRowLabelOffset{#1}}
- \define@key{RT}{axis}[\RTDefAxisInvisible]{\def\RTAxisInvisible{#1}}
- \define@key{RT}{lw}[\RTDefLineWidth]{\def\RTLineWidth{#1}}
- \define@key{RT}{style}[\RTDefLineStyle]{\def\RTLineStyle{#1}}
-
- %%
- %% temporaries
- \newdimen\sx % slot length
- \newdimen\sy % slot height
- \newdimen\hy % frame height
- \newdimen\xx % x position
- \newdimen\yy % y position
- \newdimen\xxx % x position
- \newdimen\yyy % y position
- \newcount\nsx % number of horizontal slots
- \newcount\nsy % number of vertical slots
- \newcount\nhl % number of horizonatal lines
- \newcount\nvl % number of vertical lines
- \newcount\tmp % temp
-
- \newcounter{myLabel}
-
- \def\RTGrid{\@ifnextchar[\@mygrid@begin{\@mygrid@begin[]}}
-
- \def\RTGridBegin{\@ifnextchar[\@mygrid@begin{\@mygrid@begin[]}}
- \def\@mygrid@begin[#1]#2#3{\setkeys{RT}{#1}%
- %% number of horizontal steps in the grid
- \nsx = #3 \advance \nsx by 2 %
- %% real lenght of the window (approx)
- \nvl = \nsx \advance \nvl by 1 %
- %% compute lenght of a step
- \sx = \RTWindowLength \divide \sx by \nsx %
- %% number of vertical steps in the grid
- \nsy = #2 \multiply \nsy by 3 \advance \nsy by 1 %
- %% compute lenght of a vertical step (if height is null, \sy is the
- %% same as \sx)
- \ifx\RTWindowHeight\RTNullWindowHeight%
- \sy = \sx%
- \hy = \sy \multiply \hy by \nsy \advance \hy by \sy%
- \else
- \sy = \RTWindowHeight \divide \sy by \nsy %
- \hy = \RTWindowHeight \advance \hy by \sy %
- \fi
- %% compute real height
- \nhl = \nsy \advance \nhl by 1 %
- \advance \nsy by -1 \advance \nsx by -1
- %% the picture
- \begin{pspicture}(0,0)(\RTWindowLength,\hy) %
- %% draw grid (if not invisible)
- \if\RTGridInvisible\RTDefGridInvisible
- \multips(0,\sy)(0,\sy){\nsy}{\psline[linecolor=lightgray]{-}(0,\sy)(\RTWindowLength,\sy)}%
- \multips(\sx,0)(\sx,0){\nsx}{\psline[linecolor=lightgray]{-}(0,\sy)(0,\hy)}%
- \psframe(0,\sy)(\RTWindowLength,\hy)%
- \else\relax
- \fi
- %% draw numbers (if not invisible)
- \if\RTNumbersInvisible\RTDefNumbersInvisible
- \tmp = #3 \divide \tmp by 2 \advance \tmp by 1%
- \pssetlength{\xx}{\sx}%
- \setcounter{myLabel}{\RTNumberOffset}
- \multido{\n=0+1}{\tmp}{%
- \uput{4pt}[d](\xx,\sy){%
- \usefont{T1}{phv}{m}{n}%
- \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
- \selectfont{\arabic{myLabel}}}%
- \psaddtolength{\xx}{\sx}%
- \psaddtolength{\xx}{\sx}%
- \addtocounter{myLabel}{2}
- }
- \else\relax
- \fi
- %
- %% Task Names
- \setcounter{myLabel}{1}
- \pssetlength{\yy}{\hy}%
- \psaddtolength{\yy}{-\sy}
- \multido{\n=0+1}{#2}{%
- \uput{4pt}[d](-\sx,\yy){
- \usefont{T1}{phv}{m}{n}
- \fontsize{\RTTaskLabelSize}{\RTTaskLabelSize}
- \if\RTWriteSymbols\RTDefWriteSymbols\selectfont{$\RTTaskSymbol_{\arabic{myLabel}}$}
- \else\relax
- \fi
- }%
- \psaddtolength{\yy}{-3\sy}%
- \addtocounter{myLabel}{1}
- }%
- %% Horizontal axes
-
- \if\RTAxisInvisible\RTDefAxisInvisible
- \xx = \sx \xxx = \RTWindowLength \advance \xxx by -\sx
- \yy = 2\sy
- \multido{\n=0+1}{#2}{
- \psline{->}(\xx,\yy)(\xxx,\yy)
- \advance \yy by 3\sy
- }
- \fi
- }
-
-
-
- \def\@RTDefaultValues{%
- \setkeys{RT}{height}%
- \setkeys{RT}{width}%
- \setkeys{RT}{labelsize}%
- \setkeys{RT}{numbersize}%
- \setkeys{RT}{symbol}%
- \setkeys{RT}{fillstyle}%
- \setkeys{RT}{color}
- \setkeys{RT}{linecolor}%
- \setkeys{RT}{xscale}%
- \setkeys{RT}{nosymbols}%
- }
-
- \def\@RTExecDefaultValues{
- \setkeys{RT}{color}%
- \setkeys{RT}{execlabel}%
- \setkeys{RT}{linecolor}%
- }
-
- \def\RTGridEnd{
- \end{pspicture}%
- \@RTDefaultValues%
- }
-
- \def\endRTGrid{
- \end{pspicture}%
- \@RTDefaultValues%
- }
-
- \newcommand{\RTSet}[1]{
- \setkeys{RT}{#1}
- }
-
- \newcommand{\RTSetDefault}{
- \@RTDefaultValues
- }
-
- %% internal
- \newcommand{\@compute@xx}[1]{
- \xx = #1\sx
- \divide \xx by \RTXScale
- \advance \xx by \sx
- }
-
- \newcommand{\@compute@xxx}[1]{
- \xxx = #1\sx
- \divide \xxx by \RTXScale
- \advance \xxx by \sx
- }
-
- \newcommand{\@compute@yy}[1]{
- \yy = -3\sy \multiply \yy by #1
- \advance \yy by \hy
- }
-
- \newcommand{\DrawTaskAxis}[2][nocommand=1]{%
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \@compute@xx{0}
- \xxx = \RTWindowLength \advance \xxx by -\sx
- \psline[linecolor=\RTLineColor]{->}(\xx,\yy)(\xxx,\yy)%
- \@RTExecDefaultValues%
- }
-
- \newcommand{\DrawXYAxis}[3][nocommand=1]{%
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \@compute@xx{0}
- \xxx = \RTWindowLength \advance \xxx by -\sx
- \psline[linecolor=\RTLineColor]{->}(\xx,\yy)(\xxx,\yy)%
- \yyy = 3\sy \multiply \yyy by #3 \advance \yyy by \yy
- \advance \yyy by -\sy
- \psline[linecolor=\RTLineColor]{->}(\xx,\yy)(\xx,\yyy)%
- \@RTExecDefaultValues%
- }
-
- \newcommand{\FLine}[5][nocommand=1]{%
- \setkeys{RT}{#1}%
- \@compute@xx{#2}
- \@compute@xxx{#4}
- \yy = #3\sy \advance \yy by 2\sy
- \yyy = #5\sy \advance \yyy by 2\sy
- \psline[linecolor=\RTLineColor,linestyle=\RTLineStyle,linewidth=\RTLineWidth]{-}(\xx,\yy)(\xxx,\yyy)
- \@RTExecDefaultValues%
- }
-
- %% Task Arrival: draws an up arrow at the specified slot
- %% #1 : task number from 1 to n
- %% #2 : slot number from 0 to l-1
- \newcommand{\TaskArrival}[3][nocommand=1]{%
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \@compute@xx{#3}
- \yyy = \yy \advance \yyy by 2\sy%
- \psline[linecolor=\RTLineColor]{->}(\xx,\yy)(\xx,\yyy)%
- \@RTExecDefaultValues%
- }
-
- %% Task Arrival and deadline: draws an up arrow and a down arrow at the specified slots
- %% #1 : task number from 1 to n
- %% #2 : slot number from 0 to l-1
- %% #3 : relative deadline
- \newcommand{\TaskArrDead}[4][nocommand=1]{
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \@compute@xx{#3}
- \yyy = \yy \advance \yyy by 2\sy
- \psline[linecolor=\RTLineColor]{->}(\xx,\yy)(\xx,\yyy)
- \advance \xx by #4\sx
- \psline[linecolor=\RTLineColor]{->}(\xx,\yyy)(\xx,\yy)
- \@RTExecDefaultValues
- }
-
-
- %% Task Deadline: draws a down arrow at the specified slot
- %% #1 : task number from 1 to n
- %% #2 : slot number from 0 to l-1
- \newcommand{\TaskDeadline}[3][nocommand=1]{
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \@compute@xx{#3}
- \yyy = \yy \advance \yyy by 2\sy
- \psline[linecolor=\RTLineColor]{<-}(\xx,\yy)(\xx,\yyy)
- \@RTExecDefaultValues
- }
-
- \newcommand{\TaskExecution}[4][nocommand=1]{
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \@compute@xx{#3}
- \yyy = \yy \advance \yyy by \sy
- \@compute@xxx{#4}
- \psframe[fillstyle=\RTTaskFill,fillcolor=\RTTaskColor,linecolor=\RTLineColor](\xx,\yy)(\xxx,\yyy)
- \advance \xx by \xxx \xx = .5\xx
- \uput{2pt}[u](\xx,\yy){%
- \usefont{T1}{phv}{m}{n}%
- \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
- \selectfont{\RTExecLabel}%
- }
- \@RTExecDefaultValues
- }
-
- % Task Lock
- % par 1: task
- % par 2: time
- % par 3: resource
- %
- \newcommand{\TaskLock}[4][nocommand=1]{
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \@compute@xx{#3}
- \yyy = \yy \advance \yyy by \sy
- \uput{2pt}[u](\xx,\yyy){%
- \usefont{T1}{phv}{m}{n}%
- \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
- \selectfont{L(#4)}%
- }
- \@RTExecDefaultValues
- }
-
- % \TaskUnlock
- % par 1: task
- % par 2: time
- % par 3: resource
- %
- \newcommand{\TaskUnlock}[4][nocommand=1]{
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \@compute@xx{#3}
- \yyy = \yy \advance \yyy by \sy
- \uput{2pt}[u](\xx,\yyy){%
- \usefont{T1}{phv}{m}{n}%
- \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
- \selectfont{U(#4)}%
- }
- \@RTExecDefaultValues
- }
-
- %
- % par 1: number of vertical slot
- % par 2: time
- % par 3: label
- %
- \newcommand{\Label}[4][nocommand=1]{
- \setkeys{RT}{#1}%
- %\@compute@yy{#2}
- \@compute@xx{#3}
- \yy = -\sy \multiply \yy by #2
- \advance \yy by \hy
- \yyy = \yy \advance \yyy by \sy
- \uput{2pt}[u](\xx,\yyy){%
- \psshadowbox{
- \usefont{T1}{phv}{m}{n}%
- \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
- \selectfont{{#4}}}%
- }
- \@RTExecDefaultValues
- }
-
- %
- % par 1: higher priority task (from)
- % par 2: lower priority task (to)
- % par 3: time
- %
- \newcommand{\Inherit}[4][nocommand=1]{
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \@compute@xx{#4}
- \yyy = -3\sy \multiply \yyy by #3 \advance \yyy by \sy
- \advance \yyy by \hy \advance \yyy by -\sy % \RTWindowHeight
- \psline[linestyle=dashed,linewidth=1.5pt]{->}(\xx,\yy)(\xx,\yyy)
- \@RTExecDefaultValues
- }
-
- %
- % par 1: activating task (from)
- % par 2: signal start time
- % par 3: activated task (to)
- % par 4: signal arrival time
- %
- \newcommand{\Activation}[5][nocommand=1]{
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \@compute@xx{#3}
- \yyy = -3\sy \multiply \yyy by #4 %\advance \yyy by \sy
- \advance \yyy by \hy %\advance \yyy by -\sy %\RTWindowHeight
- \xxx = #5\sx \advance \xxx by \sx
- \psline[linestyle=dashed,linewidth=1pt]{->}(\xx,\yy)(\xxx,\yyy)
- }
-
- %
- % par 1: time1
- % par 2: time2
- %
- \newcommand{\RTBox}[3][nocommand=1]{
- \setkeys{RT}{#1}%
- \yy = 0cm
- \advance \yy by \hy
- \yyy = \sy
- \@compute@xx{#2}
- \@compute@xxx{#3}
- \psframe[fillstyle=crosshatch,hatchwidth=.2pt,hatchsep=2pt,hatchcolor=lightgray,linewidth=0pt,framearc=.2](\xx,\yy)(\xxx,\yyy)
- \@RTExecDefaultValues
- }
-
- % %
- % % par 1: task
- % % par 2: first instant (arrival)
- % % par 3: second instant (deadline)
- % %
- % \newcommand{\Interval}[4][nocommand=1]{
- % \setkeys{RT}{#1}%
- % \@compute@yy{#2}
- % \advance \yy by 2.5\sy
- % \@compute@xx{#3}
- % \@compute@xxx{#4}
- % % da cambiare con psarc
- % \pscurve*[linecolor=\RTLineColor]{-}(\xx,\yy)(\xxx,\yy)
- % \@RTExecDefaultValues
- % }
-
- \newcommand{\RowLabel}[3][nocommand=1]{
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \advance \yy by 1.5\sy
- \xx = \RTRowLabelOffset %\advance \xx by \sx
- \uput{4pt}[dl](-\xx,\yy){
- \usefont{T1}{phv}{m}{n}
- \fontsize{\RTTaskLabelSize}{\RTTaskLabelSize}
- \selectfont{#3}
- }%
- }
-
- \newcommand{\TaskExecDelta}[4][nocommand=1]{
- \setkeys{RT}{#1}%
- \@compute@yy{#2}
- \@compute@xx{#3}
- \yyy = \yy \advance \yyy by \sy
- %\@compute@xxx{#4}
- \xxx = \xx \advance \xxx by #4\sx
- \psframe[fillstyle=\RTTaskFill,fillcolor=\RTTaskColor,linecolor=\RTLineColor](\xx,\yy)(\xxx,\yyy)
- \advance \xx by \xxx \xx = .5\xx
- \uput{2pt}[u](\xx,\yy){%
- \usefont{T1}{phv}{m}{n}%
- \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
- \selectfont{\RTExecLabel}%
- }
- \@RTExecDefaultValues
- }
-
- \newcommand{\TaskRespTime}[4][nocommand=1]{
- \setkeys{RT}{#1}
- \@compute@yy{#2}
- \@compute@xx{#3}
- \yyy = \yy \advance \yyy by \sy
- \xxx = \xx \advance \xxx by #4\sx
- \psframe[fillstyle=crosshatch*,hatchcolor=white,
- hatchwidth=.4pt,hatchsep=1pt,
- linestyle=none,fillcolor=\RTTaskColor](\xx,\yy)(\xxx,\yyy)
- \@RTExecDefaultValues
- }
-
- \@ifclassloaded{beamer}{
- \renewcommand<>{\TaskArrival}[3][nocommand=1]{
- \only#4{\beameroriginal{\TaskArrival}[#1]{#2}{#3}}
- }
- \renewcommand<>{\TaskArrDead}[4][nocommand=1]{
- \only#5{\beameroriginal{\TaskArrDead}[#1]{#2}{#3}{#4}}
- }
- \renewcommand<>{\TaskDeadline}[3][nocommand=1]{
- \only#4{\beameroriginal{\TaskDeadline}[#1]{#2}{#3}}
- }
- \renewcommand<>{\TaskExecution}[4][nocommand=1]{
- \only#5{\beameroriginal{\TaskExecution}[#1]{#2}{#3}{#4}}
- }
- \renewcommand<>{\TaskExecDelta}[4][nocommand=1]{
- \only#5{\beameroriginal{\TaskExecDelta}[#1]{#2}{#3}{#4}}
- }
- \renewcommand<>{\TaskRespTime}[4][nocommand=1]{
- \only#5{\beameroriginal{\TaskRespTime}[#1]{#2}{#3}{#4}}
- }
- \renewcommand<>{\TaskLock}[4][nocommand=1]{
- \only#5{\beameroriginal{\TaskLock}[#1]{#2}{#3}{#4}}
- }
- \renewcommand<>{\TaskUnlock}[4][nocommand=1]{
- \only#5{\beameroriginal{\TaskUnlock}[#1]{#2}{#3}{#4}}
- }
- \renewcommand<>{\Label}[4][nocommand=1]{
- \only#5{\beameroriginal{\Label}[#1]{#2}{#3}{#4}}
- }
- \renewcommand<>{\Inherit}[4][nocommand=1]{
- \only#5{\beameroriginal{\Inherit}[#1]{#2}{#3}{#4}}
- }
- \renewcommand<>{\Activation}[5][nocommand=1]{
- \only#6{\beameroriginal{\Activation}[#1]{#2}{#3}{#4}{#5}}
- }
- \renewcommand<>{\RTBox}[3][nocommand=1]{
- \only#4{\beameroriginal{\RTBox}[#1]{#2}{#3}}
- }
- \renewcommand<>{\FLine}[5][nocommand=1]{
- \only#6{\beameroriginal{\FLine}[#1]{#2}{#3}{#4}{#5}}
- }
- }
- {\typeout{beamer not loaded}}
-
- \endinput
|