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

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

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

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

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

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

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

                // set expanded property to the expanded element
                this.expandedTestBenchType = CyPhyClasses.TestBenchType.Cast(tempCopy);

                var tlsut = this.expandedTestBenchType.Children.TopLevelSystemUnderTestCollection.FirstOrDefault();

                // switch references
                try
                {
                    // redirect SUT
                    var switcher = new ReferenceSwitcher.ReferenceSwitcherInterpreter();
                    switcher.SwitchReference(configuration.Impl as MgaFCO, tlsut.Impl as IMgaReference);
                }
                catch (Exception ex)
                {
                    // handle failures for this (use case we can lose ports/connections/
                    // what if something is an instance/subtype/readonly etc...
                    throw new AnalysisModelExpandFailedException("ReferenceSwitcher failed.", ex);
                }

                // redirect TIPs
                this.SwitchAllTipReferences();
            }
        }
Esempio n. 2
0
 public PET(CyPhyGUIs.IInterpreterMainParameters parameters, CyPhyGUIs.GMELogger logger)
 {
     this.Logger = logger;
     this.pet = CyPhyClasses.ParametricExploration.Cast(parameters.CurrentFCO);
     this.outputDirectory = parameters.OutputDirectory;
     this.testBench = pet.Children.TestBenchRefCollection.FirstOrDefault().Referred.TestBenchType;
     this.PCCPropertyInputDistributions = new Dictionary<string, string>();
     // Determine type of driver of the Parametric Exploration
     if (this.pet.Children.PCCDriverCollection.Count() == 1)
     {
         this.theDriver = DriverType.PCC;
         this.driverName = "PCCDriver";
     }
     else if (this.pet.Children.OptimizerCollection.Count() == 1)
     {
         this.theDriver = DriverType.Optimizer;
         this.driverName = "Optimizer";
     }
     else if (this.pet.Children.ParameterStudyCollection.Count() == 1)
     {
         this.theDriver = DriverType.ParameterStudy;
         this.driverName = "ParameterStudy";
     }
 }
Esempio n. 3
0
        public void GenerateCode(CyPhy.TestBenchRef testBenchRef, string testBenchOutputDir)
        {
            this.testBench = testBenchRef.Referred.TestBenchType;
            this.testBenchOutputDir = testBenchOutputDir;
            var config = new PETConfig.Component()
            {
                parameters = new Dictionary<string, PETConfig.Parameter>(),
                unknowns = new Dictionary<string, PETConfig.Parameter>(),
                details = new Dictionary<string, string>()
            };
            config.details["directory"] = testBenchOutputDir;

            this.config.components.Add(testBenchRef.Name, config);
            foreach (var parameter in testBench.Children.ParameterCollection)
            {
                var sourcePath = GetSourcePath((MgaReference)testBenchRef.Impl, (MgaFCO)parameter.Impl);
                if (sourcePath != null)
                {
                    config.parameters.Add(parameter.Name, new PETConfig.Parameter()
                    {
                        source = sourcePath
                    });
                }
            }
            foreach (var metric in testBench.Children.MetricCollection)
            {
                config.unknowns.Add(metric.Name, new PETConfig.Parameter()
                {
                });
            }
            if (this.testBench is CyPhy.TestBench)
            {
                var interpreterProgID = Rules.Global.GetInterpreterProgIDFromTestBench(this.testBench as CyPhy.TestBench);
                if (interpreterProgID == "MGA.Interpreter.CyPhyFormulaEvaluator")
                {
                    // FIXME: does this still work
                    this.SimpleCalculation();
                }
            }
        }