123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- % Tikz File mqtt_pub_sub.tex
- \documentclass{standalone}
- \usepackage{tikz, graphicx}
-
- \begin{document}
- \begin{tikzpicture}
- %\draw[help lines] (-7,-5) grid (7,5);
-
- % Broker
- \draw (0,0) circle (2);
- \node[] at (0,-1.5) (broker) {\textbf{Broker}};
- \node[inner sep=0pt] (broker_pc) at (0,0)
- {\includegraphics[width=0.1\textwidth]{images/pc.png}};
-
- % Publisher
- \pgfmathsetmacro\xl{-6};
- \pgfmathsetmacro\xr{-3};
- \pgfmathsetmacro\w{(\xl+\xr)};
- \pgfmathsetmacro\y{6};
-
- % Text
- \node[] at (\w/2,-\y/2-0.25) (pubs) {\textbf{MQTT Clients}};
-
- % Images
- \node[inner sep=0pt] (laptop) at (\w/2,\y/3)
- {\includegraphics[width=0.1\textwidth]{images/laptop.png}};
-
- \node[inner sep=0pt] (mcu) at (\w/2,\y/3-\y/3)
- {\includegraphics[width=0.1\textwidth]{images/muc.png}};
-
- \node[inner sep=0pt] (pc) at (\w/2,\y/3-\y/3-\y/3)
- {\includegraphics[width=0.1\textwidth]{images/pc.png}};
-
- \draw (\xl-0.25, \y/2-0.25) -- (\xl-0.25, -\y/2+0.25); % left
- \draw (\xl, \y/2) arc (90:180:0.25); % top left
- \draw (\xl, \y/2) -- (\xr, \y/2); % top
- \draw (\xr+0.25, \y/2-0.25) arc (0:90:0.25); % top right
- \draw (\xr+0.25, \y/2-0.25) -- (\xr+0.25, -\y/2+0.25); % right
- \draw (\xr, -\y/2) arc (270:360:0.25); % bottom right
- \draw (\xl,-\y/2) -- (\xr,-\y/2); % bottom
- \draw (\xl-0.25, -\y/2+0.25) arc (180:270:0.25); % bottom left
-
- % Subscriber
- \pgfmathsetmacro\xl{3}
- \pgfmathsetmacro\xr{6}
- \pgfmathsetmacro\w{(\xl+\xr)};
- \pgfmathsetmacro\y{6}
-
- \node[] at (\w/2,-\y/2-0.25) (subs) {\textbf{MQTT Clients}};
-
- % Images
- \node[inner sep=0pt] (server) at (\w/2,\y/3-1)
- {\includegraphics[width=0.1\textwidth]{images/server.png}};
-
- \node[inner sep=0pt] (sub_mcu) at (\w/2,\y/3-3)
- {\includegraphics[width=0.1\textwidth]{images/muc.png}};
-
- \draw (\xl-0.25, \y/2-0.25) -- (\xl-0.25, -\y/2+0.25); % left
- \draw (\xl, \y/2) arc (90:180:0.25); % top left
- \draw (\xl, \y/2) -- (\xr, \y/2); % top
- \draw (\xr+0.25, \y/2-0.25) arc (0:90:0.25); % top right
- \draw (\xr+0.25, \y/2-0.25) -- (\xr+0.25, -\y/2+0.25); % right
- \draw (\xr, -\y/2) arc (270:360:0.25); % bottom right
- \draw (\xl,-\y/2) -- (\xr,-\y/2); % bottom
- \draw (\xl-0.25, -\y/2+0.25) arc (180:270:0.25); % bottom left
-
- % arrows
- \draw[ultra thick, ->] (mcu) -- (broker_pc);
- \draw[ultra thick, ->] (laptop) -- (broker_pc);
- \draw[ultra thick, ->] (pc) -- (broker_pc);
- \draw[ultra thick, ->] (sub_mcu) -- (broker_pc);
-
- \draw[dashed, ultra thick, <-] (server) -- (broker_pc);
- \draw[dashed, ultra thick, ->] (broker_pc.10) to (sub_mcu.north west);
-
- % legend
- \draw[dashed, ultra thick, ->] (-4,-4) -- (-1,-4);
- \node[] (Sub) at (-2.5,-4.25) {Subscribe};
-
- \draw[ultra thick, ->] (1,-4) -- (4,-4);
- \node[] (Pub) at (2.5,-4.25) {Publish};
-
- \end{tikzpicture}
- \end{document}
|