\newcommand{\nuage}[4]{
  \draw[xshift=#1-3.5cm,yshift=#2-2cm] (2.55,0.5) 
  .. controls (1.42,0.31) and (0.815,0.899) .. (0.91,1.4)
  .. controls (0,1.59) and (0.26,2.64) .. (0.68,2.64)
  .. controls (0.62,3.13) and (1.66,3.64) .. (2.25,3.38)
  .. controls (2.49,3.79) and (3.23,3.86) .. (3.96,3.88)
  .. controls (4.59,3.9)and (4.96,3.85) .. (5.23,3.57)
  .. controls (6.28,3.67) and (6.75,2.96) .. (6.52,2.46)
  .. controls (6.93,2.36) and (6.96,1.56) .. (6.37,1.45)
  .. controls (6.64,0.9) and (6.03,0.4) .. (5.2,0.5)
  .. controls (4.53,-0.08) and (2.8,0.01) .. (2.55,0.5)
  ;
  \draw[xshift=#1,yshift=#2] (0,0) node[inner sep=6mm] (#3) {#4} ;
}
% TODO : ajout de reglage sur la taille du nom
%\newbox\component@boxa
\newcounter{component@p@num}
\newcounter{component@r@num}
\newcounter{component@current@i}
\newcommand{\component@p}{}
\newcommand{\component@r}{}
\newlength\component@width
%\newlength\component@name@width
\newlength\component@pin@space
\newlength\component@height
\newlength\component@border@r
\newlength\component@border@p
\newlength\component@border
\setlength\component@border{5mm}

\usepackage{xkeyval,calc} 
%\usepackage{ifmtarg}
\newcommand{\sauna}{\textsc{SAUNA}\xspace}
% taken from pgf (modified to expand the list
\def\foreach#1in#2{%
  \def\pgffor@var{#1}%
  \edef\pgffor@values{#2, \noexpand\pgffor@stop,}%
  \ifx\pgffor@values\pgffor@emptyvalues
    \def\pgffor@values{\pgffor@stop,}%
  \fi%
  \let\pgffor@body\@empty%
  \global\pgffor@continuetrue%
  \pgffor@collectbody}
\newcommand{\declare@port}[2]{%
  \edef\@tempa{\csname component@#2\endcsname}%
  \stepcounter{component@#2@num}
  \ifx\@tempa\@empty\relax%
    \expandafter\edef\csname component@#2\endcsname{#1}%
  \else%
    \expandafter\edef\csname component@#2\endcsname{#1, \csname component@#2\endcsname}%
  \fi%
}
\define@key{port}{pos}{\def\component@port@pos{#1}}
\define@key{port}{label}{\def\component@port@label{#1}}
\define@key{port}{intern label}{\def\component@port@intern@label{#1}}
\presetkeys{port}{label=,pos=,intern label=}{}
\def\provides{\@ifnextchar[\@provides{\@provides[]}}
\def\@provides[#1]#2{
  \presetkeys{port}{pos=right}{}
  \setkeys{port}{#1}%
  \declare@port{{#2/\component@port@label/\component@port@pos/\component@port@intern@label}}{p}%
}
\def\requires{\@ifnextchar[\@requires{\@requires[]}}
\def\@requires[#1]#2{
  \presetkeys{port}{pos=left}{}
  \setkeys{port}{#1}%
  \declare@port{{#2/\component@port@label/\component@port@pos/\component@port@intern@label}}{r}%
}
%
\define@key{component}{name}{\def\component@name{#1}}
\define@key{component}{label}{\def\component@label{#1}}
\define@key{component}{width}{\setlength\component@width{#1}}
\define@key{component}{distance}{\setlength\component@pin@space{#1}}
\define@key{component}{border}{\setlength\component@border{#1}}
\presetkeys{component}{name=,label=,width=1cm,distance=1cm,border=5mm}{}
\def\component{\@ifnextchar[\@component{\@component[]}}
\def\@component[#1]#2{%
  \setkeys{component}{#1}%
  \setcounter{component@r@num}{-1}
  \setcounter{component@p@num}{-1}
  \def\component@pos{#2}
%   \setbox\component@boxa\hbox{SECURITE}
%   \setlength\component@name@width{\wd\component@boxa}
%     \show\component@name@width
%   \ifdim\wd\component@boxa>\component@width
%     \setlength\component@width{\component@name@width}
%     \show\component@width
%   \else
%   \fi
}
\def\endcomponent{
  \setlength\component@border@r{\component@border}
  \setlength\component@border@p{\component@border}
  \ifnum\value{component@r@num}>\value{component@p@num}
    \setlength\component@height{\component@border@r*2+\component@pin@space*\value{component@r@num}}
    \setlength\component@border@p{\component@border@r + \component@pin@space*(\value{component@r@num}-\value{component@p@num})/2}
  \else
    \setlength\component@height{\component@border@p*2+\component@pin@space*\value{component@p@num}}
    \setlength\component@border@r{\component@border@p + \component@pin@space*(\value{component@p@num}-\value{component@r@num})/2}
  \fi
  %REQUIRES
  \setcounter{component@current@i}{0}
  \begin{scope}[line width=1pt]
  \foreach \port@name/\port@label/\port@label@pos/\port@label@in in {\component@r}
    { 
    \draw \component@pos ++(0cm,\component@border@r+\component@pin@space*\value{component@current@i}) node[coordinate] (\port@label@in) {} ;
    \draw \component@pos ++(0cm,\component@border@r+\component@pin@space*\value{component@current@i}) -- ++(-0.3,0)  ++(-3pt,-3pt) arc (-90:90:3pt) ;
    \draw \component@pos ++(0cm,\component@border@r+\component@pin@space*\value{component@current@i}) ++(-0.3,0) node[coordinate] (\port@label) {} ;
    \draw \component@pos ++(0cm,\component@border@r+\component@pin@space*\value{component@current@i}) ++(-0.4,0) node[\port@label@pos] {\port@name};
    \addtocounter{component@current@i}{1}
    }
  %PROVIDES
  \setcounter{component@current@i}{0}
  \foreach \port@name/\port@label/\port@label@pos/\port@label@in in {\component@p}
    {
    \draw \component@pos ++(\component@width,\component@border@p+\component@pin@space*\value{component@current@i}) node[coordinate] (\port@label@in) {};
    \draw \component@pos ++(\component@width,\component@border@p+\component@pin@space*\value{component@current@i}) -- ++(0.3,0) node[circle,inner sep=0pt,minimum size=6pt,outer sep=0pt,fill] (\port@label) {} ;
    \draw \component@pos ++(\component@width,\component@border@p+\component@pin@space*\value{component@current@i}) ++(0.4,0) node[\port@label@pos]  {\port@name};
    \addtocounter{component@current@i}{1}
    }
  %COMPONENT
%  \draw \component@pos rectangle ++(\component@width,\component@height) ; (modif pour que les bords du composant soit les bords du noeuds
  \draw \component@pos ++(\component@width/2,0.2cm) node {\component@name} ;
  \ifx\component@label\empty%
    \draw \component@pos rectangle ++(\component@width,\component@height) ;
  \else%
%    \draw \component@pos ++(\component@width/2,\component@height/2) node[coordinate] (\component@label) {} ;% voir modif ci-dessus
    \draw \component@pos ++(\component@width/2,\component@height/2) node[draw,minimum width=\component@width,minimum height=\component@height] (\component@label) {} ;
  \fi
  \end{scope}
}

\usepackage{extpfeil}
\newcommand{\obj}[1]{\textbf{\textsc{OBJECTIF} : {#1}}}
\newcommand{\para}{\mathop{|}}
\newcommand{\optparam}[1]{{\color{blue!50}(#1)}}
\newcommand{\Cdash}[1][]{\ensuremath{\;{\color{blue} \vdash_{#1}}\;}}
\newcommand{\Ccol}{\ensuremath{\;{\color{blue} :}\;}}
\newcommand{\Ceval}{\ensuremath{\;{\color{blue} \mapsto}\;}}
\newcommand{\Cred}{\ensuremath{\;{\color{blue} \to}\;}}

\newcommand*{\env}[1][]{%
  \def\@tempa{#1}%
  \ifx\@tempa\@empty%
    \ensuremath{\mathcal{E}}%
  \else%
    \ensuremath{\mathcal{E}_{#1}}%
  \fi%
}
\newcommand*{\cst}[1][]{%
  \def\@tempa{#1}%
  \ifx\@tempa\@empty%
    \ensuremath{\varphi}%
  \else%
    \ensuremath{\varphi_{#1}}%
  \fi%
}

\newcommand*{\comp}{\ensuremath{\mathcal{C}}}
\newcommand*{\dg}{\ensuremath{\mathcal{G}}}
\newcommand*{\ps}{\ensuremath{\mathcal{P}_s}}
\newcommand*{\fs}{\ensuremath{\mathcal{F}_s}}
\newcommand*{\fc}{\ensuremath{\mathcal{F}_c}}
\newcommand*{\foc}{\ensuremath{\mathcal{F}_c}}
\newcommand*{\AS}{\ensuremath{\mathit{AS}}}
\newcommand*{\AC}{\ensuremath{\mathit{AC}}}
\newcommand*{\FS}{\ensuremath{\mathit{FS}}}
\newcommand*{\FC}{\ensuremath{\mathit{FC}}}

\newcommand*{\MD}{\ensuremath{\mathit{MD}}}
\newcommand*{\OD}{\ensuremath{\mathit{OD}}}
\newcommand*{\lmand}{\textsf{M}}
\newcommand*{\lopt}{\textsf{O}}
\newcommand*{\Nat}{{\mathbb N}}
\newcommand*{\Real}{{\mathbb R}}
\newcommand*{\compo}[1]{\ensuremath{C_{#1}}}
\newcommand*{\serv}[1]{\ensuremath{S_{#1}}}
\newcommand*{\kdep}[3]{\ensuremath{#1\xmapsto{#2}#3}}
\newcommand*{\manddep}[2]{\kdep{#1}{\lmand}{#2}}
\newcommand*{\manddepp}[2]{\kdep{#1}{\lmand,\varphi_c,\varphi_s}{#2}}
\newcommand*{\optdep}[2]{\kdep{#1}{\lopt}{#2}}
\newcommand*{\optdepp}[2]{\kdep{#1}{\lopt,\varphi_c,\varphi_s}{#2}}
\newcommand*{\dep}[2]{\kdep{#1}{-}{#2}}
\newcommand*{\depp}[2]{\kdep{#1}{-,\varphi_c,\varphi_s}{#2}}
\newcommand*{\optD}[1]{\ensuremath{\mathop{?}#1}}
\newcommand*{\andD}[2]{\ensuremath{#1 \mathbin{\bullet} #2}}
\newcommand*{\orD}[2]{\ensuremath{#1 \mathbin{\#} #2}}
\newcommand*{\sD}[2]{\ensuremath{#1 \Rightarrow #2}}
\newcommand*{\compP}[3]{\ensuremath{[#1 \mathbin{#2} #3]}}
\newcommand*{\vOval}{\compP{v}{O}{\mathit{val}}}
\newcommand*{\trueP}{\ensuremath{\mathit{true}}}
\newcommand*{\nP}[1]{\ensuremath{\mathop{\lnot} #1}}
\newcommand*{\replace}[2]{\ensuremath{#1 \gets #2}}
\newcommand{\maregle}[3]{
\inferrule*[left={\tiny#1:}]{#2}{#3} }
\newcommand{\maregleI}[3]{
\inferrule*{#2}{#3} }
\newcommand{\nomregle}[1]{{\small{\textsc{#1}}}}

\newcommand*{\service}[2][]{%
  \def\@tempa{#1}%
  \ifx\@tempa\@empty%
    \ensuremath{#2}%
  \else%
    \ensuremath{#2[#1]}%
  \fi
}
\newcommand*{\propset}[1][]{%
  \def\@tempa{#1}%
  \ifx\@tempa\@empty%
    \ensuremath{p_1 = v_1, \ldots, p_n = v_n}%
  \else%
    \ensuremath{p_1#1_1 v_1, \ldots, p_n#1_n v_n}
  \fi
}
