the user --- and they are then connected. When all devices are registered, the
\gls{mTask}-\glspl{Task} can be sent and \gls{iTasks}-\glspl{Task} can be
started to monitor the output. When everything is finished, the devices are
-removed and the system is shut down.
+removed and the system is shut down. To illustrate this, a demo blinking
+application is shown in Listing~\ref{lst:frameword}. The application is a
+complete \gls{iTasks} application.
\begin{lstlisting}[language=Clean,label={lst:framework},
caption={\gls{mTask} framework for building applications}]
-w :: Task ()
-w = makeDevice "dev1" (...) >>= connectDevice
- >>= \dev1->makeDevice "dev2" (...) >>= connectDevice
- >>= \dev2->...
- ...
- >>* [OnAction (Action "Shutdown") $ always
- $ deleteDevice dev1 >>| deleteDevice dev2
- >>| ...
- >>| shutDown 0
+module blinkdemo
+
+import iTasks
+import mTask
+import Devices.mTaskDevice
+
+from Data.Func import $
+
+Start world = startEngine blink world
+
+blink :: Task ()
+blink = addDevice
+ >>= connectDevice
+ >>= \stm->sendTaskToDevice "blink" blinkTask (stm, OnInterval 1000)
+ >>= \(st, [_,t])->forever (
+ updateSharedInformation "Which led to blink" [] (shareShare stm t)
+ ) >>* [OnAction (Action "Shutdown") $ always
+ $ deleteDevice stm >>| shutDown 0
]
+where
+ blinkTask = sds \led=LED1 In sds \x=True In {main =
+ ledOff led1 :. ledOff led2 :. ledOff led3 :.
+ IF x (ledOff led) (ledOn led) :.
+ x =. Not x}
\end{lstlisting}
\subsection{Thermostat}