Example #1
0
            /// <summary>
            ///     Replaces the paragraph scope by the corresponding flags
            /// </summary>
            /// <param name="obj"></param>
            /// <param name="visitSubNodes"></param>
            public override void visit(Paragraph obj, bool visitSubNodes)
            {
                Specification.Paragraph paragraph = (Specification.Paragraph)obj;

                // WARNING : This phase is completed by the next phase to place all requirement in requirement sets
                // Ensures the scope is located in the flags
                switch (paragraph.getObsoleteScope())
                {
                case acceptor.Paragraph_scope.aOBU:
                    paragraph.setObsoleteScopeOnBoard(true);
                    break;

                case acceptor.Paragraph_scope.aTRACK:
                    paragraph.setObsoleteScopeTrackside(true);
                    break;

                case acceptor.Paragraph_scope.aOBU_AND_TRACK:
                case acceptor.Paragraph_scope.defaultParagraph_scope:
                    paragraph.setObsoleteScopeOnBoard(true);
                    paragraph.setObsoleteScopeTrackside(true);
                    break;

                case acceptor.Paragraph_scope.aROLLING_STOCK:
                    paragraph.setObsoleteScopeRollingStock(true);
                    break;
                }
                paragraph.setObsoleteScope(acceptor.Paragraph_scope.aFLAGS);

                // WARNING : do not remove the preceding phase since it still required for previous versions of EFS files
                // Based on the flag information, place the requirements in their corresponding requirement set
                // STM was never used, this information is discarded
                RequirementSet scope = paragraph.Dictionary.findRequirementSet(Dictionary.ScopeName, true);

                if (paragraph.getObsoleteScopeOnBoard())
                {
                    RequirementSet onBoard = scope.findRequirementSet(RequirementSet.OnboardScopeName, false);
                    if (onBoard == null)
                    {
                        onBoard = scope.findRequirementSet(RequirementSet.OnboardScopeName, true);
                        onBoard.setRecursiveSelection(false);
                        onBoard.setDefault(true);
                    }
                    paragraph.AppendToRequirementSet(onBoard);
                    paragraph.setObsoleteScopeOnBoard(false);
                }

                if (paragraph.getObsoleteScopeTrackside())
                {
                    RequirementSet trackSide = scope.findRequirementSet(RequirementSet.TracksideScopeName, false);
                    if (trackSide == null)
                    {
                        trackSide = scope.findRequirementSet(RequirementSet.TracksideScopeName, true);
                        trackSide.setRecursiveSelection(false);
                        trackSide.setDefault(true);
                    }
                    paragraph.AppendToRequirementSet(trackSide);
                    paragraph.setObsoleteScopeTrackside(false);
                }

                if (paragraph.getObsoleteScopeRollingStock())
                {
                    RequirementSet rollingStock = scope.findRequirementSet(RequirementSet.RollingStockScopeName,
                                                                           false);
                    if (rollingStock == null)
                    {
                        rollingStock = scope.findRequirementSet(RequirementSet.RollingStockScopeName, true);
                        rollingStock.setRecursiveSelection(false);
                        rollingStock.setDefault(false);
                    }
                    paragraph.AppendToRequirementSet(rollingStock);
                    paragraph.setObsoleteScopeRollingStock(false);
                }

                // Updates the functional block information based on the FunctionalBlockName field
                if (!string.IsNullOrEmpty(paragraph.getObsoleteFunctionalBlockName()))
                {
                    RequirementSet allFunctionalBlocks =
                        paragraph.Dictionary.findRequirementSet(Dictionary.FunctionalBlockName, true);
                    RequirementSet functionalBlock =
                        allFunctionalBlocks.findRequirementSet(paragraph.getObsoleteFunctionalBlockName(), true);
                    functionalBlock.setRecursiveSelection(true);
                    functionalBlock.setDefault(false);
                    paragraph.AppendToRequirementSet(functionalBlock);
                    paragraph.setObsoleteFunctionalBlockName(null);
                }

                base.visit(obj, visitSubNodes);
            }
Example #2
0
        /// <summary>
        ///     Imports the paragraphs from the provided worksheet to the provided chapter
        /// </summary>
        /// <param name="aChapter"></param>
        /// <param name="aWorksheet"></param>
        private void importParagraphs(Chapter aChapter, string chapterId, Worksheet aWorksheet)
        {
            Range  aRange      = aWorksheet.UsedRange;
            int    paragraphId = 1;
            string text        = "";
            bool   skipRow     = false;

            for (int i = 2; i <= aRange.Rows.Count; i++)
            {
                string specId = (string)(aRange.Cells[i, 1] as Range).Value2;
                if (specId != null)
                {
                    // Create the new paragraph
                    Paragraph aParagraph = (Paragraph)acceptor.getFactory().createParagraph();
                    aParagraph.setId(chapterId + "." + paragraphId.ToString());
                    paragraphId++;
                    aParagraph.setType(acceptor.Paragraph_type.aNOTE);
                    aParagraph.setImplementationStatus(acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NotImplementable);


                    // Add the requirement set "Onboard"
                    aParagraph.setObsoleteScopeOnBoard(false);
                    aParagraph.setObsoleteScopeTrackside(false);
                    RequirementSetReference requirementSetReference =
                        (RequirementSetReference)acceptor.getFactory().createRequirementSetReference();
                    RequirementSet requirementSet = TheDictionary.findRequirementSet("Scope", false);
                    if (requirementSet != null)
                    {
                        requirementSet = requirementSet.findRequirementSet("Onboard", false);
                        if (requirementSet != null)
                        {
                            requirementSetReference.setTarget(requirementSet.Guid);
                            aParagraph.appendRequirementSets(requirementSetReference);
                        }
                        else
                        {
                            throw new Exception("Requirement set Onboard not found");
                        }
                    }
                    else
                    {
                        throw new Exception("Requirement set Scope not found");
                    }

                    // Add the paragraph to the chapter
                    aChapter.appendParagraphs(aParagraph);


                    // Create of the text of paragraph
                    aParagraph.Text = (string)(aRange.Cells[i, 2] as Range).Value2 + "\n"; // description
                    text            = (string)(aRange.Cells[i, 6] as Range).Value2;        // start condition
                    if (text != null)
                    {
                        aParagraph.Text += "START: " + text + "\n";
                        if (specId.Equals((string)(aRange.Cells[i + 1, 1] as Range).Value2))
                        // the following element can give the stop condition for the current element
                        {
                            text = (string)(aRange.Cells[i + 1, 7] as Range).Value2;  // stop condition
                            if (text != null)
                            {
                                aParagraph.Text += "STOP: " + text + "\n";
                                skipRow          = true;
                                // the remaining information of the following document is identical => let's skip it
                            }
                        }
                    }
                    text = (string)(aRange.Cells[i, 7] as Range).Value2;  // stop condition
                    if (text != null)
                    {
                        aParagraph.Text += "STOP: " + text + "\n";
                    }
                    text = (string)(aRange.Cells[i, 8] as Range).Value2;  // comment
                    if (text != null)
                    {
                        aParagraph.Text += "Comment: " + text + "\n";
                    }


                    // Create the reference to a paragraph from Subset-026
                    Specification subset026 = findSubset026Specification();

                    specId = specId.Replace(" ", ".");
                    Paragraph refParagraph = subset026.FindParagraphByNumber(specId);

                    if (refParagraph != null)
                    {
                        ReqRef aReqRef = (ReqRef)acceptor.getFactory().createReqRef();
                        aReqRef.Paragraph = aParagraph;
                        refParagraph.appendRequirements(aReqRef);
                    }
                    else
                    {
                        aParagraph.Text += "SUBSET-026 REFERENCE: " + specId + "\n";
                    }


                    // DMI references
                    text = (string)(aRange.Cells[i, 3] as Range).Value2;  // DMI object
                    if (text != null)
                    {
                        aParagraph.Text += "DMI OBJECT: " + text + "\n";
                        text             = (string)(aRange.Cells[i, 4] as Range).Value2; // DMI area
                        if (text != null)
                        {
                            aParagraph.Text += "DMI AREA: " + text + "\n";
                            object reference = (aRange.Cells[i, 5] as Range).Value2; // DMI reference
                            if (reference != null)
                            {
                                aParagraph.Text += "DMI REFERENCE: " + reference.ToString();
                            }
                        }
                    }

                    if (skipRow)
                    {
                        i++;
                        skipRow = false;
                    }
                }
            }
        }