] world
demo :: Task ()
-demo = viewSharedInformation "Devices" [] deviceStoreNP
+demo = set 5 (sharedDynamicStore "Hoi" 5)
+ >>| viewSharedInformation "Devices" [] deviceStoreNP
>>* [OnValue $ ifValue pred (cont o hd)]
where
pred [] = False
cont :: MTaskDevice -> Task ()
cont dev
- # rs = getRealShare dev (hd dev.deviceShares)
+ # rs = shareShare dev (hd dev.deviceShares)
= get rs >>= \oldvalue->
- forever (updateSharedInformation "Blinkyblink" [] (getRealShare dev (hd dev.deviceShares))
+ forever (updateSharedInformation "Blinkyblink" [] (shareShare dev (hd dev.deviceShares))
>>* [OnAction ActionContinue (const $ Just $ treturn ())])
-|| (wait "bigger than 10" (\x->x == oldvalue) rs
>>= viewInformation "Bigger:)" [])
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)]
+ >>| treturn []
+ ]
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 ()