-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
- >>= \sdss->set sdss sdsStore//MTaskShareaddToSDSShare
- >>| makeShares sdss
- >>| sendMessages msgs device
- >>| makeTask wta -1
- >>= withDevices device o addTask
- @! ()
- where
- sharename i = device.deviceChannels +++ "-" +++ toString i
- toSDSRecords st = [{MTaskShare |
- initValue=toInt (sdsval!!0)*265 + toInt (sdsval!!1),
- withTask=wta,
- identifier=sdsi,
- //We skip the only/local shares
- realShare="mTaskSDS-" +++ toString sdsi}
- \\{sdsi,sdspub,sdsval}<-st.sdss | sdspub]
- makeShares = foldr (\sh t->set sh.initValue (getSDSStore sh) >>| t) (treturn ())
-
- addTask :: MTaskTask MTaskDevice -> MTaskDevice
- addTask task device = {device & deviceTasks=[task:device.deviceTasks]}