mTaskManager :: Task ()
mTaskManager = anyTask
[ viewmTasks @! ()
+ , viewShares
, whileUnchanged deviceStore viewDevices
- , addDevice deviceStore
- , viewChannels deviceStore
] <<@ ApplyLayout layout
-// ||- whileUnchanged deviceStore (\m->if (isEmpty m)
-// (viewInformation "No devices yet" [] "" @! ()) (connectDevice m)) @! ()
-// )
where
isValue (Value _ _) = True
isValue _ = False
- viewmTasks = viewInformation "MTasks" [] ""
+ viewmTasks = enterChoice "Available mTasks" [ChooseFromList id] ["ledder", "ledon", "ledoff"]
+ >>= viewInformation "" []
layout = sequenceLayouts
[ arrangeWithSideBar 0 LeftSide 260 True
, arrangeSplit Vertical True
- , layoutSubs (SelectByPath [1, 0]) arrangeWithTabs
]
- viewChannels :: (Shared [MTaskDevice]) -> Task ()
- viewChannels sh = whileUnchanged sh (\d->if (isEmpty d)
- (viewInformation "No channels yet" [] "")
- (viewInformation "Channels available" [] "")) @! ()
+ viewShares :: Task ()
+ viewShares = viewInformation () [] ()
- viewDevices :: [MTaskDevice] -> [Task ()]
- viewDevices [] = viewInformation "No devices yet" [] "" @! ()
- viewDevices ds = [viewInformation "Device" [] d <<@ Title d.deviceName\\d<-ds]
+ viewDevices :: [MTaskDevice] -> Task ()
+ viewDevices ds = anyTask [
+ addDevice deviceStore <<@ Title "Add new device" @! ():
+ [viewDevice d <<@ Title d.deviceName\\d<-ds]]
+ <<@ ArrangeWithTabs @! ()
+
+ viewDevice :: MTaskDevice -> Task ()
+ viewDevice d = (viewInformation "Device settings" [] d
+ ||- (case d.deviceConnected of
+ Just s = viewSharedInformation "Channels" [] (channels d.deviceName) @! ()
+ Nothing = viewInformation "No channels yet" [] "" @! ()
+ )) <<@ ArrangeHorizontal
+
+ channels :: String -> Shared Channels
+ channels s = sdsFocus s $ memoryStore "" $ Just ([], [], False)
addDevice :: (Shared [MTaskDevice]) -> Task ()
addDevice devices = enterInformation "Device type and name" []
- >>= \(name, ty)->get randomInt
- >>= \ident->treturn (name +++ toString ident)
+ >>= \(name, ty)->get randomInt @ ((+++) name o toString)
>>= \realname->let ch = channels realname in case ty of
TCPDevice = enterInformation "Hostname and port" []
>>= \(host, port)->cont realname name ||- syncNetworkChannel host port ch
cont rn nm = (upd (\l->[dev rn nm:l]) devices >>| addDevice devices)
dev rn nm = {deviceConnected=Just rn,deviceName=nm}
- channels :: String -> Shared Channels
- channels s = sdsFocus s $ memoryStore "" $ Just ([], [], False)
-
getDevices :: !*World -> *(![String], !*World)
getDevices w = case readDirectory "/dev" w of
(Error (errcode, errmsg), w) = abort errmsg