コード例 #1
0
        public void ValidateInputMapping_CorrectFlow_OutputFound2()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ExperimentNode readerNode  = experiment.AddComponentFromDefinition(m_componentReaderMetaDefinition, 5, 5);
            ExperimentNode writerNode1 = experiment.AddComponentFromDefinition(m_componentWriterMetaDefinition, 15, 15);
            ExperimentNode writerNode2 = experiment.AddComponentFromDefinition(m_componentWriterMetaDefinition, 25, 25);

            experiment.AddConnection(experiment.StartNode, writerNode1);
            experiment.AddConnection(writerNode1, writerNode2);
            experiment.AddConnection(writerNode2, readerNode);
            experiment.AddConnection(readerNode, experiment.EndNode);

            (writerNode1.Data.Metadata as ComponentMetadata).IOSpec.Output["testoutput"].MappedTo = "test1";
            (writerNode2.Data.Metadata as ComponentMetadata).IOSpec.Output["testoutput"].MappedTo = "test2";
            (readerNode.Data.Metadata as ComponentMetadata).IOSpec.Input["testinput"].MappedTo    = "test1";

            RunnableNodeFactory    templateGraphNodesFactory = new RunnableNodeFactory(AppContext.WorkspaceInstance);
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            Assert.IsFalse(template.IsEmpty);

            Assert.IsFalse(readerNode.HasError);
            Assert.IsFalse(writerNode1.HasError);
            Assert.IsFalse(writerNode2.HasError);

            Assert.AreEqual(5, template.Nodes.Count);
        }
コード例 #2
0
        public void GraphStructureValidator_NoPathToEnd2()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ExperimentNode node1 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node2 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 15, 15);
            ExperimentNode node3 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 25, 25);

            experiment.AddConnection(experiment.StartNode, node1);
            experiment.AddConnection(experiment.StartNode, node3);
            experiment.AddConnection(node1, node2);
            experiment.AddConnection(node2, experiment.EndNode);

            Assert.IsFalse(node1.HasError);
            Assert.IsFalse(node2.HasError);
            Assert.IsFalse(node3.HasError);

            RunnableNodeFactory    templateGraphNodesFactory = new RunnableNodeFactory(AppContext.WorkspaceInstance);
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            Assert.IsTrue(template.IsEmpty);

            Assert.IsTrue(node3.HasError);
            Assert.AreEqual(node3.ErrorMessage, "Unable to detect path to the END node.");
        }
コード例 #3
0
ファイル: ComponentFactory.cs プロジェクト: neostoic/TraceLab
        /// <summary>
        /// Attempts to create the composite component. Component is created only if definition is a CompositeComponentMetadataDefinition.
        /// Otherwise method returns false, and null node.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="metadataDefinition">The metadata definition which component is created based on.</param>
        /// <param name="data">The data containing position of new vertex</param>
        /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a CompositeComponentMetadataDefinition</param>
        /// <returns>
        /// true if metadatadefinition was a CompositeComponentMetadataDefinition and node has been created, otherwise false
        /// </returns>
        private static bool TryCreateCompositeComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data,
                                                        out ExperimentNode newCreatedNode)
        {
            bool isCreated = false;

            newCreatedNode = null;

            CompositeComponentMetadataDefinition compositeComponentMetadataDefinition = metadataDefinition as CompositeComponentMetadataDefinition;

            if (compositeComponentMetadataDefinition != null)
            {
                data.Metadata = new CompositeComponentMetadata(compositeComponentMetadataDefinition, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));
                string componentNodeId = Guid.NewGuid().ToString();
                string componentName   = data.Metadata.Label;
                newCreatedNode = new CompositeComponentNode(componentNodeId, data, experiment.Settings);
                experiment.AddVertex(newCreatedNode);

                //set the log settings of the new component
                experiment.SetLogLevelSettings(newCreatedNode);

                isCreated = true;
            }

            return(isCreated);
        }
コード例 #4
0
        /// <summary>
        /// Adds the component from definition to experiment.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="metadataDefinition">The metadata definition that defines newly added component.</param>
        /// <param name="positionX">The position X at where new component is added</param>
        /// <param name="positionY">The position Y at where new comopnent is added</param>
        /// <returns>The newly constucted node</returns>
        public static ExperimentNode AddComponentFromDefinitionToExperiment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, double positionX, double positionY)
        {
            if (metadataDefinition == null)
                throw new ArgumentNullException("metadataDefinition");

            ExperimentNode newNode = null;

            SerializedVertexData data = new SerializedVertexData();
            data.X = positionX;
            data.Y = positionY;

            // case 1. Primitive Component
            bool isCreated = TryCreateComponent(experiment, metadataDefinition, data, out newNode);

            // case 2. Composite Component
            if(!isCreated)
                isCreated = TryCreateCompositeComponent(experiment, metadataDefinition, data, out newNode);

            // case 3. Decision
            if (!isCreated)
                isCreated = TryCreateDecisionComponent(experiment, metadataDefinition, data, out newNode);

            // case 4. Loop
            if (!isCreated)
                isCreated = TryCreateLoopComponent(experiment, metadataDefinition, data, out newNode);
            
            return newNode;
        }
コード例 #5
0
        /// <summary>
        /// Generates the scope node.
        /// </summary>
        /// <param name="scopeName">Name of the scope.</param>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="positionX">The position X.</param>
        /// <param name="positionY">The position Y.</param>
        /// <returns></returns>
        private static LoopScopeNode CreateLoopScopeNode(string scopeName, IEditableExperiment experiment, double positionX, double positionY)
        {
            var data = new SerializedVertexDataWithSize();

            data.X      = positionX;
            data.Y      = positionY;
            data.Width  = 160;
            data.Height = 160;

            string componentId = Guid.NewGuid().ToString();

            var componentGraph = new CompositeComponentEditableGraph(true);

            componentGraph.References = new System.Collections.ObjectModel.ObservableCollection <TraceLabSDK.PackageSystem.IPackageReference>(experiment.References);

            data.Metadata = new LoopScopeMetadata(componentGraph, scopeName, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));

            string componentNodeId = Guid.NewGuid().ToString();
            string componentName   = data.Metadata.Label;

            var loopScopeNode = new LoopScopeNode(Guid.NewGuid().ToString(), data);

            experiment.AddVertex(loopScopeNode);

            return(loopScopeNode);
        }
コード例 #6
0
ファイル: ComponentFactory.cs プロジェクト: neostoic/TraceLab
        /// <summary>
        /// Generates the challenge node.
        /// </summary>
        /// <param name="challengeName">Name of the challenge.</param>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="positionX">The position X.</param>
        /// <param name="positionY">The position Y.</param>
        /// <returns></returns>
        private static ChallengeNode CreateChallengeNode(string challengeName, IEditableExperiment experiment, double positionX, double positionY)
        {
            var data = new SerializedVertexDataWithSize();

            data.X      = positionX;
            data.Y      = positionY;
            data.Width  = 160;
            data.Height = 160;

            string componentId = Guid.NewGuid().ToString();

            var componentGraph = new CompositeComponentEditableGraph(true);

            if (componentGraph.References != null)
            {
                componentGraph.References = experiment.References.CopyCollection();
            }

            data.Metadata = new ChallengeMetadata(componentGraph, challengeName, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));

            string componentNodeId = Guid.NewGuid().ToString();
            string componentName   = data.Metadata.Label;

            var challengeNode = new ChallengeNode(Guid.NewGuid().ToString(), data);

            experiment.AddVertex(challengeNode);

            return(challengeNode);
        }
コード例 #7
0
        /// <summary>
        /// Connects the end.
        /// When connecting the end, it also updates information in the experiment model data.
        /// </summary>
        /// <param name='end'>
        /// End.
        /// </param>
        public override void ConnectEnd(MonoHotDraw.Connectors.IConnector end)
        {
            base.ConnectEnd(end);

            if (end != null)
            {
                IComponentControl startComponentControl = StartConnector.Owner as IComponentControl;
                IComponentControl endComponentControl   = end.Owner as IComponentControl;
                if (endComponentControl != null && startComponentControl != null)
                {
                    //get access to owner experiment
                    IEditableExperiment ownerExperiment = endComponentControl.ExperimentNode.Owner as IEditableExperiment;
                    if (ownerExperiment != null)
                    {
                        ExperimentNodeConnection nodeConnection = ownerExperiment.AddConnection(startComponentControl.ExperimentNode, endComponentControl.ExperimentNode);
                        OnConnectionCompleted(nodeConnection);
                        m_experimentNodeConnection = nodeConnection;

                        // SPRINT 2: TLAB-129
                        CommentNode comment = nodeConnection.Source as CommentNode;
                        if (comment != null)
                        {
                            isSourceComment = true;
                        }
                        // END SPRINT 2: TLAB-129
                    }
                }
            }
        }
コード例 #8
0
ファイル: ComponentFactory.cs プロジェクト: CoEST/TraceLab
        // HERZUM SPRINT 1.0
        private static bool TryCreateComment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, 
                                               SerializedVertexData data, out ExperimentNode newCreatedNode)
        {
            bool isCreated = false;
            newCreatedNode = null;

            CommentMetadataDefinition commentMetadataDefinition = metadataDefinition as CommentMetadataDefinition;
            if (commentMetadataDefinition != null)
            {
                data.Metadata = new CommentMetadata(commentMetadataDefinition.Label);
                string commentNodeId = Guid.NewGuid().ToString();

                // HERZUM SPRINT 1.2 COMMENT
                // newCreatedNode = new CommentNode(commentNodeId, data);
                var data_with_size = new SerializedVertexDataWithSize();
                data_with_size.X = data.X;
                data_with_size.Y = data.Y;
                data_with_size.Metadata = data.Metadata;
                data_with_size.Width  = 160;
                data_with_size.Height = 160;
                data_with_size.WidgetStatus = "normal";
                newCreatedNode = new CommentNode(commentNodeId, data_with_size);
                // END SPRINT 1.2 COMMENT

                experiment.AddVertex(newCreatedNode);

                //set the log settings of the new component
                experiment.SetLogLevelSettings(newCreatedNode);

                isCreated = true;
            }

            return isCreated;
        }
コード例 #9
0
        public void TestTemplateGraphDisposal_InValidNodes()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            //construct some simple m_experiment
            ExperimentNode node1 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node2 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node3 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);

            node1.Data.Metadata.Label = "Broken Component";

            experiment.AddConnection(experiment.StartNode, node1);
            experiment.AddConnection(node1, node2);
            experiment.AddConnection(node2, node3);
            experiment.AddConnection(node3, experiment.EndNode);

            //initiate mockNodesFactory
            MockNodesFactory       mockNodesFactory = new MockNodesFactory();
            RunnableExperimentBase template         = GraphAdapter.Adapt(experiment, mockNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            //adaptation should have failed and graph should be empty because broken node construction failed
            Assert.IsTrue(template.IsEmpty);

            //but also all of the previously created nodes before reaching the broken node during adaptation should have been disposed.
            foreach (MockNode node in mockNodesFactory.CreatedNodes)
            {
                Assert.IsTrue(node.disposed);
            }
        }
コード例 #10
0
ファイル: GraphView.cs プロジェクト: thbin/TraceLab
        /// <summary>
        /// Performs operation of adding the new scope to the given decision.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        protected void ExecuteAddScopeToDecision(object sender, ExecutedRoutedEventArgs e)
        {
            GraphSharp.Controls.VertexControl vertexControl = e.Parameter as GraphSharp.Controls.VertexControl;

            if (vertexControl != null)
            {
                ExperimentDecisionNode decisionNode = vertexControl.Vertex as ExperimentDecisionNode;

                if (decisionNode != null)
                {
                    ExitDecisionNode    exitDecisionNode = null;
                    IEditableExperiment experiment       = decisionNode.Owner as IEditableExperiment;
                    double           rightmostX          = decisionNode.Data.X;
                    HashSet <string> currentLabels       = new HashSet <string>();

                    //iterate through outgoing scopes and find the scope with right border located most to the right among all scopes
                    //also locate among outgoing edges reference to exit
                    IEnumerable <ExperimentNodeConnection> outEdges;
                    if (experiment.TryGetOutEdges(decisionNode, out outEdges))
                    {
                        foreach (ExperimentNodeConnection connection in outEdges)
                        {
                            ScopeNode scope = connection.Target as ScopeNode;

                            if (scope != null)
                            {
                                double candidateRightMostX = scope.DataWithSize.X + scope.DataWithSize.Width / 2;
                                if (candidateRightMostX > rightmostX)
                                {
                                    rightmostX = candidateRightMostX;
                                }

                                //also collect labels
                                currentLabels.Add(scope.Data.Metadata.Label);
                            }
                            else if (exitDecisionNode == null)
                            {
                                //try find exit decision node
                                exitDecisionNode = connection.Target as ExitDecisionNode;
                            }
                        }
                    }

                    double xPosition = rightmostX + 100;
                    double yPosition = decisionNode.Data.Y + 120;

                    string finalLabel = DetermineNewScopeLabel(currentLabels);

                    //check if deicion node is not null. In old decision nodes without scopes, there were no associated exit node,
                    //thus the scope cannot be added for these decisions.
                    if (exitDecisionNode != null)
                    {
                        ComponentFactory.AddScopeToDecision(finalLabel, xPosition, yPosition, decisionNode, exitDecisionNode, experiment);
                    }
                }
            }
        }
        public TopLevelEditableExperimentViewModel(IEditableExperiment experiment)
            : base(experiment)
        {
            m_experiment = experiment;

            RemoveNode = new DelegateCommand(RemoveNodeFunc, CanRemoveNodeFunc);
            RemoveSelectedNodes = new DelegateCommand(RemoveSelectedNodesFunc, CanRemoveSelectedNodesFunc);
            DragOver = new DelegateCommand(DragOverFunc);
            Drop = new DelegateCommand(DropFunc, CanDropFunc);
            ToogleLogLevel = new DelegateCommand(ToogleLogLevelFunc, CanToogleLogLevelFunc);
        }
コード例 #12
0
        public TopLevelEditableExperimentViewModel(IEditableExperiment experiment)
            : base(experiment)
        {
            m_experiment = experiment;

            RemoveNode          = new DelegateCommand(RemoveNodeFunc, CanRemoveNodeFunc);
            RemoveSelectedNodes = new DelegateCommand(RemoveSelectedNodesFunc, CanRemoveSelectedNodesFunc);
            DragOver            = new DelegateCommand(DragOverFunc);
            Drop           = new DelegateCommand(DropFunc, CanDropFunc);
            ToogleLogLevel = new DelegateCommand(ToogleLogLevelFunc, CanToogleLogLevelFunc);
        }
コード例 #13
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            IEditableExperiment graph = value as IEditableExperiment;

            if (graph == null)
            {
                return(null);
            }

            return(new TopLevelEditableExperimentViewModel(graph));
        }
コード例 #14
0
ファイル: RemoveNodeHandle.cs プロジェクト: thbin/TraceLab
        public override void InvokeEnd(double x, double y, IDrawingView view)
        {
            base.InvokeEnd(x, y, view);

            if (clicked)
            {
                IEditableExperiment experiment = m_ownerComponent.ExperimentNode.Owner as IEditableExperiment;
                if (experiment != null)
                {
                    experiment.RemoveVertex(m_ownerComponent.ExperimentNode);
                }
            }

            clicked = false;
        }
コード例 #15
0
ファイル: RemoveNodeHandle.cs プロジェクト: thbin/TraceLab
        public override void InvokeEnd(MouseEvent ev)
        {
            base.InvokeEnd(ev);

            if (clicked)
            {
                IEditableExperiment experiment = m_ownerComponent.ExperimentNode.Owner as IEditableExperiment;
                if (experiment != null)
                {
                    experiment.RemoveVertex(m_ownerComponent.ExperimentNode);
                }
            }

            clicked = false;
        }
コード例 #16
0
ファイル: ComponentFactory.cs プロジェクト: neostoic/TraceLab
        private static void GenerateScopesAndExit(IEditableExperiment experiment, SerializedVertexData data, ExperimentDecisionNode decisionNode)
        {
            ExitDecisionNode exitDecisionNode = GenerateExitDecisionNode(data.X, data.Y + 240);

            experiment.AddVertex(exitDecisionNode);

            //add invisible fixed connection between decision and exit - so that if scope can be skipped upon condition
            experiment.AddFixedConnection(decisionNode, exitDecisionNode, true);

            //set the log settings of all new nodes
            experiment.SetLogLevelSettings(decisionNode);
            experiment.SetLogLevelSettings(exitDecisionNode);

            AddScopeToDecision("Scope 1", data.X - 90, data.Y + 120, decisionNode, exitDecisionNode, experiment);
            AddScopeToDecision("Scope 2", data.X + 90, data.Y + 120, decisionNode, exitDecisionNode, experiment);
        }
コード例 #17
0
ファイル: ComponentFactory.cs プロジェクト: neostoic/TraceLab
        // END HERZUM 0.0

        // HERZUM SPRINT 2.0: TLAB-65 CLASS
        /// <summary>
        /// Attempts to create the composite component. Component is created only if definition is a ChallengeMetadataDefinition.
        /// Otherwise method returns false, and null node.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="metadataDefinition">The metadata definition which component is created based on.</param>
        /// <param name="data">The data containing position of new vertex</param>
        /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a LoopMetadataDefinition</param>
        /// <returns>
        /// true if metadatadefinition was a ChallengeMetadataDefinition and node has been created, otherwise false
        /// </returns>
        private static bool TryCreateChallengeComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data,
                                                        out ExperimentNode newCreatedNode)
        {
            bool isCreated = false;

            newCreatedNode = null;

            ChallengeMetadataDefinition challengeMetadataDefinition = metadataDefinition as ChallengeMetadataDefinition;

            if (challengeMetadataDefinition != null)
            {
                newCreatedNode = CreateChallengeNode(challengeMetadataDefinition.Label, experiment, data.X, data.Y);
                isCreated      = true;
            }

            return(isCreated);
        }
コード例 #18
0
ファイル: ComponentFactory.cs プロジェクト: CoEST/TraceLab
        /// <summary>
        /// Adds the component from definition to experiment.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="metadataDefinition">The metadata definition that defines newly added component.</param>
        /// <param name="positionX">The position X at where new component is added</param>
        /// <param name="positionY">The position Y at where new comopnent is added</param>
        /// <returns>The newly constucted node</returns>
        public static ExperimentNode AddComponentFromDefinitionToExperiment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, double positionX, double positionY)
        {
            if (metadataDefinition == null)
                throw new ArgumentNullException("metadataDefinition");

            ExperimentNode newNode = null;

            SerializedVertexData data = new SerializedVertexData();
            data.X = positionX;
            data.Y = positionY;

            // case 1. Primitive Component
            bool isCreated = TryCreateComponent(experiment, metadataDefinition, data, out newNode);

            // case 2. Composite Component
            if(!isCreated)
                isCreated = TryCreateCompositeComponent(experiment, metadataDefinition, data, out newNode);

            // case 3. Decision
            if (!isCreated)
                isCreated = TryCreateDecisionComponent(experiment, metadataDefinition, data, out newNode);

            // case 4. Loop
            if (!isCreated)
                isCreated = TryCreateLoopComponent(experiment, metadataDefinition, data, out newNode);

            // HERZUM SPRINT 0.0
            // case 5. Scope
            if (!isCreated)
                isCreated = TryCreateScopeComponent(experiment, metadataDefinition, data, out newNode);
            // END HERZUM 0.0

            // HERZUM SPRINT 1.0
            if (!isCreated)
                isCreated = TryCreateComment(experiment, metadataDefinition, data, out newNode);
            // END HERZUM SPRINT 1.0

            // HERZUM SPRINT 2.0: TLAB-65
            // case 5. Challenge
            if (!isCreated)
                isCreated = TryCreateChallengeComponent(experiment, metadataDefinition, data, out newNode);
            // END HERZUM SPRINT 2.0: TLAB-65

            
            return newNode;
        }
コード例 #19
0
ファイル: ComponentFactory.cs プロジェクト: neostoic/TraceLab
        /// <summary>
        /// Creates the decision component.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="decisionMetadataDefinition">The decision metadata definition.</param>
        /// <param name="data">The data containing position of new vertex</param>
        /// <returns>Newly added desicion node (note, that in case of decision additional nodes are constructed, two scopes and exit decision node). They are not returned.</returns>
        private static ExperimentDecisionNode CreateDecisionComponent(IEditableExperiment experiment, DecisionMetadataDefinition decisionMetadataDefinition, SerializedVertexData data)
        {
            data.Metadata = new DecisionMetadata(decisionMetadataDefinition.Label);

            ExperimentDecisionNode decisionNode = new ExperimentDecisionNode(Guid.NewGuid().ToString(), data);

            experiment.AddVertex(decisionNode);

            if (decisionMetadataDefinition.ID == DecisionMetadataDefinition.DecisionGuid)
            {
                //generate corresponding scopes and exit nodes
                GenerateScopesAndExit(experiment, data, decisionNode);
            }
            //otherwise it is GoTo decision that does not have corresponding scopes, so simply return it

            return(decisionNode);
        }
コード例 #20
0
ファイル: ComponentFactory.cs プロジェクト: neostoic/TraceLab
        /// <summary>
        /// Attempts to create the composite component. Component is created only if definition is a LoopMetadataDefinition.
        /// Otherwise method returns false, and null node.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="metadataDefinition">The metadata definition which component is created based on.</param>
        /// <param name="data">The data containing position of new vertex</param>
        /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a LoopMetadataDefinition</param>
        /// <returns>
        /// true if metadatadefinition was a LoopMetadataDefinition and node has been created, otherwise false
        /// </returns>
        private static bool TryCreateLoopComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data,
                                                   out ExperimentNode newCreatedNode)
        {
            bool isCreated = false;

            newCreatedNode = null;

            LoopMetadataDefinition loopMetadataDefinition = metadataDefinition as LoopMetadataDefinition;

            if (loopMetadataDefinition != null)
            {
                newCreatedNode = CreateLoopScopeNode(loopMetadataDefinition.Label, experiment, data.X, data.Y);
                isCreated      = true;
            }

            return(isCreated);
        }
コード例 #21
0
ファイル: ComponentFactory.cs プロジェクト: neostoic/TraceLab
        /// <summary>
        /// Attempts to create the composite component. Component is created only if definition is a DecisionMetadataDefinition.
        /// Otherwise method returns false, and null node.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="metadataDefinition">The metadata definition which component is created based on.</param>
        /// <param name="data">The data containing position of new vertex</param>
        /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a DecisionMetadataDefinition</param>
        /// <returns>
        /// true if metadatadefinition was a DecisionMetadataDefinition and node has been created, otherwise false
        /// </returns>
        private static bool TryCreateDecisionComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data,
                                                       out ExperimentNode newCreatedNode)
        {
            bool isCreated = false;

            newCreatedNode = null;

            DecisionMetadataDefinition decisionMetadataDefinition = metadataDefinition as DecisionMetadataDefinition;

            if (decisionMetadataDefinition != null)
            {
                newCreatedNode = CreateDecisionComponent(experiment, decisionMetadataDefinition, data);
                isCreated      = true;
            }

            return(isCreated);
        }
コード例 #22
0
        public override void InvokeEnd(MouseEvent ev)
        {
            base.InvokeEnd(ev);

            if (clicked)
            {
                // HERZUM SPRINT 2.0 TLAB-99
                // Experiment ownerExperiment = m_ownerConnection.Owner;
                IEditableExperiment ownerExperiment = m_ownerConnection.ExperimentNodeConnection.Target.Owner as IEditableExperiment;
                if (ownerExperiment != null)
                {
                    // END HERZUM SPRINT 2.0 TLAB-99
                    ownerExperiment.RemoveConnection(m_ownerConnection.ExperimentNodeConnection);
                }
            }

            clicked = false;
        }
コード例 #23
0
ファイル: NodeControlSelector.cs プロジェクト: thbin/TraceLab
        /// <summary>
        /// Determines whether the given decision is an old version decision.
        /// Previously decisions were independent nodes without scopes and corresponding exit node.
        /// Thus for old decisions we want to choose another template.
        /// </summary>
        /// <param name="decisionNode">The decision node.</param>
        /// <returns>
        ///   <c>true</c> if the specified decision node is old decision; otherwise, <c>false</c>.
        /// </returns>
        private static bool IsGotoDecision(ExperimentDecisionNode decisionNode)
        {
            IEditableExperiment experiment = decisionNode.Owner as IEditableExperiment;

            IEnumerable <ExperimentNodeConnection> outEdges;

            if (experiment.TryGetOutEdges(decisionNode, out outEdges))
            {
                foreach (ExperimentNodeConnection connection in outEdges)
                {
                    if (connection.Target is ExitDecisionNode)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #24
0
        /// <summary>
        /// Connects the end.
        /// When connecting the end, it also updates information in the experiment model data.
        /// </summary>
        /// <param name='end'>
        /// End.
        /// </param>
        public override void ConnectEnd(MonoHotDraw.Connectors.IConnector end)
        {
            base.ConnectEnd(end);

            if (end != null)
            {
                IComponentControl startComponentControl = StartConnector.Owner as IComponentControl;
                IComponentControl endComponentControl   = end.Owner as IComponentControl;
                if (endComponentControl != null && startComponentControl != null)
                {
                    //get access to owner experiment
                    IEditableExperiment ownerExperiment = endComponentControl.ExperimentNode.Owner as IEditableExperiment;
                    if (ownerExperiment != null)
                    {
                        ExperimentNodeConnection nodeConnection = ownerExperiment.AddConnection(startComponentControl.ExperimentNode, endComponentControl.ExperimentNode);
                        OnConnectionCompleted(nodeConnection);
                        m_experimentNodeConnection = nodeConnection;
                    }
                }
            }
        }
コード例 #25
0
ファイル: ExperimentViewModel.cs プロジェクト: thbin/TraceLab
        /// <summary>
        /// Initializes a new instance of the <see cref="ExperimentViewModel"/> class.
        /// </summary>
        /// <param name="experiment">The experiment that this ViewModel represents.  This is intentionally NOT the interface</param>
        public ExperimentViewModel(BaseExperiment experiment)
        {
            if (experiment == null)
            {
                throw new ArgumentNullException("experiment");
            }

            //determine if experiment is editable
            IEditableExperiment editableExperiment = experiment as IEditableExperiment;

            if (editableExperiment != null)
            {
                m_topLevel = new TopLevelEditableExperimentViewModel(editableExperiment);
            }
            else
            {
                m_topLevel = new TopLevelExperimentViewModel(experiment);
            }

            m_currentView = m_topLevel;

            OpenComponentGraph     = new DelegateCommand(OpenComponentGraphFunc, CanOpenComponentGraph);
            RunExperiment          = new DelegateCommand(RunExperimentFunc, CanRunExperimentFunc);
            StopExperiment         = new DelegateCommand(StopExperimentFunc, CanStopExperimentFunc);
            AboutExperimentCommand = new DelegateCommand(DoAboutExperiment);
            PackExperiment         = new DelegateCommand(PackExperimentFunc);

            //top level does not have parent id
            AddSubLevels(String.Empty, m_topLevel);

            experiment.NodeAdded   += OnNodeAdded;
            experiment.NodeRemoved += OnNodeRemoved;

            experiment.NodeFinished += OnNodeFinished;
            experiment.NodeHasError += OnNodeHasError;

            experiment.ExperimentStarted   += OnExperimentStarted;
            experiment.ExperimentCompleted += OnExperimentCompleted;
        }
コード例 #26
0
        /// <summary>
        /// Attempts to create the primitive component. Component is created only if definition is a ComponentMetadataDefinition.
        /// Otherwise method returns false, and null node.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="metadataDefinition">The metadata definition which component is created based on.</param>
        /// <param name="data">The data containing position of new vertex</param>
        /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a ComponentMetadataDefinition</param>
        /// <returns>
        /// true if metadatadefinition was a ComponentMetadataDefinition and node has been created, otherwise false
        /// </returns>
        private static bool TryCreateComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, 
                                               SerializedVertexData data, out ExperimentNode newCreatedNode)
        {
            bool isCreated = false;
            newCreatedNode = null;

            ComponentMetadataDefinition componentMetadataDefinition = metadataDefinition as ComponentMetadataDefinition;
            if (componentMetadataDefinition != null)
            {
                data.Metadata = new ComponentMetadata(componentMetadataDefinition, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));
                string componentNodeId = Guid.NewGuid().ToString();
                newCreatedNode = new ComponentNode(componentNodeId, data);
                experiment.AddVertex(newCreatedNode);

                //set the log settings of the new component
                experiment.SetLogLevelSettings(newCreatedNode);

                isCreated = true;
            }

            return isCreated;
        }
コード例 #27
0
        /// <summary>
        /// Adds the component from definition to experiment.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="metadataDefinition">The metadata definition that defines newly added component.</param>
        /// <param name="positionX">The position X at where new component is added</param>
        /// <param name="positionY">The position Y at where new comopnent is added</param>
        /// <returns>The newly constucted node</returns>
        public static ExperimentNode AddComponentFromDefinitionToExperiment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, double positionX, double positionY)
        {
            if (metadataDefinition == null)
            {
                throw new ArgumentNullException("metadataDefinition");
            }

            ExperimentNode newNode = null;

            SerializedVertexData data = new SerializedVertexData();

            data.X = positionX;
            data.Y = positionY;

            // case 1. Primitive Component
            bool isCreated = TryCreateComponent(experiment, metadataDefinition, data, out newNode);

            // case 2. Composite Component
            if (!isCreated)
            {
                isCreated = TryCreateCompositeComponent(experiment, metadataDefinition, data, out newNode);
            }

            // case 3. Decision
            if (!isCreated)
            {
                isCreated = TryCreateDecisionComponent(experiment, metadataDefinition, data, out newNode);
            }

            // case 4. Loop
            if (!isCreated)
            {
                isCreated = TryCreateLoopComponent(experiment, metadataDefinition, data, out newNode);
            }

            return(newNode);
        }
コード例 #28
0
        public void ValidateInputMapping_NoOutputFound2()
        {
            Assert.Fail("Test temporarily broken. The input mapping validator temporarily validates across all components, " +
                        "not only predecessors nodes. Test ignored till the validator feature is going to be revisited.");

            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ExperimentNode readerNode1 = experiment.AddComponentFromDefinition(m_componentReaderMetaDefinition, 5, 5);
            ExperimentNode readerNode2 = experiment.AddComponentFromDefinition(m_componentReaderMetaDefinition, 15, 15);
            ExperimentNode writerNode  = experiment.AddComponentFromDefinition(m_componentWriterMetaDefinition, 25, 25);

            experiment.AddConnection(experiment.StartNode, writerNode);
            experiment.AddConnection(experiment.StartNode, readerNode1);
            experiment.AddConnection(writerNode, readerNode2);
            experiment.AddConnection(readerNode1, experiment.EndNode);
            experiment.AddConnection(readerNode2, experiment.EndNode);

            (writerNode.Data.Metadata as ComponentMetadata).IOSpec.Output["testoutput"].MappedTo = "fakemapping";
            (readerNode1.Data.Metadata as ComponentMetadata).IOSpec.Input["testinput"].MappedTo  = "fakemapping";
            (readerNode2.Data.Metadata as ComponentMetadata).IOSpec.Input["testinput"].MappedTo  = "fakemapping";

            Assert.IsFalse(readerNode1.HasError);
            Assert.IsFalse(readerNode2.HasError);
            Assert.IsFalse(writerNode.HasError);

            RunnableNodeFactory    templateGraphNodesFactory = new RunnableNodeFactory(AppContext.WorkspaceInstance);
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            Assert.IsTrue(template.IsEmpty);

            Assert.IsFalse(readerNode2.HasError);
            Assert.IsFalse(writerNode.HasError);

            Assert.IsTrue(readerNode1.HasError);
            Assert.AreEqual(readerNode1.ErrorMessage, "The component attempts to load 'fakemapping' from the Workspace. However, none of the previous components outputs 'fakemapping' to the Workspace.");
        }
コード例 #29
0
        public void TestTemplateGraphDisposal_ValidNodes()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            //construct some simple m_experiment
            ExperimentNode node1 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node2 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);

            experiment.AddConnection(experiment.StartNode, node1);
            experiment.AddConnection(node1, node2);
            experiment.AddConnection(node2, experiment.EndNode);

            //initiate mockNodesFactory
            MockNodesFactory       mockNodesFactory = new MockNodesFactory();
            RunnableExperimentBase template         = GraphAdapter.Adapt(experiment, mockNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            foreach (MockNode node in mockNodesFactory.CreatedNodes)
            {
                Assert.IsFalse(node.disposed);
            }

            //execute disptacher, because in case of correct graph dispatcher disposes nodes
            MockProgress progress = new MockProgress();

            using (var dispatcher = ExperimentRunnerFactory.CreateExperimentRunner(template))
            {
                dispatcher.ExecuteExperiment(progress);
                Assert.IsFalse(progress.HasError);
            }

            foreach (MockNode node in mockNodesFactory.CreatedNodes)
            {
                Assert.IsTrue(node.disposed);
            }
        }
コード例 #30
0
ファイル: ComponentFactory.cs プロジェクト: neostoic/TraceLab
        // HERZUM SPRINT 1.0
        private static bool TryCreateComment(IEditableExperiment experiment, MetadataDefinition metadataDefinition,
                                             SerializedVertexData data, out ExperimentNode newCreatedNode)
        {
            bool isCreated = false;

            newCreatedNode = null;

            CommentMetadataDefinition commentMetadataDefinition = metadataDefinition as CommentMetadataDefinition;

            if (commentMetadataDefinition != null)
            {
                data.Metadata = new CommentMetadata(commentMetadataDefinition.Label);
                string commentNodeId = Guid.NewGuid().ToString();

                // HERZUM SPRINT 1.2 COMMENT
                // newCreatedNode = new CommentNode(commentNodeId, data);
                var data_with_size = new SerializedVertexDataWithSize();
                data_with_size.X            = data.X;
                data_with_size.Y            = data.Y;
                data_with_size.Metadata     = data.Metadata;
                data_with_size.Width        = 160;
                data_with_size.Height       = 160;
                data_with_size.WidgetStatus = "normal";
                newCreatedNode = new CommentNode(commentNodeId, data_with_size);
                // END SPRINT 1.2 COMMENT

                experiment.AddVertex(newCreatedNode);

                //set the log settings of the new component
                experiment.SetLogLevelSettings(newCreatedNode);

                isCreated = true;
            }

            return(isCreated);
        }
コード例 #31
0
        public void ValidateInputMapping_NoOutputFound()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ExperimentNode readerNode = experiment.AddComponentFromDefinition(m_componentReaderMetaDefinition, 5, 5);
            ExperimentNode writerNode = experiment.AddComponentFromDefinition(m_componentWriterMetaDefinition, 5, 5);

            experiment.AddConnection(experiment.StartNode, writerNode);
            experiment.AddConnection(writerNode, readerNode);
            experiment.AddConnection(readerNode, experiment.EndNode);

            (readerNode.Data.Metadata as ComponentMetadata).IOSpec.Input["testinput"].MappedTo = "fakemapping";

            Assert.IsFalse(readerNode.HasError);

            RunnableNodeFactory    templateGraphNodesFactory = new RunnableNodeFactory(AppContext.WorkspaceInstance);
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            Assert.IsTrue(template.IsEmpty);

            Assert.IsTrue(readerNode.HasError);
            Assert.AreEqual(readerNode.ErrorMessage, "The component attempts to load 'fakemapping' from the Workspace. However, none of the previous components outputs 'fakemapping' to the Workspace.");
        }
コード例 #32
0
        /// <summary>
        /// Attempts to create the composite component. Component is created only if definition is a LoopMetadataDefinition.
        /// Otherwise method returns false, and null node.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="metadataDefinition">The metadata definition which component is created based on.</param>
        /// <param name="data">The data containing position of new vertex</param>
        /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a LoopMetadataDefinition</param>
        /// <returns>
        /// true if metadatadefinition was a LoopMetadataDefinition and node has been created, otherwise false
        /// </returns>
        private static bool TryCreateLoopComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data,
                                                       out ExperimentNode newCreatedNode)
        {
            bool isCreated = false;
            newCreatedNode = null;

            LoopMetadataDefinition loopMetadataDefinition = metadataDefinition as LoopMetadataDefinition;
            if (loopMetadataDefinition != null)
            {
                newCreatedNode = CreateLoopScopeNode(loopMetadataDefinition.Label, experiment, data.X, data.Y);
                isCreated = true;
            }

            return isCreated;
        }
コード例 #33
0
ファイル: ComponentFactory.cs プロジェクト: CoEST/TraceLab
        /// <summary>
        /// Generates the challenge node.
        /// </summary>
        /// <param name="challengeName">Name of the challenge.</param>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="positionX">The position X.</param>
        /// <param name="positionY">The position Y.</param>
        /// <returns></returns>
        private static ChallengeNode CreateChallengeNode(string challengeName, IEditableExperiment experiment, double positionX, double positionY)
        {
            var data = new SerializedVertexDataWithSize();
            data.X = positionX;
            data.Y = positionY;
            data.Width = 160;
            data.Height = 160;

            string componentId = Guid.NewGuid().ToString();

            var componentGraph = new CompositeComponentEditableGraph(true);

            if (componentGraph.References != null)
            {
                componentGraph.References = experiment.References.CopyCollection();
            }

            data.Metadata = new ChallengeMetadata(componentGraph, challengeName, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));

            string componentNodeId = Guid.NewGuid().ToString();
            string componentName = data.Metadata.Label;

            var challengeNode = new ChallengeNode(Guid.NewGuid().ToString(), data);

            experiment.AddVertex(challengeNode);

            return challengeNode;
        }
コード例 #34
0
        /// <summary>
        /// Adds the scope to decision.
        /// Default scope size is 160 by 160
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="positionX">The center X position of the scope.</param>
        /// <param name="positionY">The center Y position of the scope.</param>
        /// <param name="decisionNode">The decision node.</param>
        /// <param name="exitDecisionNode">The exit decision node.</param>
        /// <param name="experiment">The experiment.</param>
        public static void AddScopeToDecision(string label, double positionX, double positionY, ExperimentDecisionNode decisionNode, ExitDecisionNode exitDecisionNode, IEditableExperiment experiment, double width = 160, double height = 160)
        {
            ScopeNode scopeNode = GenerateScopeNode(label, experiment, positionX, positionY, width, height);
            
            //set decision and exit decision references
            //(also note that ExperimentFactory also sets it when deseralizing experiment)
            scopeNode.DecisionNode = decisionNode;
            scopeNode.ExitDecisionNode = exitDecisionNode;
            
            experiment.AddVertex(scopeNode);
            experiment.AddFixedConnection(decisionNode, scopeNode, true);
            experiment.AddFixedConnection(scopeNode, exitDecisionNode, true);

            experiment.SetLogLevelSettings(scopeNode);
        }
コード例 #35
0
ファイル: ComponentFactory.cs プロジェクト: CoEST/TraceLab
        // END HERZUM 0.0

        // HERZUM SPRINT 2.0: TLAB-65 CLASS
        /// <summary>
        /// Attempts to create the composite component. Component is created only if definition is a ChallengeMetadataDefinition.
        /// Otherwise method returns false, and null node.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="metadataDefinition">The metadata definition which component is created based on.</param>
        /// <param name="data">The data containing position of new vertex</param>
        /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a LoopMetadataDefinition</param>
        /// <returns>
        /// true if metadatadefinition was a ChallengeMetadataDefinition and node has been created, otherwise false
        /// </returns>
        private static bool TryCreateChallengeComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data,
                                                    out ExperimentNode newCreatedNode)
        {

            bool isCreated = false;
            newCreatedNode = null;

            ChallengeMetadataDefinition challengeMetadataDefinition = metadataDefinition as ChallengeMetadataDefinition;
            if (challengeMetadataDefinition != null)
            {
                newCreatedNode = CreateChallengeNode(challengeMetadataDefinition.Label, experiment, data.X, data.Y);
                isCreated = true;
            }

            return isCreated;
        }
コード例 #36
0
ファイル: ComponentFactory.cs プロジェクト: neostoic/TraceLab
        /// <summary>
        /// Adds the scope to decision.
        /// Default scope size is 160 by 160
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="positionX">The center X position of the scope.</param>
        /// <param name="positionY">The center Y position of the scope.</param>
        /// <param name="decisionNode">The decision node.</param>
        /// <param name="exitDecisionNode">The exit decision node.</param>
        /// <param name="experiment">The experiment.</param>
        public static void AddScopeToDecision(string label, double positionX, double positionY, ExperimentDecisionNode decisionNode, ExitDecisionNode exitDecisionNode, IEditableExperiment experiment, double width = 160, double height = 160)
        {
            ScopeNode scopeNode = GenerateScopeNode(label, experiment, positionX, positionY, width, height);

            //set decision and exit decision references
            //(also note that ExperimentFactory also sets it when deseralizing experiment)
            scopeNode.DecisionNode     = decisionNode;
            scopeNode.ExitDecisionNode = exitDecisionNode;

            experiment.AddVertex(scopeNode);
            experiment.AddFixedConnection(decisionNode, scopeNode, true);
            experiment.AddFixedConnection(scopeNode, exitDecisionNode, true);

            experiment.SetLogLevelSettings(scopeNode);
        }
コード例 #37
0
        /// <summary>
        /// Attempts to create the composite component. Component is created only if definition is a DecisionMetadataDefinition.
        /// Otherwise method returns false, and null node.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="metadataDefinition">The metadata definition which component is created based on.</param>
        /// <param name="data">The data containing position of new vertex</param>
        /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a DecisionMetadataDefinition</param>
        /// <returns>
        /// true if metadatadefinition was a DecisionMetadataDefinition and node has been created, otherwise false
        /// </returns>
        private static bool TryCreateDecisionComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, 
                                                       out ExperimentNode newCreatedNode)
        {
            bool isCreated = false;
            newCreatedNode = null;

            DecisionMetadataDefinition decisionMetadataDefinition = metadataDefinition as DecisionMetadataDefinition;
            if (decisionMetadataDefinition != null)
            {
                newCreatedNode = CreateDecisionComponent(experiment, decisionMetadataDefinition, data);
                isCreated = true;
            }

            return isCreated;
        }
コード例 #38
0
        /// <summary>
        /// Creates the decision component.
        /// </summary>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="decisionMetadataDefinition">The decision metadata definition.</param>
        /// <param name="data">The data containing position of new vertex</param>
        /// <returns>Newly added desicion node (note, that in case of decision additional nodes are constructed, two scopes and exit decision node). They are not returned.</returns>
        private static ExperimentDecisionNode CreateDecisionComponent(IEditableExperiment experiment, DecisionMetadataDefinition decisionMetadataDefinition, SerializedVertexData data)
        {
            data.Metadata = new DecisionMetadata(decisionMetadataDefinition.Label);
            
            ExperimentDecisionNode decisionNode = new ExperimentDecisionNode(Guid.NewGuid().ToString(), data);
            experiment.AddVertex(decisionNode);

            if (decisionMetadataDefinition.ID == DecisionMetadataDefinition.DecisionGuid)
            {
                //generate corresponding scopes and exit nodes
                GenerateScopesAndExit(experiment, data, decisionNode);
            }
            //otherwise it is GoTo decision that does not have corresponding scopes, so simply return it

            return decisionNode;
        }
コード例 #39
0
        /// <summary>
        /// Generates the scope node.
        /// </summary>
        /// <param name="scopeName">Name of the scope.</param>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="positionX">The position X.</param>
        /// <param name="positionY">The position Y.</param>
        /// <returns></returns>
        private static LoopScopeNode CreateLoopScopeNode(string scopeName, IEditableExperiment experiment, double positionX, double positionY)
        {
            var data = new SerializedVertexDataWithSize();
            data.X = positionX;
            data.Y = positionY;
            data.Width = 160;
            data.Height = 160;

            string componentId = Guid.NewGuid().ToString();

            var componentGraph = new CompositeComponentEditableGraph(true);
            componentGraph.References = new System.Collections.ObjectModel.ObservableCollection<TraceLabSDK.PackageSystem.IPackageReference>(experiment.References);

            data.Metadata = new LoopScopeMetadata(componentGraph, scopeName, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));

            string componentNodeId = Guid.NewGuid().ToString();
            string componentName = data.Metadata.Label;

            var loopScopeNode = new LoopScopeNode(Guid.NewGuid().ToString(), data);

            experiment.AddVertex(loopScopeNode);

            return loopScopeNode;
        }
コード例 #40
0
        private static void GenerateScopesAndExit(IEditableExperiment experiment, SerializedVertexData data, ExperimentDecisionNode decisionNode)
        {
            ExitDecisionNode exitDecisionNode = GenerateExitDecisionNode(data.X, data.Y + 240);
            experiment.AddVertex(exitDecisionNode);

            //add invisible fixed connection between decision and exit - so that if scope can be skipped upon condition
            experiment.AddFixedConnection(decisionNode, exitDecisionNode, true);

            //set the log settings of all new nodes
            experiment.SetLogLevelSettings(decisionNode);
            experiment.SetLogLevelSettings(exitDecisionNode);

            AddScopeToDecision("Scope 1", data.X - 90, data.Y + 120, decisionNode, exitDecisionNode, experiment);
            AddScopeToDecision("Scope 2", data.X + 90, data.Y + 120, decisionNode, exitDecisionNode, experiment);
        }