%==============================================================================
% Document header
%==============================================================================
\documentclass[a4paper,11pt]{article}

% Margin setup to use more of the page
\usepackage[top=3cm, bottom=3cm, left=2cm, right=2cm]{geometry}

% Color package
\usepackage[usenames,dvipsnames,table]{xcolor}

% Hyperrefs
\usepackage[
  colorlinks = true,
  linkcolor  = black,
  citecolor  = black,
  urlcolor   = blue,
]{hyperref}

% Longtable
\usepackage{longtable}

% Graphics, multirow
\usepackage{graphicx}
\usepackage{multirow}

% Appendix package
\usepackage[toc,page]{appendix}

\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}
\fancyhead[L]{\nouppercase{\leftmark}}
\fancyhead[R]{}
\renewcommand{\footrulewidth}{0.4pt}

% Row number command
\newcounter{rownr}
\newcommand{\rownumber}{\stepcounter{rownr}\arabic{rownr}}

%==============================================================================
% Start of document
%==============================================================================
\begin{document}

%------------------------------------------------------------------------------
% Title
%------------------------------------------------------------------------------
\include{cern-title}

%------------------------------------------------------------------------------
% Licensing info
%------------------------------------------------------------------------------
\pagebreak

\thispagestyle{empty}

\addcontentsline{toc}{section}{Licensing information}
\section*{Licensing information}

\noindent
This document is licensed under a Creative Commons Attribution-ShareAlike 4.0
International License. If you have not received a copy of the license along with this
work, see \\
\url{http://creativecommons.org/licenses/by-sa/4.0/}

%------------------------------------------------------------------------------
% Revision history
%------------------------------------------------------------------------------
\section*{Revision history}
\addcontentsline{toc}{section}{Revision history}

\centerline
{
  \rowcolors{2}{white}{gray!25}
  \begin{tabular}{l c p{.6\textwidth}}
  \hline
  \multicolumn{1}{c}{\textbf{Date}} & \multicolumn{1}{c}{\textbf{Version}} & \multicolumn{1}{c}{\textbf{Change}} \\
  \hline
  DATE & 0.1 & First draft \\
  \hline
  \end{tabular}
}

%------------------------------------------------------------------------------
% Table of contents, list of figs, tables
%------------------------------------------------------------------------------
\pagebreak
\pdfbookmark[1]{\contentsname}{toc}
\tableofcontents

\listoffigures
\listoftables

%------------------------------------------------------------------------------
% List of abbreviations
%------------------------------------------------------------------------------
\pagebreak
\section*{List of abbreviations}
\begin{tabular}{l l}
FM & Front Module \\
\end{tabular}
\addcontentsline{toc}{section}{List of abbreviations}

%==============================================================================
% SEC: Intro
%==============================================================================
\pagebreak
\section{Introduction}
\label{sec:intro}

This document shows how to install a PTS test system for the CONV-TTL-RS485 FM cards.
It takes the reader through installing wires that are needed for these cards through the 19'' rack,
and then focuses on installing the test system (scripts, preparing shortcuts, etc.) on the PTS laptop.

%==============================================================================
% SEC: Rack setup
%==============================================================================
\section{Rack setup}
\label{sec:rack}

To setup the rack for the PTS system, we will need to pass some Lemo 00 cables from the
front to the back of the 19'' rack. Then, we'll need to connect two RS-485 tester cards
to these cables so that the FM can drive the tester card to perform the tests.
The following steps should be performed:

\begin{enumerate}
  \item Open the top and back of the 19'' rack
  \item Take four \textcolor{red}{\textbf{LENGTH}} Lemo 00 cables and pass them from the front
  to the back of the rack
  \item Fix them to the rack so that they can be inserted in slot 5 of the ELMA crate
  \item Take four Lemo 00 T splitters and connect one short (1~ns delay) Lemo 00 cable
  on each female plug of the T splitters
  \item Using Lemo 00 female-to-female adapters, connect the long cables coming
  from the front of the rack to the T splitters' male side
  \item Label each of the long cables with colored labels on both sides, in this order from
  left to right:
  \begin{itemize}
    \item blue
    \item green
    \item red
    \item yellow
  \end{itemize}
  \item Take the two RS-485 tester cards and insert the short (1~ns) cables to the plugs
  according to the color coding:
  \begin{itemize}
    \item blue cables to BLU plugs
    \item green cables to GRN plugs
    \item red cables to RED plugs
    \item yellow cables to YEL plugs
  \end{itemize}
  \item Insert a CONV-TTL-RTM-RS485 card into the back of the ELMA crate, in slot 4
  \item Insert the two RS485 tester cards all the way into the RTM in slot 5:
  \begin{itemize}
    \item one tester card for channels 1--3
    \item the other for channels 4--6
  \end{itemize}
  \item Close the top of the 19'' rack
  \item Close the back of the 19'' rack
\end{enumerate}

%==============================================================================
% SEC: Install Ubuntu on the laptop
%==============================================================================
\pagebreak
\section{Install Ubuntu on the laptop}
\label{sec:install-ubuntu}

If you end up with a bare laptop without an OS installed, you have to follow the
laptop installation guide written by Julian for the SVEC PTS system:

  \begin{itemize}
    \item \url{http://cern.ch/go/H9tv}
  \end{itemize}

Note that this guide can be followed selectively, for example you need not set up your
system to gain remote access to the laptop, the installation of the system can also be done
on the laptop directly. However, the steps related to network drivers and configuration
should be followed in order to have a properly working PTS system.

The guide should be followed until \textbf{step 17} of section \textbf{Set up the PTS user account}.
After this step, the guide is SVEC-related and need not be followed. We will continue with
the details in the next section to test our system and network was properly installed.

%==============================================================================
% SEC: ELMA setup
%==============================================================================
\section{Setting up the ELMA crate}
\label{sec:elma-setup}

\begin{enumerate}
  \item The ELMA crate should be configured to have the password \verb=ADMIN= for the \verb=admin= account
  \item Login to the ELMA crate to test the setup in Section~\ref{sec:install-ubuntu}:
  \begin{verbatim}
  $ telnet elma
  Trying 192.168.20.22...
  Connected to elma.
  Escape character is '^]'.
  login:admin
  password: ADMIN
  %>
  \end{verbatim}
  \item If the prompt appears as above, the setup is fine. Now we need to disable the telnet ping
  that the SysMon does, so it doesn't get in the way of our Python scripts:
  \begin{verbatim}
  %> telnetping 0
  %> saveenv
  %> reboot
  \end{verbatim}
  \item This last command will reboot the SysMon to store the telnetping settings, so the connection to the
  ELMA will be lost. This is an expected behaviour and should not get in our way. Simply reconnect
  as in step 2 to make sure the connection still works after reboot.
\end{enumerate}

%==============================================================================
% SEC: Test environment
%==============================================================================
\section{Preparing the laptop test environment}
\label{sec:environment}

\end{document}
