startupDevices :: Task [MTaskDevice]
connectDevice :: (MTaskDevice (Shared Channels) -> Task ()) MTaskDevice -> Task ()
manageDevices :: (MTaskDevice (Shared Channels) -> Task ()) [MTaskDevice] -> Task ()
-sendToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task ()
sendMessages :: [MTaskMSGSend] -> (MTaskDevice -> Task Channels)
+withDevices :: MTaskDevice (MTaskDevice -> MTaskDevice) -> Task ()
+
deviceTaskDelete :: MTaskDevice MTaskTask -> Task ()
deviceTaskAcked :: MTaskDevice Int -> Task ()
deviceTaskDeleteAcked :: MTaskDevice Int -> Task ()
// >>| upd (removeShares d) sdsStore
@! ()
-sendToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task ()
-sendToDevice wta mTask (device, timeout) =
- get bcStateStore @ toMessages timeout o toRealByteCode (unMain mTask)
- >>= \(msgs, st1)->set st1 bcStateStore
- >>| toSDSRecords st1
- >>= \sdss->set sdss sdsStore//MTaskShareaddToSDSShare
- >>| sendMessages msgs device
- >>| makeTask wta -1
- >>= withDevices device o addTask
- @! ()
- where
- sharename i = device.deviceChannels +++ "-" +++ toString i
- toSDSRecords st = sequence "" [makeShare wta sdsi sdsval\\{sdsi,sdspub,sdsval}<-st.sdss]// | sdspub]
-
- addTask :: MTaskTask MTaskDevice -> MTaskDevice
- addTask task device = {device & deviceTasks=[task:device.deviceTasks]}
sendMessages :: [MTaskMSGSend] -> (MTaskDevice -> Task Channels)
sendMessages msgs = upd (\(r,s,ss)->(r,msgs++s,ss)) o channels
}
makeTask :: String Int -> Task MTaskTask
+sendTaskToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task ()
import mTask
import iTasks
+import Devices.mTaskDevice
+
import iTasks._Framework.Serialization
makeTask :: String Int -> Task MTaskTask
makeTask name ident = get currentDateTime
@ \dt->{MTaskTask | name=name,ident=ident,dateAdded=dt}
+
+sendTaskToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task ()
+sendTaskToDevice wta mTask (device, timeout) =
+ get bcStateStore @ toMessages timeout mTask
+ >>= \(msgs, st1)->set st1 bcStateStore
+ >>| toSDSRecords msgs st1
+ >>= \sdss->upd (mergeShares sdss) sdsStore
+ >>| sendMessages msgs device
+ >>| makeTask wta -1
+ >>= withDevices device o addTask
+ @! ()
+ where
+ sharename i = device.deviceChannels +++ "-" +++ toString i
+
+ toSDSRecords :: [MTaskMSGSend] BCState -> Task [MTaskShare]
+ toSDSRecords s st = sequence ""
+ [makeShare wta sdsi sdsval
+ \\{sdsi,sdspub,sdsval}<-st.sdss
+ , (MTSds sdsi` _)<-s
+ | sdsi == sdsi`]
+
+ mergeShares a b = a ++ b
+
+ addTask :: MTaskTask MTaskDevice -> MTaskDevice
+ addTask task device = {device & deviceTasks=[task:device.deviceTasks]}
instance seq ByteCode
instance serial ByteCode
-toMessages :: MTaskInterval (String, BCState) -> ([MTaskMSGSend], BCState)
+toMessages :: MTaskInterval (Main (ByteCode a b)) BCState -> ([MTaskMSGSend], BCState)
toSDSUpdate :: Int Int -> [MTaskMSGSend]
toByteVal :: BC -> String
where
(ex, newls) = splitAt (bclength b - 1) ls
-toMessages :: MTaskInterval (String, BCState) -> ([MTaskMSGSend], BCState)
-toMessages interval (bytes, st=:{sdss}) = (
- [MTSds sdsi $ toByteCode e\\{sdsi,sdsval=(BCValue e)}<-sdss] ++
- [MTTask interval bytes], st)
+toMessages :: MTaskInterval (Main (ByteCode a b)) BCState -> ([MTaskMSGSend], BCState)
+toMessages interval x s
+# (bc, newstate) = toRealByteCode (unMain x) s
+# newsdss = 'DL'.difference s.sdss newstate.sdss
+= ([MTSds sdsi $ toByteCode e\\{sdsi,sdsval=(BCValue e)}<-newsdss] ++
+ [MTTask interval bc], newstate)
+
+instance == BCShare where (==) a b = a.sdsi == b.sdsi
toSDSUpdate :: Int Int -> [MTaskMSGSend]
toSDSUpdate i v = [MTUpd i (to16bit v)]
ds = fromJust ('DM'.get mTaskTask allmTasks)
>>= \bc->(enterChoice "Choose Device" [ChooseFromDropdown \t->t.deviceName] ds
-&&- enterInformation "Timeout" []
- ) >>* [OnAction (Action "Send") (withValue $ Just o sendToDevice mTaskTask bc)]
+ ) >>* [OnAction (Action "Send") (withValue $ Just o sendTaskToDevice mTaskTask bc)]
@! ()
)