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 ()
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
// >>| 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 @! ()
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