X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=Devices%2FmTaskDevice.icl;h=6a8c3699d3384b9a450a9b4da123260a61f049cf;hb=547eb2278f48ab8b94e70ef4a1fc2bf5093bdfb2;hp=4fff9ae4813499c32a39bbb6828f2beab889468c;hpb=71787cb6678d7a0d2014d373af5e55447796f78d;p=mTask.git diff --git a/Devices/mTaskDevice.icl b/Devices/mTaskDevice.icl index 4fff9ae..6a8c369 100644 --- a/Devices/mTaskDevice.icl +++ b/Devices/mTaskDevice.icl @@ -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 @@ -82,28 +82,29 @@ deleteDevice d = upd (\(r,s,ss)->(r,s,True)) (channels d) >>| upd (filter ((==)d)) deviceStore @! () -sendToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, Int) -> Task () +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->upd ((++)sdss) sdsStore//MTaskShareaddToSDSShare + >>= \(msgs, st1)->set st1 bcStateStore @ toSDSRecords + >>= \sdss->set sdss sdsStore//MTaskShareaddToSDSShare >>| makeShares sdss >>| sendMessage device msgs >>| makeTask wta -1 - >>= withDevices device o addTask timeout + >>= withDevices device o addTask @! () 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 :: Int MTaskTask MTaskDevice -> MTaskDevice - addTask timeout task device = {device & deviceTasks=[task:device.deviceTasks]} + addTask :: MTaskTask MTaskDevice -> MTaskDevice + addTask task device = {device & deviceTasks=[task:device.deviceTasks]} sendMessage :: MTaskDevice [MTaskMSGSend] -> Task () sendMessage dev msgs = upd (\(r,s,ss)->(r,msgs++s,ss)) (channels dev) @! ()