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

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