add task deletion and acknowledgements
[mTask.git] / Utils / SDS.icl
1 implementation module Utils.SDS
2
3 import iTasks
4 import iTasks._Framework.Store
5 import Devices.mTaskDevice
6 import Shares.mTaskShare
7 from Data.Func import $
8
9 derive class iTask MTaskShare, BCState
10
11 memoryShare :: String a -> Shared a | iTask a
12 memoryShare s d = sdsFocus s $ memoryStore "" $ Just d
13
14 deviceStore :: Shared [MTaskDevice]
15 deviceStore = sharedStore "mTaskDevices" []
16
17 sdsStore :: Shared [MTaskShare]
18 sdsStore = memoryShare "mTaskShares" []
19
20 bcStateStore :: Shared BCState
21 bcStateStore = memoryShare "mTaskBCState" zero
22
23 mTaskTaskStore :: Shared [String]
24 mTaskTaskStore = memoryShare "mTaskTasks" ["count", "ledon", "ledoff"]
25
26 getSDSStore :: MTaskShare -> Shared Int
27 getSDSStore sh = memoryShare sh.realShare 0
28
29 getSDSRecord :: Int -> Task MTaskShare
30 getSDSRecord i = get sdsStore @ \l->hd [s\\s<-l | s.identifier == i]