X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=methods.mtask.tex;h=a35883a596e5944f5afa91da706fdfee1cd007b3;hb=d118ff9d857683084065145df45135ef6fa06711;hp=837933db63c1317e632f94a9b810941348eee21a;hpb=0318eb1b212df7d3980f268f03429936d2f1d617;p=msc-thesis1617.git diff --git a/methods.mtask.tex b/methods.mtask.tex index 837933d..a35883a 100644 --- a/methods.mtask.tex +++ b/methods.mtask.tex @@ -1,15 +1,14 @@ -\section{mTask} The \gls{mTask}-\gls{EDSL} is the basis on which the system is built. The -\gls{mTask} was created by Koopman et al.\ to support several views such as an -\gls{iTasks} simulation and a \gls{C}-code generator. The \gls{EDSL} was -designed to generate a ready to compile \gls{TOP}-like system for +\gls{mTask}-\gls{EDSL} was created by Koopman et al.\ to support several views +such as an \gls{iTasks} simulation and a \gls{C}-code generator. The \gls{EDSL} +was designed to generate a ready to compile \gls{TOP}-like system for microcontrollers such as the Arduino\cite{koopman_type-safe_nodate}% \cite{plasmeijer_shallow_2016}. The \gls{mTask}-\gls{EDSL} is a shallowly embedded class based \gls{EDSL} and therefore it is very suitable to have a new backend that partly implements the -given classes. The following subsections show the details of the \gls{EDSL} -that are used in the extension. The parts of the \gls{EDSL} that are not used +given classes. The following sections show the details of the \gls{EDSL} +that are used in this extension. The parts of the \gls{EDSL} that are not used will not be discussed and the details of those parts can be found in the cited literature. @@ -36,7 +35,14 @@ instance isExpr Upd instance isExpr Expr \end{lstlisting} -\subsection{Expressions} +\section{Semantics} +\gls{mTask} do not behave like functions but more like +\gls{iTasks}-\glspl{Task}. When an \gls{mTask} is created it returns immediatly +and the \gls{Task} will be executed sometime in the future. \glspl{Task} can +run at an interval and they can start other tasks. +\todo{Meer uitwijden over de mTask semantiek} + +\section{Expressions} Expressions in the \gls{mTask}-\gls{EDSL} are divided into two types, namely boolean expressions and arithmetic expressions. The class of arithmetic language constructs also contains the function \CI{lit} that lifts a @@ -60,10 +66,27 @@ class boolExpr v where (==.) infix 4 :: (v a p) (v a q) -> v Bool Expr | ==, toCode a & ... \end{lstlisting} -\subsection{Control flow} -\todo{Write this} +\section{Control flow} +Looping of \glspl{Task} happens because \glspl{Task} are launched at regular +intervals or relaunch themselves. Therefore there is no need for loop control +flow functionality such as \CI{While} or \CI{For} constructions. The main +control flow is the sequence operator and the \CI{If} statement. Both are shown +in Listing~\ref{lst:control}. The first class of \CI{If} statements describe +the regular if statement. The expressions given can have any role. The +functional dependency on \CI{s} determines the return type of the statement. +The sequence operator is very straightforward and just ties the two expressions +together in sequence. + +\begin{lstlisting}[% + language=Clean,label={lst:control},caption={Control flow operators}] +class If v q r ~s where + If :: (v Bool p) (v t q) (v t r) -> v t s | ... + +class seq v where + (:.) infixr 0 :: (v t p) (v u q) -> v u Stmt | ... +\end{lstlisting} -\subsection{Input/Output and class extensions} +\section{Input/Output and class extensions} All expressions that have an \CI{Upd} role can be assigned to. Examples of such expressions are \glspl{SDS} and \gls{GPIO}. Moreover, class extensions can be created for specific peripherals such as user LEDs. The classes facilitating @@ -109,7 +132,7 @@ class sds v where sds :: ((v t Upd)->In t (Main (v c s))) -> (Main (v c s)) | ... \end{lstlisting} -\subsection{Example \gls{mTask}} +\section{Example mTask} \todo{Also explain semantics about running tasks} Some example \glspl{mTask} using almost all of the functionality are show in Listing~\ref{lst:exmtask}. The \glspl{mTask} shown in the example do not belong