+\section{iTasks}
+The server part of the system is written in \gls{iTasks}. Functions for
+managing devices, \glspl{Task} and \glspl{SDS} have been created to support the
+functionality. An interactive application has been created that allows an
+interactive management console for the \gls{mTask} system. This interface
+provides functionality to list \glspl{SDS}, add \glspl{Task}, remove
+\glspl{Task}, administrate devices and view the state of the system.
+
+\subsection{Integration}
+When the system starts up the devices from the previous execution still
+residing in the \gls{SDS} must be cleaned up. It might be the case that they
+contain \glspl{Task}, \glspl{SDS} or errors that are no longer applicable in
+this run. A user or programmer can later choose to reconnect to some devices.
+
+\begin{lstlisting}[caption={Starting up the devices},%
+ label={lst:startupdevs}]
+startupDevices :: Task [MTaskDevice]
+startupDevices = upd (map reset) deviceStoreNP
+ where reset d = {d & deviceTask=Nothing, deviceTasks=[], deviceError=Nothing}
+\end{lstlisting}
+
+An image of the management interface is shown in Figure~\ref{lst:manage}.
+The system management is done by a single \gls{Task} called \CI{mTaskManager}.
+To manage the system, a couple of different functionalities are needed and
+are launched. The left sidebar of the interface shows the list of example
+\glspl{Task} that are present in the system. When clicking a \gls{Task}, a
+dialog opens in which you can select the device to send the \gls{Task} to. The
+dialog might contain user specified variables. All example \glspl{mTask} are of
+the type \CI{Task (Main (ByteCode () Stmt))} and can thus ask for user input
+first.
+
+The bottom panel shows the device information. In this panel, the devices can
+be created and modified. Moreover, this panel allows the user to reconnect with
+a device after a restart of the server application.
+
+\begin{figure}[H]
+ \centering
+ \includegraphics[width=\linewidth]{manage}
+ \caption{The device management interface}\label{lst:manage}
+\end{figure}
+
+\subsection{Shares}
+The architecture of the system needs to keep track of the \glspl{SDS} stored on
+the client. \glspl{SDS} can be stored on only one device at the same time.
+that also stores the of devices. This means that if a \gls{SDS} updates,
+everyone watching it will be notified. This would result in to a lot of
+notifications that are not ment to be for the listener. Moreover, when a client
+updates the \gls{SDS} this is processed by the connection handler and results
+in an update of the real \gls{SDS}.
+Finally, the \gls{SDS} of a client must be synchronized with the actual device.
+There are several ways of tackling this problem each with their own pros and
+cons and their own level of abstraction.
+
+\begin{itemize}
+ \item Instantiate an actual \gls{iTasks}-\gls{SDS} for every \gls{SDS} used
+ in a client.
+
+ \item Instantiate a \gls{iTasks}-\gls{SDS} for every device that stores all
+ their \glspl{SDS}.
+
+ \item Use only one \gls{iTasks}-\gls{SDS} for all devices.
+\end{itemize}
+
+\begin{lstlisting}[label={lst:actualdev},%
+ caption={Real types for the device \gls{SDS}}]
+deviceStoreNP :: Shared [MTaskDevice]
+deviceStore :: RWShared (Maybe (MTaskDevice, Int)) [MTaskDevice] [MTaskDevice]
+\end{lstlisting}
+
+\subsection{Parametric Lenses}
+The type of the parametric lens is \CI{Maybe (MTaskDevice, Int)}. The \gls{SDS}
+can be responsible for the entire list of devices, from now on global.
+Moreover, the \gls{SDS} can focus on a single device, from now on local. A
+local \gls{SDS} can also specifically focus on a single \gls{SDS} on a single
+device, from now on called local-share.
+
+\paragraph{Global \glspl{SDS}: }
+Accessing the global \gls{SDS} is just a matter of focussing the
+\CI{deviceStore} with the \CI{Nothing} parameter. The signature for
+\CI{deviceStore} was given in Chapter~\ref{chp:arch}. The actual implementation
+is as in Listing~\ref{lst:global}
+
+\begin{lstlisting}[label={lst:shareimpl},%
+ caption={Base share implementation}]
+deviceStoreNP :: RWShared (Maybe (MTaskDevice, Int)) [MTaskDevice] [MTaskDevice]
+deviceStoreNP = sdsFocus Nothing deviceStore
+\end{lstlisting}
+
+
+
+
+\paragraph{Local \glspl{SDS}: }
+\paragraph{Local-share specific \glspl{SDS}: }
+
+The implementation for the share is shown in Listing~\ref{lst:shareimpl}. The
+\CI{realDeviceStore} \gls{SDS} is not exported through the header files. This
+\gls{SDS} contains the actual \gls{SDS} that writes to disk or memory.
+\CI{Int} is the identifier of the \gls{SDS}. The \gls{iTasks} way of applying
+lenses is through the \CI{sdsFocus} function and through the \CI{sdsLens}
+functions. \CI{sdsFocus} allows the programmer to fix the parameter.
+\CI{sdsLens} is basically a \CI{mapReadWrite} that has access to the parameter.
+This allows the programmer to create filters and lenses. Both of the methods
+are not good enough for the device \gls{SDS} because they do not achieve the
+writing to the actual device. Writing to a device requires being able to write
+to \glspl{SDS}. To solve this problem, a real base \gls{SDS} is created. All
+the details are visible in Listing~\ref{lst:shareimpl}.
+