X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=Utils%2FSDS.icl;h=a7c376341a23dbf844bd764dddc323cc9742ccac;hb=684c702b39ebd339cb123a24f1f37a63d708e688;hp=cd684aee3ded7bf6a151a6135a25ff0baf32063b;hpb=7fec7868123d56d410e807042cb3e031ebda12b9;p=mTask.git diff --git a/Utils/SDS.icl b/Utils/SDS.icl index cd684ae..a7c3763 100644 --- a/Utils/SDS.icl +++ b/Utils/SDS.icl @@ -4,27 +4,33 @@ import iTasks import iTasks._Framework.Store import Devices.mTaskDevice import Shares.mTaskShare +import Tasks.Examples +import qualified Data.Map as DM from Data.Func import $ - -derive class iTask MTaskShare, BCState +import Data.Tuple memoryShare :: String a -> Shared a | iTask a -memoryShare s d = sdsFocus s $ memoryStore "" $ Just d +memoryShare s d = sdsFocus s $ memoryStore s $ Just d + +deviceStoreNP :: Shared [MTaskDevice] +deviceStoreNP = sdsFocus Nothing $ deviceStore + +deviceStore :: RWShared (Maybe Int) [MTaskDevice] [MTaskDevice] +deviceStore = SDSSource {SDSSource + | name = "deviceStore" + , read = \_->read realDeviceStore + , write= \p w->appFst ((<$) (lens p)) o write w realDeviceStore + } -deviceStore :: Shared [MTaskDevice] -deviceStore = sharedStore "mTaskDevices" [] +lens Nothing _ = True +lens _ Nothing = True +lens (Just p) (Just p`) = p` == -1 || p == p` -sdsStore :: Shared [MTaskShare] -sdsStore = memoryShare "mTaskShares" [] +realDeviceStore :: Shared [MTaskDevice] +realDeviceStore = sharedStore "mTaskDevices" [] bcStateStore :: Shared BCState bcStateStore = memoryShare "mTaskBCState" zero mTaskTaskStore :: Shared [String] -mTaskTaskStore = memoryShare "mTaskTasks" ["count", "ledon", "ledoff"] - -getSDSStore :: MTaskShare -> Shared Int -getSDSStore sh = memoryShare sh.realShare 0 - -getSDSRecord :: Int -> Task MTaskShare -getSDSRecord i = get sdsStore @ \l->hd [s\\s<-l | s.identifier == i] +mTaskTaskStore = memoryShare "mTaskTasks" $ 'DM'.keys allmTasks