Debian Codegraph @

texmf-dist/tex/latex/reotex/reotex.sty

raw
1 % Defintion of Reo Channels and other utilities to design Reo Circuits
2 % using the pgf (tikz) by Till Tantau (pgf manual for v2.10)
3 %
4 % author: Nuno Oliveira
5 % version: 1.0
6 %
7 % This package may be distributed and modified to better suit the user's
8 % interests. Please, keep the credits to the original author (but you may
9 % add yours)
10 %
11 % License: LaTeX Project Public License and/or GNU Public License.
12 %
13
14
15 \NeedsTeXFormat{LaTeX2e}
16 \ProvidesPackage{reotex}[2014/08/13 A Tex way to draw reo circuits!]
17
18 %releases:
19 %2014/08/13 - version 1.1
20 %WHAT HAS CHANGED:
21 % - arrow tips used in drain/spout were corrected. The update to tikz3.0 caused a problem concerning the size of such arrows.
22
23 %2012/01/05 - version 1, first published at CTAN.
24
25 \RequirePackage{ifthen}
26 \RequirePackage{tikz}
27 \RequirePackage{verbatim}
28 \usetikzlibrary{arrows,%
29 decorations.pathmorphing,%
30 decorations.shapes,%
31 calc%
32 }
33
34 %makes @ as a normal letter and not as a special latex character...
35 \makeatletter
36
37 %%%%%% VARIABLES %%%%%%%%%%%
38
39 \newdimen\rt@thearrowsize
40 \newdimen\rt@width
41 \newdimen\rt@xa
42 \newdimen\rt@xb
43 \newdimen\rt@xc
44 \newdimen\rt@ya
45 \newdimen\rt@yb
46 \newdimen\rt@yc
47
48 \newcommand{\rt@arrowtip}{-stealth}
49
50 %%%%%%%%%%%% BASE COMMANDS %%%%%%%%%%%%
51
52
53 \newcommand{\rt@midpoints}[4]{%
54 \pgfextractx{\rt@xa}{\pgfpointlineattime{#1}{\pgfpointanchor{#3}{center}}{\pgfpointanchor{#4}{center}}}
55 \pgfextracty{\rt@ya}{\pgfpointlineattime{#1}{\pgfpointanchor{#3}{center}}{\pgfpointanchor{#4}{center}}}
56 \pgfextractx{\rt@xb}{\pgfpointlineattime{#2}{\pgfpointanchor{#3}{center}}{\pgfpointanchor{#4}{center}}}
57 \pgfextracty{\rt@yb}{\pgfpointlineattime{#2}{\pgfpointanchor{#3}{center}}{\pgfpointanchor{#4}{center}}}
58 }
59
60
61 \newcommand{\rt@middlepoint}[2]{%
62 \pgfextractx{\rt@xc}{\pgfpointlineattime{.5}{\pgfpointanchor{#1}{center}}{\pgfpointanchor{#2}{center}}}
63 \pgfextracty{\rt@yc}{\pgfpointlineattime{.5}{\pgfpointanchor{#1}{center}}{\pgfpointanchor{#2}{center}}}
64 }
65
66
67
68 %%%%%%%% TIKZ DEFINITIONS %%%%%%%%%%%%%%%
69
70 \tikzset{cross/.style={path picture={
71 \draw[black]
72 (path picture bounding box.south east) --
73 (path picture bounding box.north west)
74 (path picture bounding box.south west) --
75 (path picture bounding box.north east);
76 }
77 }
78 }
79
80
81 %%%%%%%%%%%%%%%% SYNCHRONOUS CHANNELS %%%%%%%%%%
82
83
84
85
86 % Synchronous
87
88 \newcommand{\sync}{%
89 \@ifstar\sync@noarrow\sync@arrow
90 }
91
92
93 \newcommand{\sync@arrow}[3]{%
94 \draw[\rt@arrowtip] #1 to #3 #2;
95 }
96
97 \newcommand{\sync@noarrow}[3]{%
98 \draw #1 to #3 #2;
99 }
100
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102
103
104 % Lossy Synchronous
105
106 \newcommand{\lossysync}{%
107 \@ifstar\lossysync@noarrow\lossysync@arrow
108 }
109
110 \newcommand{\lossysync@arrow}[3]{%
111 \draw[\rt@arrowtip,dashed] #1 to #3 #2;
112 }
113
114 \newcommand{\lossysync@noarrow}[3]{%
115 \draw[dashed] #1 to #3 #2;
116 }
117
118
119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120
121
122
123 % Synchronous Drain
124 \newcommand{\syncdrain}{%
125 \@ifstar \syncdrain@arrow \syncdrain@arrow
126 }
127
128 \newcommand{\syncdrain@arrow}[3]{%
129 \draw[inwards-inwards, shorten >=-0.5mm, shorten <=-0.5mm] #1 to #3 #2;
130 }
131
132 %\newcommand{\syncdrain@noarrow}[3]{%
133 % \draw[inwards-inwards] #1 to #2 #3;
134 %}
135
136
137 % Synchronous Spout
138 \newcommand{\syncspout}{%
139 \@ifstar \syncspout@arrow \syncspout@arrow
140 }
141 \newcommand{\syncspout@arrow}[3]{%
142 \draw[outwards-outwards,shorten >=-0.5mm, shorten <=-0.5mm] #1 to #3 #2;
143 }
144 %\newcommand{\syncspout@noarrow}[3]{%
145 % \draw[outwards-outwards,] #1 to #2 #3;
146 %}
147
148
149
150
151
152
153
154 %Filter
155
156 \newcommand{\filter}{%
157 \@ifstar\filter@noarrow\filter@arrow
158 }
159
160 \newcommand{\filter@arrow}[3]{%
161 \node (rt@p1) at #1 {} ;
162 \node (rt@p2) at #2 {} ;
163
164 \rt@midpoints{0.25}{0.75}{rt@p1}{rt@p2}
165
166 \draw[thin] #1 to (\rt@xa,\rt@ya);
167 \draw decorate [decoration=zigzag] {(\rt@xa,\rt@ya) -- #3 (\rt@xb,\rt@yb)};
168 \draw[\rt@arrowtip, thin] (\rt@xb,\rt@yb) to #2;
169
170 }
171
172
173 \newcommand{\filter@noarrow}[3]{%
174 \node (rt@p1) at #1 {} ;
175 \node (rt@p2) at #2 {} ;
176
177 \rt@midpoints{0.25}{0.75}{rt@p1}{rt@p2}
178
179 \draw[thin] #1 to (\rt@xa,\rt@ya);
180 \draw decorate [decoration=zigzag] {(\rt@xa,\rt@ya) -- #3 (\rt@xb,\rt@yb)};
181 \draw[thin] (\rt@xb,\rt@yb) to #2;
182
183 }
184
185
186 %%%%%%%%%%%%%%%%%%%%%%%%%%%
187
188
189
190
191 %%%%%%%% ASYNCHRONOUS CHANNELS %%%%%%%%%%%%
192
193 %Fifo1 (Empty)
194
195 \newcommand{\fifoe}{%
196 \@ifstar\fifoe@noarrow\fifoe@arrow
197 }
198
199 \newcommand{\fifoe@arrow}[3]{%
200 \node (rt@p1) at #1 {} ;
201 \node (rt@p2) at #2 {} ;
202
203 \rt@midpoints{0.30}{0.65}{rt@p1}{rt@p2}
204 \pgfmathsetlength{\rt@width}{sqrt((\rt@xa - \rt@xb)^2 + (\rt@ya - \rt@yb)^2)}
205 %, shorten <=1mm
206 \draw[thin] #1 to (\rt@xa,\rt@ya);
207 \draw decorate[decoration={shape backgrounds, shape=rectangle, shape height=7pt, shape width=\rt@width, shape evenly spread=1}] {(\rt@xa,\rt@ya) -- (\rt@xb,\rt@yb)};
208 \draw[\rt@arrowtip, thin] (\rt@xb,\rt@yb) to #3 #2;
209 }
210
211
212 \newcommand{\fifoe@noarrow}[3]{%
213 \node (rt@p1) at #1 {} ;
214 \node (rt@p2) at #2 {} ;
215
216 \rt@midpoints{0.30}{0.70}{rt@p1}{rt@p2}
217 \pgfmathsetlength{\rt@width}{sqrt((\rt@xa - \rt@xb)^2 + (\rt@ya - \rt@yb)^2)}
218
219 \draw[thin] #1 to (\rt@xa,\rt@ya);
220 \draw decorate[decoration={shape backgrounds, shape=rectangle, shape height=8pt, shape width=\rt@width, shape evenly spread=1}] {(\rt@xa,\rt@ya) -- (\rt@xb,\rt@yb)};
221 \draw[thin] (\rt@xb,\rt@yb) to #3 #2;
222 }
223
224
225 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226
227
228 %Fifo1 (Full)
229
230 \newcommand{\fifof}{%
231 \@ifstar\fifof@noarrow\fifof@arrow
232 }
233
234 \newcommand{\fifof@arrow}[3]{%
235 \node (rt@p1) at #1 {} ;
236 \node (rt@p2) at #2 {} ;
237
238 \rt@midpoints{0.30}{0.65}{rt@p1}{rt@p2}
239
240 \pgfmathsetlength{\rt@width}{sqrt((\rt@xa - \rt@xb)^2 + (\rt@ya - \rt@yb)^2)}
241
242 \draw[thin] #1 to (\rt@xa,\rt@ya);
243 \draw decorate[decoration={shape backgrounds, shape=rectangle, shape height=7pt, shape width=\rt@width, shape evenly spread=1}] {(\rt@xa,\rt@ya) -- node[sloped] {$\bullet$} (\rt@xb,\rt@yb)};
244 \draw[\rt@arrowtip, thin] (\rt@xb,\rt@yb) to #3 #2;
245 }
246
247
248 \newcommand{\fifof@noarrow}[3]{%
249 \node (rt@p1) at #1 {} ;
250 \node (rt@p2) at #2 {} ;
251
252 \rt@midpoints{0.30}{0.70}{rt@p1}{rt@p2}
253
254 \pgfmathsetlength{\rt@width}{sqrt((\rt@xa - \rt@xb)^2 + (\rt@ya - \rt@yb)^2)}
255
256 \draw[thin] #1 to (\rt@xa,\rt@ya);
257 \draw decorate[decoration={shape backgrounds, shape=rectangle, shape height=7pt, shape width=\rt@width, shape evenly spread=1}] {(\rt@xa,\rt@ya) -- node[sloped] {$\bullet$} (\rt@xb,\rt@yb)};
258 \draw[thin] (\rt@xb,\rt@yb) to #3 #2;
259 }
260
261
262
263 %AsyncDrain
264 \newcommand{\asyncdrain}{%
265 \@ifstar \asyncdrain@arrow \asyncdrain@arrow
266 }
267
268 \newcommand{\asyncdrain@arrow}[3]{%
269
270 \coordinate (rt@p1) at ($#1!.47!#2$);
271 \coordinate (rt@p2) at ($(rt@p1)!6pt!90:#1$);
272 \coordinate (rt@p3) at ($(rt@p1)!6pt!-90:#1$);
273
274 \coordinate (rt@p4) at ($#1!.53!#2$);
275 \coordinate (rt@p5) at ($(rt@p4)!6pt!90:#1$);
276 \coordinate (rt@p6) at ($(rt@p4)!6pt!-90:#1$);
277
278 \draw[inwards-inwards, thin, shorten >=-0.5mm, shorten <=-0.5mm]
279 #1 to #3 #2;
280 \draw[thin] (rt@p1) -- (rt@p2);
281 \draw[thin] (rt@p1) -- (rt@p3);
282 \draw[thin] (rt@p4) -- (rt@p5);
283 \draw[thin] (rt@p4) -- (rt@p6);
284 }
285
286
287
288 %AsyncSpout
289
290 \newcommand{\asyncspout}{%
291 \@ifstar \asyncspout@arrow \asyncspout@arrow
292 }
293
294 \newcommand{\asyncspout@arrow}[3]{%
295 \coordinate (rt@p1) at ($#1!.47!#2$);
296 \coordinate (rt@p2) at ($(rt@p1)!6pt!90:#1$);
297 \coordinate (rt@p3) at ($(rt@p1)!6pt!-90:#1$);
298
299 \coordinate (rt@p4) at ($#1!.53!#2$);
300 \coordinate (rt@p5) at ($(rt@p4)!6pt!90:#1$);
301 \coordinate (rt@p6) at ($(rt@p4)!6pt!-90:#1$);
302
303 \draw[outwards-outwards, thin,shorten >=-0.5mm, shorten <=-0.5mm]
304 #1 to #3 #2;
305 \draw[thin] (rt@p1) -- (rt@p2);
306 \draw[thin] (rt@p1) -- (rt@p3);
307 \draw[thin] (rt@p4) -- (rt@p5);
308 \draw[thin] (rt@p4) -- (rt@p6);
309 }
310
311 %\newcommand{\asyncspout@noarrow}[3]{%
312 %\coordinate (rt@p1) at ($#1!.47!#2$);
313 %\coordinate (rt@p2) at ($(rt@p1)!6pt!90:#1$);
314 %\coordinate (rt@p3) at ($(rt@p1)!6pt!-90:#1$);
315
316 %\coordinate (rt@p4) at ($#1!.53!#2$);
317 %\coordinate (rt@p5) at ($(rt@p4)!6pt!90:#1$);
318 %\coordinate (rt@p6) at ($(rt@p4)!6pt!-90:#1$);
319
320 %\draw[outwards-outwards, thin]
321 % #1 to #3 #2;
322 %\draw[thin] (rt@p1) -- (rt@p2);
323 %\draw[thin] (rt@p1) -- (rt@p3);
324 %\draw[thin] (rt@p4) -- (rt@p5);
325 %\draw[thin] (rt@p4) -- (rt@p6);
326 %}
327
328 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
329
330
331
332 %FifoN
333
334 \newcommand{\fifon}{%
335 \@ifstar\fifon@noarrow\fifon@arrow
336 }
337
338 \newcommand{\fifon@arrow}[3]{%
339
340 \node (rt@p1) at #1 {} ;
341 \node (rt@p2) at #2 {} ;
342
343 \rt@midpoints{0.30}{0.65}{rt@p1}{rt@p2}
344
345 \pgfmathsetlength{\rt@width}{sqrt((\rt@xa - \rt@xb)^2 + (\rt@ya - \rt@yb)^2)}
346
347 \draw[thin] #1 to (\rt@xa,\rt@ya);
348 \draw decorate[decoration={shape backgrounds, shape=rectangle, shape height=8pt, shape width=\rt@width, shape evenly spread=1}] {(\rt@xa,\rt@ya) -- node[sloped] {\tiny 1$|$...$|$n} (\rt@xb,\rt@yb)};
349 \draw[\rt@arrowtip, thin] (\rt@xb,\rt@yb) to #3 #2;
350 }
351
352
353
354 \newcommand{\fifon@noarrow}[3]{%
355
356 \node (rt@p1) at #1 {} ;
357 \node (rt@p2) at #2 {} ;
358
359 \rt@midpoints{0.30}{0.70}{rt@p1}{rt@p2}
360
361 \pgfmathsetlength{\rt@width}{sqrt((\rt@xa - \rt@xb)^2 + (\rt@ya - \rt@yb)^2)}
362
363 \draw[thin] #1 to (\rt@xa,\rt@ya);
364 \draw decorate[decoration={shape backgrounds, shape=rectangle, shape height=8pt, shape width=\rt@width, shape evenly spread=1}] {(\rt@xa,\rt@ya) -- node[sloped] {\tiny 1$|$...$|$n} (\rt@xb,\rt@yb)};
365 \draw[thin] (\rt@xb,\rt@yb) to #3 #2;
366 }
367
368
369 %%%%%%%%%%%%%%%%%%%%%%%%%
370
371
372
373 % Shift Fifo n
374
375 \newcommand{\shiftfifon}{%
376 \@ifstar\shiftfifon@noarrow\shiftfifon@arrow
377 }
378
379 \newcommand{\shiftfifon@arrow}[3]{%
380
381 \node (rt@p1) at #1 {} ;
382 \node (rt@p2) at #2 {} ;
383
384 \rt@midpoints{0.30}{0.65}{rt@p1}{rt@p2}
385
386 \pgfmathsetlength{\rt@width}{sqrt((\rt@xa - \rt@xb)^2 + (\rt@ya - \rt@yb)^2)}
387
388 \draw[thin] #1 to (\rt@xa,\rt@ya);
389 \draw[dashed] decorate[decoration={shape backgrounds, shape=rectangle, shape height=8pt, shape width=\rt@width, shape evenly spread=1}] {(\rt@xa,\rt@ya) -- node[sloped] {\tiny 1$|$...$|$n} (\rt@xb,\rt@yb)};
390 \draw[\rt@arrowtip, thin, dashed] (\rt@xb,\rt@yb) to #3 #2;
391 }
392
393
394 \newcommand{\shiftfifon@noarrow}[3]{%
395
396 \node (rt@p1) at #1 {} ;
397 \node (rt@p2) at #2 {} ;
398
399 \rt@midpoints{0.30}{0.70}{rt@p1}{rt@p2}
400
401 \pgfmathsetlength{\rt@width}{sqrt((\rt@xa - \rt@xb)^2 + (\rt@ya - \rt@yb)^2)}
402
403 \draw[thin] #1 to (\rt@xa,\rt@ya);
404 \draw[dashed] decorate[decoration={shape backgrounds, shape=rectangle, shape height=8pt, shape width=\rt@width, shape evenly spread=1}] {(\rt@xa,\rt@ya) -- node[sloped] {\tiny 1$|$...$|$n} (\rt@xb,\rt@yb)};
405 \draw[thin, dashed] (\rt@xb,\rt@yb) to #3 #2;
406 }
407
408 %%%%%%%%%%%%%%%%%%%%%%%%%%%
409
410
411
412 % Lossy Fifo n
413
414 \newcommand{\lossyfifon}{%
415 \@ifstar\lossyfifon@noarrow\lossyfifon@arrow
416 }
417
418
419 \newcommand{\lossyfifon@arrow}[3]{%
420
421 \node (rt@p1) at #1 {} ;
422 \node (rt@p2) at #2 {} ;
423
424 \rt@midpoints{0.30}{0.65}{rt@p1}{rt@p2}
425
426 \pgfmathsetlength{\rt@width}{sqrt((\rt@xa - \rt@xb)^2 + (\rt@ya - \rt@yb)^2)}
427
428 \draw[dashed, thin] #1 to (\rt@xa,\rt@ya);
429 \draw[dashed] decorate[decoration={shape backgrounds, shape=rectangle, shape height=8pt, shape width=\rt@width, shape evenly spread=1}] {(\rt@xa,\rt@ya) -- node[sloped] {\tiny 1$|$...$|$n} (\rt@xb,\rt@yb)};
430 \draw[\rt@arrowtip, thin] (\rt@xb,\rt@yb) to #3 #2;
431 }
432
433
434 \newcommand{\lossyfifon@noarrow}[3]{%
435
436 \node (rt@p1) at #1 {} ;
437 \node (rt@p2) at #2 {} ;
438
439 \rt@midpoints{0.30}{0.70}{rt@p1}{rt@p2}
440
441 \pgfmathsetlength{\rt@width}{sqrt((\rt@xa - \rt@xb)^2 + (\rt@ya - \rt@yb)^2)}
442
443 \draw[dashed, thin] #1 to (\rt@xa,\rt@ya);
444 \draw[dashed] decorate[decoration={shape backgrounds, shape=rectangle, shape height=8pt, shape width=\rt@width, shape evenly spread=1}] {(\rt@xa,\rt@ya) -- node[sloped] {\tiny 1$|$...$|$n} (\rt@xb,\rt@yb)};
445 \draw[thin] (\rt@xb,\rt@yb) to #3 #2;
446 }
447
448
449
450
451 %Timer
452
453
454
455
456 \newcommand{\timer}{%
457 \@ifstar\timer@noarrow\timer@arrow
458 }
459
460 \newcommand{\timer@arrow}[3]{%
461 \node (rt@p1) at #1 {} ;
462 \node (rt@p2) at #2 {} ;
463
464 \rt@middlepoint{rt@p1}{rt@p2}
465 \rt@midpoints{0.4}{0.60}{rt@p1}{rt@p2}
466 \pgfmathsetlength{\rt@width}{(sqrt((\rt@xa - \rt@xc)^2 + (\rt@ya - \rt@yc)^2))}
467
468 \draw[thin] #1 to (\rt@xa,\rt@ya);
469 \draw (\rt@xc,\rt@yc) circle (\rt@width) ;
470 \draw[\rt@arrowtip, thin] (\rt@xb,\rt@yb) to #3 #2;
471 }
472
473
474 \newcommand{\timer@noarrow}[3]{%
475 \node (rt@p1) at #1 {} ;
476 \node (rt@p2) at #2 {} ;
477
478 \rt@middlepoint{rt@p1}{rt@p2}
479 \rt@midpoints{0.4}{0.60}{rt@p1}{rt@p2}
480 \pgfmathsetlength{\rt@width}{(sqrt((\rt@xa - \rt@xc)^2 + (\rt@ya - \rt@yc)^2))}
481
482 \draw[thin] #1 to (\rt@xa,\rt@ya);
483 \draw (\rt@xc,\rt@yc) circle (\rt@width) ;
484 \draw[\rt@arrowtip, thin] (\rt@xb,\rt@yb) to #3 #2;
485 }
486
487
488
489
490
491
492
493
494
495
496
497
498 %Auxiliary Channel
499
500 \newcommand{\baseasyncchannels@arrow}[4]{%
501
502 \node (rt@p1) at #1 {} ;
503 \node (rt@p2) at #2 {} ;
504
505 \rt@midpoints{0.25}{0.75}{rt@p1}{rt@p2}
506
507 \draw[thin]%
508 #1 to (\rt@xa,\rt@ya) ;
509 \draw[white, thin]
510 (\rt@xa,\rt@ya) to node[color=black, sloped] {{\small #4}} (\rt@xb,\rt@yb);
511 \draw[\rt@arrowtip, thin]%
512 (\rt@xb,\rt@yb) to #3 #2;
513
514 }
515
516
517 \newcommand{\baseasyncchannels@noarrow}[4]{%
518
519 \node (rt@p1) at #1 {} ;
520 \node (rt@p2) at #2 {} ;
521
522 \rt@midpoints{0.25}{0.75}{rt@p1}{rt@p2}
523
524 \draw[thin]%
525 #1 to (\rt@xa,\rt@ya) ;
526 \draw[white, thin]
527 (\rt@xa,\rt@ya) to node[color=black, sloped] {{\small #4}} (\rt@xb,\rt@yb);
528 \draw[ thin]%
529 (\rt@xb,\rt@yb) to #3 #2;
530
531 }
532
533
534 %Ordered
535
536 \newcommand{\ordered}{%
537 \@ifstar \ordered@noarrow \ordered@arrow
538 }
539
540 \newcommand{\ordered@arrow}[3]{%
541 \baseasyncchannels@arrow{#1}{#2}{#3}{ord}
542 }
543
544 \newcommand{\ordered@noarrow}[3]{%
545 \baseasyncchannels@noarrow{#1}{#2}{#3}{ord}
546 }
547
548
549 %%%%%%%%%%%%%%
550
551
552
553 %Ordered N
554 \newcommand{\orderedn}{%
555 \@ifstar \orderedn@noarrow \orderedn@arrow
556 }
557
558 \newcommand{\orderedn@arrow}[3]{%
559 \baseasyncchannels@arrow{#1}{#2}{#3}{ord$_n$}
560 }
561
562 \newcommand{\orderedn@noarrow}[3]{%
563 \baseasyncchannels@noarrow{#1}{#2}{#3}{ord$_n$}
564 }
565
566
567 %%%%%%%%%%%%%%%%%%
568
569 %Bag
570
571 \newcommand{\bag}{%
572 \@ifstar \bag@noarrow \bag@arrow
573 }
574
575 \newcommand{\bag@arrow}[3]{%
576 \baseasyncchannels@arrow{#1}{#2}{#3}{({\tiny ...})}
577 }
578
579 \newcommand{\bag@noarrow}[3]{%
580 \baseasyncchannels@noarrow{#1}{#2}{#3}{({\tiny ...})}
581 }
582
583
584 %Bag N
585
586 \newcommand{\bagn}{%
587 \@ifstar \bagn@noarrow \bagn@arrow
588 }
589
590 \newcommand{\bagn@arrow}[3]{%
591 \baseasyncchannels@arrow{#1}{#2}{#3}{({\tiny ...})$_n$}
592 }
593
594 \newcommand{\bagn@noarrow}[3]{%
595 \baseasyncchannels@noarrow{#1}{#2}{#3}{({\tiny ...})$_n$}
596 }
597
598
599 %Set
600
601 \newcommand{\set}{%
602 \@ifstar \set@noarrow \set@arrow
603 }
604
605 \newcommand{\set@arrow}[3]{%
606 \baseasyncchannels@arrow{#1}{#2}{#3}{\{{\tiny ...}\}}
607 }
608
609 \newcommand{\set@noarrow}[3]{%
610 \baseasyncchannels@noarrow{#1}{#2}{#3}{\{{\tiny ...}\}}
611 }
612
613
614 %Set N
615
616 \newcommand{\setn}{%
617 \@ifstar \setn@noarrow \setn@arrow
618 }
619
620 \newcommand{\setn@arrow}[3]{%
621 \baseasyncchannels@arrow{#1}{#2}{#3}{\{{\tiny ...}\}$_n$}
622 }
623
624 \newcommand{\setn@noarrow}[3]{%
625 \baseasyncchannels@noarrow{#1}{#2}{#3}{\{{\tiny ...}\}$_n$}
626 }
627
628
629 %Dealy Set
630
631 \newcommand{\delayset}{%
632 \@ifstar \delayset@noarrow \delayset@arrow
633 }
634
635 \newcommand{\delayset@arrow}[3]{%
636 \baseasyncchannels@arrow{#1}{#2}{#3}{DSet}
637 }
638
639 \newcommand{\delayset@noarrow}[3]{%
640 \baseasyncchannels@noarrow{#1}{#2}{#3}{DSet}
641 }
642
643
644 %Delay Set N
645 \newcommand{\delaysetn}{%
646 \@ifstar \delaysetn@noarrow \delaysetn@arrow
647 }
648
649 \newcommand{\delaysetn@arrow}[3]{%
650 \baseasyncchannels@arrow{#1}{#2}{#3}{DSet$_n$}
651 }
652
653 \newcommand{\delaysetn@noarrow}[3]{%
654 \baseasyncchannels@noarrow{#1}{#2}{#3}{DSet$_n$}
655 }
656
657
658
659 %Keyed Set
660
661 \newcommand{\keyedset}{%
662 \@ifstar \keyedset@noarrow \keyedset@arrow
663 }
664
665 \newcommand{\keyedset@arrow}[3]{%
666 \baseasyncchannels@arrow{#1}{#2}{#3}{KSet}
667 }
668
669
670 \newcommand{\keyedset@noarrow}[3]{%
671 \baseasyncchannels@noarrow{#1}{#2}{#3}{KSet}
672 }
673
674 %Keyed Set N
675
676 \newcommand{\keyedsetn}{%
677 \@ifstar \keyedsetn@noarrow \keyedsetn@arrow
678 }
679
680 \newcommand{\keyedsetn@arrow}[3]{%
681 \baseasyncchannels@arrow{#1}{#2}{#3}{KSet$_n$}
682 }
683
684 \newcommand{\keyedsetn@noarrow}[3]{%
685 \baseasyncchannels@noarrow{#1}{#2}{#3}{KSet$_n$}
686 }
687
688
689
690
691
692 %%%%%%%%%%%%%% L shaped %%%%%%%%%%%%%%%%%%%
693 %Generic\Lhannel*?[<option>]?{<channel name>}{<start>}{<target>}{<height>}{<orientation>}{<polarization>}{<node>}
694 %Example: \Lhannel[??]{fifoe}{(0,0)}{(2,0.5)}{0.5}{v}{+}{node {a}}
695 %|-a>
696
697 \newcommand{\Lchannel}{
698 \@ifstar \Lchannel@arrow@part \Lchannel@arrow@channel
699 }
700
701 \newcommand{\Lchannel@arrow@channel}[8][solid]{
702
703 \ifthenelse{\equal{#6}{v} \and \equal{#7}{+}}{
704 \rt@pin{(rt@pinlc1)}{($ #3 + (0,#5) $)}
705 }
706 {
707 \ifthenelse{\equal{#6}{v} \and \equal{#7}{-}}{
708 \rt@pin{(rt@pinlc1)}{($ #3 - (0,#5) $)}
709 }
710 {
711 \ifthenelse{\equal{#6}{h} \and \equal{#7}{+}}{
712 \rt@pin{(rt@pinlc1)}{($ #3 + (#5,0) $)}
713 }
714 {
715 \ifthenelse{\equal{#6}{h} \and \equal{#7}{-}}{
716 \rt@pin{(rt@pinlc1)}{($ #3 - (#5,0) $)}
717 }
718 {
719 \PackageError{reotex}{Expecting: v/h and +/- as 5th and 6th arguments (resp.)}{The 5th argument must be one of v or h, for vertical or horizontal orientation.\MessageBreak The 6th argument must be one of + or - for a positive or negative polarisation.}
720 } % ERROR STATE
721 }
722 }
723 }
724 \rt@cp[#1]{#3}{(rt@pinlc1)}
725 \csname #2\endcsname{(rt@pinlc1)}{#4}{#8}
726 %csname expands the argument name x to \x. Care should be taken: there should not exist a space after the name to expand as command. The arguments of the command should come after the \endcsname
727 }
728
729
730
731 \newcommand{\Lchannel@arrow@part}[8][solid]{
732 \ifthenelse{\equal{#6}{v} \and \equal{#7}{+}}{
733 \rt@pin{(rt@pinlc2)}{($ #3 + (0,#5) $)}
734 }
735 {
736 \ifthenelse{\equal{#6}{v} \and \equal{#7}{-}}{
737 \rt@pin{(rt@pinlc2)}{($ #3 - (0,#5) $)}
738 }
739 {
740 \ifthenelse{\equal{#6}{h} \and \equal{#7}{+}}{
741 \rt@pin{(rt@pinlc2)}{($ #3 + (#5,0) $)}
742 }
743 {
744 \ifthenelse{\equal{#6}{h} \and \equal{#7}{-}}{
745 \rt@pin{(rt@pinlc2)}{($ #3 - (#5,0) $)}
746 }
747 {
748 \PackageError{reotex}{Expecting: v/h and +/- as 5th and 6th arguments (resp.)}{The 5th argument must be one of v or h, for vertical or horizontal orientation.\MessageBreak The 6th argument must be one of + or - for a positive or negative polarisation.}
749 } % ERROR STATE
750 }
751 }
752 }
753 \rt@cp*[#1]{(rt@pinlc2)}{#3}
754 \csname #2\endcsname *{#4}{(rt@pinlc2)}{#8}
755 }
756
757
758
759
760
761
762 %%%%%%%%%%%%%% U shaped %%%%%%%%%%%%%%%%%%%
763 %Generic\Uhannel*?[<option>]?{<channel name>}{<start>}{<target>}{<height>}{<orientation>}{<polarization>}{<label>}
764 %Example: \Uchannel[dashed]{lossysync}{(0,0)}{(2,0.5)}{0.5}{v}{+}{node {a}}
765 %|---a>
766
767 %\newcommand{\Uchannel}{
768 % \@ifstar \Uchannel@arrow@target \Uchannel@arrow@target
769 %}
770
771 \newcommand{\Uchannel}[8][solid]{
772
773 \ifthenelse{\equal{#6}{v} \and \equal{#7}{+}}{
774 \rt@pin{(rt@pinuc1)}{($ #3 + (0,#5) $)}
775 \rt@pin{(rt@pinuc2)}{($ #4 + (0,#5) $)}
776 }
777 {
778 \ifthenelse{\equal{#6}{v} \and \equal{#7}{-}}{
779 \rt@pin{(rt@pinuc1)}{($ #3 - (0,#5) $)}
780 \rt@pin{(rt@pinuc2)}{($ #4 - (0,#5) $)}
781 }
782 {
783 \ifthenelse{\equal{#6}{h} \and \equal{#7}{+}}{
784 \rt@pin{(rt@pinuc1)}{($ #3 + (#5,0) $)}
785 \rt@pin{(rt@pinuc2)}{($ #4 + (#5,0) $)}
786 }
787 {
788 \ifthenelse{\equal{#6}{h} \and \equal{#7}{-}}{
789 \rt@pin{(rt@pinuc1)}{($ #3 - (#5,0) $)}
790 \rt@pin{(rt@pinuc2)}{($ #4 - (#5,0) $)}
791 }
792 {
793 \PackageError{reotex}{Expecting: v/h and +/- as 5th and 6th arguments (resp.)}{The 5th argument must be one of v or h, for vertical or horizontal orientation.\MessageBreak The 6th argument must be one of + or - for a positive or negative polarisation.}
794 } % ERROR STATE
795 }
796 }
797 }
798 %
799 \ifthenelse{\equal{#2}{shiftfifon}}{
800 \rt@cp*[dashed]{(rt@pinuc2)}{#4}
801 \rt@cp[solid]{#3}{(rt@pinuc1)}
802 }
803 {
804 \ifthenelse{\equal{#2}{lossyfifon}}{
805 \rt@cp[dashed]{#3}{(rt@pinuc1)}
806 \rt@cp*[solid]{(rt@pinuc2)}{#4}
807 }
808 {
809 \rt@cp[#1]{#3}{(rt@pinuc1)}
810 \rt@cp*[#1]{(rt@pinuc2)}{#4}
811 }
812 }
813 \csname #2\endcsname *{(rt@pinuc1)}{(rt@pinuc2)}{#8}
814
815 }
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832 %%%%%%%%%% ARROWS %%%%%%%%%%%%%
833
834 %outwards
835 \pgfarrowsdeclare{outwards}{outwards}
836 {
837 \rt@thearrowsize=1.4pt
838 \advance\rt@thearrowsize by .5\pgflinewidth
839 \pgfarrowsleftextend{-.5\pgflinewidth}
840 \pgfarrowsrightextend{3\rt@thearrowsize+.5\pgflinewidth}
841 }
842 {
843 \advance\rt@thearrowsize by .5\pgflinewidth
844 \pgfpathmoveto{\pgfpoint{-4.5\rt@thearrowsize}{1.2\rt@thearrowsize}}
845 \pgfpathlineto{\pgfpoint{-4.5\rt@thearrowsize}{-1.2\rt@thearrowsize}}
846 \pgfpathlineto{\pgfpoint{-2.0\rt@thearrowsize}{0pt}}
847 \pgfpathlineto{\pgfpoint{-4.5\rt@thearrowsize}{1.2\rt@thearrowsize}}
848 \pgfusepathqfill
849 }
850
851
852
853
854
855
856
857
858 %inwards
859 \pgfarrowsdeclare{inwards}{inwards}
860 {
861 \rt@thearrowsize=1.4pt
862 \advance\rt@thearrowsize by .5\pgflinewidth
863 \pgfarrowsleftextend{-.5\pgflinewidth}
864 \pgfarrowsrightextend{3\rt@thearrowsize+.5\pgflinewidth}
865 }
866 {
867 \advance\rt@thearrowsize by .5\pgflinewidth
868 \pgfpathmoveto{\pgfpoint{-2\rt@thearrowsize}{1.2\rt@thearrowsize}}
869 \pgfpathlineto{\pgfpoint{-2\rt@thearrowsize}{-1.2\rt@thearrowsize}}
870 \pgfpathlineto{\pgfpoint{-4.5\rt@thearrowsize}{0pt}}
871 \pgfpathlineto{\pgfpoint{-2\rt@thearrowsize}{1.2\rt@thearrowsize}}
872 \pgfusepathqfill
873 }
874
875
876
877
878
879
880 %%%%%%%%%% NODES %%%%%%%%%%%%%%%%%%
881
882
883 \newcommand{\rt@pin}[2]{%
884 \node[outer sep=-1.3mm] #1 at #2 {} ;
885 }
886
887
888 \newcommand{\ionode}[3]{%
889 \node[outer sep=-0.15mm] #1 at #2 {} ;
890 \draw[fill=white, minimum size=2pt] #2 circle (2.7pt) #3 ;
891 }
892
893
894 \newcommand{\mixednode}[3]{%
895 \node[outer sep=-0.2mm] #1 at #2 {} ;
896 \draw[fill=gray!20!black, minimum size=2.9pt] #2 circle (2.2pt) #3 ;
897 }
898
899
900 \newcommand{\reader}[3]{%
901 \node[outer sep=0mm] #1 at #2 {} ;
902 \draw[fill=white, minimum size=3pt] ($#2 + (-0.15,0.15)$) rectangle ($ #2 + (0.15,-0.15) $) #3 ;
903 }
904
905 \newcommand{\writer}[3]{%
906 \node[outer sep=0mm] #1 at #2 {} ;
907 \draw[fill=black, minimum size=3pt] ($#2 + (-0.15,0.15)$) rectangle ($ #2 + (0.15,-0.15) $) #3 ;
908 }
909
910
911
912 \newcommand{\xrouter}[3]{%
913 \node[outer sep=0.35mm] #1 at #2 {} ;
914 \draw[cross, fill=white, minimum size=2.3pt] #2 circle (5pt) #3 ;
915 }
916
917
918
919 %%%%%%%%%%%% UTILITIES %%%%%%%%%%%%%%%%%%%%
920
921 \newcommand{\rt@cp}{%
922 \@ifstar \rt@cp@arrow \rt@cp@noarrow
923 }
924
925 \newcommand{\rt@cp@noarrow}[3][solid]{%
926 \draw[#1] #2 to #3;
927 }
928
929 \newcommand{\rt@cp@arrow}[3][solid]{%
930 \draw[\rt@arrowtip ,#1] #2 to #3;
931 }
932
933
934
935
936 %% added on: 2012/07/27 %%
937
938 %%%%%%%%%%% COMPONENTS (BLACK BOXES)%%%%%
939 % arg1: corner 1
940 % arg2: corner 2
941 % arg3: text node
942 \newcommand{\component}[3]{%
943 \draw[rounded corners=1ex] #1 rectangle #2 #3;
944 }
945
946
947 \makeatother
948
949
950 \endinput