named sds's
[mTask.git] / Tasks / mTaskTask.icl
1 implementation module Tasks.mTaskTask
2
3 import mTask
4 import iTasks
5 import Devices.mTaskDevice
6
7 import iTasks._Framework.Serialization
8
9 derive class iTask MTaskTask, MTaskInterval, Main, ByteCode, Stmt, Expr, BC, BCState, RWST, Identity
10
11 makeTask :: String Int -> Task MTaskTask
12 makeTask name ident = get currentDateTime
13 @ \dt->{MTaskTask | name=name,ident=ident,dateAdded=dt}
14
15 import StdDebug
16 import StdMisc
17 sendTaskToDevice :: String (Main (ByteCode a Stmt)) (MTaskDevice, MTaskInterval) -> Task [MTaskDevice]
18 sendTaskToDevice wta mTask (device, timeout)
19 | not (trace_tn "compiling task") = undef
20 # (msgs, newState=:{sdss}) = toMessages timeout mTask device.deviceState
21 | not (trace_tn "Done compiling task") = undef
22 # shares = [makeShare wta "" sdsi sdsval\\{sdsi,sdsval}<-sdss, (MTSds sdsi` _)<-msgs | sdsi == sdsi`]
23 = updateShares device ((++) shares)
24 >>| sendMessages msgs device
25 >>| makeTask wta -1
26 >>= withDevices device o addTaskUpState newState
27 where
28 addTaskUpState :: BCState MTaskTask MTaskDevice -> MTaskDevice
29 addTaskUpState st task device = { MTaskDevice | device &
30 deviceState=st, deviceTasks=[task:device.deviceTasks]}
31
32 //liftmTask :: String (Main (ByteCode a Stmt)) (MTaskDevice, MTaskInterval) -> Task a
33 //liftmTask wta mTask (device, timeout)
34 // = sendTaskToDevice wta mTask (device, timeout)
35 // >>| wait "waiting for task to return" $ sdsFocus
36 // >>| treturn