I am a beginner in LaTeX, and TikZ trying to make an industrial document, with a series of keying patterns. I have managed to produce in the attached MWE what is needed, put I have to adjust manually the position of every half circle into the corresponding hexagon. I wonder if there would be a more sensible way to do this... (ie aligning the center of the half circle with the center of the hexagon). As I have many other configurations to show, where each half circle is to be placed at different angles, I have tried to use a \foreach loop, but could not find a way that would work....I would appreciate any help to improve the code.
\documentclass{standalone}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz} % Enabling watermarks and special graphics
\usetikzlibrary{positioning,chains, matrix,shapes,decorations,backgrounds,}
\begin{document}
\begin{tikzpicture}[every node/.style={on grid, regular polygon, regular polygon sides=6, minimum width=10mm, minimum height=10 mm, draw, very thick, node distance=15mm, anchor= west},]
\begin{scope}
\node[draw= white, rectangle, text width=18em, ] (0) {\textbf{Coding pattern for plug}};
\node[right of=0, xshift= 4 em, label=above:1 ] (1) {};
\node [right of=0, xshift= 4 em, circle, draw, minimum size=7.8mm] {};
\node [right of=0, xshift= 4 em, yshift =1ex, semicircle, fill= black, minimum size=3.8mm,] {};
\node[right of=1, label=above:2] (2) {};
\node [right of=1, circle, draw, minimum size=7.8mm] {};
\node [right of=1, semicircle, fill= black, xshift= 0.9ex, yshift= 0.5ex, minimum size=3.8mm, rotate=-60] {};
\node [right of=1, circle, draw, minimum size=7.8mm] {};
\node[right of=2, label=above:3] (3) {};
\node [right of=2, circle, draw, minimum size=7.8mm] {};
\node [right of=2, semicircle, fill= black, xshift= 0.7ex, yshift =-0.4ex, minimum size=3.8mm, rotate=-120] {};
\end{scope}
\begin{scope}[yshift=2cm]
\node[draw= white, rectangle,text width=18em ] (0) {\textbf{Coding pattern for receptacle}};
\node[right of=0, xshift= 4 em, label=above:4 ] (4) {};
\node [right of=0, xshift= 4 em, yshift=-1ex, semicircle, fill= black, minimum size=3.8mm, rotate=180] {};
\node [right of=0, xshift= 4 em, circle, draw, minimum size=7.8mm] {};
\node[right of=4, label=above:3] (3) {};
\node [right of=4, semicircle, fill= black,xshift=-1ex, yshift= -0.5ex, minimum size=3.8mm, rotate=120] {};
\node [right of=4, circle, draw, minimum size=7.8mm] {};
\node[right of=3, label=above:2] (2) {};
\node [right of=3, semicircle, fill= black, xshift=-0.7 ex, yshift=0.4ex,minimum size=3.8mm, rotate=60] {};
\node [right of=3, circle, draw, minimum size=7.8mm] {};
\end{scope}
\end{tikzpicture}
\end{document}

