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