/// <summary> /// Initializes a new instance of the <see cref="RunnableNode"/> class. /// </summary> /// <param name="id">The id.</param> /// <param name="label">The label.</param> /// <param name="nextNodes">The next nodes.</param> /// <param name="previousNodes">The previous nodes.</param> /// <param name="library">The library.</param> /// <param name="waitForAllPredecessor">if set to <c>true</c> the node will wait for all predecessor nodes to be completed.</param> protected RunnableNode(String id, String label, RunnableNodeCollection nextNodes, RunnableNodeCollection previousNodes, TraceLab.Core.Components.ComponentsLibrary library, bool waitForAllPredecessors) { Id = id; Label = label; NextNodes = nextNodes; PreviousNodes = previousNodes; Library = library; WaitsForAllPredecessors = waitForAllPredecessors; }
/// <summary> /// Initializes a new instance of the <see cref="RunnableDecisionNode"/> class. /// </summary> /// <param name="id">The id of this decision node.</param> /// <param name="label">The label - useful for debugging.</param> /// <param name="decisionModule">The decision module that is going to be invoked to select nodes to be executed after decision</param> /// <param name="library">The reference to the components library.</param> public RunnableDecisionNode(String id, String label, TraceLab.Core.Decisions.IDecisionModule decisionModule, ComponentsLibrary library, bool waitForAllPredecessors) : base(id, label, new RunnableNodeCollection(), new RunnableNodeCollection(), library, waitForAllPredecessors) { if (decisionModule == null) { throw new ArgumentNullException("decisionModule"); } m_candidateNodes = new RunnableNodeCollection(); m_decisionModule = decisionModule; }
/// <summary> /// The decision node first delegates decision by calling its decision module to select nodes that are going to be run, from among all candidates nodes. /// Based on the decision the graph is being slightly modified. The nodes, which are going to be executed as a result of this decision, are discovered /// and their execution status is set to NOTACTIVE. /// Their Previous nodes (predecesoor nodes) are modified by removing nodes coming from paths that are not taken as a result of this decision. /// This successor nodes are being cleared, and only selected nodes are being added to the collection of the Next Nodes. /// Thanks to this solution dispatcher doesn't need to know anything about underlying graph. /// </summary> public override void RunInternal() { RunnableNodeCollection selectedNodes = m_decisionModule.Decide(m_candidateNodes); if (selectedNodes == null || selectedNodes.Count == 0) { HasError = true; ErrorMessage = "A decision node must make a decision."; } else { // send signal only to selected nodes... NextNodes.Clear(); NextNodes.AddRange(selectedNodes); } }
/// <summary> /// Initializes a new s_instance of the <see cref="RunnableExperiment"/> class. /// </summary> /// <param name="nodesFactory">The nodes factory that is going to be used to create nodes when nodes are added to template graph.</param> /// <param name="library">The library.</param> /// <param name="componentsAppDomain">The components app domain is the app domain which components assemblies are going to be loaded into.</param> /// <param name="terminateExperimentExecutionResetEvent">The event that allows signalling termination of the experiment</param> public RunnableExperiment(IRunnableNodeFactory nodesFactory, TraceLab.Core.Components.ComponentsLibrary library, AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent) { if (componentsAppDomain == null) { throw new ArgumentNullException("componentsAppDomain"); } if (terminateExperimentExecutionResetEvent == null) { throw new ArgumentNullException("terminateExperimentExecutionResetEvent"); } m_componentsAppDomain = componentsAppDomain; m_terminateExperimentExecutionResetEvent = terminateExperimentExecutionResetEvent; m_nodes = new RunnableNodeCollection(); m_nodesFactory = nodesFactory; Library = library; }