add sections about the original mTask
[msc-thesis1617.git] / results.arch.tex
1 \section{Architecture}
2 \subsection{Devices}
3 The client code for the devices is compiled from one codebase. For a device to
4 be eligible for \glspl{mTask} it must be able to compile the shared codebase
5 and implement (part of) the device specific interface. The shared codebase only
6 uses standard \gls{C} and no special libraries or tricks are used. Therefore
7 the code is compilable for almost any device or system. Note that it is not
8 needed to implement a full interface. The full interface excluding the device
9 specific settings is listed in Appendix~\ref{app:device-interface}. The
10 interface works in a similar fashion as the \gls{EDSL}. Devices do not have to
11 implement all functionality, this is analogous to the fact that views do not
12 have to implement all type classes in the \gls{EDSL}. When the device connects
13 for the first time with a server the specifications of what is implemented is
14 communicated.
15
16 At the time of writing the following device families are supported and can run
17 the device software.
18 \begin{itemize}
19 \item \texttt{POSIX} compatible systems
20
21 This includes systems running \emph{Linux} and \emph{MacOS}.
22 \item \texttt{STM32} family microcontrollers supported by \texttt{ChibiOS}.
23
24 This is tested in particular on the \texttt{STM32f7x} series \gls{ARM}
25 development board.
26 \item Microcontrollers programmable by the \emph{Arduino} \gls{IDE}.\\
27
28 This does not only include \emph{Arduino} compatible boards but also
29 other boards capable of running \emph{Arduino} code. The code
30 has been found working on the \texttt{ESP8266} powered \emph{NodeMCU}.
31 It is tested on devices as small as the regular \emph{Arduino UNO}
32 board that only boasts a meager \emph{2K} of \emph{RAM}.
33 \end{itemize}
34
35 \subsection{Specification}
36 Devices are stored in a record type and all devices in the system are stored in
37 a \gls{SDS} containing all devices. From the macro settings in the interface
38 file a profile is created for the device that describes the specification. When
39 a connection between the server and a client is established the server will
40 send a request for specification. The client will serialize his specification
41 and send it to the server so that the server knows what the client is capable
42 of. The exact specification is listed in Listing~\ref{lst:devicespec}
43
44 \begin{lstlisting}[language=Clean,label={lst:devicespec},
45 caption={Device specification for \glspl{mTask}}]
46 :: MTaskDeviceSpec =
47 {haveLed :: Bool
48 ,haveAio :: Bool
49 ,haveDio :: Bool
50 ,bytesMemory :: Int
51 }
52 \end{lstlisting}
53
54 \subsection{Memory Management}
55 \todo{Explain specification, combine task and share space}
56
57 \subsection{Communication}
58 The communication to and fro a device runs via a single \gls{SDS}. Every
59 device has a specific resource that is used to connect to the device. The
60 current system supports connecting devices via a serial connection and via a
61 \gls{TCP} connection. Every device has the type \CI{MTaskDevice} and which
62 is listed in Listing~\ref{lst:mtaskdevice}. When a device is added a background
63 task is started that runs the \CI{synFun}. The \CI{synFun} is the task that
64 synchronizes the channel \gls{SDS} with the actual device. For the \gls{TCP}
65 device this is a simple \CI{tcpconnect}. The \CI{TaskId} of the background task
66 is saved to be able to stop the task in the future. When the task is unable to
67 connect it will set the \CI{deviceError} field to notify the user.
68 \todo{netter maken}
69
70 \begin{lstlisting}[language=Clean,caption={Device type},label={lst:mtaskdevice}]
71 :: Channels :== ([MTaskMSGRecv], [MTaskMSGSend], Bool)
72 :: MTaskResource
73 = TCPDevice TCPSettings
74 | SerialDevice TTYSettings
75 :: MTaskDevice =
76 { deviceTask :: Maybe TaskId
77 , deviceError :: Maybe String
78 , deviceChannels :: String
79 , deviceName :: String
80 , deviceTasks :: [MTaskTask]
81 , deviceData :: MTaskResource
82 , deviceSpec :: Maybe MTaskDeviceSpec
83 }
84
85 class MTaskDuplex a where
86 synFun :: a (Shared Channels) -> Task ()
87 \end{lstlisting}