/// <summary>
        ///     Provides the description of a variable
        /// </summary>
        /// <param name="variable">The variable to describe</param>
        /// <returns></returns>
        private void CreateVariableHeader(IVariable variable)
        {
            AddTable(new string[] { variable.Name }, new int[] { 40, 80 });

            ICommentable commentable = variable as ICommentable;

            if (commentable != null && !string.IsNullOrEmpty(commentable.Comment))
            {
                AddRow(commentable.Comment);
            }

            if (!string.IsNullOrEmpty(variable.TypeName))
            {
                AddTableHeader("Type");
                AddRow(variable.TypeName);
            }

            ReqRelated reqRelated = variable as ReqRelated;

            if (reqRelated != null)
            {
                AddTableHeader("Related requirements");
                AddRow(GetRequirementsAsString(reqRelated.Requirements));
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a table for a given set of paragraphs
        /// </summary>
        /// <param name="title">Title of the table</param>
        /// <param name="paragraphs">The paragraphs to display</param>
        /// <param name="showAssociatedImplementations">Indicates if we need to show the model elements implementing the paragraphs</param>
        /// <returns></returns>
        private void CreateImplementedParagraphsTable(HashSet <DataDictionary.Specification.Paragraph> paragraphs, Dictionary dictionary)
        {
            Dictionary <DataDictionary.Specification.Paragraph, List <ReqRef> > paragraphsReqRefDictionary = dictionary.ParagraphsReqRefs;

            foreach (DataDictionary.Specification.Paragraph paragraph in paragraphs)
            {
                Cell previousCell = null;

                if (paragraphsReqRefDictionary.ContainsKey(paragraph))
                {
                    AddSubParagraph("Requirement " + paragraph.FullId);
                    AddTable(new string[] { "Requirement " + paragraph.FullId }, new int[] { 40, 60, 40 });
                    AddRow(paragraph.Text);

                    foreach (ReqRef reqRef in paragraph.Implementations)
                    {
                        string fullName = null;
                        string comment  = null;

                        ReqRelated reqRelated = reqRef.Enclosing as ReqRelated;
                        if (reqRelated != null)
                        {
                            fullName = reqRelated.FullName;
                            comment  = reqRelated.Comment;
                        }
                        else
                        {
                            DataDictionary.Specification.Paragraph par = reqRef.Enclosing as DataDictionary.Specification.Paragraph;
                            if (par != null)
                            {
                                fullName = paragraph.FullName;
                                comment  = paragraph.Comment;
                            }
                        }

                        if (fullName != null && comment != null)
                        {
                            if (previousCell == null)
                            {
                                AddRow("Associated implementation", fullName, comment);
                                previousCell = lastRow.Cells[0];
                            }
                            else
                            {
                                AddRow("", fullName, comment);
                                previousCell.MergeDown += 1;
                            }
                        }
                    }
                    CloseSubParagraph();
                }
            }
        }
        /// <summary>
        /// Creates a containing the implementation/verification status and the
        /// requirements of a ReqRelated element
        /// </summary>
        /// <param name="aReqRelated">The ReqRelated element</param>
        /// <returns></returns>
        private void CreateStatusTable(ReqRelated aReqRelated)
        {
            AddTable(new string[] { "Modeling information" }, new int[] { 40, 30, 70 });

            string implemented = "not implemented";
            string verified    = "not verified";

            if (aReqRelated.getImplemented())
            {
                implemented = "implemented";
            }
            if (aReqRelated.getVerified())
            {
                verified = "verified";
            }

            AddRow("Status", implemented, verified);
            AddRow("Requirements", GetRequirementsAsString(aReqRelated.Requirements));
        }
        /// <summary>
        ///     Provides the description of a procedure or a function
        /// </summary>
        /// <param name="callable">The callable to describe</param>
        /// <returns></returns>
        private void CreateProcedureOrFunctionHeader(ICallable callable)
        {
            AddTable(new[] { callable.Name }, new[] { 40, 80 });

            ICommentable commentable = callable as ICommentable;

            if (commentable != null && !string.IsNullOrEmpty(commentable.Comment))
            {
                AddRow(commentable.Comment);
            }

            if (callable.FormalParameters.Count > 0)
            {
                AddTableHeader("Parameters");
                AddTableHeader("Name", "Type");
                foreach (Parameter parameter in callable.FormalParameters)
                {
                    AddRow(parameter.Name, parameter.getTypeName());
                }
            }

            ITypedElement typedElement = callable as ITypedElement;

            if (typedElement != null && !string.IsNullOrEmpty(typedElement.TypeName))
            {
                AddTableHeader("Return value");
                AddRow(typedElement.TypeName);
            }

            ReqRelated reqRelated = callable as ReqRelated;

            if (reqRelated != null)
            {
                AddTableHeader("Related requirements");
                AddRow(GetRequirementsAsString(reqRelated.Requirements));
            }
        }
Exemple #5
0
        /// <summary>
        /// Provides the set of covered requirements by the model
        /// </summary>
        /// <param name="aDictionary">The model</param>
        /// <param name="covered">Indicates if we need compute covered or non covered requirements</param>
        /// <returns></returns>
        public static HashSet <DataDictionary.Specification.Paragraph> CoveredRequirements(Dictionary aDictionary, bool covered)
        {
            HashSet <DataDictionary.Specification.Paragraph> retVal = new HashSet <DataDictionary.Specification.Paragraph>();

            ICollection <DataDictionary.Specification.Paragraph> applicableParagraphs = aDictionary.Specifications.ApplicableParagraphs;
            Dictionary <DataDictionary.Specification.Paragraph, List <ReqRef> > paragraphsReqRefDictionary = aDictionary.ParagraphsReqRefs;

            foreach (DataDictionary.Specification.Paragraph paragraph in applicableParagraphs)
            {
                bool implemented = paragraph.getImplementationStatus() == DataDictionary.Generated.acceptor.SPEC_IMPLEMENTED_ENUM.Impl_Implemented;
                if (implemented)
                {
                    if (paragraphsReqRefDictionary.ContainsKey(paragraph))
                    {
                        List <ReqRef> implementations = paragraphsReqRefDictionary[paragraph];
                        for (int i = 0; i < implementations.Count; i++)
                        {
                            // the implementation may be also a ReqRef
                            if (implementations[i].Enclosing is ReqRelated)
                            {
                                ReqRelated reqRelated = implementations[i].Enclosing as ReqRelated;
                                // Do not consider tests
                                if (Utils.EnclosingFinder <DataDictionary.Tests.Frame> .find(reqRelated) == null)
                                {
                                    implemented = implemented && reqRelated.ImplementationCompleted;
                                }
                            }
                        }
                    }
                }
                if (implemented == covered)
                {
                    retVal.Add(paragraph);
                }
            }
            return(retVal);
        }
Exemple #6
0
        /// <summary>
        ///     Creates the stat message according to the list of paragraphs provided
        /// </summary>
        /// <param name="paragraphs"></param>
        /// <returns></returns>
        public static ParagraphSetMetrics CreateParagraphSetMetrics(List <Paragraph> paragraphs)
        {
            ParagraphSetMetrics retVal = new ParagraphSetMetrics {
                SubParagraphCount = paragraphs.Count
            };

            Dictionary <Paragraph, List <ReqRef> > paragraphsReqRefDictionary = null;

            foreach (Paragraph p in paragraphs)
            {
                if (paragraphsReqRefDictionary == null)
                {
                    paragraphsReqRefDictionary = p.Dictionary.ParagraphsReqRefs;
                }

                if (p.ConsiderInMetrics())
                {
                    switch (p.getImplementationStatus())
                    {
                    case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_Implemented:
                        retVal.ImplementableCount += 1;

                        bool implemented = true;
                        if (paragraphsReqRefDictionary.ContainsKey(p))
                        {
                            List <ReqRef> implementations = paragraphsReqRefDictionary[p];
                            foreach (ReqRef implementation in implementations)
                            {
                                // the implementation may be also a ReqRef
                                ReqRelated reqRelated = implementation.Enclosing as ReqRelated;
                                if (reqRelated != null)
                                {
                                    // Do not consider tests
                                    if (EnclosingFinder <Frame> .find(reqRelated) == null)
                                    {
                                        implemented = implemented && reqRelated.ImplementationCompleted;
                                    }
                                }
                            }
                        }
                        if (implemented)
                        {
                            retVal.ImplementedCount += 1;
                        }
                        else
                        {
                            retVal.UnImplementedCount += 1;
                        }
                        break;

                    case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NA:
                    case acceptor.SPEC_IMPLEMENTED_ENUM.defaultSPEC_IMPLEMENTED_ENUM:
                        retVal.ImplementableCount += 1;
                        retVal.UnImplementedCount += 1;
                        break;

                    case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NotImplementable:
                        retVal.NotImplementable += 1;
                        break;

                    case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NewRevisionAvailable:
                        retVal.ImplementableCount   += 1;
                        retVal.NewRevisionAvailable += 1;
                        break;
                    }
                }
                else
                {
                    retVal.NotImplementable += 1;
                }
            }

            // Count the tested paragraphs
            HashSet <Paragraph> testedParagraphs = new HashSet <Paragraph>();

            foreach (Dictionary dictionary in EfsSystem.Instance.Dictionaries)
            {
                foreach (Paragraph p in dictionary.CoveredRequirements())
                {
                    testedParagraphs.Add(p);
                }
            }

            foreach (Paragraph p in paragraphs)
            {
                if (testedParagraphs.Contains(p))
                {
                    retVal.TestedCount += 1;
                }
            }

            return(retVal);
        }