Browse Source

Added a way to draw lines and axis (in other words, simple linear functions).

The documentation needs updating!
Giuseppe Lipari 11 years ago
parent
commit
287017fa34
1 changed files with 511 additions and 469 deletions
  1. 511
    469
      rtsched.sty

+ 511
- 469
rtsched.sty View File

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

Loading…
Cancel
Save