/// <summary> /// Creates the Runnable node with a specific id based on the given metadata. /// </summary> /// <param name="nodeId">The node id.</param> /// <param name="metadata">The component metadata.</param> /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param> /// <param name="library">The library of components.</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; /// Needed for the composite components sublevel experiments, so that they hold the referance to the same termination event as top level experiment.</param> /// <returns> /// Created node /// </returns> public virtual RunnableNode CreateNode(String nodeId, Metadata metadata, LoggerNameRoot loggerNameRoot, ComponentsLibrary library, AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent) { RunnableNode retNode; ComponentMetadata componentMetadata = metadata as ComponentMetadata; DecisionMetadata decisionMetadata = metadata as DecisionMetadata; StartNodeMetadata startNodeMetadata = metadata as StartNodeMetadata; EndNodeMetadata endNodeMetadata = metadata as EndNodeMetadata; ScopeBaseMetadata scopeMetadata = metadata as ScopeBaseMetadata; LoopScopeMetadata loopMetadata = metadata as LoopScopeMetadata; CompositeComponentMetadata compositeComponentMetadata = metadata as CompositeComponentMetadata; ExitDecisionMetadata exitDecisionMetadata = metadata as ExitDecisionMetadata; if (componentMetadata != null) { TraceLabSDK.ComponentLogger logger = TraceLab.Core.Components.LoggerFactory.CreateLogger(loggerNameRoot, nodeId, componentMetadata); IComponent component = library.LoadComponent(componentMetadata, Workspace, logger, componentsAppDomain); retNode = new RunnableComponentNode(nodeId, componentMetadata.Label, component, logger, library, componentMetadata.WaitsForAllPredecessors); } else if (decisionMetadata != null) { IDecisionModule decisionModule = DecisionModuleFactory.LoadDecisionModule(decisionMetadata, Workspace, componentsAppDomain); retNode = new RunnableDecisionNode(nodeId, decisionMetadata.Label, decisionModule, library, decisionMetadata.WaitsForAllPredecessors); } else if (startNodeMetadata != null) { retNode = new RunnableStartNode(nodeId); } else if (endNodeMetadata != null) { retNode = new RunnableEndNode(nodeId, endNodeMetadata.WaitsForAllPredecessors); } else if (loopMetadata != null) { retNode = CreateLoopNode(nodeId, loopMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent); } else if (scopeMetadata != null) { retNode = CreateScopeCompositeComponentNode(nodeId, scopeMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent); } else if (compositeComponentMetadata != null) { retNode = CreateCompositeComponentNode(nodeId, compositeComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent); } else if (exitDecisionMetadata != null) { retNode = new RunnablePrimitiveNode(nodeId, exitDecisionMetadata.WaitsForAllPredecessors); } else { throw new Exceptions.InconsistentTemplateException("Could not identify node type."); } return(retNode); }
/// <summary> /// Creates the Runnable node with a specific id based on the given metadata. /// </summary> /// <param name="nodeId">The node id.</param> /// <param name="metadata">The component metadata.</param> /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param> /// <param name="library">The library of components.</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; /// Needed for the composite components sublevel experiments, so that they hold the referance to the same termination event as top level experiment.</param> /// <returns> /// Created node /// </returns> public virtual RunnableNode CreateNode(String nodeId, Metadata metadata, LoggerNameRoot loggerNameRoot, ComponentsLibrary library, AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent) { RunnableNode retNode; ComponentMetadata componentMetadata = metadata as ComponentMetadata; DecisionMetadata decisionMetadata = metadata as DecisionMetadata; StartNodeMetadata startNodeMetadata = metadata as StartNodeMetadata; EndNodeMetadata endNodeMetadata = metadata as EndNodeMetadata; ScopeBaseMetadata scopeMetadata = metadata as ScopeBaseMetadata; LoopScopeMetadata loopMetadata = metadata as LoopScopeMetadata; CompositeComponentMetadata compositeComponentMetadata = metadata as CompositeComponentMetadata; ExitDecisionMetadata exitDecisionMetadata = metadata as ExitDecisionMetadata; if (componentMetadata != null) { TraceLabSDK.ComponentLogger logger = TraceLab.Core.Components.LoggerFactory.CreateLogger(loggerNameRoot, nodeId, componentMetadata); IComponent component = library.LoadComponent(componentMetadata, Workspace, logger, componentsAppDomain); retNode = new RunnableComponentNode(nodeId, componentMetadata.Label, component, logger, library, componentMetadata.WaitsForAllPredecessors); } else if (decisionMetadata != null) { IDecisionModule decisionModule = DecisionModuleFactory.LoadDecisionModule(decisionMetadata, Workspace, componentsAppDomain); retNode = new RunnableDecisionNode(nodeId, decisionMetadata.Label, decisionModule, library, decisionMetadata.WaitsForAllPredecessors); } else if (startNodeMetadata != null) { retNode = new RunnableStartNode(nodeId); } else if (endNodeMetadata != null) { retNode = new RunnableEndNode(nodeId, endNodeMetadata.WaitsForAllPredecessors); } else if (loopMetadata != null) { retNode = CreateLoopNode(nodeId, loopMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent); } else if (scopeMetadata != null) { retNode = CreateScopeCompositeComponentNode(nodeId, scopeMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent); } else if (compositeComponentMetadata != null) { retNode = CreateCompositeComponentNode(nodeId, compositeComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent); } else if (exitDecisionMetadata != null) { retNode = new RunnablePrimitiveNode(nodeId, exitDecisionMetadata.WaitsForAllPredecessors); } else { throw new Exceptions.InconsistentTemplateException("Could not identify node type."); } return retNode; }