\subsection{Overview}
\begin{frame}
	\frametitle{Solution}
	\begin{block}{Downsides of the current mTask view}
		\begin{itemize}
			\item It all seems perfect
			\item \ldots\pause{} but\ldots
			\pause{}
			\item No interaction
			\item Compilation requires reprogramming
		\end{itemize}
	\end{block}
	\pause{}
	\begin{block}{Solution}
		\begin{itemize}[<+->]
			\item New bytecode backend for mTask
			\item Interpreter on client
			\item Server in iTasks with integration
			\item No taskserver generation, onetime programming
			\item Explicit SDS publishing
		\end{itemize}
	\end{block}
\end{frame}

\subsection{Extending mTask}
\begin{frame}[fragile]
	\frametitle{Adding a View}
	\begin{lstlisting}
:: ByteCode a p = BC (RWS () [BC] BCState ())
:: BC           = BCNop | BCPush BCValue | ...
:: BCValue      = E.e: BCValue e              & mTaskType, TC e
:: BCShare      = { sdsi   :: Int, sdsval :: BCValue, sdsname :: String    }
:: BCState      = { freshl :: Int, freshs :: Int,     sdss    :: [BCShare] }

instance ByteCode arith, boolExpr, ...
	\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Implementation}
	\begin{itemize}
		\item Writing instruction
		\item Carrying state
		\item Hand-crafted helpers
	\end{itemize}
	\begin{lstlisting}
op2 :: (ByteCode a p1) (ByteCode a p2) BC -> ByteCode b Expr
op2 (BC x) (BC y) bc = BC (x >>| y >>| tell [bc])

tell2 :: [BC] -> (ByteCode a p)
tell2 x = BC (tell x)

instance arith ByteCode where
	lit x = tell2 [BCPush (BCValue x)]
	(+.) x y = op2 x y BCDiv
	...
	\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Control flow}
	\begin{itemize}
		\item Use labels
		\item Label resolving
		\pause{}
		\item Thus no reuse
	\end{itemize}
	\pause{}
	\begin{lstlisting}
:: BC = ... | BCLab Int | ...

freshlabel = get >>= \st=:{freshl}->put {st & freshl=freshl+1} >>| pure freshl

instance If ByteCode Stmt Stmt Stmt where If b t e = BCIfStmt b t e
...
BCIfStmt (BC b) (BC t) (BC e) = BC (
	freshlabel >>= \else->freshlabel >>= \endif->
	b >>| tell [BCJmpF else] >>|
	t >>| tell [BCJmp endif, BCLab else] >>|
	e >>| tell [BCLab endif]
	)
	\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Functionality}
	\begin{block}{SDS scope and naming}
		\begin{itemize}
			\item SDS is lost
			\item State per device
			\item Tasks are sent and gone
			\item Save bandwidth
		\end{itemize}
		\pause{}
		\begin{lstlisting}
class namedsds v where
	namedsds :: ((v t Upd) -> In (Named t String) (Main (v c s)))
		-> (Main (v c s)) | ...
:: Named a b = Named infix 1 a b

instance sdspub ByteCode where
	pub (BC x) = BC (censor (\[BCSdsFetch s]->[BCSdsPublish s]) x)
		\end{lstlisting}
	\end{block}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Assignment}
	\begin{lstlisting}
instance sds ByteCode where
	sds f = {main = BC (freshshare
			>>= \sdsi->pure {BCShare|sdsname="",sdsi=sdsi,sdsval=BCValue 0}
			>>= \sds->pure (f (tell2 [BCSdsFetch sds]))
			>>= \(v In bdy)->modify (addSDS sds v)
			>>| unBC (unMain bdy))
		}

instance assign ByteCode where
	(=.) (BC v) (BC e) = BC (e >>| censor makeStore v)

makeStore [BCSdsFetch i]    = [BCSdsStore i]
makeStore [BCDigitalRead i] = [BCDigitalWrite i]
makeStore [...]             = [...]
	\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
	\frametitle{Task scheduling}
	\begin{block}{Old}
		\begin{itemize}
			\item Task server
			\item Tasks start other tasks
		\end{itemize}
	\end{block}
	\pause{}
	\begin{block}{New}
		\begin{itemize}
			\item Old system, taskserver, tasks start tasks
			\item New system, task+strategy
				\pause{}
				\begin{itemize}
					\item \CI{OnShot}
					\item \CI{OnInterval}
					\item \CI{OnInterrupt}
				\end{itemize}
			\pause{}
			\item How to handle termination
		\end{itemize}
		\pause{}
		\begin{lstlisting}
class retrn v where
	retrn :: v () Expr
		\end{lstlisting}
	\end{block}
\end{frame}

\subsection{Interpretation}
\begin{frame}[fragile]
	\frametitle{mTask implementation}
	%TODO
\end{frame}

\subsection{Devices}
\begin{frame}
	\frametitle{Devices}
	\begin{itemize}
		\item Standard C
		\item Implement some classes in interface
		\pause{}
		\item How to handle termination
	\end{itemize}
\end{frame}

\subsection{Server}
\subsection{Examples}
