From: Mart Lubbers Date: Fri, 19 May 2017 14:47:44 +0000 (+0200) Subject: should have real share access now X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=5bb47d85ee13e4c0907a82971a907657511211cc;p=mTask.git should have real share access now --- diff --git a/Devices/mTaskDevice.dcl b/Devices/mTaskDevice.dcl index 2af19ea..b1c7acc 100644 --- a/Devices/mTaskDevice.dcl +++ b/Devices/mTaskDevice.dcl @@ -41,7 +41,9 @@ withDevice :: (MTaskDevice -> Task a) String -> Task a | iTask a startupDevices :: Task [MTaskDevice] connectDevice :: (MTaskDevice (Shared Channels) -> Task ()) MTaskDevice -> Task () manageDevices :: (MTaskDevice (Shared Channels) -> Task ()) [MTaskDevice] -> Task () -sendMessages :: [MTaskMSGSend] -> (MTaskDevice -> Task Channels) + +sendMessages :: [MTaskMSGSend] MTaskDevice -> Task Channels +sendMessagesIW :: [MTaskMSGSend] MTaskDevice *IWorld -> *(MaybeError TaskException (), *IWorld) withDevices :: MTaskDevice (MTaskDevice -> MTaskDevice) -> Task () diff --git a/Devices/mTaskDevice.icl b/Devices/mTaskDevice.icl index 7316f94..378a5e3 100644 --- a/Devices/mTaskDevice.icl +++ b/Devices/mTaskDevice.icl @@ -14,6 +14,7 @@ import Utils.Devices import GenBimap import Devices.mTaskSerial import Devices.mTaskTCP +import Data.Tuple import iTasks._Framework.Store import iTasks.UI.Definition, iTasks.UI.Editor, iTasks.UI.Editor.Builtin, iTasks.UI.Editor.Common, iTasks.UI.Layout.Default, iTasks.UI.Layout.Common @@ -108,8 +109,15 @@ deleteDevice d = sendMessages [MTShutdown] d // >>| cleanSharesDevice d.deviceName @! () -sendMessages :: [MTaskMSGSend] -> (MTaskDevice -> Task Channels) -sendMessages msgs = upd (\(r,s,ss)->(r,msgs++s,ss)) o channels +sendMessages :: [MTaskMSGSend] MTaskDevice -> Task Channels +sendMessages msgs dev = upd (realMessageSend msgs) $ channels dev + +sendMessagesIW :: [MTaskMSGSend] MTaskDevice *IWorld -> *(MaybeError TaskException (), *IWorld) +sendMessagesIW msgs dev iworld + = modify (tuple () o realMessageSend msgs) (channels dev) iworld + +realMessageSend :: [MTaskMSGSend] Channels -> Channels +realMessageSend msgs (r,s,ss) = (r,msgs++s,ss) withDevices :: MTaskDevice (MTaskDevice -> MTaskDevice) -> Task () withDevices a trans = upd (map \b->if (b == a) (trans b) b) deviceStore @! () diff --git a/Shares/mTaskShare.icl b/Shares/mTaskShare.icl index a360bf8..68b519e 100644 --- a/Shares/mTaskShare.icl +++ b/Shares/mTaskShare.icl @@ -103,6 +103,18 @@ getRealShare dev {sdsi} = SDSSource {SDSSource Just share = (Ok share.MTaskShare.value, iworld) // Also send messages - ww name value iworld = undef//case modify (modFun name value) sdsStore of -// (Error e, iworld) = (Error e, iworld) -// (Ok shares, iworld) = (Ok $ const True, iworld) + ww name value iworld = case modify (\r->((), map (modFun value) r)) deviceStore iworld of + (Error e, iworld) = (Error e, iworld) + (Ok _, iworld) = case sendMessagesIW [MTUpd sdsi value] dev iworld of + (Error e, iworld) = (Error e, iworld) + (Ok _, iworld) = (Ok $ const True, iworld) + + //Selects the correct device + modFun value d + | d == dev = {d & deviceShares=map (modFun2 value) d.deviceShares} + = d + + //Selects the correct share + modFun2 value share + | sdsi == share.MTaskShare.identifier = {MTaskShare | share & value=value} + = share