From 96bcbbd100188d284eac9c00630657b85c57a6ae Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Sun, 11 Jun 2017 11:16:29 +0200 Subject: [PATCH] clean up task generation --- Tasks/mTaskTask.dcl | 2 +- Tasks/mTaskTask.icl | 21 +++++---------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/Tasks/mTaskTask.dcl b/Tasks/mTaskTask.dcl index 0beddf2..f5976d3 100644 --- a/Tasks/mTaskTask.dcl +++ b/Tasks/mTaskTask.dcl @@ -13,4 +13,4 @@ derive class iTask MTaskTask, MTaskInterval, Main, ByteCode, Stmt, Expr, BC, BCS } makeTask :: String Int -> Task MTaskTask -sendTaskToDevice :: String (Main (ByteCode a Stmt)) (MTaskDevice, MTaskInterval) -> Task () +sendTaskToDevice :: String (Main (ByteCode a Stmt)) (MTaskDevice, MTaskInterval) -> Task [MTaskDevice] diff --git a/Tasks/mTaskTask.icl b/Tasks/mTaskTask.icl index 41741d2..dcd0b8a 100644 --- a/Tasks/mTaskTask.icl +++ b/Tasks/mTaskTask.icl @@ -12,26 +12,15 @@ makeTask :: String Int -> Task MTaskTask makeTask name ident = get currentDateTime @ \dt->{MTaskTask | name=name,ident=ident,dateAdded=dt} -sendTaskToDevice :: String (Main (ByteCode a Stmt)) (MTaskDevice, MTaskInterval) -> Task () +sendTaskToDevice :: String (Main (ByteCode a Stmt)) (MTaskDevice, MTaskInterval) -> Task [MTaskDevice] sendTaskToDevice wta mTask (device, timeout) # (msgs, newState) = toMessages timeout mTask device.deviceState -= toSDSRecords msgs newState device - >>= \sdss->updateShares device ((++) sdss) +# shares = [makeShare wta sdsi sdsval\\{sdsi,sdsval}<-newState.sdss, (MTSds sdsi` _)<-msgs | sdsi == sdsi`] += updateShares device ((++) shares) >>| sendMessages msgs device >>| makeTask wta -1 >>= withDevices device o addTaskUpState newState - @! () where - sharename i = device.deviceChannels +++ "-" +++ toString i - - toSDSRecords :: [MTaskMSGSend] BCState MTaskDevice -> Task [MTaskShare] - toSDSRecords s st device = treturn - [makeShare wta sdsi sdsval - \\{sdsi,sdsval}<-st.sdss, (MTSds sdsi` _)<-s | sdsi == sdsi`] - addTaskUpState :: BCState MTaskTask MTaskDevice -> MTaskDevice - addTaskUpState st task device = - { MTaskDevice - | device - & deviceState=st - , deviceTasks=[task:device.deviceTasks]} + addTaskUpState st task device = { MTaskDevice | device & + deviceState=st, deviceTasks=[task:device.deviceTasks]} -- 2.20.1