コード例 #1
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;
        }
コード例 #2
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;
        }
コード例 #3
0
        public ComponentNode(string id, SerializedVertexData data) : base(id, data)
        {
            if (id == null)
                throw new ArgumentNullException("id");
            if (data == null)
                throw new ArgumentNullException("data");

            ID = id;
            ComponentMetadata metadata = data.Metadata as ComponentMetadata;
        }
コード例 #4
0
ファイル: ComponentFactory.cs プロジェクト: neostoic/TraceLab
        /// <summary>
        /// Generates the exit decision node.
        /// </summary>
        /// <param name="positionX">The position X.</param>
        /// <param name="positionY">The position Y.</param>
        /// <returns></returns>
        private static ExitDecisionNode GenerateExitDecisionNode(double positionX, double positionY)
        {
            var data = new SerializedVertexData();

            data.X        = positionX;
            data.Y        = positionY;
            data.Metadata = new ExitDecisionMetadata();
            var exitDecisionNode = new ExitDecisionNode(Guid.NewGuid().ToString(), data);

            return(exitDecisionNode);
        }
コード例 #5
0
        public virtual SerializedVertexData Clone()
        {
            SerializedVertexData clone = new SerializedVertexData();

            clone.X        = X;
            clone.Y        = Y;
            clone.Metadata = Metadata.Clone();

            clone.m_isInitialized = m_isInitialized;

            return(clone);
        }
コード例 #6
0
ファイル: ComponentNode.cs プロジェクト: thbin/TraceLab
        public ComponentNode(string id, SerializedVertexData data) : base(id, data)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            ID = id;
            ComponentMetadata metadata = data.Metadata as ComponentMetadata;
        }
コード例 #7
0
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (nodeData == null)
            {
                throw new ArgumentNullException("nodeData");
            }

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return(node);
        }
コード例 #8
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);
        }
コード例 #9
0
        public override bool Equals(object obj)
        {
            SerializedVertexData other = obj as SerializedVertexData;

            if (other == null)
            {
                return(false);
            }

            bool isEqual = true;

            isEqual &= object.Equals(X, other.X);
            isEqual &= object.Equals(Y, other.Y);

            return(isEqual);
        }
コード例 #10
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;
        }
コード例 #11
0
        /// <summary>
        /// Constructs experiment node from given xml xpath navigator to the node.
        /// </summary>
        /// <param name="reader">The reader with a root to the node.</param>
        /// <returns>Experiment Node</returns>
        public ExperimentNode NodeFactory(XPathNavigator reader)
        {
            string id = reader.GetAttribute("id", String.Empty);

            SerializedVertexData nodeData = null;

            XPathNavigator serializedNodeData = reader.SelectSingleNode("SerializedVertexData");

            if (serializedNodeData != null)
            {
                nodeData = (SerializedVertexData)m_nodeSerializer.Deserialize(serializedNodeData.ReadSubtree());
                nodeData.PostProcessReadXml(m_library, m_experimentLocationRoot);
            }
            else
            {
                //it may be serialized vertex data with size
                serializedNodeData = reader.SelectSingleNode("SerializedVertexDataWithSize");
                if (serializedNodeData != null)
                {
                    nodeData = (SerializedVertexDataWithSize)m_nodeSerializerWithSize.Deserialize(serializedNodeData.ReadSubtree());
                    nodeData.PostProcessReadXml(m_library, m_experimentLocationRoot);
                }
            }

            ExperimentNode vert = null;

            if (nodeData != null)
            {
                vert = NodeGenerator(id, nodeData);
                if (nodeData.Metadata != null)
                {
                    if (nodeData.Metadata.HasDeserializationError)
                    {
                        vert.SetError(nodeData.Metadata.DeserializationErrorMessage);
                    }
                }
                m_vertices[id] = vert;
            }

            return(vert);
        }
コード例 #12
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;
        }
コード例 #13
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);
        }
コード例 #14
0
ファイル: ComponentFactory.cs プロジェクト: neostoic/TraceLab
        // END HERZUM SPRINT 1.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);
        }
コード例 #15
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);
        }
コード例 #16
0
 public CompositeComponentNode(string id, SerializedVertexData data, TraceLab.Core.Settings.Settings settings)
     : base(id, data)
 {
     InitializeComponentGraph(settings);
 }
コード例 #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
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
                throw new ArgumentNullException("id");
            if (nodeData == null)
                throw new ArgumentNullException("nodeData");

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return node;
        }
コード例 #19
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);
        }
コード例 #20
0
 public ExperimentStartNode(string id, SerializedVertexData nodeData) : base(id, nodeData)
 {
 }
コード例 #21
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;
        }
コード例 #22
0
 public CompositeComponentNode(string id, SerializedVertexData data)
     : base(id, data)
 {
     InitializeComponentGraph();
 }
コード例 #23
0
 protected ExperimentNode(string id, SerializedVertexData data)
 {
     ID   = id;
     Data = data;
 }
コード例 #24
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;
        }
コード例 #25
0
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
                throw new ArgumentNullException("id");
            if (nodeData == null)
                throw new ArgumentNullException("nodeData");

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            // HERZUM SPRINT 1.0
            else if (nodeData.Metadata is CommentMetadata)
            {
                // HERZUM SPRINT 1.2
                // node = new CommentNode(id, nodeData);
                node = new CommentNode(id, (SerializedVertexDataWithSize) nodeData);
                // END HERZUM SPRINT 1.2
            }
            // END HERZUM SPRINT 1.0
            // HERZUM SPRINT 2.0: TLAB-65 CLASS
            else if (nodeData.Metadata is ChallengeMetadata)
            {
                node = new ChallengeNode(id, (SerializedVertexDataWithSize) nodeData);
            }
            // END HERZUM SPRINT 2.0: TLAB-65 CLASS
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return node;
        }
コード例 #26
0
 public ExperimentStartNode(string id, SerializedVertexData nodeData) : base(id, nodeData) { }
コード例 #27
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;
        }
コード例 #28
0
        public virtual SerializedVertexData Clone()
        {
            SerializedVertexData clone = new SerializedVertexData();
            clone.X = X;
            clone.Y = Y;
            clone.Metadata = Metadata.Clone();

            clone.m_isInitialized = m_isInitialized;

            return clone;
        }
コード例 #29
0
 public CompositeComponentNode(string id, SerializedVertexData data)
     : base(id, data)
 {
     InitializeComponentGraph();
 }
コード例 #30
0
 /// <summary>
 /// Generates the exit decision node.
 /// </summary>
 /// <param name="positionX">The position X.</param>
 /// <param name="positionY">The position Y.</param>
 /// <returns></returns>
 private static ExitDecisionNode GenerateExitDecisionNode(double positionX, double positionY)
 {
     var data = new SerializedVertexData();
     data.X = positionX;
     data.Y = positionY;
     data.Metadata = new ExitDecisionMetadata();
     var exitDecisionNode = new ExitDecisionNode(Guid.NewGuid().ToString(), data);
     return exitDecisionNode;
 }
コード例 #31
0
ファイル: ExperimentNode.cs プロジェクト: CoEST/TraceLab
 protected ExperimentNode(string id, SerializedVertexData data)
 {
     ID = id;
     Data = data;
 }
コード例 #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
 public CompositeComponentNode(string id, SerializedVertexData data, TraceLab.Core.Settings.Settings settings)
     : base(id, data)
 {
     InitializeComponentGraph(settings);
 }
コード例 #34
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);
        }
コード例 #35
0
        /// <summary>
        /// Adds a new decision node at the specified coordinates
        /// </summary>
        public ExperimentDecisionNode AddDecisionToExperiment(Experiment experiment, double positionX, double positionY)
        {
            ExperimentDecisionNode newNode = null;

            SerializedVertexData data = new SerializedVertexData();
            data.X = positionX;
            data.Y = positionY;
            data.Metadata = new DecisionMetadata("Decision");

            newNode = new ExperimentDecisionNode(Guid.NewGuid().ToString(), data);
            experiment.AddVertex(newNode);

            return newNode;
        }
コード例 #36
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);
        }
コード例 #37
0
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (nodeData == null)
            {
                throw new ArgumentNullException("nodeData");
            }

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            // HERZUM SPRINT 1.0
            else if (nodeData.Metadata is CommentMetadata)
            {
                // HERZUM SPRINT 1.2
                // node = new CommentNode(id, nodeData);
                node = new CommentNode(id, (SerializedVertexDataWithSize)nodeData);
                // END HERZUM SPRINT 1.2
            }
            // END HERZUM SPRINT 1.0
            // HERZUM SPRINT 2.0: TLAB-65 CLASS
            else if (nodeData.Metadata is ChallengeMetadata)
            {
                node = new ChallengeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            // END HERZUM SPRINT 2.0: TLAB-65 CLASS
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return(node);
        }
コード例 #38
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);
        }