errata
[phd-thesis.git] / top / lst / example.icl
index 4bdf9ef..d1f6222 100644 (file)
@@ -7,7 +7,7 @@ import mTask.Interpret
 import mTask.Interpret.Device.TCP
 import mTask.Interpret.Device.Serial
 
-//Start w = doTasks autoHome w
+Start w = doTasks autoHome w
 
 arduino = {TTYSettings | zero & devicePath="/dev/ttyACM0"}/*\label{lst:example:spec1}*/
 nodeMCU = {TCPSettings | host="192.168.0.1", port=8123, pingTimeout= ?None}/*\label{lst:example:spec2}*/
@@ -26,10 +26,9 @@ chooseTask dev1 dev2 stl = tune (Title "Run a task") $
        >>? \device->appendTask Embedded (mkTask n i device) stl
        >-| chooseTask dev1 dev2 stl
 where
-       mkTask n i device stl
-               # dev = if (device == "node") dev2 dev1
-               = ((snd (tasks !! i) $ dev)
-                       >>* [OnAction ActionClose $ always $ return ()]) <<@ Title n/*\label{lst:example:ct2}*/
+       mkTask n i device stl = ((snd (tasks !! i) $ dev)
+               >>* [OnAction ActionClose $ always $ return ()]) <<@ Title n/*\label{lst:example:ct2}*/
+       where dev = if (device == "node") dev2 dev1
 
 tasks :: [(String, MTDevice -> Task ())]/*\label{lst:example:tasks1}*/
 tasks =
@@ -44,7 +43,7 @@ tasks =
                withShared False \sh->
                            liftmTask (lightswitch sh) dev
                        -|| updateSharedInformation [] sh <<@ Hint "Switch")/*\label{lst:example:ls2}*/
-       , ("factorial", \dev->
+       , ("remote computation", \dev->
                        updateInformation [] 5 <<@ Hint "Factorial of what?"
                >>? \i->liftmTask (factorial i) dev
                >>- \r->viewInformation [] r <<@ Hint "Result" @! ())
@@ -62,16 +61,12 @@ blink d =
                >>|. delay (lit d)
                >>|. bl (Not st))
        In {main=bl true}
-lightswitch :: (Shared sds Bool) -> Main (MTask v ()) | liftsds, mtask v & RWShared sds & TC (sds () Bool Bool)
+lightswitch :: (Shared sds Bool) -> Main (MTask v ()) | lowerSds, mtask v & RWShared sds & TC (sds () Bool Bool)
 lightswitch sh =
        declarePin D13 PMOutput \d13->
-       liftsds \ls=sh
+       lowerSds \ls=sh
        In fun \f=(\st->
                     getSds ls
                >>*. [IfValue ((!=.)st) (\v->writeD d13 v)]
                >>|. f (Not st))
        In {main=f true}
-
-Start w = doTasks t w
-t = withShared True \sh->
-       updateSharedInformation [] sh <<@ Hint "Light switch"