shares
[msc-thesis1617.git] / results.itasks.tex
1 The glue in the system is written in \gls{iTasks}. Functions for managing
2 devices, \glspl{Task} and \glspl{SDS} are created. An interface is made that
3 allows an interactive management console for the \gls{mTask} system. This
4 interface provides functionality to list shares, add tasks, remove tasks,
5 administrate devices and view the state of the system.
6
7 \section{Integration}
8 When the system starts up the devices residing in the \gls{SDS} must be cleaned
9 up. It might be the case that they contain tasks, shares or errors. A user or
10 programmer can then choose to reconnect some devices using the
11 \CI{connectDevice} function.
12
13 \begin{lstlisting}[caption={Starting up the devices},%
14 label={lst:startupdevs}]
15 startupDevices :: Task [MTaskDevice]
16 startupDevices = upd (map reset) deviceStoreNP
17 where reset d = {d & deviceTask=Nothing, deviceTasks=[], deviceError=Nothing}
18 \end{lstlisting}
19
20 An image of the management interface is shown in Figure~\ref{lst:manage}.
21 The system management is done by a single \gls{Task} called \CI{mTaskManager}.
22 To manage the system, a couple of different functionalities are needed and
23 are launched. The left sidebar of the interface shows the list of example
24 \glspl{Task} that are present in the system. When clicking a task, a dialog
25 opens in which you can select the device to send the task to. The dialog might
26 contain user specified variables. All example \glspl{mTask} are of the type
27 \CI{Task (Main (ByteCode () Stmt))} and can thus ask for user input first.
28
29 The bottom panel shows the device information. In this panel, the devices can
30 be created and modified. Moreover, this panel allows the user to reconnect with
31 a device after a restart of the server application.
32
33 \begin{figure}[H]
34 \centering
35 \includegraphics[width=\linewidth]{manage}
36 \caption{The device management interface}\label{lst:management}
37 \end{figure}
38
39 \section{Shares}
40 The architecture of the system stores the \glspl{SDS} in the \gls{SDS} that
41 stores the list of devices. This means that if a \gls{SDS} updates, everyone
42 watching it will be notified. This would result in to a lot of notifications
43 that are not ment to be for the listener. Moreover, when a client updates the
44 \gls{SDS} this is processed by the connection handler and results in an update
45 of the real \gls{SDS}. When an \gls{iTasks}-\gls{Task} writes to a \gls{SDS}
46 this is not passed on to the device.
47
48 To solve the problem, parametric lenses are used on the device storage.
49 Listing~\ref{lst:actualdev} shows the actual types for the device storage.
50 Programmers wanting to access the entire \gls{SDS} use the \CI{deviceStoreNP}.
51 Programmers wanting to access a single \gls{SDS} on a device can use the
52 \CI{getRealShare} function which is a wrapper around the \CI{deviceStore} which
53 applies a parametric lens.
54
55 \begin{lstlisting}[label={lst:actualdev},%
56 caption={Real types for the device \gls{SDS}}]
57 deviceStoreNP :: Shared [MTaskDevice]
58 deviceStore :: RWShared (Maybe (MTaskDevice, Int)) [MTaskDevice] [MTaskDevice]
59
60 realDeviceStore :: Shared [MTaskDevice]
61
62 getRealShare :: MTaskDevice MTaskShare -> Shared BCValue
63 \end{lstlisting}
64
65 \subsection{Parametric Lens}
66 Therefore the main device store
67 \todo{Semantiek van shares, hoe ze in iTasks zijn, hoe typering}