<<@ ArrangeWithTabs @! ()
viewDevice :: (MTaskDevice (Shared Channels) -> Task ()) MTaskDevice -> Task ()
-viewDevice pf d = forever $ anyTask
+viewDevice pf d = forever $ traceValue "viewDevice" >>| anyTask
[viewInformation "Device settings" [] d @! ()
,viewSharedInformation "Channels" [ViewAs dropEmpty] (channels d) @! ()
,forever $
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
+ traceValue "starting to send"
+ >>| get bcStateStore @ toMessages timeout o toRealByteCode (unMain mTask)
+ >>= \(msgs, st1)->traceValue "messages generated"
+ >>| set st1 bcStateStore
+ >>| traceValue "bcstate store updated"
+ >>| toSDSRecords st1
+ >>= \sdss->traceValue "Shares created"
+ >>| set sdss sdsStore//MTaskShareaddToSDSShare
+ >>| traceValue "Shares store updated"
>>| sendMessages msgs device
+ >>| traceValue "Messages sent"
>>| makeTask wta -1
- >>= withDevices device o addTask
+ >>= \t->traceValue "Task made"
+ >>| withDevices device (addTask t)
+ >>| traceValue "Tasks share updated"
@! ()
where
sharename i = device.deviceChannels +++ "-" +++ toString i
- toSDSRecords st = [{MTaskShare |
- withTask=wta,
- identifier=sdsi,
- initVal=sdsval,
- //We skip the only/local shares
- realShare="mTaskSDS-" +++ toString sdsi}
- \\{sdsi,sdspub,sdsval}<-st.sdss | sdspub]
-
- makeShares :: [MTaskShare] -> Task ()
- makeShares shs = treturn () //foldr (\sh t->set sh.initValue (getSDSStore sh) >>| t) (treturn ())
+ 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]}