TaskEval.dcl 2.8 KB
Newer Older
1
definition module iTasks.Internal.TaskEval
2 3 4 5
/**
* This module provides functions for creation, evaluation and removal of task/workflow instances.
*/

6
from iTasks.WF.Definition           import :: Task, :: TaskResult, :: TaskException, :: TaskValue, :: Event, :: TaskId, :: InstanceNo
7
from iTasks.WF.Combinators.Core     import :: TaskListItem
8 9 10
from iTasks.Internal.IWorld		import :: IWorld
from iTasks.Internal.SDS          import :: SDS, :: Shared, :: ReadOnlyShared
from iTasks.Internal.Tonic        import :: ExprId
11
from iTasks.Internal.TaskState import :: DeferredJSON
12
from Text.GenJSON import :: JSONNode
13
from Data.Maybe         import :: Maybe
14
from Data.Error import :: MaybeErrorString, :: MaybeError
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
from Data.CircularStack import :: CircularStack

//Extra types used during evaluation

//Additional options to pass down the tree when evaluating a task
:: TaskEvalOpts	=
	{ noUI              :: Bool
    , tonicOpts         :: TonicOpts
	}

:: TonicOpts =
  { inAssignNode            :: Maybe ExprId
  , inParallel              :: Maybe TaskId
  , captureParallel         :: Bool
  , currBlueprintModuleName :: String
  , currBlueprintFuncName   :: String
  , currBlueprintTaskId     :: TaskId
  , currBlueprintExprId     :: ExprId
  , callTrace               :: CircularStack TaskId
  }

mkEvalOpts :: TaskEvalOpts
defaultTonicOpts :: TonicOpts

//Additional information passed up from the tree when evaluating a task
:: TaskEvalInfo =
	{ lastEvent			:: !TaskTime	        //When was the last edit, action or focus event in this task
    , removedTasks      :: ![(TaskId,TaskId)]   //Which embedded parallel tasks were removed (listId,taskId)
	, refreshSensitive	:: !Bool		        //Can refresh events change the value or ui of this task (e.g. because shared data is read)
	}

:: TaskTime			:== Int

/**
* Extend the call trace with the current task number
*/
extendCallTrace :: !TaskId !TaskEvalOpts -> TaskEvalOpts
52

53 54 55 56
/**
 * Get the next TaskId
 */
getNextTaskId :: *IWorld -> (!TaskId,!*IWorld)
57

58
/**
59
* Evaluate a task instance
60
*
61 62
* @param The instance id
* @param The event to process
63 64
* @param The IWorld state
*
65
* @return The result of the targeted main task or an error
66 67
* @return The IWorld state
*/
68
evalTaskInstance :: !InstanceNo !Event !*IWorld -> (!MaybeErrorString (TaskValue DeferredJSON),!*IWorld)
69

70
//Update the I/O information for task instances
71 72 73
updateInstanceLastIO        ::          ![InstanceNo]       !*IWorld -> *(!MaybeError TaskException (), !*IWorld)
updateInstanceConnect       :: !String  ![InstanceNo]       !*IWorld -> *(!MaybeError TaskException (), !*IWorld)
updateInstanceDisconnect    ::          ![InstanceNo]       !*IWorld -> *(!MaybeError TaskException (), !*IWorld)
74

75 76
//Shares providing access to the evaluation information (constants from an evaluation point of view)
currentInstanceShare        :: ReadOnlyShared InstanceNo