<%namespace name="tools" file="tools.tex"/>

<%def name="text2symbol(text)">

<%
    if text == 'STARTED':
        context.write('?')
    elif text == 'FINISHED':
        context.write('\color{green}\\ding{51}')
    elif text == 'FAILED':
        context.write('{\color{red}\\ding{55}}')
    elif text == 'MAXRUNTIME':
        context.write('\\clock')
%>

</%def>

<%def name="info2text(info, item)">

<%
    if type(info) is dict:
        if item in info:
            if item == 'configuration':
                if info[item] in ('1', '1D', 'one', 'one-dimensional'):
                    context.write('1D')
                elif info[item] in ('2', '2D', 'two', 'two-dimensional'):
                    context.write('2D')
                else:
                    context.write('?')
            elif item == 'waves':
		if info[item] in ('s', 'stationary', 'ST'):
		    context.write('ST')
		elif info[item] in ('w', 'wave groups', 'wavegroups', 'WG'):
                    context.write('WG')
                elif info[item] in ('n', 'non-hydrostatic', 'non hydrostatic', 'NH'):
                    context.write('NH')
                else:
                    context.write('?')
            elif item == 'waterlevels':
                if info[item] in ('c', 'constant', 'invariant'):
                    context.write('C')
                elif info[item] in ('v', 'varying', 'variable'):
                    context.write('V')
                else:
                    context.write('?')
            elif item == 'fractions':
                context.write(str(int(info[item])))
            elif item == 'morphology':
                if info[item] in ('1', 'yes', 'y', 'on'):
                    context.write('\\ding{51}')
                elif info[item] in ('0', 'no', 'n', 'off'):
                    context.write(' ')
                else:
                    context.write('?')
            elif item == 'hardlayers':
                if info[item] in ('1', 'yes', 'y', 'on'):
                    context.write('\\ding{51}')
                elif info[item] in ('0', 'no', 'n', 'off'):
                    context.write(' ')
                else:
                    context.write('?')
            elif item == 'groundwaterflow':
                if info[item] in ('1', 'yes', 'y', 'on'):
                    context.write('\\ding{51}')
                elif info[item] in ('0', 'no', 'n', 'off'):
                    context.write(' ')
                else:
                    context.write('?')
            elif item == 'type':
                if info[item] == 'custom':
                    context.write(' ')
                elif info[item] == 'default':
                    context.write('\\ding{51}')
                else:
                    context.write('?')
        else:
            context.write('?')
    elif type(info) is str:
        if item == 'type':
            if info == 'custom':
                context.write(' ')
            elif info == 'default':
                context.write('\\ding{51}')
            else:
                context.write('?')
        else:
            context.write('?')
%>

</%def>

<%def name="maxlength(text, length)">

<%
    if len(text)>length:
        text = text[0:length-4]+'...'
        
    return text
%>

</%def>

\begin{center}
    \begin{longtable}{llcccccccccc}
        \caption{Status overview skillbed tests}
        \label{tab:overview}
        \hline
            Test &
            Run &
            \begin{sideways}Status\end{sideways} &
            \begin{sideways}Matlab\end{sideways} &
            \begin{sideways}Default settings\end{sideways} &
            \begin{sideways}Configuration\end{sideways} &
            \begin{sideways}Waves*\end{sideways} &
            \begin{sideways}Water levels**\end{sideways} &
            \begin{sideways}Fractions\end{sideways} &
            \begin{sideways}Morphology\end{sideways} &
            \begin{sideways}Hard layers\end{sideways} &
            \begin{sideways}Groundwater flow\end{sideways} \\ 
        \hline
        \endhead
        
% for test in sorted(status.keys()):

% for run in sorted(status[test].keys()):

<%
        test_stat = status[test][run]['test']
        matlab_stat = status[test][run]['matlab']
%>

            ${tools.latex_escape(maxlength(test, 20))} &
            ${tools.latex_escape(maxlength(run, 10))} &
            ${text2symbol(test_stat)} & 
            ${text2symbol(matlab_stat)} &
            ${info2text(info[test][run],'type')} &
            ${info2text(info[test][run],'configuration')} &
            ${info2text(info[test][run],'waves')} &
            ${info2text(info[test][run],'waterlevels')} &
            ${info2text(info[test][run],'fractions')} &
            ${info2text(info[test][run],'morphology')} &
            ${info2text(info[test][run],'hardlayers')} &
            ${info2text(info[test][run],'groundwaterflow')} \\ 

% endfor

% endfor
            
        \hline
        \multicolumn{12}{l}{* ST = stationary, WG = wave groups, NH = non-hydrostatic} \\ 
	\multicolumn{12}{l}{** C = constant, V = varying}
    \end{longtable}
\end{center}