Style file for drawing timing diagrams in LaTeX, forked from https://github.com/glipari/rtsched
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

rtsched.sty 20KB

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