+ viewmTasks = listmTasks
+ >&^ \sh->whileUnchanged sh $ \mi->case mi of
+ Nothing = viewInformation "No task selected" [] ()
+ Just mTaskTask = get deviceStore
+ >>= \devices->case devices of
+ [] = viewInformation "No devices yet" [] ()
+ ds = sendmTask mTaskTask ds @! ()
+ where
+ listmTasks :: Task String
+ listmTasks = enterChoiceWithShared "Available mTasks" [ChooseFromList id] mTaskTaskStore
+
+ sendmTask mTaskId ds =
+ (enterChoice "Choose Device" [ChooseFromDropdown \t->t.deviceName] ds
+ -&&- enterInformation "Timeout, 0 for one-shot" [])
+ >>* [OnAction (Action "Send") (withValue $ Just o sendToDevice mTaskId)]
+
+ sendToDevice :: String (MTaskDevice, Int) -> Task ()
+ sendToDevice mTask (device, timeout) = get bcStateStore
+ @ toMessages timeout o toRealByteCode (unMain $ fromJust ('DM'.get mTask mTaskMap))
+ >>= \(msgs, st1)->set st1 bcStateStore
+ //@ map f
+ >>| upd (\(r,s,ss)->(r,s++msgs,ss)) (channels device)
+ @! ()
+ where
+ f (i,d) = (i, sharedStore ("mTaskSDS-" +++ toString i) (dd d))
+ dd [x,y] = toInt x*265 + toInt y
+
+// = (msgs, map f st.sdss)
+// where
+// upd (\(r,s,ss)->(r,s++[],ss)) (channels device) @! ()
+// # (msgs, st) = toMessages timeout (toRealByteCode (unMain bc))
+// = Just $ viewInformation "" [] device
+// = (msgs, map f st.sdss)
+// where
+// f (i,d) = (i, sharedStore ("mTaskSDS-" +++ toString i) (dd d))
+// dd [x,y] = toInt x*265 + toInt y
+// #
+// = Just $ viewInformation "" [] device
+
+
+ channels :: MTaskDevice -> Shared Channels
+ channels d = memoryShare (fromJust d.deviceConnected) ([], [], False)