\begin{frame}
\frametitle{Problems with IoT}
- \begin{itemize}
+ \begin{itemize}[<+->]
\item Device $\rightarrow$ Server $\rightarrow$ Application
- \pause{}
\item Myriads of devices: Arduino, ESP8266, Raspberry pi\ldots
- \pause{}
\item Tons of languages: C++, Lua, C, python\ldots
- \pause{}
\item Heaps of communication methods: LoRa (Sigfox, KPN, TTN), BTLE, WiFi, ZigBee\ldots
- \pause{}
+ \item Resulting in
\item Separated logic
+
\item Integration problems
\end{itemize}
\end{frame}
\item EDSL in Clean
\end{itemize}
\end{block}
- \pause{}
\begin{block}{Tasks}
\begin{itemize}[<+->]
\item Filling in forms
\begin{itemize}
\item iTasks works
\item IoT works
- \item But...\pause{} integration does not
+ \item But\ldots\pause{} integration does not
\end{itemize}
\end{block}
\begin{block}{Why is this interesting?}
\begin{itemize}[<+->]
- \item Make IoT integration easier
+ \item Makes IoT integration easier
+ \item Safer IoT clients
\item Extend the reach of iTasks
- \item Fully integrated systems
+ \item Generate all three components of IoT from one source
\end{itemize}
\end{block}
\end{frame}
\item Observables
\item Given the state, a \CI{TaskValue} is observed.
\item Continuous execution
- \item Generics
\end{itemize}
\end{block}
\pause{}
\begin{figure}[ht]
\centering
- \includegraphics[width=\linewidth]{fig-taskvalue}
+ \includegraphics[width=.6\linewidth]{fig-taskvalue}
\caption{The states of a \CI{TaskValue}}
\end{figure}
\end{frame}
\begin{frame}[fragile]
\frametitle{Shared Data Sources (SDS)}
\begin{block}{What is an SDS}
- \begin{itemize}[<+->]
+ \begin{itemize}
\item Read function
\item Write function
+ \pause{}
\item Both have access to the world
+ \item Default: JSON file storage
\end{itemize}
\end{block}
\end{frame}
\begin{frame}
- \frametitle{But not all Tasks or SDSs are suitable for microcontrollers\ldots}
- \pause\centering\Large EDSLs to the rescue
+ \frametitle{How to express Tasks suitable for microcontrollers}
+ \pause\centering\Huge EDSLs to the rescue
\end{frame}
\begin{frame}[fragile]
\frametitle{Adding a View}
\begin{lstlisting}[language=Clean]
+
:: ByteCode a p = BC (RWS () [BC] BCState ())
+
+:: RWS r w s a = RWS (r s -> (a, s, w))
:: 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] }
+class mTaskType a | toByteCode, fromByteCode, iTask, TC a
+class toByteCode a :: a -> String
+class fromByteCode a :: String -> a
+
instance ByteCode arith, boolExpr, ...
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Implementation}
\begin{itemize}
- \item Writing instruction
- \item Carrying state
+ \item Reader Write State Transformer Monad
+ \item Write instruction
+ \item Carry state
\item Hand-crafted helpers
\end{itemize}
\begin{lstlisting}[language=Clean]
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
-...
+instance IF ByteCode
+where
+ IF b t e = BCIfStmt b t e
+ (?) b t = BCIfStmt b t (tell` [])
+
BCIfStmt (BC b) (BC t) (BC e) = BC (
freshlabel >>= \else->freshlabel >>= \endif->
b >>| tell [BCJmpF else] >>|
instance assign ByteCode where
(=.) (BC v) (BC e) = BC (e >>| censor makeStore v)
-instance sdspub ByteCode where
- pub (BC x) = BC (censor (\[BCSdsFetch s]->[BCSdsPublish s]) x)
+addSDS sds v s = {s & sdss=[{sds & sdsval=BCValue v}:s.sdss]}
makeStore [BCSdsFetch i] = [BCSdsStore i]
makeStore [BCDigitalRead i] = [BCDigitalWrite i]
\begin{lstlisting}
class sdspub v where
pub :: (v t Upd) -> (v () Stmt)
+
instance sdspub ByteCode where
- pub (BC x) = BC (censor (\[BCSdsFetch s]->[BCSdsPublish s]) x)
+ pub (BC x)
+ = BC (censor (\[BCSdsFetch s]->[BCSdsPublish s]) x)
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Task scheduling}
- \begin{block}{Old}
+ \begin{block}{Arduino C++ system}
\begin{itemize}
\item Task server
\item Tasks start other tasks
\end{itemize}
\end{block}
\pause{}
- \begin{block}{New}
+ \begin{block}{Interpreted Bytecode system}
\begin{itemize}[<+->]
- \item Old system, taskserver, tasks start tasks
- \item New system, task+strategy
+ \item Task accompanied with strategy
\item \CI{OnShot}, \CI{OnInterval}, \CI{OnInterrupt}
- \item How to handle termination
+ \item How to handle termination?
\end{itemize}
\pause{}
\begin{lstlisting}[language=Clean]
\item Modular implementation
\item Specification generated from the macros
\end{itemize}
-
+ \pause{}
\begin{lstlisting}[language=C,caption={interface.h}]
...
#elif defined TARGET_STM32F767ZI
#define APINS 128
-#define DPINS 128
-#define STACKSIZE 1024
-#define MEMSIZE 1024
+...
#define HAVELED 1
#define HAVEHB 1
\item Used for notifications
\item On write the SDS returns \CI{p -> Bool}
\end{itemize}
+ \pause{}
\end{block}
\begin{lstlisting}[language=Clean]
sdsFocus :: p1 (RWShared p1 r w) -> RWShared p2 r w | iTask p
realDeviceStore :: Shared [MTaskDevice]
realDeviceStore = sharedStore "mTaskDevices" []
- realRead :: P *IWorld
- -> (MaybeError TaskException [MTaskDevice], *IWorld)
+ realRead :: P *IWorld -> (MaybeError TaskException [MTaskDevice], *IWorld)
realRead p iw = read realDeviceStore iw
\end{lstlisting}
\end{onlyenv}
Just d = Ok d)
, \w ds->case splitWith ((==)d) ds of
([], _) = Error $ exception "Device lost"
- ([_:_], ds) = Ok $ Just [w:ds])
+ ([_], ds) = Ok $ Just [w:ds])
$ sdsFocus (Just (d, -1)) deviceStore
shareShare :: MTaskDevice MTaskShare -> Shared BCValue
\subsection{Communication}
\begin{frame}
\frametitle{The glue of the system}
- \begin{itemize}
- \item Compile, send and interact with Tasks
- \item Interact with SDSs
- \item All communication via channels
- \end{itemize}
+ \pause{}
+ \begin{block}{Communication}
+ \begin{itemize}
+ \item Compile, send and interact with Tasks
+ \item Interact with SDSs
+ \item All communication via channels
+ \end{itemize}
+ \end{block}
\end{frame}
\begin{frame}[fragile]