X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=Tasks%2FmTaskTask.icl;h=e8282576116ca1f56420a76720048d4078a6dd7a;hb=6d956995e169ae8fd44d62e26e35d499a9660225;hp=9bd56126d40de228dd6863dfd121db21b30ec112;hpb=41ba74ece94d91858a6683a58a0f064c36900c4b;p=mTask.git diff --git a/Tasks/mTaskTask.icl b/Tasks/mTaskTask.icl index 9bd5612..e828257 100644 --- a/Tasks/mTaskTask.icl +++ b/Tasks/mTaskTask.icl @@ -9,30 +9,28 @@ import iTasks._Framework.Serialization derive class iTask MTaskTask, MTaskInterval, Main, ByteCode, Stmt, Expr, BC, BCState, RWST, Identity makeTask :: String Int -> Task MTaskTask -makeTask name ident = get currentDateTime +makeTask name ident = get currentDateTime @ \dt->{MTaskTask | name=name,ident=ident,dateAdded=dt} -sendTaskToDevice :: String (Main (ByteCode a Stmt)) (MTaskDevice, MTaskInterval) -> Task () -sendTaskToDevice wta mTask (device, timeout) = - get bcStateStore @ toMessages timeout mTask - >>= \(msgs, st1)->set st1 bcStateStore - >>| toSDSRecords msgs st1 device - >>= \sdss->upd (mergeShares sdss) sdsStore +import StdDebug +import StdMisc +sendTaskToDevice :: String (Main (ByteCode a Stmt)) (MTaskDevice, MTaskInterval) -> Task [MTaskDevice] +sendTaskToDevice wta mTask (device, timeout) +| not (trace_tn "compiling task") = undef +# (msgs, newState=:{sdss}) = toMessages timeout mTask device.deviceState +| not (trace_tn "Done compiling task") = undef +# shares = [makeShare wta "" sdsi sdsval\\{sdsi,sdsval}<-sdss, (MTSds sdsi` _)<-msgs | sdsi == sdsi`] += updateShares device ((++) shares) >>| sendMessages msgs device >>| makeTask wta -1 - >>= withDevices device o addTask - @! () + >>= 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 device.deviceName sdsi sdsval - \\{sdsi,sdspub,sdsval}<-st.sdss - , (MTSds sdsi` _)<-s - | sdsi == sdsi`] - - mergeShares a b = a ++ b - - addTask :: MTaskTask MTaskDevice -> MTaskDevice - addTask task device = {device & deviceTasks=[task:device.deviceTasks]} + addTaskUpState :: BCState MTaskTask MTaskDevice -> MTaskDevice + addTaskUpState st task device = { MTaskDevice | device & + deviceState=st, deviceTasks=[task:device.deviceTasks]} + +//liftmTask :: String (Main (ByteCode a Stmt)) (MTaskDevice, MTaskInterval) -> Task a +//liftmTask wta mTask (device, timeout) +// = sendTaskToDevice wta mTask (device, timeout) +// >>| wait "waiting for task to return" $ sdsFocus +// >>| treturn