-- T_GenChannel.tex
--
-- To test the declaration and use of generic channels and channels that 
-- synchronize on multiple values.
-- GUI for these types of channels have not been implemented yet.
--------------------------------------------------------------------------------

\begin{\begin{zed}
  Colour ::= blue | red | green | yellow
\end{zed}  

\begin{\begin{zed}
  Weekend ::= saturday | sunday
\end{zed}  

\begin{\begin{zed}
  Angel ::= A | N | G | E | L
\end{zed}  

\begin{circus}
  \circchannel scIn: Colour \cross Weekend; scOut: Weekend \cross Colour; sc: Angel \cross Colour; simple: Colour
\end{circus}  

\begin{circus}
  \circchannel [X, Y] g : Angel \cross X \cross Y; [X] gIn: X \cross X; [Y] gOut: Angel \cross Y
\end{circus}  

\begin{circus}  
    \circprocess GenChannel_P \defs \circbegin
\end{circus}

    \begin{circus}
        SyncChannel \defs 
            simple.red \then
            sc.A.blue \then 
            scIn.blue?saturday \then
            scOut.sunday!yellow \then
            Skip
    \end{circus}     

    \begin{circus}
        Gen \defs g[Colour, Weekend].A.red.saturday \then 
            g[Weekend, Colour].N.sunday.green \then
            g[Angel, Angel].A.N.G \then
            Skip
    \end{circus}

    \begin{circus}
        GenInOut \defs 
            gIn[Colour].blue?red \then 
                gIn[Weekend].saturday?sunday \then
                    gOut[Angel].A!N \then
                        gOut[Colour].A!green \then
                            Skip
    \end{circus}

    :: Maybe it is not necessary to differentiate Input and AltingInput channels
    :: anymore
    begin{circus}
        ExtChoice \defs 
            (gIn[Colour].blue?red \then Skip)
            \extchoice
            (scIn.blue?saturday \then Skip)
            \extchoice
            (sc.A.blue \then Skip)
    \end{circus}

\begin{circus}      
      @ Skip
\circend
\end{circus}
