Inheritance: AnalysisModelProcessor
        public override void Expand(CyPhy.ComponentAssembly configuration)
        {
            this.Configuration = configuration;

            if (this.OriginalSystemUnderTest == null)
            {
                // don't need to do anything
            }
            else if (this.OriginalSystemUnderTest.Referred.DesignEntity.ID == configuration.ID)
            {
                this.expandedTestBenchSuite = this.testBenchSuite;
            }
            else
            {
                // create temp folder for test bench suite
                CyPhy.TestBenchSuiteFolder testing = CyPhyClasses.TestBenchSuiteFolder.Cast(this.testBenchSuite.ParentContainer.Impl);

                var tempFolderName = AnalysisModelProcessor.GetTemporaryFolderName(this.testBenchSuite.Impl);

                CyPhy.TestBenchSuiteFolder tempFolder = testing.Children.TestBenchSuiteFolderCollection.FirstOrDefault(x => x.Name == tempFolderName);
                if (tempFolder == null)
                {
                    tempFolder      = CyPhyClasses.TestBenchSuiteFolder.Create(testing);
                    tempFolder.Name = tempFolderName;

                    this.AddToTraceabilityAndTemporary(tempFolder.Impl, testing.Impl, recursive: false);
                }

                // copy test bench suite
                var tempCopy = (tempFolder.Impl as MgaFolder).CopyFCODisp(this.testBenchSuite.Impl as MgaFCO);
                // fix name
                tempCopy.Name = AnalysisModelProcessor.GetTemporaryObjectName(this.testBenchSuite.Impl, configuration.Impl);

                this.AddToTraceabilityAndTemporary(tempCopy, this.testBenchSuite.Impl);

                // set expanded property to the expanded element
                this.expandedTestBenchSuite = CyPhyClasses.TestBenchSuite.Cast(tempCopy);
            }

            // expand all test benches
            foreach (var testBenchRef in this.expandedTestBenchSuite.Children.TestBenchRefCollection)
            {
                var testBenchTypeExpander = new TestBenchTypeProcessor(testBenchRef.Referred.TestBenchType);
                testBenchTypeExpander.Expand(configuration);

                // switch references
                var switcher = new ReferenceSwitcher.ReferenceSwitcherInterpreter();
                // TODO: handle failures for this
                switcher.SwitchReference(testBenchTypeExpander.expandedTestBenchType.Impl as MgaFCO, testBenchRef.Impl as IMgaReference);

                this.InnerExpanders.Push(testBenchTypeExpander);
            }
        }
Exemple #2
0
        public override void Expand(CyPhy.ComponentAssembly configuration)
        {
            this.Configuration = configuration;

            // FIXME: this test should be repaired. It does not work correctly if TBs have different SUTs. Be safe and make a copy always
            // if (this.OriginalSystemUnderTest.Referred.DesignEntity.ID == configuration.ID)
            if (false)
            {
                this.expandedParametricExploration = this.parametricExploration;
            }
            else
            {
                // create temp folder for parametric exploration
                CyPhy.ParametricExplorationFolder testing = CyPhyClasses.ParametricExplorationFolder.Cast(this.parametricExploration.ParentContainer.Impl);

                var tempFolderName = AnalysisModelProcessor.GetTemporaryFolderName(this.parametricExploration.Impl);

                CyPhy.ParametricExplorationFolder tempFolder = testing.Children.ParametricExplorationFolderCollection.FirstOrDefault(x => x.Name == tempFolderName);
                if (tempFolder == null)
                {
                    tempFolder      = CyPhyClasses.ParametricExplorationFolder.Create(testing);
                    tempFolder.Name = tempFolderName;

                    this.AddToTraceabilityAndTemporary(tempFolder.Impl, testing.Impl, recursive: false);
                }

                // copy parametric exploration
                var tempCopy = (tempFolder.Impl as MgaFolder).CopyFCODisp(this.parametricExploration.Impl as MgaFCO);
                // fix name
                tempCopy.Name = AnalysisModelProcessor.GetTemporaryObjectName(this.parametricExploration.Impl, configuration.Impl);

                this.AddToTraceabilityAndTemporary(tempCopy, this.parametricExploration.Impl);

                // set expanded property to the expanded element
                this.expandedParametricExploration = CyPhyClasses.ParametricExploration.Cast(tempCopy);
            }

            // expand all test benches
            foreach (var testBenchRef in this.expandedParametricExploration.Children.TestBenchRefCollection)
            {
                var testBenchTypeExpander = new TestBenchTypeProcessor(testBenchRef.Referred.TestBenchType);
                testBenchTypeExpander.Expand(configuration);

                // switch references
                var switcher = new ReferenceSwitcher.ReferenceSwitcherInterpreter();
                // TODO: handle failures for this
                switcher.SwitchReference(testBenchTypeExpander.expandedTestBenchType.Impl as MgaFCO, testBenchRef.Impl as IMgaReference);

                this.InnerExpanders.Push(testBenchTypeExpander);
            }
        }
        public override void Expand(CyPhy.ComponentAssembly configuration)
        {
            this.Configuration = configuration;

            if (this.OriginalSystemUnderTest.Referred.DesignEntity.ID == configuration.ID)
            {
                this.expandedTestBenchSuite = this.testBenchSuite;
            }
            else
            {
                // create temp folder for test bench suite
                CyPhy.TestBenchSuiteFolder testing = CyPhyClasses.TestBenchSuiteFolder.Cast(this.testBenchSuite.ParentContainer.Impl);

                var tempFolderName = AnalysisModelProcessor.GetTemporaryFolderName(this.testBenchSuite.Impl);

                CyPhy.TestBenchSuiteFolder tempFolder = testing.Children.TestBenchSuiteFolderCollection.FirstOrDefault(x => x.Name == tempFolderName);
                if (tempFolder == null)
                {
                    tempFolder = CyPhyClasses.TestBenchSuiteFolder.Create(testing);
                    tempFolder.Name = tempFolderName;

                    this.AddToTraceabilityAndTemporary(tempFolder.Impl, testing.Impl, recursive: false);
                }

                // copy test bench suite
                var tempCopy = (tempFolder.Impl as MgaFolder).CopyFCODisp(this.testBenchSuite.Impl as MgaFCO);
                // fix name
                tempCopy.Name = AnalysisModelProcessor.GetTemporaryObjectName(this.testBenchSuite.Impl, configuration.Impl);

                this.AddToTraceabilityAndTemporary(tempCopy, this.testBenchSuite.Impl);

                // set expanded property to the expanded element
                this.expandedTestBenchSuite = CyPhyClasses.TestBenchSuite.Cast(tempCopy);
            }

            // expand all test benches
            foreach (var testBenchRef in this.expandedTestBenchSuite.Children.TestBenchRefCollection)
            {
                var testBenchTypeExpander = new TestBenchTypeProcessor(testBenchRef.Referred.TestBenchType);
                testBenchTypeExpander.Expand(configuration);

                // switch references
                var switcher = new ReferenceSwitcher.ReferenceSwitcherInterpreter();
                // TODO: handle failures for this
                switcher.SwitchReference(testBenchTypeExpander.expandedTestBenchType.Impl as MgaFCO, testBenchRef.Impl as IMgaReference);

                this.InnerExpanders.Push(testBenchTypeExpander);
            }
        }
        /// <summary>
        /// Factory method to get a new analysis model processor instance based on a given context.
        /// </summary>
        /// <param name="context">Model context</param>
        /// <returns>New instance of an analysis model processor.</returns>
        /// <exception cref="ArgumentNullException">If context is null.</exception>
        /// <exception cref="AnalysisModelContextNotSupportedException">If context is not supported.</exception>
        public static AnalysisModelProcessor GetAnalysisModelProcessor(IMgaModel context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            AnalysisModelProcessor analysisModelProcessor = null;
            if (context.MetaBase.Name == typeof(CyPhy.ParametricExploration).Name)
            {
                analysisModelProcessor = new ParametricExplorationProcessor(CyPhyClasses.ParametricExploration.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.TestBenchSuite).Name)
            {
                analysisModelProcessor = new TestBenchSuiteProcessor(CyPhyClasses.TestBenchSuite.Cast(context));
            }
            else if (TestBenchTypeProcessor.SupportedTestBenchTypes.Contains(context.MetaBase.Name))
            {
                if (context.Meta.Name == typeof(CyPhy.CFDTestBench).Name)
                {
                    string[] openFoamKinds = new string[] {
                        typeof(CyPhy.CalmWaterSolverSettings).Name,
                        typeof(CyPhy.CorrelationSettings).Name,
                        typeof(CyPhy.WaveResistanceSolverSettings).Name };
                    if (context.ChildFCOs.Cast<MgaFCO>().Any(fco => openFoamKinds.Contains(fco.Meta.Name)))
                    {
                        analysisModelProcessor = new MultiJobRunProcessor(CyPhyClasses.CFDTestBench.Cast(context));
                    }
                    else
                    {
                        analysisModelProcessor = new TestBenchTypeProcessor(CyPhyClasses.TestBenchType.Cast(context));
                    }
                }
                else if (context.Meta.Name == typeof(CyPhy.BlastTestBench).Name)
                {
                    var blastTestBench = CyPhyClasses.BlastTestBench.Cast(context);
                    int tierLevel = (int)blastTestBench.Attributes.BlastTier;
                    int tierThresholdForMuliJobRun = (int)CyPhyClasses.BlastTestBench.AttributesClass.BlastTier_enum._2;

                    if (tierLevel > tierThresholdForMuliJobRun)
                    {
                        // use MultiJobRunProcessor if the current tier level is greater than the defined threshold
                        analysisModelProcessor = new MultiJobRunProcessor(blastTestBench);
                    }
                    else
                    {
                        analysisModelProcessor = new TestBenchTypeProcessor(blastTestBench);
                    }
                }
                else if (context.Meta.Name == typeof(CyPhy.BallisticTestBench).Name)
                {
                    var ballisticTestBench = CyPhyClasses.BallisticTestBench.Cast(context);
                    int tierLevel = (int)ballisticTestBench.Attributes.Tier;
                    int tierThresholdForMuliJobRun = (int)CyPhyClasses.BallisticTestBench.AttributesClass.Tier_enum._2;

                    if (tierLevel > tierThresholdForMuliJobRun)
                    {
                        // use MultiJobRunProcessor if the current tier level is greater than the defined threshold
                        analysisModelProcessor = new MultiJobRunProcessor(ballisticTestBench);
                    }
                    else
                    {
                        analysisModelProcessor = new TestBenchTypeProcessor(ballisticTestBench);
                    }
                }
                else
                {
                    // test bench type
                    analysisModelProcessor = new TestBenchTypeProcessor(CyPhyClasses.TestBenchType.Cast(context));
                }
            }
            else
            {
                throw new AnalysisModelContextNotSupportedException(string.Format("{0} does not supported", context.MetaBase.Name));
            }

            analysisModelProcessor.OriginalCurrentFCOName = context.Name;
            return analysisModelProcessor;
        }
        /// <summary>
        /// Factory method to get a new analysis model processor instance based on a given context.
        /// </summary>
        /// <param name="context">Model context</param>
        /// <returns>New instance of an analysis model processor.</returns>
        /// <exception cref="ArgumentNullException">If context is null.</exception>
        /// <exception cref="AnalysisModelContextNotSupportedException">If context is not supported.</exception>
        public static AnalysisModelProcessor GetAnalysisModelProcessor(IMgaModel context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            AnalysisModelProcessor analysisModelProcessor = null;

            if (context.MetaBase.Name == typeof(CyPhy.ParametricExploration).Name)
            {
                analysisModelProcessor = new ParametricExplorationProcessor(CyPhyClasses.ParametricExploration.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.TestBenchSuite).Name)
            {
                analysisModelProcessor = new TestBenchSuiteProcessor(CyPhyClasses.TestBenchSuite.Cast(context));
            }
            else if (TestBenchTypeProcessor.SupportedTestBenchTypes.Contains(context.MetaBase.Name))
            {
                if (context.Meta.Name == typeof(CyPhy.CFDTestBench).Name)
                {
                    string[] openFoamKinds = new string[] {
                        typeof(CyPhy.CalmWaterSolverSettings).Name,
                        typeof(CyPhy.CorrelationSettings).Name,
                        typeof(CyPhy.WaveResistanceSolverSettings).Name
                    };
                    if (context.ChildFCOs.Cast <MgaFCO>().Any(fco => openFoamKinds.Contains(fco.Meta.Name)))
                    {
                        analysisModelProcessor = new MultiJobRunProcessor(CyPhyClasses.CFDTestBench.Cast(context));
                    }
                    else
                    {
                        analysisModelProcessor = new TestBenchTypeProcessor(CyPhyClasses.TestBenchType.Cast(context));
                    }
                }
                else if (context.Meta.Name == typeof(CyPhy.BlastTestBench).Name)
                {
                    var blastTestBench             = CyPhyClasses.BlastTestBench.Cast(context);
                    int tierLevel                  = (int)blastTestBench.Attributes.BlastTier;
                    int tierThresholdForMuliJobRun = (int)CyPhyClasses.BlastTestBench.AttributesClass.BlastTier_enum._2;

                    if (tierLevel > tierThresholdForMuliJobRun)
                    {
                        // use MultiJobRunProcessor if the current tier level is greater than the defined threshold
                        analysisModelProcessor = new MultiJobRunProcessor(blastTestBench);
                    }
                    else
                    {
                        analysisModelProcessor = new TestBenchTypeProcessor(blastTestBench);
                    }
                }
                else if (context.Meta.Name == typeof(CyPhy.BallisticTestBench).Name)
                {
                    var ballisticTestBench         = CyPhyClasses.BallisticTestBench.Cast(context);
                    int tierLevel                  = (int)ballisticTestBench.Attributes.Tier;
                    int tierThresholdForMuliJobRun = (int)CyPhyClasses.BallisticTestBench.AttributesClass.Tier_enum._2;

                    if (tierLevel > tierThresholdForMuliJobRun)
                    {
                        // use MultiJobRunProcessor if the current tier level is greater than the defined threshold
                        analysisModelProcessor = new MultiJobRunProcessor(ballisticTestBench);
                    }
                    else
                    {
                        analysisModelProcessor = new TestBenchTypeProcessor(ballisticTestBench);
                    }
                }
                else
                {
                    // test bench type
                    analysisModelProcessor = new TestBenchTypeProcessor(CyPhyClasses.TestBenchType.Cast(context));
                }
            }
            else
            {
                throw new AnalysisModelContextNotSupportedException(string.Format("{0} does not supported", context.MetaBase.Name));
            }

            analysisModelProcessor.OriginalCurrentFCOName = context.Name;
            return(analysisModelProcessor);
        }