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 19KB

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