add taskvalue graph and split up methods
[msc-thesis1617.git] / methods.tex
1 \input{methods.top.tex}
2
3 \input{methods.dsl.tex}
4
5 \section{Architecture}
6 \subsection{Devices}
7 The client code for the devices is compiled from one codebase. For a device to
8 be eligible for \glspl{mTask} it must be able to compile the shared codebase
9 and implement (part of) the device specific interface. The shared codebase only
10 uses standard \gls{C} and no special libraries or tricks are used. Therefore
11 the code is compilable for almost any device or system. Note that it is not
12 needed to implement a full interface. The full interface, listed in
13 Appendix~\label{app:device-interface}\todo{update interface listing}, also
14 includes functions for accessing the peripherals that not every device might
15 have. Devices can choose what to implement by setting the correct macros in the
16 top of the file. When a server connects to a client the specifications are
17 communicated.
18
19 The current list of supported and tested devices is as follows:
20 \begin{itemize}
21 \item $^*$\texttt{NIX} systems such as Linux
22 \item STM32 like development boards supported by \texttt{ChibiOS}.
23 \item \emph{Arduino} compatible microcontrollers
24 \end{itemize}
25
26 \subsection{Specification}
27 Devices are stored in a record type and all devices in the system are stored in
28 a \gls{SDS} containing all devices. From the macro settings in the interface
29 file a profile is created for the device that describes the specification. When
30 a connection between the server and a client is established the server will
31 send a request for specification. The client will serialize his specs and send
32 it to the server so that the server knows what the client is capable of. The
33 exact specification is listed in Listing~\ref{lst:devicespec}
34
35 \begin{lstlisting}[language=Clean,label={lst:devicespec},
36 caption={Device specification for \glspl{mTask}}]
37 :: MTaskDeviceSpec =
38 {haveLed :: Bool
39 ,haveAio :: Bool
40 ,haveDio :: Bool
41 ,bytesMemory :: Int
42 }
43 \end{lstlisting}
44 \todo{Explain specification, combine task and share space}
45
46 \subsection{Communication}
47
48 \section{mTasks}
49 \subsection{\gls{EDSL}}
50 The \gls{mTask}-\gls{EDSL} contains several classes that need to be implemented
51 by a type for it to be an \gls{mTask}. For numeric and boolean arithmetic the
52 classes \texttt{arith} and \texttt{boolExpr} are available and listed in a
53 shortened version in Listing~\ref{lst:arithbool}. All classes are to be
54 implemented by types of kind \texttt{*->*->*} a type \texttt{v t p},
55 respectively a view with a type and the role.
56
57 \texttt{lit} lifts a constant to the \gls{mTask} domain. For a type to be a
58 valid \gls{mTask} type it needs to implement the \texttt{mTaskType} class. The
59 binary operators work as expected.
60
61 \begin{lstlisting}[language=Clean,label={lst:arithbool},
62 caption={Basic classes for expressions}]
63 class mTaskType a | toByteCode, fromByteCode, iTask, TC a
64
65 class arith v where
66 lit :: t -> v t Expr | mTaskType t
67 (+.) infixl 6 :: (v t p) (v t q) -> v t Expr | type, +, zero t & isExpr p & isExpr q
68 ...
69 class boolExpr v where
70 (&.) infixr 3 :: (v Bool p) (v Bool q) -> v Bool Expr | isExpr p & isExpr q
71 Not :: (v Bool p) -> v Bool Expr | isExpr p
72 ...
73 (==.) infix 4 :: (v a p) (v a q) -> v Bool Expr | ==, toCode a & isExpr p & isExpr q
74 \end{lstlisting}
75
76
77 \subsection{Tasks}
78
79 \subsection{Shares}
80 Shares can live on multiple clients at the same time. For every share created
81 for an \gls{mTask} a real \gls{SDS} is created that mirrors the value on the
82 client. All shares currently in use are stored in a system-wide \gls{SDS} in
83 such a way that the actual share can be retrieved at any moment. All shares
84 have a unique numeric identifier and an initial value.
85
86 \begin{lstlisting}[language=Clean,label={lst:sharespec}, caption={\acrlong{SDS}}]
87 :: BCValue = E.e: BCValue e & mTaskType e
88 :: MTaskShareType = MTaskWithShare String | MTaskLens String
89 :: MTaskShare =
90 {withTask :: [String]
91 ,withDevice :: [String]
92 ,identifier :: Int
93 ,realShare :: MTaskShareType
94 ,value :: BCValue
95 }
96
97 sdsStore :: Shared [MTaskShare]
98 \end{lstlisting}
99 \todo{Do something with the sharetype}
100
101 \subsection{Communication}
102 %\todo{Handshake, device specification sending, spec.c}
103 %\todo{mTaskDevice class interface}
104
105 \section{mTasks}
106 \subsection{\gls{EDSL}}
107 \todo{Show the classes}
108
109 \subsection{Shares}
110 \todo{Show the types and why}
111
112 Shares are used to store the values
113
114 Shares all have