use share lenses
[mTask.git] / Devices / mTaskDevice.icl
index 0116b57..0a6ab0f 100644 (file)
@@ -28,11 +28,11 @@ instance == MTaskDevice where
        (==) a b = a.deviceChannels == b.deviceChannels
 
 startupDevices :: Task [MTaskDevice]
-startupDevices = upd (map reset) deviceStore
+startupDevices = upd (map reset) deviceStoreNP
        where reset d = {d & deviceTask=Nothing, deviceTasks=[], deviceError=Nothing}
 
 withDevice :: (MTaskDevice -> Task a) String -> Task a | iTask a
-withDevice f s = get deviceStore
+withDevice f s = get deviceStoreNP
        >>= \ds->case 'DL'.find (\d->d.deviceName == s) ds of
                Nothing = throw "Device not available"
                Just d = f d
@@ -89,7 +89,7 @@ connectDevice procFun device = let ch = channels device
 
 manageDevices :: (MTaskDevice (Shared Channels) -> Task ()) [MTaskDevice] -> Task ()
 manageDevices processFun ds = anyTask [
-               addDevice deviceStore processFun <<@ Title "Add new device" @! ():
+               addDevice deviceStoreNP processFun <<@ Title "Add new device" @! ():
                        [viewDevice processFun d 
                                <<@ Title d.deviceName\\d<-ds]]
        <<@ ArrangeWithTabs @! ()
@@ -114,7 +114,7 @@ deleteDevice d = sendMessages [MTShutdown] d
        >>| wait "Waiting for the channels to empty" (\(r,s,ss)->isEmpty s) (channels d)
        >>| upd (\(r,s,ss)->(r,s,True)) (channels d)
        >>| maybe (treturn ()) (flip removeTask topLevelTasks) d.deviceTask
-       >>| upd (filter ((<>)d)) deviceStore
+       >>| upd (filter ((<>)d)) deviceStoreNP
 //     >>| cleanSharesDevice d.deviceName
        @! ()
 
@@ -129,7 +129,7 @@ realMessageSend :: [MTaskMSGSend] Channels -> Channels
 realMessageSend msgs (r,s,ss) = (r,msgs++s,ss)
 
 withDevices :: MTaskDevice (MTaskDevice -> MTaskDevice) -> Task [MTaskDevice]
-withDevices a trans = upd (map \b->if (b == a) (trans b) b) deviceStore
+withDevices a trans = upd (map \b->if (b == a) (trans b) b) deviceStoreNP
 
 deviceTaskAcked :: MTaskDevice Int Int -> Task [MTaskDevice]
 deviceTaskAcked dev i mem