-sendToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task ()
-sendToDevice wta mTask (device, timeout) =
- get bcStateStore
- @ (\st->toMessages timeout (toRealByteCode (unMain mTask) {st & sdss=[]}))
- >>= \(msgs, st1)->set st1 bcStateStore @ toSDSRecords
- >>= \sdss->upd ((++)sdss) sdsStore//MTaskShareaddToSDSShare
- >>| makeShares sdss
- >>| sendMessage device msgs
- >>| makeTask wta -1
- >>= withDevices device o addTask
- @! ()
- where
- sharename i = device.deviceChannels +++ "-" +++ toString i
- toSDSRecords st = [{MTaskShare |
- initValue=toInt d1*265 + toInt d2,
- withTask=wta,
- identifier=i,
- realShare="mTaskSDS-" +++ toString i}
- \\(i,[d1,d2])<-st.sdss]
- makeShares = foldr (\sh t->set sh.initValue (getSDSStore sh) >>| t) (treturn ())