Style file for drawing timing diagrams in LaTeX, forked from https://github.com/glipari/rtsched
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rtsched.sty 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. %% rtsched.sty
  2. %% Copyright 2005 Giuseppe Lipari
  3. %% Copyright 2015 Antoine Bertout <bertout.antoine@gmail.com> Transition from PSTricks to TikZ/PGF.
  4. %% Copyright 2018 Clayton G. Hobbs <clay@lakeserv.net>
  5. % This work may be distributed and/or modified under the
  6. % conditions of the LaTeX Project Public License, either version 1.3
  7. % of this license or (at your option) any later version.
  8. % The latest version of this license is in
  9. % http://www.latex-project.org/lppl.txt
  10. % and version 1.3 or later is part of all distributions of LaTeX
  11. % version 2005/12/01 or later.
  12. %
  13. % This work has the LPPL maintenance status `maintained'.
  14. %
  15. % The Current Maintainer of this work is Giuseppe Lipari
  16. %
  17. % This work consists of the file rtsched.sty.
  18. \NeedsTeXFormat{LaTeX2e}[1995/12/01]
  19. \ProvidesPackage{rtsched}[2015/05/01]
  20. \typeout{'rtsched' style for Latex and TikZ/PGF}
  21. \typeout{Easily draw real-time schedules in TeX/Latex.}
  22. \typeout{(c) 2005, Giuseppe Lipari, Pisa, Italy (g.lipari@sssup.it)}
  23. \typeout{(c) 2015, Antoine Bertout (bertout.antoine@gmail.com)}
  24. \typeout{(c) 2018, Clayton G. Hobbs (clay@lakeserv.net)}
  25. \typeout{Version 2.1 (WIP)}
  26. \RequirePackage{tikz}
  27. \usetikzlibrary{shadows, patterns}
  28. \RequirePackage{keyval}
  29. \newcommand\rtfont{\usefont{T1}{phv}{m}{n}}
  30. \@ifpackagelater{pgf}{2008/01/15}
  31. {
  32. %pgf package date is 2008/01/15 or later
  33. }
  34. {
  35. %pgf package date is older than 2008/01/15
  36. \PackageError{rtsched}{%
  37. rtsched requires version 2.10 of pgf or greater\MessageBreak
  38. }{%
  39. Please update pgf to version 2.10 minimum!\MessageBreak
  40. \space \space Try typing \space \protect\pgfversion
  41. \space to print your current version of pgf.
  42. }
  43. }
  44. %%
  45. %% These can be changed at any time
  46. %%
  47. \def\RTWindowLength{10cm} % window length
  48. \def\RTWindowHeight{0} % window height
  49. \def\RTNullWindowHeight{0} % nullwindow height
  50. \def\RTTaskLabelSize{\normalsize} % font size the task label
  51. \def\RTNumberLabelSize{\normalsize} % font size of the number labels
  52. \def\RTDefTaskSymbol{\tau}
  53. \def\RTDefNumberOffset{0}
  54. \def\RTDefTaskFill{solid}
  55. \def\RTDefTaskColor{gray}
  56. \def\RTDefLineColor{black}
  57. \def\RTDefXScale{1}
  58. \def\RTDefWriteSymbols{0}
  59. \def\RTDefGridInvisible{0}
  60. \def\RTDefNumbersInvisible{0}
  61. \def\RTDefRowLabelOffset{0pt}
  62. \def\RTDefAxisInvisible{0}
  63. \def\RTDefLineWidth{1pt}
  64. \def\RTDefLineStyle{solid}
  65. \def\RTDefExecHeight{1}
  66. \def\RTArrowStyle{stealth}
  67. \def\RTTeeStyle{|}
  68. %arrow style for deadlines, arrivals and horizontal axes
  69. % -{Triangle 45}[length=x] with length is a more modern arrow style but requires arrows.meta tikz library (available on latest texlive but rarely up to date on linux distribution)
  70. %-stealth is a predefined more classical arrow style
  71. \def\RTDefEndInstance{0}
  72. \def\RTExecLabel{\ }
  73. \def\RTTaskSymbol{\RTDefTaskSymbol}
  74. \def\RTTaskFill{\RTDefTaskFill}
  75. \def\RTTaskColor{\RTDefTaskColor}
  76. \def\RTLineColor{\RTDefLineColor}
  77. \def\RTXScale{\RTDefXScale}
  78. \def\RTWriteSymbols{\RTDefWriteSymbols}
  79. \def\RTNumberOffset{\RTDefNumberOffset}
  80. \def\RTGridInvisible{\RTDefGridInvisible}
  81. \def\RTNumbersInvisible{\RTDefNumbersInvisible}
  82. \def\RTAxisInvisible{\RTDefAxisInvisible}
  83. \def\RTRowLabelOffset{\RTDefRowLabelOffset}
  84. \def\RTLineWidth{\RTDefLineWidth}
  85. \def\RTLineStyle{\RTDefLineStyle}
  86. \def\RTExecHeight{\RTDefExecHeight}
  87. \def\RTEndInstance{\RTDefEndInstance}
  88. \define@key{RT}{height}[\RTNullWindowHeight]{\def\RTWindowHeight{#1}}
  89. \define@key{RT}{width}[10]{\def\RTWindowLength{#1}}
  90. \define@key{RT}{labelsize}[\normalsize]{\def\RTTaskLabelSize{#1}}
  91. \define@key{RT}{numbersize}[\normalsize]{\def\RTNumberLabelSize{#1}}
  92. \define@key{RT}{color}[\RTDefTaskColor]{\def\RTTaskColor{#1}}
  93. \define@key{RT}{linecolor}[\RTDefLineColor]{\def\RTLineColor{#1}}
  94. \define@key{RT}{execlabel}[\ ]{\def\RTExecLabel{#1}}
  95. \define@key{RT}{fillstyle}[\RTDefTaskFill]{\def\RTTaskFill{#1}}
  96. \define@key{RT}{nocommand}{}
  97. \define@key{RT}{xscale}[\RTDefXScale]{\def\RTXScale{#1}}
  98. \define@key{RT}{symbol}[{\tau}]{\def\RTTaskSymbol{#1}}
  99. \define@key{RT}{nosymbols}[\RTDefWriteSymbols]{\def\RTWriteSymbols{#1}}
  100. \define@key{RT}{numoffset}[\RTDefNumberOffset]{\def\RTNumberOffset{#1}}
  101. \define@key{RT}{nogrid}[\RTDefGridInvisible]{\def\RTGridInvisible{#1}}
  102. \define@key{RT}{nonumbers}[\RTDefNumbersInvisible]{\def\RTNumbersInvisible{#1}}
  103. \define@key{RT}{labeloffset}[\RTDefRowLabelOffset]{\def\RTRowLabelOffset{#1}}
  104. \define@key{RT}{axis}[\RTDefAxisInvisible]{\def\RTAxisInvisible{#1}}
  105. \define@key{RT}{lw}[\RTDefLineWidth]{\def\RTLineWidth{#1}}
  106. \define@key{RT}{style}[\RTDefLineStyle]{\def\RTLineStyle{#1}}
  107. \define@key{RT}{exeheight}[\RTDefExecHeight]{\def\RTExecHeight{#1}}
  108. \define@key{RT}{end}[\RTDefEndInstance]{\def\RTEndInstance{#1}}
  109. %%
  110. %% temporaries
  111. \newdimen\sx % slot length
  112. \newdimen\sy % slot height
  113. \newdimen\hy % frame height
  114. \newdimen\xx % x position
  115. \newdimen\yy % y position
  116. \newdimen\xxx % x position
  117. \newdimen\yyy % y position
  118. \newdimen\xtmp % x position
  119. \newcount\nsx % number of horizontal slots
  120. \newcount\nsy % number of vertical slots
  121. \newcount\nhl % number of horizontal lines
  122. \newcount\nvl % number of vertical lines
  123. \newcount\ntasks % number of tasks
  124. \newcount\tmp % temp
  125. \newcounter{myLabel}
  126. \def\RTGrid{\@ifnextchar[\@mygrid@begin{\@mygrid@begin[]}}
  127. \def\RTGridBegin{\@ifnextchar[\@mygrid@begin{\@mygrid@begin[]}}
  128. \def\@mygrid@begin[#1]#2#3{\setkeys{RT}{#1}%
  129. %% get the number of tasks
  130. \ntasks = #2
  131. %% number of horizontal steps in the grid
  132. \nsx = #3 \advance \nsx by 2 %
  133. %% real length of the window (approx)
  134. \nvl = \nsx \advance \nvl by 1 %
  135. %% compute length of a step
  136. \sx = \RTWindowLength \divide \sx by \nsx %
  137. %% number of vertical steps in the grid
  138. \nsy = #2 \multiply \nsy by 3 \advance \nsy by 1 %
  139. %% compute length of a vertical step (if height is null, \sy is the
  140. %% same as \sx)
  141. \ifx\RTWindowHeight\RTNullWindowHeight%
  142. \sy = \sx%
  143. \hy = \sy \multiply \hy by \nsy %\advance \hy by \sy%
  144. \else
  145. \sy = \RTWindowHeight \divide \sy by \nsy %
  146. \hy = \RTWindowHeight %\advance \hy by \sy %
  147. \fi
  148. %% compute real height
  149. \nhl = \nsy \advance \nhl by 1 %
  150. \advance \nsy by -1 \advance \nsx by -1
  151. %% the picture
  152. \pgfdeclarelayer{foreground}
  153. \pgfsetlayers{main,foreground}
  154. \begin{tikzpicture}
  155. %% draw grid (if not invisible)
  156. \if\RTGridInvisible\RTDefGridInvisible
  157. \draw[lightgray, semithick] (0,0) grid[xstep = \sx,ystep=\sy ] (\RTWindowLength,\hy);
  158. %% draw border grid
  159. \draw [black, thick] (0,0) rectangle (\RTWindowLength,\hy);
  160. \else\relax
  161. \fi
  162. %% draw numbers (if not invisible)
  163. \if\RTNumbersInvisible\RTDefNumbersInvisible
  164. \foreach \i [evaluate = \i as \j using \i*\sx] in {0,...,#3}{
  165. \ifodd \i
  166. \else
  167. \pgfmathsetmacro\nbwithoffset{\i + \RTNumberOffset};
  168. \node[below, font=\RTNumberLabelSize \rtfont] at (\j +\sx , 0) {\pgfmathprintnumber[int trunc,/pgf/number format/assume math mode=true]{\nbwithoffset }};
  169. \fi
  170. }
  171. \else
  172. \relax
  173. \fi
  174. %% Task Names
  175. \if\RTWriteSymbols\RTDefWriteSymbols
  176. \foreach \i [evaluate = \i as \j using (\hy -3*\i*\sy)] in {0,...,\numexpr \ntasks - 1}{
  177. \pgfmathsetmacro\task{\i + 1};
  178. \node[below, font=\rtfont] at (-\sx , \j-\sy) {\RTTaskLabelSize $\RTTaskSymbol_{\pgfmathprintnumber[int trunc]{\task}}$};
  179. }
  180. \else\relax
  181. \fi
  182. %% Horizontal axes
  183. \if\RTAxisInvisible\RTDefAxisInvisible
  184. \begin{pgfonlayer}{foreground}
  185. \foreach \i [evaluate = \i as \j using (\hy -3*\i*\sy)] in {0,...,\numexpr \ntasks - 1}{
  186. \draw [very thick,-\RTArrowStyle] (\sx,\j-3*\sy) -- (\RTWindowLength - \sx,\j-3*\sy);
  187. }
  188. \end{pgfonlayer}
  189. \fi
  190. }
  191. \def\@RTDefaultValues{%
  192. \setkeys{RT}{height}%
  193. \setkeys{RT}{width}%
  194. \setkeys{RT}{labelsize}%
  195. \setkeys{RT}{numbersize}%
  196. \setkeys{RT}{symbol}%
  197. \setkeys{RT}{fillstyle}%
  198. \setkeys{RT}{color}
  199. \setkeys{RT}{linecolor}%
  200. \setkeys{RT}{xscale}%
  201. \setkeys{RT}{nosymbols}%
  202. \setkeys{RT}{end}%
  203. }
  204. \def\@RTExecDefaultValues{
  205. \setkeys{RT}{color}%
  206. \setkeys{RT}{execlabel}%
  207. \setkeys{RT}{linecolor}%
  208. \setkeys{RT}{end}%
  209. }
  210. \def\RTGridEnd{
  211. \end{tikzpicture}%
  212. \@RTDefaultValues%
  213. }
  214. \def\endRTGrid{
  215. \end{tikzpicture}%
  216. \@RTDefaultValues%
  217. }
  218. \newcommand{\RTSet}[1]{
  219. \setkeys{RT}{#1}
  220. }
  221. \newcommand{\RTSetDefault}{
  222. \@RTDefaultValues
  223. }
  224. %% internal
  225. \newcommand{\@compute@xx}[1]{
  226. \xx = #1\sx
  227. \divide \xx by \RTXScale
  228. \advance \xx by \sx
  229. }
  230. \newcommand{\@compute@xxx}[1]{
  231. \xxx = #1\sx
  232. \divide \xxx by \RTXScale
  233. \advance \xxx by \sx
  234. }
  235. \newcommand{\@compute@yy}[1]{
  236. \yy = -3\sy \multiply \yy by #1
  237. \advance \yy by \hy
  238. }
  239. \newcommand{\DrawTaskAxis}[2][nocommand=1]{%
  240. \setkeys{RT}{#1}%
  241. \@compute@yy{#2}
  242. \@compute@xx{0}
  243. \xxx = \RTWindowLength \advance \xxx by -\sx
  244. \draw [\RTLineColor,-\RTArrowStyle] (\xx,\yy) -- (\xx,\yyy);
  245. \@RTExecDefaultValues%
  246. }
  247. \newcommand{\DrawXYAxis}[3][nocommand=1]{%
  248. \setkeys{RT}{#1}%
  249. \@compute@yy{#2}
  250. \@compute@xx{0}
  251. \xxx = \RTWindowLength \advance \xxx by -\sx
  252. \draw [\RTLineColor,-\RTArrowStyle] (\xx,\yy) -- (\xxx,\yy);
  253. \yyy = 3\sy \multiply \yyy by #3 \advance \yyy by \yy
  254. \advance \yyy by -\sy
  255. \draw [\RTLineColor,-\RTArrowStyle] (\xx,\yy) -- (\xx,\yyy);
  256. \@RTExecDefaultValues%
  257. }
  258. \newcommand{\FLine}[5][nocommand=1]{%
  259. \setkeys{RT}{#1}%
  260. \@compute@xx{#2}
  261. \@compute@xxx{#4}
  262. \yy = #3\sy \advance \yy by 2\sy
  263. \yyy = #5\sy \advance \yyy by 2\sy
  264. \draw [\RTLineColor, line width=\RTLineWidth,\RTLineStyle] (\xx,\yy) -- (\xxx,\yyy);
  265. \@RTExecDefaultValues%
  266. }
  267. %
  268. % TaskArrival
  269. % Task arrival: draws an up arrow at the specified slot
  270. % par 1 : task number from 1 to n
  271. % par 2 : slot number from 0 to l-1
  272. \newcommand{\TaskArrival}[3][nocommand=1]{%
  273. \setkeys{RT}{#1}%
  274. \@compute@yy{#2}
  275. \@compute@xx{#3}
  276. \yyy = \yy \advance \yyy by 2\sy%
  277. \begin{pgfonlayer}{foreground}
  278. \draw [\RTLineColor, thick,-\RTArrowStyle] (\xx,\yy) -- (\xx,\yyy);
  279. \end{pgfonlayer}
  280. \@RTExecDefaultValues%
  281. }
  282. %
  283. % TaskNArrival
  284. % Task arrivals: draws periodically up arrows from the specified slot
  285. % par 1 : task number from 1 to n
  286. % par 2 : slot number from 0 to l-1
  287. % par 3 : period
  288. % par 4 : number of instances
  289. \newcommand{\TaskNArrival}[5][nocommand=1]{%
  290. \foreach \instance [evaluate = \instance as \activation using (#3 + \instance * #4)] in {0,...,\numexpr #5-1}{
  291. \TaskArrival[#1]{#2}{\activation}{#4}
  292. }
  293. }
  294. %
  295. % TaskArrDead
  296. % Task arrival and deadline: draws an up arrow and a down arrow at the specified slots
  297. % par 1 : task number from 1 to n
  298. % par 2 : slot number from 0 to l-1
  299. % par 3 : relative deadline
  300. \newcommand{\TaskArrDead}[4][nocommand=1]{
  301. \setkeys{RT}{#1}%
  302. \@compute@yy{#2}
  303. \@compute@xx{#3}
  304. \yyy = \yy \advance \yyy by 2\sy
  305. \begin{pgfonlayer}{foreground}
  306. \draw [\RTLineColor, thick,-\RTArrowStyle] (\xx,\yy) -- (\xx,\yyy);
  307. \end{pgfonlayer}
  308. \advance \xx by #4\sx
  309. \begin{pgfonlayer}{foreground}
  310. \draw [\RTLineColor, thick, -\RTArrowStyle] (\xx,\yyy) -- (\xx,\yy);
  311. \end{pgfonlayer}
  312. \@RTExecDefaultValues
  313. }
  314. %
  315. % TaskNArrDead
  316. % Task arrivals and deadlines: draws periodically up arrows and down arrows from the specified slots
  317. % par 1 : task number from 1 to n
  318. % par 2 : slot number from 0 to l-1
  319. % par 3 : relative deadline
  320. % par 4 : period
  321. % par 5 : number of instances
  322. \newcommand{\TaskNArrDead}[6][nocommand=1]{
  323. \foreach \instance [evaluate = \instance as \activation using (#3 + \instance * #5)] in {0,...,\numexpr #6-1}{
  324. \TaskArrDead[#1]{#2}{\activation}{#4}
  325. }
  326. }
  327. %
  328. % TaskCompletion
  329. % Task completion: draws a tee at the specified slot
  330. % par 1 : task number from 1 to n
  331. % par 2 : slot number from 0 to l-1
  332. \newcommand{\TaskCompletion}[3][nocommand=1]{
  333. \setkeys{RT}{#1}%
  334. \@compute@yy{#2}
  335. \@compute@xx{#3}
  336. \yyy = \yy \advance \yyy by 2\sy
  337. \begin{pgfonlayer}{foreground}
  338. \draw [\RTLineStyle, \RTLineColor, thick, -\RTTeeStyle] (\xx,\yy) -- (\xx,\yyy);
  339. \end{pgfonlayer}
  340. \@RTExecDefaultValues
  341. }
  342. %
  343. % TaskDeadline
  344. % Task deadline: draws a down arrow at the specified slot
  345. % par 1 : task number from 1 to n
  346. % par 2 : slot number from 0 to l-1
  347. \newcommand{\TaskDeadline}[3][nocommand=1]{
  348. \setkeys{RT}{#1}%
  349. \@compute@yy{#2}
  350. \@compute@xx{#3}
  351. \yyy = \yy \advance \yyy by 2\sy
  352. \begin{pgfonlayer}{foreground}
  353. \draw [\RTLineStyle, \RTLineColor, thick, \RTArrowStyle-] (\xx,\yy) -- (\xx,\yyy);
  354. \end{pgfonlayer}
  355. \@RTExecDefaultValues
  356. }
  357. %
  358. % TaskNDeadline
  359. % periodic task deadlines: draws periodically down arrows from the specified slot
  360. % par 1 : task number from 1 to n
  361. % par 2 : slot number from 0 to l-1
  362. % par 3 : period
  363. % par 4 : number of instances
  364. \newcommand{\TaskNDeadline}[5][nocommand=1]{%
  365. \foreach \instance [evaluate = \instance as \activation using (#3 + \instance * #4)] in {0,...,\numexpr #5-1}{
  366. \TaskDeadline[#1]{#2}{\activation}{#4}
  367. }
  368. }
  369. %
  370. % TaskExecution
  371. % Task execution: draws an execution from start time to finish time
  372. % par 1: task
  373. % par 2: start time
  374. % par 3: finish time
  375. \newcommand{\TaskExecution}[4][nocommand=1]{
  376. \setkeys{RT}{#1}%
  377. \@compute@yy{#2}
  378. \@compute@xx{#3}
  379. \yyy = \yy \advance \yyy by \RTExecHeight\sy
  380. \@compute@xxx{#4}
  381. \draw [fill=\RTTaskColor,\RTTaskFill,draw=\RTLineColor, thick] (\xx,\yy) rectangle (\xxx,\yyy);
  382. \advance \xx by \xxx \xx = .5\xx
  383. \advance \yy by .5\RTExecHeight\sy
  384. \draw (\xx,\yy) node[font=\rtfont] {\RTNumberLabelSize \RTExecLabel};%\RTNumberLabelSize
  385. \if\RTEndInstance\RTDefEndInstance
  386. \relax
  387. \else
  388. \begin{pgfonlayer}{foreground}
  389. \draw[\RTLineColor, fill] (\xxx,\yyy) circle (1.5pt);
  390. \end{pgfonlayer}
  391. \fi
  392. \@RTExecDefaultValues
  393. }
  394. %
  395. % Task Lock
  396. % par 1: task
  397. % par 2: time
  398. % par 3: resource
  399. %
  400. \newcommand{\TaskLock}[4][nocommand=1]{
  401. \setkeys{RT}{#1}%
  402. \@compute@yy{#2}
  403. \@compute@xx{#3}
  404. \yyy = \yy \advance \yyy by \sy
  405. \advance \yyy by .5\sy
  406. \node[font=\rtfont] at (\xx , \yyy) {\RTNumberLabelSize L(#4)}; %\RTNumberLabelSize
  407. \@RTExecDefaultValues
  408. }
  409. %
  410. % TaskUnlock
  411. % par 1: task
  412. % par 2: time
  413. % par 3: resource
  414. %
  415. \newcommand{\TaskUnlock}[4][nocommand=1]{
  416. \setkeys{RT}{#1}%
  417. \@compute@yy{#2}
  418. \@compute@xx{#3}
  419. \yyy = \yy \advance \yyy by \sy
  420. \advance \yyy by .5\sy
  421. \node[font=\rtfont] at (\xx , \yyy) {\RTNumberLabelSize U(#4)}; %\RTNumberLabelSize
  422. \@RTExecDefaultValues
  423. }
  424. %
  425. % Label
  426. % par 1: number of vertical slot
  427. % par 2: time
  428. % par 3: label
  429. %
  430. \newcommand{\Label}[4][nocommand=1]{
  431. \setkeys{RT}{#1}%
  432. %\@compute@yy{#2}
  433. \@compute@xx{#3}
  434. \yy = -\sy \multiply \yy by #2
  435. \advance \yy by \hy
  436. \yyy = \yy \advance \yyy by 2\sy %\yyy = \yy \advance \yyy by \sy
  437. \node[font=\rtfont, fill = white, draw=\RTLineColor, thin, drop shadow = {color = black}] at (\xx , \yyy) {\RTNumberLabelSize #4}; %\RTNumberLabelSize
  438. \@RTExecDefaultValues
  439. }
  440. %
  441. % Inherit
  442. % par 1: higher priority task (from)
  443. % par 2: lower priority task (to)
  444. % par 3: time
  445. %
  446. \newcommand{\Inherit}[4][nocommand=1]{
  447. \setkeys{RT}{#1}%
  448. \@compute@yy{#2}
  449. \@compute@xx{#4}
  450. \yyy = -3\sy \multiply \yyy by #3 \advance \yyy by \sy
  451. \advance \yyy by \hy \advance \yyy by -\sy % \RTWindowHeight
  452. \begin{pgfonlayer}{foreground}
  453. \draw [dashed, thick,-\RTArrowStyle] (\xx,\yy) -- (\xx,\yyy);
  454. \end{pgfonlayer}
  455. \@RTExecDefaultValues
  456. }
  457. %
  458. % Activation
  459. % par 1: activating task (from)
  460. % par 2: signal start time
  461. % par 3: activated task (to)
  462. % par 4: signal arrival time
  463. \newcommand{\Activation}[5][nocommand=1]{
  464. \setkeys{RT}{#1}%
  465. \@compute@yy{#2}
  466. \@compute@xx{#3}
  467. \yyy = -3\sy \multiply \yyy by #4 %\advance \yyy by \sy
  468. \advance \yyy by \hy %\advance \yyy by -\sy %\RTWindowHeight
  469. \xxx = #5\sx \advance \xxx by \sx
  470. \begin{pgfonlayer}{foreground}
  471. \draw [dashed, thick,-\RTArrowStyle] (\xx,\yy) -- (\xxx,\yyy);
  472. \end{pgfonlayer}
  473. }
  474. %
  475. % RTBox
  476. % par 1: time1
  477. % par 2: time2
  478. %
  479. \newcommand{\RTBox}[3][nocommand=1]{
  480. \setkeys{RT}{#1}%
  481. \yy = 0cm
  482. \advance \yy by \hy
  483. \yyy = 0cm % \yyy = \sy
  484. \@compute@xx{#2}
  485. \@compute@xxx{#3}
  486. \draw [pattern color=lightgray, draw=\RTLineColor, pattern=crosshatch, rounded corners, thin](\xx,\yy) rectangle (\xxx,\yyy);
  487. \@RTExecDefaultValues
  488. }
  489. %
  490. % TaskInterval : specify an interval with an horizontal double arrow
  491. % par 1: task
  492. % par 2: start time
  493. % par 3: finish time
  494. % par 4: label
  495. \newcommand{\TaskInterval}[5][nocommand=1]{
  496. \setkeys{RT}{#1}
  497. \@compute@yy{#2}
  498. \@compute@xx{#3}
  499. \@compute@xxx{#4}
  500. \advance \yy by .5\sy
  501. \draw [\RTLineColor, thick, \RTArrowStyle-\RTArrowStyle] (\xx,\yy) -- (\xxx,\yy);
  502. \advance \xx by \xxx \xx = .5\xx
  503. %\advance \yy by .5\RTExecHeight\sy
  504. \draw (\xx,\yy) node[above,font=\rtfont] {\RTTaskLabelSize #5};%
  505. \@RTExecDefaultValues
  506. }
  507. % TaskEnd
  508. % Task end: draws a circle, typically to indicate job termination
  509. % (see also the end key in \TaskExecDelta and \TaskExecution)
  510. % par 1: task number from 1 to n
  511. % par 2: slot number from 0 to l-1
  512. \newcommand{\TaskEnd}[3][nocommand=1]{%
  513. \setkeys{RT}{#1}%
  514. \@compute@yy{#2}
  515. \@compute@xx{#3}
  516. \yyy = \yy \advance \yyy by \sy%
  517. \begin{pgfonlayer}{foreground}
  518. \draw[\RTLineColor, fill=\RTTaskColor] (\xx,\yyy) circle (1.5pt);
  519. \end{pgfonlayer}
  520. \@RTExecDefaultValues%
  521. }
  522. %
  523. % TaskNEnd
  524. % Task ends: draws periodically a circle when the job terminates
  525. % par 1 : task number from 1 to n
  526. % par 2 : slot number from 0 to l-1
  527. % par 3 : period
  528. % par 4 : number of instances
  529. \newcommand{\TaskNEnd}[5][nocommand=1]{%
  530. \foreach \instance [evaluate = \instance as \activation using (#3 + \instance * #4)] in {0,...,\numexpr #5-1}{
  531. \TaskEnd[#1]{#2}{\activation}{#4}
  532. }
  533. }
  534. %% %
  535. % % par 1: task
  536. % % par 2: first instant (arrival)
  537. % % par 3: second instant (deadline)
  538. % %
  539. % \newcommand{\Interval}[4][nocommand=1]{
  540. % \setkeys{RT}{#1}%
  541. % \@compute@yy{#2}
  542. % \advance \yy by 2.5\sy
  543. % \@compute@xx{#3}
  544. % \@compute@xxx{#4}
  545. % % da cambiare con psarc
  546. % \pscurve*[linecolor=\RTLineColor]{-}(\xx,\yy)(\xxx,\yy)
  547. % \@RTExecDefaultValues
  548. % }
  549. %
  550. %
  551. % RowLabel
  552. % par 1: task
  553. % par 2: label
  554. %
  555. \newcommand{\RowLabel}[3][nocommand=1]{
  556. \setkeys{RT}{#1}%
  557. \@compute@yy{#2}
  558. \advance \yy by 2\sy
  559. \xx = \RTRowLabelOffset %\advance \xx by \sx
  560. \node[below left,font=\rtfont] at (-\xx , \yy) {\RTTaskLabelSize #3};%\RTTaskLabelSize
  561. }
  562. %
  563. % TaskExecDelta
  564. % Task execution delta: draws an execution from start time during delta time
  565. % par 1: task
  566. % par 2: start time
  567. % par 3: delta
  568. %
  569. \newcommand{\TaskExecDelta}[4][nocommand=1]{
  570. \setkeys{RT}{#1}%
  571. \@compute@yy{#2}
  572. \@compute@xx{#3}
  573. \yyy = \yy \advance \yyy by \RTExecHeight \sy
  574. %\@compute@xxx{#4}
  575. \xxx = \xx \advance \xxx by #4\sx
  576. \draw [fill=\RTTaskColor,\RTTaskFill,draw=\RTLineColor, thick] (\xx,\yy) rectangle (\xxx,\yyy);
  577. \advance \xx by \xxx \xx = .5\xx
  578. \draw (\xx,\yy) node[above, font=\rtfont] {\RTTaskLabelSize \RTExecLabel}; %\RTNumberLabelSize
  579. \if\RTEndInstance\RTDefEndInstance
  580. \relax
  581. \else
  582. \begin{pgfonlayer}{foreground}
  583. \draw[\RTLineColor, fill] (\xxx,\yyy) circle (1.5pt);
  584. \end{pgfonlayer}
  585. \fi
  586. \@RTExecDefaultValues
  587. }
  588. %
  589. % TaskNExecDelta
  590. % Task execution deltas: draws periodically executions from start time during delta time
  591. % par 1: task
  592. % par 2: start time
  593. % par 3: delta
  594. % par 4: period
  595. % par 5: number of instances
  596. \newcommand{\TaskNExecDelta}[6][nocommand=1]{
  597. \foreach \instance [evaluate = \instance as \activation using (#3 + \instance * #5)] in {0,...,\numexpr #6-1}{
  598. \TaskExecDelta[#1]{#2}{\activation}{#4}
  599. }
  600. }
  601. %
  602. % TaskRespTime
  603. % par 1: task
  604. % par 2: start time
  605. % par 3: finish time
  606. %
  607. \newcommand{\TaskRespTime}[4][nocommand=1]{
  608. \setkeys{RT}{#1}
  609. \@compute@yy{#2}
  610. \@compute@xx{#3}
  611. \yyy = \yy \advance \yyy by \sy
  612. \xxx = \xx \advance \xxx by #4\sx
  613. \draw [pattern color=\RTTaskColor,draw=\RTLineColor, pattern=crosshatch, thin] (\xx,\yy) rectangle (\xxx,\yyy);
  614. \@RTExecDefaultValues
  615. }
  616. \@ifclassloaded{beamer}{
  617. \renewcommand<>{\TaskArrival}[3][nocommand=1]{
  618. \only#4{\beameroriginal{\TaskArrival}[#1]{#2}{#3}}
  619. }
  620. \renewcommand<>{\TaskNArrival}[5][nocommand=1]{
  621. \only#6{\beameroriginal{\TaskNArrival}[#1]{#2}{#3}{#4}{#5}}
  622. }
  623. \renewcommand<>{\TaskArrDead}[4][nocommand=1]{
  624. \only#5{\beameroriginal{\TaskArrDead}[#1]{#2}{#3}{#4}}
  625. }
  626. \renewcommand<>{\TaskNArrDead}[6][nocommand=1]{
  627. \only#7{\beameroriginal{\TaskNArrDead}[#1]{#2}{#3}{#4}{#5}{#6}}
  628. }
  629. \renewcommand<>{\TaskDeadline}[3][nocommand=1]{
  630. \only#4{\beameroriginal{\TaskDeadline}[#1]{#2}{#3}}
  631. }
  632. \renewcommand<>{\TaskNDeadline}[5][nocommand=1]{
  633. \only#6{\beameroriginal{\TaskNDeadline}[#1]{#2}{#3}{#4}{#5}}
  634. }
  635. \renewcommand<>{\TaskExecution}[4][nocommand=1]{
  636. \only#5{\beameroriginal{\TaskExecution}[#1]{#2}{#3}{#4}}
  637. }
  638. \renewcommand<>{\TaskExecDelta}[4][nocommand=1]{
  639. \only#5{\beameroriginal{\TaskExecDelta}[#1]{#2}{#3}{#4}}
  640. }
  641. \renewcommand<>{\TaskExecDeltaEnd}[4][nocommand=1]{
  642. \only#5{\beameroriginal{\TaskExecDeltaEnd}[#1]{#2}{#3}{#4}}
  643. }
  644. \renewcommand<>{\TaskNExecDelta}[6][nocommand=1]{
  645. \only#7{\beameroriginal{\TaskNExecDelta}[#1]{#2}{#3}{#4}{#5}{#6}}
  646. }
  647. \renewcommand<>{\TaskRespTime}[4][nocommand=1]{
  648. \only#5{\beameroriginal{\TaskRespTime}[#1]{#2}{#3}{#4}}
  649. }
  650. \renewcommand<>{\TaskLock}[4][nocommand=1]{
  651. \only#5{\beameroriginal{\TaskLock}[#1]{#2}{#3}{#4}}
  652. }
  653. \renewcommand<>{\TaskUnlock}[4][nocommand=1]{
  654. \only#5{\beameroriginal{\TaskUnlock}[#1]{#2}{#3}{#4}}
  655. }
  656. \renewcommand<>{\Label}[4][nocommand=1]{
  657. \only#5{\beameroriginal{\Label}[#1]{#2}{#3}{#4}}
  658. }
  659. \renewcommand<>{\Inherit}[4][nocommand=1]{
  660. \only#5{\beameroriginal{\Inherit}[#1]{#2}{#3}{#4}}
  661. }
  662. \renewcommand<>{\Activation}[5][nocommand=1]{
  663. \only#6{\beameroriginal{\Activation}[#1]{#2}{#3}{#4}{#5}}
  664. }
  665. \renewcommand<>{\RTBox}[3][nocommand=1]{
  666. \only#4{\beameroriginal{\RTBox}[#1]{#2}{#3}}
  667. }
  668. \renewcommand<>{\FLine}[5][nocommand=1]{
  669. \only#6{\beameroriginal{\FLine}[#1]{#2}{#3}{#4}{#5}}
  670. }
  671. \renewcommand<>{\TaskInterval}[5][nocommand=1]{
  672. \only#6{\beameroriginal{\TaskInterval}[#1]{#2}{#3}{#4}{#5}}
  673. }
  674. \renewcommand<>{\TaskEnd}[3][nocommand=1]{
  675. \only#4{\beameroriginal{\TaskEnd}[#1]{#2}{#3}}
  676. }
  677. \renewcommand<>{\TaskNEnd}[5][nocommand=1]{
  678. \only#6{\beameroriginal{\TaskNEnd}[#1]{#2}{#3}{#4}{#5}}
  679. }
  680. }
  681. {\typeout{beamer not loaded}}
  682. \endinput