Explorar el Código

Merge pull request #1 from abertout/master

use of TikZ/PGF instead of pstrics
Giuseppe Lipari hace 9 años
padre
commit
04c7c84040
Se han modificado 4 ficheros con 219 adiciones y 182 borrados
  1. 3
    3
      README.md
  2. 2
    1
      rtsched-beamer-doc.tex
  3. 51
    55
      rtsched-doc.tex
  4. 163
    123
      rtsched.sty

+ 3
- 3
README.md Ver fichero

@@ -3,14 +3,14 @@
3 3
 =========================================
4 4
 
5 5
 Author:  Giuseppe Lipari (g.lipari@sssup.it)
6
-Version: 1.1
7
-Date:    2013/01/11
6
+Version: 2.0
7
+Date:    2015/05/01
8 8
 
9 9
 This package contains the rtsched package for drawing GANTT charts
10 10
 (chronograms). The package can be useful for drawing real-time timing
11 11
 diagrams in LaTeX, as often needs to be done for preparing articles,
12 12
 lectures and presentation in the Real-Time Scheduling research
13
-community. The package depends on keyval, multido and pstricks.
13
+community. The package depends on keyval and TikZ/PGF.
14 14
 
15 15
 A more complete documentation, with a set of examples, is available in
16 16
 file rtsched-doc.pdf.

+ 2
- 1
rtsched-beamer-doc.tex Ver fichero

@@ -1,8 +1,9 @@
1
-\documentclass[dvips]{beamer}
1
+\documentclass{beamer}
2 2
 
3 3
 \usepackage{rtsched}
4 4
 \usepackage[english]{babel}
5 5
 \usepackage[latin1]{inputenc}
6
+\usepackage{multido}
6 7
 
7 8
 \title{An example of using the \texttt{rtsched} package with Beamer}
8 9
 \author{Giuseppe Lipari}

+ 51
- 55
rtsched-doc.tex Ver fichero

@@ -2,8 +2,9 @@
2 2
 
3 3
 \usepackage{rtsched}
4 4
 \usepackage{url}
5
+\usepackage{multido}
5 6
 
6
-\title{The \texttt{rtsched} package for \LaTeX \\ (version 1.0)}
7
+\title{The \texttt{rtsched} package for \LaTeX \\ (version 2.0)}
7 8
 \author{Giuseppe Lipari}
8 9
 
9 10
 \begin{document}
@@ -18,19 +19,12 @@ In this document, I give an overview of the \texttt{rtsched} \LaTeX
18 19
 package, which can be used to easily draw chronograms (GANTT charts).
19 20
 These diagrams are quite common in real-time scheduling research.
20 21
 
21
-The package depends on keyval, multido and pstricks, all widely
22
+The package depends on keyval and TikZ/PGF, both widely
22 23
 available on any \TeX distribution.
23 24
 
24
-The drawing capabilities are completely based on the PSTricks: for
25
-this reason, it may not be safe to use \texttt{pdfLaTeX} to compile a
26
-document that uses the \texttt{rtsched} package, due to the fact that
27
-at the time of this writing, PSTricks is not well supported by
28
-pdfLatex. If you want to produce pdf files (for example for making
29
-slides with Beamer), consider using the following compilation chain:
30
-
31
-\begin{verbatim}
32
-latex doc.tex && dvips doc.dvi && ps2pdf doc.ps 
33
-\end{verbatim}
25
+The drawing capabilities are completely based on TikZ. Thus, you can compile
26
+ a document that uses \texttt{rtsched} package with modern tools producing pdf document
27
+as \texttt{pdfLaTeX}, \texttt{XeLaTeX} or \texttt{LuaLaTeX}.
34 28
 
35 29
 As said, the style works also with Beamer, and it is also possible to
36 30
 use animations.
@@ -73,12 +67,12 @@ using the following commands:
73 67
 \TaskArrDeadl{i}{t}{reld}
74 68
 \end{verbatim}
75 69
 \noindent where \texttt{i} is the task index (from 1 to \texttt{n}
76
-included), \texttt{t} is the arival time, and \texttt{reld} is the
70
+included), \texttt{t} is the arrival time, and \texttt{reld} is the
77 71
 relative deadline; an absolute deadline will be drawn at \texttt{t +
78 72
   reld}.
79 73
 
80 74
 In this example there are a lot of repetitions. These can be avoided
81
-if you use the \texttt{multido} macro, as shown in the example of
75
+if you use the \texttt{multido} macro from the \texttt{multido} package, as shown in the example of
82 76
 Figure \ref{fig:ex1a}.
83 77
 
84 78
 To draw the execution rectangle, you can use the following command:
@@ -95,7 +89,7 @@ arrows, and how to specify offsets. Finally, in Figure \ref{fig:ex1c}
95 89
 you can see an example with 2 tasks with relative deadlines different
96 90
 from periods (the so-called \emph{constrained deadline tasks}).
97 91
 
98
-\begin{figure}[h]
92
+\begin{figure}[!htbp]
99 93
   \centering
100 94
   % 2 tasks, for 20 units of time
101 95
   % we specify the width (10cm is the default
@@ -163,17 +157,17 @@ from periods (the so-called \emph{constrained deadline tasks}).
163 157
   \label{fig:ex1}
164 158
 \end{figure}
165 159
 
166
-\begin{figure}[h]
160
+\begin{figure}[!htbp]
167 161
   \centering
168 162
   \begin{RTGrid}{2}{20}
169 163
     \multido{\n=0+4}{5}{        % 5 instances of period 4 
170
-      \TaskArrDead{1}{\n}{4}    % draw the arrival and deadline
171
-      \TaskExecDelta{1}{\n}{1}  % draw execution (highest priority), 
164
+      \TaskArrDead{1}{\n}{4}    % draws the arrival and deadline
165
+      \TaskExecDelta{1}{\n}{1}  % draws execution (highest priority), 
172 166
                                 % from \n to \n+1
173 167
     }
174 168
  
175 169
     \multido{\n=0+6}{3}{        % 3 instances of period 6 
176
-      \TaskArrDead{2}{\n}{6}    % draw the arrival and deadline
170
+      \TaskArrDead{2}{\n}{6}    % draws the arrival and deadline
177 171
     }
178 172
     % no simple formula for lowest priority, sorry!
179 173
     \TaskExecution{2}{1}{4}
@@ -185,13 +179,13 @@ from periods (the so-called \emph{constrained deadline tasks}).
185 179
 \begin{verbatim}
186 180
   \begin{RTGrid}{2}{20}
187 181
     \multido{\n=0+4}{5}{        % 4 instances of period 4 
188
-      \TaskArrDead{1}{\n}{4}    % draw the arrival and deadline
189
-      \TaskExecDelta{1}{\n}{1}  % draw execution (highest priority), 
182
+      \TaskArrDead{1}{\n}{4}    % draws the arrival and deadline
183
+      \TaskExecDelta{1}{\n}{1}  % draws execution (highest priority), 
190 184
                                 % from \n to \n+1
191 185
     }
192 186
  
193 187
     \multido{\n=0+6}{3}{        % 3 instances of period 6 
194
-      \TaskArrDead{2}{\n}{6}    % draw the arrival and deadline
188
+      \TaskArrDead{2}{\n}{6}    % draws the arrival and deadline
195 189
     }
196 190
     % no simple formula for lowest priority, sorry!
197 191
     \TaskExecution{2}{1}{4}
@@ -204,24 +198,24 @@ from periods (the so-called \emph{constrained deadline tasks}).
204 198
   \label{fig:ex1a}
205 199
 \end{figure}
206 200
 
207
-\begin{figure}[h]
201
+\begin{figure}[!htbp]
208 202
   \centering
209 203
   \begin{RTGrid}{3}{14}
210 204
     \multido{\n=0+3}{4}{        % 4 instances of period 3, starting from 0 
211
-      \TaskArrival{1}{\n}       % draw only the arrival
212
-      \TaskExecDelta{1}{\n}{1}  % draw execution (highest priority), 
205
+      \TaskArrival{1}{\n}       % draws only the arrival
206
+      \TaskExecDelta{1}{\n}{1}  % draws execution (highest priority), 
213 207
                                 % from \n to \n+1
214 208
     }
215 209
  
216 210
     \multido{\n=3+4}{3}{        % 3 instances of period 4, starting from 3 
217
-      \TaskArrival{2}{\n}       % draw only the arrival
211
+      \TaskArrival{2}{\n}       % draws only the arrival
218 212
     }
219 213
     \TaskExecDelta{2}{4}{1}
220 214
     \TaskExecDelta{2}{7}{1}
221 215
     \TaskExecDelta{2}{11}{1}
222 216
 
223 217
     \multido{\n=1+5}{3}{        % 3 instances of period 5, starting from 1 
224
-      \TaskArrival{3}{\n}       % draw only the arrival
218
+      \TaskArrival{3}{\n}       % draws only the arrival
225 219
     }
226 220
     \TaskExecDelta{3}{1}{1}
227 221
     \TaskExecDelta{3}{8}{1}
@@ -231,19 +225,19 @@ from periods (the so-called \emph{constrained deadline tasks}).
231 225
 \begin{verbatim}
232 226
   \begin{RTGrid}{3}{14}
233 227
     \multido{\n=0+3}{4}{        % 4 instances of period 3 
234
-      \TaskArrival{1}{\n}       % draw only the arrival
235
-      \TaskExecDelta{1}{\n}{1}} % draw execution (highest priority), 
228
+      \TaskArrival{1}{\n}       % draws only the arrival
229
+      \TaskExecDelta{1}{\n}{1}} % draws execution (highest priority), 
236 230
                                 % from \n to \n+1
237 231
  
238 232
     \multido{\n=3+4}{3}{        % 3 instances of period 4, starting from 3 
239
-      \TaskArrival{2}{\n}}      % draw only the arrival
233
+      \TaskArrival{2}{\n}}      % draws only the arrival
240 234
 
241 235
     \TaskExecDelta{2}{4}{1}
242 236
     \TaskExecDelta{2}{7}{1}
243 237
     \TaskExecDelta{2}{11}{1}
244 238
 
245 239
     \multido{\n=1+5}{3}{        % 3 instances of period 5, starting from 1 
246
-      \TaskArrival{3}{\n}}      % draw only the arrival
240
+      \TaskArrival{3}{\n}}      % draws only the arrival
247 241
 
248 242
     \TaskExecDelta{3}{1}{1}
249 243
     \TaskExecDelta{3}{8}{1}
@@ -254,7 +248,7 @@ from periods (the so-called \emph{constrained deadline tasks}).
254 248
   \label{fig:ex1b}
255 249
 \end{figure}
256 250
 
257
-\begin{figure}[h]
251
+\begin{figure}[!htbp]
258 252
   \centering
259 253
   \begin{RTGrid}[width=8cm]{2}{15}
260 254
     \multido{\n=0+6}{3}{
@@ -280,13 +274,13 @@ style. An example is in Figure~\ref{fig:resp-time} that uses command
280 274
   \centering
281 275
   \begin{RTGrid}{2}{20}
282 276
     \multido{\n=0+4}{5}{        % 5 instances of period 4 
283
-      \TaskArrDead{1}{\n}{4}    % draw the arrival and deadline
284
-      \TaskExecDelta{1}{\n}{1}  % draw execution (highest priority), 
277
+      \TaskArrDead{1}{\n}{4}    % draws the arrival and deadline
278
+      \TaskExecDelta{1}{\n}{1}  % draws execution (highest priority), 
285 279
                                 % from \n to \n+1
286 280
     }
287 281
  
288 282
     \multido{\n=0+6}{3}{        % 3 instances of period 6 
289
-      \TaskArrDead{2}{\n}{6}    % draw the arrival and deadline
283
+      \TaskArrDead{2}{\n}{6}    % draws the arrival and deadline
290 284
     }
291 285
 
292 286
     \TaskRespTime{2}{0}{4}
@@ -305,11 +299,11 @@ style. An example is in Figure~\ref{fig:resp-time} that uses command
305 299
     \multido{\n=0+6}{3}{        
306 300
       \TaskArrDead{2}{\n}{6}}
307 301
 
308
-    \TaskRespTime{2}{0}{4}   % draws the hatched rectangle in [0,4]
309
-    \TaskExecution{2}{1}{4}  % draws execution (over the previous rectangle)
310
-    \TaskRespTime{2}{6}{4}   % draws the hatched rectangle in [6,10]
311
-    \TaskExecution{2}{6}{8}  % draws execution
312
-    \TaskExecution{2}{9}{10} % draws execution
302
+    \TaskRespTime{2}{0}{4}    % draws the hatched rectangle in [0,4]
303
+    \TaskExecution{2}{1}{4}   % draws execution (over the previous rectangle)
304
+    \TaskRespTime{2}{6}{4}    % draws the hatched rectangle in [6,10]
305
+    \TaskExecution{2}{6}{8}   % draws execution
306
+    \TaskExecution{2}{9}{10}  % draws execution
313 307
     \TaskRespTime{2}{12}{4}   % draws the hatched rectangle in [12,16]
314 308
     \TaskExecution{2}{13}{16} % draws execution   
315 309
   \end{RTGrid}  
@@ -322,10 +316,10 @@ style. An example is in Figure~\ref{fig:resp-time} that uses command
322 316
 \subsection{Controlling visualization}
323 317
 
324 318
 It is possible to specify many options in the \texttt{RTGrid}
325
-environment.  Maybe you don't like the grid: then, you can decide to
319
+environment. Maybe you don't like the grid: then, you can decide to
326 320
 not visualise it as in Figure \ref{fig:ex2}, where we also removed the
327 321
 task symbols.
328
-\begin{figure}[h]
322
+\begin{figure}[!htbp]
329 323
   \centering
330 324
   %% no grid and no symbols
331 325
   \begin{RTGrid}[nogrid=1,nosymbols=1]{2}{20}
@@ -361,16 +355,17 @@ The next figure \ref{fig:ex2a} uses different task symbols, does not
361 355
 show the numbers on the time line, and the color of the boxes that
362 356
 denote the execution of the second instance of the second task are
363 357
 changed to red. Also, I am changing the width, so the figure looks
364
-smaller.
358
+smaller. Notice that you can directly specify colors using the TikZ
359
+ way (color!percentage for example).
365 360
 
366
-\begin{figure}[h]
361
+\begin{figure}[!htbp]
367 362
   \centering
368 363
   %% specify 1) no numbers on the time line, 2) a different symbol, 3)
369
-  %% a different size of the symbol (default is 8pt).
364
+  %% a different size of the symbol using latex size commands (default is \normalsize).
370 365
   %% Notice that you should not use the math mode in the
371 366
   %% specification of the symbol, as the symbol is already used in a
372 367
   %% math environment inside the macro
373
-  \begin{RTGrid}[width=8cm,symbol=\gamma,nonumbers=1,labelsize=11pt]{2}{20}
368
+  \begin{RTGrid}[width=8cm,symbol=\gamma,nonumbers=1,labelsize=\small]{2}{20}
374 369
     \multido{\n=0+4}{5}{         
375 370
       \TaskArrDead{1}{\n}{4}    
376 371
       \TaskExecDelta{1}{\n}{1}}
@@ -381,17 +376,17 @@ smaller.
381 376
     \TaskExecution[linecolor=cyan,color=white]{2}{1}{4}
382 377
     %% the next two boxes are filled with red instead of gray
383 378
     \TaskExecution[color=red]{2}{6}{8}
384
-    \TaskExecution[color=red]{2}{9}{10}
379
+    \TaskExecution[color=red!50]{2}{9}{10}
385 380
     \TaskExecution{2}{13}{16}        
386 381
   \end{RTGrid}
387 382
 
388 383
 \begin{verbatim}
389 384
   %% specify 1) no numbers on the time line, 2) a different symbol, 3)
390
-  %% a different size of the symbol (default is 8pt).
385
+  %% a different size of the symbol (default is \normalsize).
391 386
   %% Notice that you should not use the math mode in the
392 387
   %% specification of the symbol, as the symbol is already used in a
393 388
   %% math environment inside the macro
394
-  \begin{RTGrid}[symbol=\gamma,nonumbers=1,labelsize=11pt]{2}{20}
389
+  \begin{RTGrid}[symbol=\gamma,nonumbers=1,labelsize=\Large]{2}{20}
395 390
     \multido{\n=0+4}{5}{         
396 391
       \TaskArrDead{1}{\n}{4}    
397 392
       \TaskExecDelta{1}{\n}{1}}
@@ -406,7 +401,7 @@ smaller.
406 401
     \TaskExecution{2}{13}{16}        
407 402
   \end{RTGrid}
408 403
 \end{verbatim}
409
-  \caption{Different symbols (with size 11pt), no numbers, a different
404
+  \caption{Different symbols (with \textbackslash Large size), no numbers, a different
410 405
     task color}
411 406
   \label{fig:ex2a}
412 407
 \end{figure}
@@ -420,7 +415,7 @@ which writes the \texttt{label} at the specified row (index 1 stays at
420 415
 the top). Here we show also how to specify an arbitrary starting
421 416
 number in the time line, using the \texttt{numoffset=12} option.
422 417
 
423
-\begin{figure}[h]
418
+\begin{figure}[!htbp]
424 419
   \centering
425 420
   %% specify 1) no numbers on the time line, 2) number starting from
426 421
   %% 12
@@ -466,7 +461,7 @@ number in the time line, using the \texttt{numoffset=12} option.
466 461
 % In the last example (Figure \ref{fig:ex2c}), we show an empty grid in
467 462
 % which we specify width and height.
468 463
 
469
-% \begin{figure}[h]
464
+% \begin{figure}[!htbp]
470 465
 %   \centering
471 466
 %   %% 3 tasks, 10 units of time
472 467
 %   \begin{RTGrid}[width=12cm, height=4cm]{3}{10}
@@ -506,7 +501,7 @@ to highlight a portion of the schedule with \texttt{RTBox}:
506 501
 \RTBox{t1}{t2}
507 502
 \end{verbatim}
508 503
 
509
-\begin{figure}[h]
504
+\begin{figure}[!htbp]
510 505
   \centering
511 506
   \begin{RTGrid}{2}{20}
512 507
     \RTBox{12}{16}
@@ -535,8 +530,9 @@ to highlight a portion of the schedule with \texttt{RTBox}:
535 530
 \end{figure}
536 531
 
537 532
 Notice that the order with which the objects are drawn is exactly the
538
-same as the order in which they are specified in the code. For
539
-example, in Figure \ref{fig:ex3a}, the executions of all the tasks are
533
+same as the order in which they are specified in the code, excepted 
534
+for horizontal axes, arrivals and deadlines that are always drawn on the foreground.
535
+ For example, in Figure \ref{fig:ex3a}, the executions of all the tasks are
540 536
 drawn on top of the box. You can try to move the \texttt{RTBox}
541 537
 command at the end to see what happens.
542 538
 

+ 163
- 123
rtsched.sty Ver fichero

@@ -1,23 +1,43 @@
1
+  %% rtsched.sty
2
+  %% Copyright 2005 M. G. Lipari
3
+  %
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 G. Lipari
15
+  %
16
+  % This work consists of the file pig.sty.
17
+  
18
+  
1 19
 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
2 20
 \ProvidesPackage{rtsched}[2005/01/01]
3
-\typeout{'rtsched' style for Latex and PSTricks}
21
+\typeout{'rtsched' style for Latex and TikZ/PGF}
4 22
 \typeout{Easily draw real-time schedules in TeX/Latex.}
5 23
 \typeout{(c) 2005, Giuseppe Lipari, Pisa, Italy (g.lipari@sssup.it)}
6
-\typeout{Version 1.2beta}
24
+\typeout{Version 2.0}
7 25
 
8
-\RequirePackage{multido}
9
-\RequirePackage{pstricks}
26
+\RequirePackage{tikz}
27
+\usetikzlibrary{shadows, patterns}
10 28
 \RequirePackage{keyval}
29
+\newcommand\rtfont{\usefont{T1}{phv}{m}{n}}
30
+
11 31
 
12 32
 %%
13 33
 %% These can be changed at any time
14 34
 %% 
15 35
 \def\RTWindowLength{10cm}    % window length
16
-\def\RTWindowHeight{0cm}     % window height
17
-\def\RTNullWindowHeight{0cm} % nullwindow height
18
-\def\RTTaskLabelSize{10pt}   % Size in pt of the task label
19
-\def\RTNumberLabelSize{10pt} % Size in pt of the number labels
20
-\def\RTDefTaskSymbol{\tau}
36
+\def\RTWindowHeight{0}     % window height
37
+\def\RTNullWindowHeight{0} % nullwindow height
38
+\def\RTTaskLabelSize{\normalsize}   % font size the task label
39
+\def\RTNumberLabelSize{\normalsize} % font size of the number labels
40
+\def\RTDefTaskSymbol{\tau} 
21 41
 \def\RTDefNumberOffset{0}
22 42
 \def\RTDefTaskFill{solid}
23 43
 \def\RTDefTaskColor{gray}
@@ -31,6 +51,9 @@
31 51
 \def\RTDefLineWidth{1pt}
32 52
 \def\RTDefLineStyle{solid}
33 53
 \def\RTDefExecHeight{1}
54
+\def\RTArrowStyle{-stealth} %arrow style for deadlines, arrivals and horizontal axes
55
+% -{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)
56
+%-stealth is a predefined more classical arrow style
34 57
 
35 58
 \def\RTExecLabel{\ }
36 59
 \def\RTTaskSymbol{\RTDefTaskSymbol}
@@ -40,19 +63,21 @@
40 63
 \def\RTXScale{\RTDefXScale}
41 64
 \def\RTWriteSymbols{\RTDefWriteSymbols}
42 65
 \def\RTNumberOffset{\RTDefNumberOffset}
43
-\def\RTNumberOffset{\RTDefNumberOffset}
44 66
 \def\RTGridInvisible{\RTDefGridInvisible}
67
+\def\RTNumbersInvisible{\RTDefNumbersInvisible}
45 68
 \def\RTAxisInvisible{\RTDefAxisInvisible}
46
-\def\RTNumbersInvisible{\RTDefGridInvisible}
47 69
 \def\RTRowLabelOffset{\RTDefRowLabelOffset}
48 70
 \def\RTLineWidth{\RTDefLineWidth}
49 71
 \def\RTLineStyle{\RTDefLineStyle}
50 72
 \def\RTExecHeight{\RTDefExecHeight}
51 73
 
74
+
75
+
76
+
52 77
 \define@key{RT}{height}[\RTNullWindowHeight]{\def\RTWindowHeight{#1}}
53
-\define@key{RT}{width}[10cm]{\def\RTWindowLength{#1}}
54
-\define@key{RT}{labelsize}[10pt]{\def\RTTaskLabelSize{#1}}
55
-\define@key{RT}{numbersize}[10pt]{\def\RTNumberLabelSize{#1}}
78
+\define@key{RT}{width}[10]{\def\RTWindowLength{#1}}
79
+\define@key{RT}{labelsize}[\normalsize]{\def\RTTaskLabelSize{#1}}
80
+\define@key{RT}{numbersize}[\normalsize]{\def\RTNumberLabelSize{#1}}
56 81
 \define@key{RT}{color}[\RTDefTaskColor]{\def\RTTaskColor{#1}}
57 82
 \define@key{RT}{linecolor}[\RTDefLineColor]{\def\RTLineColor{#1}}
58 83
 \define@key{RT}{execlabel}[\ ]{\def\RTExecLabel{#1}}
@@ -70,8 +95,10 @@
70 95
 \define@key{RT}{style}[\RTDefLineStyle]{\def\RTLineStyle{#1}}
71 96
 \define@key{RT}{exeheight}[\RTDefExecHeight]{\def\RTExecHeight{#1}}
72 97
 
98
+
73 99
 %%
74 100
 %% temporaries
101
+
75 102
 \newdimen\sx % slot length
76 103
 \newdimen\sy % slot height
77 104
 \newdimen\hy % frame height
@@ -81,91 +108,88 @@
81 108
 \newdimen\yyy % y position
82 109
 \newcount\nsx % number of horizontal slots
83 110
 \newcount\nsy % number of vertical slots
84
-\newcount\nhl % number of horizonatal lines
111
+\newcount\nhl % number of horizontal lines
85 112
 \newcount\nvl % number of vertical lines
113
+\newcount\ntasks % number of tasks
114
+\newcount\ntaskslessone %number of tasks less one
86 115
 \newcount\tmp % temp
87 116
 
117
+
88 118
 \newcounter{myLabel}
89 119
 
90 120
 \def\RTGrid{\@ifnextchar[\@mygrid@begin{\@mygrid@begin[]}}
91 121
 
92 122
 \def\RTGridBegin{\@ifnextchar[\@mygrid@begin{\@mygrid@begin[]}}
93 123
 \def\@mygrid@begin[#1]#2#3{\setkeys{RT}{#1}%
124
+  %% get the number of tasks
125
+  \ntasks = #2
126
+  \ntaskslessone = \ntasks
127
+  \advance \ntaskslessone by -1
94 128
   %% number of horizontal steps in the grid
95 129
   \nsx = #3 \advance \nsx by 2 %
96
-  %% real lenght of the window (approx)
130
+  %% real length of the window (approx)
97 131
   \nvl = \nsx \advance \nvl by 1 %
98
-  %% compute lenght of a step
132
+  %% compute length of a step
99 133
   \sx = \RTWindowLength \divide \sx by \nsx %
100 134
   %% number of vertical steps in the grid
101 135
   \nsy = #2 \multiply \nsy by 3 \advance \nsy by 1 %
102
-  %% compute lenght of a vertical step (if height is null, \sy is the
136
+  %% compute length of a vertical step (if height is null, \sy is the
103 137
   %% same as \sx)
104 138
   \ifx\RTWindowHeight\RTNullWindowHeight%
105 139
     \sy = \sx%
106
-    \hy = \sy \multiply \hy by \nsy \advance \hy by \sy%
140
+    \hy = \sy \multiply \hy by \nsy %\advance \hy by \sy%
107 141
   \else 
108 142
     \sy = \RTWindowHeight \divide \sy by \nsy %
109
-    \hy = \RTWindowHeight \advance \hy by \sy %
143
+    \hy = \RTWindowHeight %\advance \hy by \sy %
110 144
   \fi
111 145
   %% compute real height
112 146
   \nhl = \nsy \advance \nhl by 1 %
113 147
   \advance \nsy by -1 \advance \nsx by -1
114 148
   %% the picture
115
-  \begin{pspicture}(0,0)(\RTWindowLength,\hy) %
149
+  \pgfdeclarelayer{foreground} 
150
+  \pgfsetlayers{main,foreground}
151
+
152
+  \begin{tikzpicture}
116 153
     %% draw grid (if not invisible)
117 154
     \if\RTGridInvisible\RTDefGridInvisible
118
-      \multips(0,\sy)(0,\sy){\nsy}{\psline[linecolor=lightgray]{-}(0,\sy)(\RTWindowLength,\sy)}%
119
-      \multips(\sx,0)(\sx,0){\nsx}{\psline[linecolor=lightgray]{-}(0,\sy)(0,\hy)}%
120
-      \psframe(0,\sy)(\RTWindowLength,\hy)%
155
+      \draw[lightgray, semithick] (0,0) grid[xstep = \sx,ystep=\sy ] (\RTWindowLength,\hy);
156
+    %% draw border grid
157
+      \draw [black, thick] (0,0) rectangle (\RTWindowLength,\hy);
121 158
     \else\relax
122 159
     \fi
160
+
123 161
     %% draw numbers (if not invisible)
124 162
     \if\RTNumbersInvisible\RTDefNumbersInvisible
125
-      \tmp = #3 \divide \tmp by 2 \advance \tmp by 1%
126
-      \pssetlength{\xx}{\sx}%
127
-      \setcounter{myLabel}{\RTNumberOffset}
128
-      \multido{\n=0+1}{\tmp}{%
129
-        \uput{4pt}[d](\xx,\sy){%
130
-          \usefont{T1}{phv}{m}{n}%
131
-          \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
132
-          \selectfont{\arabic{myLabel}}}%
133
-        \psaddtolength{\xx}{\sx}%
134
-        \psaddtolength{\xx}{\sx}%
135
-        \addtocounter{myLabel}{2}
136
-      }
137
-    \else\relax
163
+       \foreach \i [evaluate = \i as \j using \i*\sx] in {0,...,#3}{
164
+       \ifodd \i
165
+       \else
166
+       \pgfmathsetmacro\nbwithoffset{\i + \RTNumberOffset};
167
+       \node[below, font=\RTNumberLabelSize \rtfont] at (\j +\sx , 0) {\pgfmathprintnumber[int trunc,/pgf/number format/assume math mode=true]{\nbwithoffset }};
168
+       \fi
169
+       }
170
+    \else
171
+    \relax
138 172
     \fi
139
-    % 
173
+
140 174
     %% Task Names
141
-    \setcounter{myLabel}{1}
142
-    \pssetlength{\yy}{\hy}%
143
-    \psaddtolength{\yy}{-\sy}
144
-    \multido{\n=0+1}{#2}{%
145
-      \uput{4pt}[d](-\sx,\yy){
146
-        \usefont{T1}{phv}{m}{n}
147
-        \fontsize{\RTTaskLabelSize}{\RTTaskLabelSize}
148
-        \if\RTWriteSymbols\RTDefWriteSymbols\selectfont{$\RTTaskSymbol_{\arabic{myLabel}}$}
149
-          \else\relax
150
-        \fi
151
-      }%
152
-      \psaddtolength{\yy}{-3\sy}%
153
-      \addtocounter{myLabel}{1}
154
-    }%    
175
+    \if\RTWriteSymbols\RTDefWriteSymbols
176
+     \foreach \i  [evaluate = \i as \j using (\hy -3*\i*\sy)] in {0,...,\ntaskslessone}{
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
+          
155 183
     %% Horizontal axes
156
-
157 184
     \if\RTAxisInvisible\RTDefAxisInvisible
158
-      \xx = \sx \xxx = \RTWindowLength \advance \xxx by -\sx
159
-      \yy = 2\sy 
160
-      \multido{\n=0+1}{#2}{
161
-        \psline{->}(\xx,\yy)(\xxx,\yy)
162
-        \advance \yy by 3\sy
185
+      \begin{pgfonlayer}{foreground} 
186
+      \foreach \i [evaluate = \i as \j using (\hy -3*\i*\sy)] in {0,...,\ntaskslessone}{
187
+      \draw [very thick,\RTArrowStyle] (\sx,\j-3*\sy) -- (\RTWindowLength - \sx,\j-3*\sy);
163 188
       }
164
-    \fi
189
+      \end{pgfonlayer} 
190
+    \fi 
165 191
 }
166
-
167
-
168
-
192
+ 
169 193
 \def\@RTDefaultValues{%
170 194
   \setkeys{RT}{height}%
171 195
   \setkeys{RT}{width}%
@@ -186,12 +210,12 @@
186 210
 }
187 211
 
188 212
 \def\RTGridEnd{
189
-    \end{pspicture}%
213
+    \end{tikzpicture}%
190 214
     \@RTDefaultValues%
191 215
 }
192 216
 
193 217
 \def\endRTGrid{
194
-    \end{pspicture}%
218
+    \end{tikzpicture}%
195 219
     \@RTDefaultValues%
196 220
 }
197 221
 
@@ -221,11 +245,13 @@
221 245
   \advance \yy by \hy
222 246
 }
223 247
 
248
+
224 249
 \newcommand{\DrawTaskAxis}[2][nocommand=1]{%
225 250
     \setkeys{RT}{#1}%
226 251
     \@compute@yy{#2}
227 252
     \@compute@xx{0}
228 253
     \xxx = \RTWindowLength \advance \xxx by -\sx 
254
+    \draw [\RTLineColor,\RTArrowStyle] (\xx,\yy) -- (\xx,\yyy);
229 255
     \psline[linecolor=\RTLineColor]{->}(\xx,\yy)(\xxx,\yy)%
230 256
     \@RTExecDefaultValues%
231 257
 }
@@ -235,10 +261,10 @@
235 261
     \@compute@yy{#2}
236 262
     \@compute@xx{0}
237 263
     \xxx = \RTWindowLength \advance \xxx by -\sx 
238
-    \psline[linecolor=\RTLineColor]{->}(\xx,\yy)(\xxx,\yy)%
264
+    \draw [\RTLineColor,\RTArrowStyle] (\xx,\yy) -- (\xxx,\yy);
239 265
     \yyy = 3\sy \multiply \yyy by #3 \advance \yyy by \yy
240 266
     \advance \yyy by -\sy
241
-    \psline[linecolor=\RTLineColor]{->}(\xx,\yy)(\xx,\yyy)%
267
+    \draw [\RTLineColor,\RTArrowStyle] (\xx,\yy) -- (\xx,\yyy);
242 268
     \@RTExecDefaultValues%
243 269
 }
244 270
 
@@ -248,7 +274,7 @@
248 274
     \@compute@xxx{#4}
249 275
     \yy = #3\sy \advance \yy by 2\sy
250 276
     \yyy = #5\sy \advance \yyy by 2\sy
251
-    \psline[linecolor=\RTLineColor,linestyle=\RTLineStyle,linewidth=\RTLineWidth]{-}(\xx,\yy)(\xxx,\yyy)
277
+    \draw [\RTLineColor, line width=\RTLineWidth,\RTLineStyle] (\xx,\yy) -- (\xxx,\yyy);
252 278
     \@RTExecDefaultValues%
253 279
 }
254 280
 
@@ -260,7 +286,10 @@
260 286
     \@compute@yy{#2}
261 287
     \@compute@xx{#3}
262 288
     \yyy = \yy \advance \yyy by 2\sy%
263
-    \psline[linecolor=\RTLineColor]{->}(\xx,\yy)(\xx,\yyy)%
289
+     \begin{pgfonlayer}{foreground} 
290
+    \draw [\RTLineColor, thick,\RTArrowStyle] (\xx,\yy) -- (\xx,\yyy);
291
+     \end{pgfonlayer}
292
+
264 293
     \@RTExecDefaultValues%
265 294
 }
266 295
 
@@ -273,9 +302,13 @@
273 302
   \@compute@yy{#2}
274 303
   \@compute@xx{#3}
275 304
   \yyy = \yy \advance \yyy by 2\sy
276
-  \psline[linecolor=\RTLineColor]{->}(\xx,\yy)(\xx,\yyy)
305
+  \begin{pgfonlayer}{foreground} 
306
+  \draw [\RTLineColor, thick,\RTArrowStyle] (\xx,\yy) -- (\xx,\yyy);
307
+  \end{pgfonlayer}
277 308
   \advance \xx by #4\sx
278
-  \psline[linecolor=\RTLineColor]{->}(\xx,\yyy)(\xx,\yy)
309
+  \begin{pgfonlayer}{foreground} 
310
+  \draw [\RTLineColor, thick,\RTArrowStyle] (\xx,\yyy) -- (\xx,\yy);
311
+  \end{pgfonlayer}
279 312
   \@RTExecDefaultValues
280 313
 }
281 314
 
@@ -288,7 +321,9 @@
288 321
   \@compute@yy{#2}
289 322
   \@compute@xx{#3}
290 323
   \yyy = \yy \advance \yyy by 2\sy
291
-  \psline[linecolor=\RTLineColor]{<-}(\xx,\yy)(\xx,\yyy)
324
+  \begin{pgfonlayer}{foreground} 
325
+  \draw [\RTLineColor, thick,<-] (\xx,\yy) -- (\xx,\yyy);
326
+  \end{pgfonlayer}
292 327
   \@RTExecDefaultValues
293 328
 }
294 329
 
@@ -298,16 +333,12 @@
298 333
   \@compute@xx{#3}
299 334
   \yyy = \yy \advance \yyy by \RTExecHeight\sy
300 335
   \@compute@xxx{#4}
301
-  \psframe[fillstyle=\RTTaskFill,fillcolor=\RTTaskColor,linecolor=\RTLineColor](\xx,\yy)(\xxx,\yyy)
336
+ \draw [fill=\RTTaskColor,\RTTaskFill,draw=\RTLineColor, thick] (\xx,\yy) rectangle (\xxx,\yyy);
302 337
   \advance \xx by \xxx \xx = .5\xx
303
-  \uput{2pt}[u](\xx,\yy){%
304
-    \usefont{T1}{phv}{m}{n}%
305
-    \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
306
-    \selectfont{\RTExecLabel}%
307
-  }
338
+ \draw (\xx,\yy) node[above, font=\rtfont] {\RTNumberLabelSize \RTExecLabel};%\RTNumberLabelSize
308 339
   \@RTExecDefaultValues
309 340
 }
310
-
341
+%
311 342
 % Task Lock
312 343
 % par 1:  task 
313 344
 % par 2:  time
@@ -318,15 +349,11 @@
318 349
   \@compute@yy{#2}
319 350
   \@compute@xx{#3}
320 351
   \yyy = \yy \advance \yyy by \sy
321
-  \uput{2pt}[u](\xx,\yyy){%
322
-    \usefont{T1}{phv}{m}{n}%
323
-    \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
324
-    \selectfont{L(#4)}%
325
-  }
352
+   \node[above,font=\rtfont] at (\xx , \yyy) {\RTNumberLabelSize L(#4)}; %\RTNumberLabelSize
326 353
   \@RTExecDefaultValues
327 354
 }
328
-
329
-% \TaskUnlock
355
+%
356
+% TaskUnlock
330 357
 % par 1:  task 
331 358
 % par 2:  time
332 359
 % par 3:  resource
@@ -336,15 +363,11 @@
336 363
   \@compute@yy{#2}
337 364
   \@compute@xx{#3}
338 365
   \yyy = \yy \advance \yyy by \sy
339
-  \uput{2pt}[u](\xx,\yyy){%
340
-    \usefont{T1}{phv}{m}{n}%
341
-    \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
342
-    \selectfont{U(#4)}%
343
-  }
366
+   \node[above, font=\rtfont] at (\xx , \yyy) {\RTNumberLabelSize U(#4)}; %\RTNumberLabelSize
344 367
   \@RTExecDefaultValues
345 368
 }
346
-
347
-% 
369
+%
370
+% Label
348 371
 % par 1:  number of vertical slot 
349 372
 % par 2:  time
350 373
 % par 3:  label
@@ -355,17 +378,13 @@
355 378
   \@compute@xx{#3}
356 379
   \yy = -\sy \multiply \yy by #2
357 380
   \advance \yy by \hy
358
-  \yyy = \yy \advance \yyy by \sy
359
-  \uput{2pt}[u](\xx,\yyy){%
360
-    \psshadowbox{
361
-      \usefont{T1}{phv}{m}{n}%
362
-      \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
363
-      \selectfont{{#4}}}%
364
-  }
381
+  \yyy = \yy \advance \yyy by 2\sy   %\yyy = \yy \advance \yyy by \sy
382
+
383
+  \node[font=\rtfont, fill = white, draw=\RTLineColor, thin,  drop shadow = {color = black}] at (\xx , \yyy) {\RTNumberLabelSize #4}; %\RTNumberLabelSize
365 384
   \@RTExecDefaultValues
366 385
 }
367
-
368
-% 
386
+%
387
+% Inherit
369 388
 % par 1:  higher priority task (from) 
370 389
 % par 2:  lower priority task (to)
371 390
 % par 3:  time
@@ -376,16 +395,19 @@
376 395
   \@compute@xx{#4}
377 396
   \yyy = -3\sy \multiply \yyy by #3 \advance \yyy by \sy
378 397
   \advance \yyy by \hy \advance \yyy by -\sy % \RTWindowHeight
379
-  \psline[linestyle=dashed,linewidth=1.5pt]{->}(\xx,\yy)(\xx,\yyy)
398
+  \begin{pgfonlayer}{foreground} 
399
+  \draw [dashed, thick,\RTArrowStyle] (\xx,\yy) -- (\xx,\yyy);
400
+  \end{pgfonlayer}
380 401
   \@RTExecDefaultValues
381 402
 }
382 403
 
383 404
 % 
405
+% Activation
384 406
 % par 1:  activating task (from) 
385 407
 % par 2:  signal start time 
386 408
 % par 3:  activated task (to)
387 409
 % par 4:  signal arrival time
388
-%
410
+
389 411
 \newcommand{\Activation}[5][nocommand=1]{
390 412
   \setkeys{RT}{#1}%
391 413
   \@compute@yy{#2}
@@ -393,10 +415,14 @@
393 415
   \yyy = -3\sy \multiply \yyy by #4 %\advance \yyy by \sy
394 416
   \advance \yyy by \hy %\advance \yyy by -\sy %\RTWindowHeight
395 417
   \xxx = #5\sx \advance \xxx by \sx
396
-  \psline[linestyle=dashed,linewidth=1pt]{->}(\xx,\yy)(\xxx,\yyy)
418
+   \begin{pgfonlayer}{foreground} 
419
+  \draw [dashed, thick,\RTArrowStyle] (\xx,\yy) -- (\xxx,\yyy);
420
+   \end{pgfonlayer}
421
+
397 422
 }
398 423
 
399 424
 % 
425
+% RTBox
400 426
 % par 1:  time1
401 427
 % par 2:  time2
402 428
 %
@@ -404,14 +430,16 @@
404 430
   \setkeys{RT}{#1}%
405 431
   \yy = 0cm
406 432
   \advance \yy by \hy
407
-  \yyy = \sy
433
+    \yyy = 0cm  %  \yyy = \sy
408 434
   \@compute@xx{#2}
409 435
   \@compute@xxx{#3}
410
-  \psframe[fillstyle=crosshatch,hatchwidth=.2pt,hatchsep=2pt,hatchcolor=lightgray,linewidth=0pt,framearc=.2](\xx,\yy)(\xxx,\yyy)
436
+   \draw [pattern color=lightgray, draw=\RTLineColor, pattern=crosshatch, rounded corners, thin](\xx,\yy) rectangle (\xxx,\yyy);
411 437
   \@RTExecDefaultValues
412 438
 }
413 439
 
414
-% %
440
+
441
+
442
+%% %
415 443
 % % par 1: task
416 444
 % % par 2: first instant (arrival)
417 445
 % % par 3: second instant (deadline)
@@ -426,48 +454,59 @@
426 454
 %   \pscurve*[linecolor=\RTLineColor]{-}(\xx,\yy)(\xxx,\yy)
427 455
 %   \@RTExecDefaultValues  
428 456
 % }
457
+%
429 458
 
459
+
460
+% 
461
+% RowLabel
462
+% par 1:  task
463
+% par 2:  label
464
+%
430 465
 \newcommand{\RowLabel}[3][nocommand=1]{
431 466
   \setkeys{RT}{#1}%
432 467
   \@compute@yy{#2}
433 468
   \advance \yy by 1.5\sy
434 469
   \xx = \RTRowLabelOffset %\advance \xx by \sx
435
-  \uput{4pt}[dl](-\xx,\yy){
436
-    \usefont{T1}{phv}{m}{n}
437
-    \fontsize{\RTTaskLabelSize}{\RTTaskLabelSize}
438
-    \selectfont{#3}
439
-  }%
470
+  \node[below left,font=\rtfont] at (-\xx , \yy) {\RTTaskLabelSize #3};%\RTTaskLabelSize
440 471
 }
441 472
 
473
+% 
474
+% TaskExecDelta
475
+% par 1:  task
476
+% par 2:  start time
477
+% par 3:  delta
478
+%
442 479
 \newcommand{\TaskExecDelta}[4][nocommand=1]{
443 480
   \setkeys{RT}{#1}%
444 481
   \@compute@yy{#2}
445 482
   \@compute@xx{#3}
446
-  \yyy = \yy \advance \yyy by \RTExecHeight\sy
483
+  \yyy = \yy \advance \yyy by \RTExecHeight \sy
447 484
   %\@compute@xxx{#4}
448 485
   \xxx = \xx \advance \xxx by #4\sx
449
-  \psframe[fillstyle=\RTTaskFill,fillcolor=\RTTaskColor,linecolor=\RTLineColor](\xx,\yy)(\xxx,\yyy)
486
+   \draw [fill=\RTTaskColor,\RTTaskFill,draw=\RTLineColor, thick] (\xx,\yy) rectangle (\xxx,\yyy);
450 487
   \advance \xx by \xxx \xx = .5\xx
451
-  \uput{2pt}[u](\xx,\yy){%
452
-    \usefont{T1}{phv}{m}{n}%
453
-    \fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
454
-    \selectfont{\RTExecLabel}%
455
-  }
488
+   \draw (\xx,\yy) node[above, font=\rtfont] {\RTTaskLabelSize \RTExecLabel}; %\RTNumberLabelSize
456 489
   \@RTExecDefaultValues
457 490
 }
458 491
 
492
+
493
+% 
494
+% TaskRespTime
495
+% par 1:  task
496
+% par 2:  start time
497
+% par 3:  finish time
498
+%
459 499
 \newcommand{\TaskRespTime}[4][nocommand=1]{
460 500
   \setkeys{RT}{#1}
461 501
   \@compute@yy{#2}
462 502
   \@compute@xx{#3}
463 503
   \yyy = \yy \advance \yyy by \sy  
464 504
   \xxx = \xx \advance \xxx by #4\sx
465
-  \psframe[fillstyle=crosshatch*,hatchcolor=white,
466
-  hatchwidth=.4pt,hatchsep=1pt,
467
-  linestyle=none,fillcolor=\RTTaskColor](\xx,\yy)(\xxx,\yyy)
505
+  \draw [pattern color=\RTTaskColor,draw=\RTLineColor, pattern=crosshatch, thin] (\xx,\yy) rectangle (\xxx,\yyy);
468 506
   \@RTExecDefaultValues
469 507
 }
470 508
 
509
+
471 510
 \@ifclassloaded{beamer}{
472 511
   \renewcommand<>{\TaskArrival}[3][nocommand=1]{
473 512
     \only#4{\beameroriginal{\TaskArrival}[#1]{#2}{#3}}
@@ -511,4 +550,5 @@
511 550
 }
512 551
 {\typeout{beamer not loaded}}
513 552
 
514
-\endinput
553
+\endinput
554
+

Loading…
Cancelar
Guardar