clean up share code and only show published tasks
[mTask.git] / Devices / mTaskDevice.icl
index bb5b353..6a8c369 100644 (file)
@@ -16,7 +16,7 @@ import iTasks._Framework.Store
 
 from Data.Func import $
 
-derive class iTask MTaskDevice, MTaskResource, MTaskMSGRecv, MTaskMSGSend
+derive class iTask MTaskDevice, MTaskResource, MTaskMSGRecv, MTaskMSGSend, BCShare
 derive conses MTaskResource, TTYSettings, BaudRate, Parity, ByteSize, TCPSettings
 derive consName MTaskResource, TTYSettings, BaudRate, Parity, ByteSize, TCPSettings
 
@@ -85,7 +85,7 @@ deleteDevice d = upd (\(r,s,ss)->(r,s,True)) (channels d)
 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
+       >>= \(msgs, st1)->set st1 bcStateStore @ toSDSRecords 
        >>= \sdss->set sdss sdsStore//MTaskShareaddToSDSShare
        >>| makeShares sdss
        >>| sendMessage device msgs
@@ -95,11 +95,12 @@ sendToDevice wta mTask (device, timeout) =
        where
                sharename i = device.deviceChannels +++ "-" +++ toString i
                toSDSRecords st = [{MTaskShare |
-                       initValue=toInt d1*265 + toInt d2,
+                       initValue=toInt (sdsval!!0)*265 + toInt (sdsval!!1),
                        withTask=wta,
-                       identifier=i,
-                       realShare="mTaskSDS-" +++ toString i}
-                               \\(i,[d1,d2])<-st.sdss]
+                       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