migrate to new version
[mTask.git] / miTask.icl
index 233e072..8c17f09 100644 (file)
@@ -55,28 +55,28 @@ demo = viewSharedInformation "Devices" [] deviceStoreNP
 
 mTaskManager :: Task ()
 mTaskManager = (>>|) startupDevices $ 
-               viewmTasks ||-
+               forever viewmTasks ||-
                ((manageShares ||- forever (manageDevices process)) <<@ ArrangeSplit Vertical True)
                <<@ ArrangeWithSideBar 0 LeftSide 260 True
        where
-               viewmTasks :: Task String
+               viewmTasks :: Task [MTaskDevice]
                viewmTasks = enterChoiceWithShared "Available mTasks" [ChooseFromList id] mTaskTaskStore
-                       >&^ \sh->whileUnchanged sh $ \mi->forever (case mi of
-                               Nothing = viewInformation "No task selected" [] ()
-                               Just mTaskTask = get deviceStoreNP
-                                       >>= \devices->case devices of
-                                               [] = viewInformation "No devices yet" [] ()
-                                               ds = fromJust ('DM'.get mTaskTask allmTasks)
-                                                       >>= \bc->(enterChoice "Choose Device" [ChooseFromDropdown \t->t.deviceName] ds
-                                                               -&&- enterInformation "Timeout" []
-                                                       ) >>* [OnAction (Action "Send") (withValue $ Just o sendTaskToDevice mTaskTask bc)]
-                                                       @! ()
-                               )
+                       >>= \task->get deviceStoreNP
+                       >>* [OnValue $ (ifValue isEmpty)         $ \_->
+                                       viewInformation "No devices yet" [] [] >>= treturn
+                               ,OnValue $ (ifValue $ not o isEmpty) $ \d->
+                                       fromJust ('DM'.get task allmTasks)
+                                       >>= \bc->(enterChoice "Choose Device" [ChooseFromDropdown \t->t.deviceName] d
+                                               -&&- enterInformation "Timeout" []
+                                       ) >>* [OnAction (Action "Send") (withValue $ Just o sendTaskToDevice task bc)]
+                               ]
 
                process :: MTaskDevice (Shared Channels) -> Task ()
-               process device ch = forever (watch ch >>* [OnValue (
-                               ifValue (not o isEmpty o fst3)
-                               (\t->upd (appFst3 (const [])) ch >>| proc (fst3 t)))])
+               process device ch = forever
+                         $ traceValue "Waiting for channel change"
+                       >>| wait "process" (not o isEmpty o fst3) ch
+                       >>= \(r,s,ss)->upd (appFst3 (const [])) ch
+                       >>| proc r
                        where
                                proc :: [MTaskMSGRecv] -> Task ()
                                proc [] = treturn ()