/// <summary> /// Loads the decision module based on the decision metadata /// </summary> /// <param name="decisionMetadata">The decision metadata.</param> /// <param name="workspaceWrapper">The workspace wrapper.</param> /// <param name="componentsAppDomain">The components app domain is the app domain which decision assembly is going to be loaded into.</param> /// <returns>Loaded decision</returns> internal static ILoopDecisionModule LoadDecisionModule(LoopScopeMetadata loopMetadata, IWorkspaceInternal workspaceWrapper, AppDomain componentsAppDomain) { DecisionLoader loader = ConstructDecisionModuleInComponentsAppDomain(loopMetadata, workspaceWrapper, componentsAppDomain); return((ILoopDecisionModule)loader.LoadedDecisionModule); }
/// <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 scope composite component node. It actually returns the composite component, but with different nested workspace wrapper. /// </summary> /// <param name="id">The id.</param> /// <param name="loopScopeMetadata">The scope metadata.</param> /// <param name="loggerNameRoot">The logger name root.</param> /// <param name="library">The library.</param> /// <param name="componentsAppDomain">The components app domain.</param> /// <param name="terminateExperimentExecutionResetEvent">The terminate experiment execution reset event.</param> /// <returns></returns> protected RunnableNode CreateLoopNode(string id, LoopScopeMetadata loopScopeMetadata, LoggerNameRoot loggerNameRoot, ComponentsLibrary library, AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent) { ScopeNestedWorkspaceWrapper workspaceWrapper = WorkspaceWrapperFactory.CreateCompositeComponentWorkspaceWrapper(loopScopeMetadata, Workspace, id, componentsAppDomain); //scope can standard runnable factory, unlike the composite component IRunnableNodeFactory nodesFactory = new RunnableNodeFactory(workspaceWrapper); RunnableExperimentBase subExperiment = ConstructSubExperiment(loopScopeMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent, nodesFactory); ILoopDecisionModule decisionModule = DecisionModuleFactory.LoadDecisionModule(loopScopeMetadata, Workspace, componentsAppDomain); return(new RunnableLoopNode(id, decisionModule, loopScopeMetadata, subExperiment, workspaceWrapper, library, loopScopeMetadata.WaitsForAllPredecessors)); }
private void CompileLoopDecision(string code) { //constuct mock loop metadata - subgraph does not matter in code compilation LoopScopeMetadata mockLoopMetadata = new LoopScopeMetadata(null, "Mock loop", String.Empty); Dictionary <string, string> mockSuccessorNodeLabelIdLookup = new Dictionary <string, string>(); Dictionary <string, string> mockPredeccessorsOutputsNameTypeLookup = new Dictionary <string, string>(); mockPredeccessorsOutputsNameTypeLookup.Add("test", "int"); mockLoopMetadata.DecisionCode = code; DecisionCompilationRunner_Accessor.BuildSourceAndCompileDecisionModule(mockLoopMetadata, mockSuccessorNodeLabelIdLookup, mockPredeccessorsOutputsNameTypeLookup, AppContext.WorkspaceInstance.TypeDirectories, new LoggerNameRoot("Mock")); }