Beispiel #1
0
        protected MgaFCO GetTestAssembly(MgaProject project)
        {
            var filter = project.CreateFilter();

            filter.Kind = "ComponentAssembly";
            return(project.AllFCOs(filter).Cast <MgaFCO>().Where(fco => fco.GetGuidDisp() == new Guid(testAssemblyId).ToString("B")).First());
        }
Beispiel #2
0
        public void ShouldThrowExceptions()
        {
            // null context
            Assert.Throws <ArgumentNullException>(() => { AnalysisModelProcessor.GetAnalysisModelProcessor(null); });

            Assert.True(File.Exists(this.mgaFile), "Project file does not exist.");
            string ProjectConnStr = "MGA=" + Path.GetFullPath(this.mgaFile);

            MgaProject project = new MgaProject();

            project.OpenEx(ProjectConnStr, "CyPhyML", null);
            try
            {
                var terr = project.BeginTransactionInNewTerr();
                var componentAssembly = project.RootFolder.GetDescendantFCOs(project.CreateFilter()).OfType <MgaModel>().FirstOrDefault(x => x.MetaBase.Name == "ComponentAssembly");

                Assert.True(componentAssembly != null, string.Format("{0} project must contain one component assembly.", Path.GetFullPath(this.mgaFile)));

                // invalid context
                Assert.Throws <AnalysisModelContextNotSupportedException>(() => { AnalysisModelProcessor.GetAnalysisModelProcessor(componentAssembly); });
            }
            finally
            {
                project.AbortTransaction();
                project.Close(true);
            }
        }
Beispiel #3
0
        public ValueFlowTestFixture()
        {
            String connectionString;

            GME.MGA.MgaUtils.ImportXMEForTest(path_XME, out connectionString);

            Boolean ro_mode;

            Project = new MgaProject();
            Project.Open(connectionString, out ro_mode);
            Project.EnableAutoAddOns(true);

            MgaFilter filter = Project.CreateFilter();

            filter.Kind = "Component";
            filter.Name = "ValueFlow";

            var mgaGateway = new MgaGateway(Project);

            mgaGateway.PerformInTransaction(delegate
            {
                ValueFlow = Project.AllFCOs(filter)
                            .Cast <MgaFCO>()
                            .Select(x => CyPhyC.Component.Cast(x))
                            .First();

                RunFormulaEvaluator(ValueFlow.Impl as MgaFCO);
            },
                                            transactiontype_enum.TRANSACTION_GENERAL,
                                            abort: false);
        }
Beispiel #4
0
        public static IEnumerable <CyPhy.ComponentAssembly> GetComponentAssembliesByName(this MgaProject project, String name)
        {
            MgaFilter filter = project.CreateFilter();

            filter.Kind = "ComponentAssembly";
            filter.Name = name;

            return(project.AllFCOs(filter)
                   .Cast <MgaFCO>()
                   .Select(x => CyPhyClasses.ComponentAssembly.Cast(x)));
        }
Beispiel #5
0
        public static IEnumerable <CyPhy.DesignContainer> GetDesignContainersByName(this MgaProject project, String name)
        {
            MgaFilter filter = project.CreateFilter();

            filter.Kind = "DesignContainer";
            filter.Name = name;

            return(project.AllFCOs(filter)
                   .Cast <MgaFCO>()
                   .Select(x => CyPhyClasses.DesignContainer.Cast(x)));
        }
Beispiel #6
0
        public static IEnumerable <CyPhy.Component> GetComponentsByName(this MgaProject project, String name)
        {
            MgaFilter filter = project.CreateFilter();

            filter.Kind = "Component";
            filter.Name = name;

            return(project.AllFCOs(filter)
                   .Cast <MgaFCO>()
                   .Select(x => CyPhyClasses.Component.Cast(x))
                   .Where(c => c.ParentContainer.Kind == "Components"));
        }
Beispiel #7
0
        public void convertFluidParameters(MgaProject project)
        {
            MgaFilter modelicaFluidPortFilter = project.CreateFilter();
            modelicaFluidPortFilter.ObjType = "OBJTYPE_MODEL";
            modelicaFluidPortFilter.Kind = "ModelicaConnector";
            var modelicaFluidPortArchetypes = 
                project
                .AllFCOs(modelicaFluidPortFilter)
                .Cast<MgaModel>()
                .Where(x => x.ChildFCOs.OfType<MgaAtom>().ToList().Count() != 0 &&
                     x.ParentModel != null &&
                    x.ArcheType == null); //.ToList()

            //GMEConsole.Info.WriteLine("Number of FluidPort Archetypes: {0}", modelicaFluidPortArchetypes.Count());

            foreach (var port in modelicaFluidPortArchetypes)
            {
                //GMEConsole.Out.WriteLine("{0}", port.StrAttrByName["Class"]);

                try
                {
                    MgaAtom packageParameter =
                        port.ChildFCOs.OfType<MgaAtom>()
                        .Where(x => x.Name == "redeclare package Medium").FirstOrDefault();
                    if (packageParameter != null)
                    {
                        MgaFCO modelicaRedeclare = makeFCO(port, "ModelicaRedeclare");
                        modelicaRedeclare.Name = "Medium";
                        modelicaRedeclare.StrAttrByName["ModelicaRedeclareType"] = "Package";
                        modelicaRedeclare.StrAttrByName["Value"] = packageParameter.StrAttrByName["Value"];
                    }
                }
                catch (Exception ex)
                {
                    GMEConsole.Warning.WriteLine(
                        "Could not make ModelicaRedeclare block within {0}.{1}",
                        port.ParentModel.Name,
                        port.Name);
                    GMEConsole.Error.WriteLine("{0}", ex.Message);
                    GMEConsole.Info.WriteLine("{0}", ex.StackTrace);
                }
            }
        }
        public void InvokeEx(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, int param)
        {
            if (!enabled)
            {
                return;
            }

            try
            {
                GMEConsole = GMEConsole.CreateFromProject(project);
                MgaGateway = new MgaGateway(project);
                project.CreateTerritoryWithoutSink(out MgaGateway.territory);

                this.InteractiveMode = this.Convert(param) != ComponentStartMode.GME_SILENT_MODE;

                //bool runNewImplementationOnly = true;
                //runNewImplementationOnly = false;

                //if (runNewImplementationOnly)
                //{
                //    this.NewMasterInterpreterImplementationFull(currentobj);
                //    return;
                //}

                List<IMgaFCO> objectsToCheck = new List<IMgaFCO>();
                List<IMgaFCO> objectsToGetConfigurations = new List<IMgaFCO>();

                MgaGateway.PerformInTransaction(() =>
                {
                    if (currentobj == null)
                    {
                        var allObjects = project
                           .RootFolder
                           .ChildFolders
                           .Cast<MgaFolder>()
                           .Where(x => x.Name.StartsWith("0"))
                           .SelectMany(x => x.GetDescendantFCOs(project.CreateFilter()).Cast<IMgaFCO>())
                           .Where(x => x.RootFCO == x);

                        // get all objects from folders starts with 0 within the root folder.
                        objectsToCheck.AddRange(allObjects.Where(x => x.AbsPath.Contains("TestingContextChecker")));

                        objectsToGetConfigurations.AddRange(allObjects.Where(x => x.AbsPath.Contains("TestingGetConfigurations")));
                    }
                    else
                    {
                        objectsToCheck.Add(currentobj);
                        //objectsToGetConfigurations.Add(currentobj);
                    }

                    objectsToCheck.Sort((x, y) =>
                    {
                        return x.Meta.Name.CompareTo(y.Meta.Name) != 0 ?
                            x.Meta.Name.CompareTo(y.Meta.Name) :
                            x.AbsPath.CompareTo(y.AbsPath);
                    });
                });




                System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

                sw.Start();

                int numContexts = objectsToCheck.Count;
                int numSuccess = 0;
                int numFailures = 0;

                StringBuilder sbAssumptions = new StringBuilder();

                sbAssumptions.Append("Implemented".PadToCenter(11));
                sbAssumptions.Append("Valid".PadToCenter(11));
                sbAssumptions.Append("Context".PadToCenter(30));
                sbAssumptions.Append("Assumption");
                sbAssumptions.AppendLine();

                foreach (var subject in objectsToCheck)
                {
                    var masterInterpreter = new CyPhyMasterInterpreter.CyPhyMasterInterpreterAPI();

                    IEnumerable<CyPhyMasterInterpreter.Rules.ContextCheckerResult> contextCheckerResults = null;

                    // check context
                    var checkerSuccess = masterInterpreter.TryCheckContext(subject as MgaModel, out contextCheckerResults);

                    List<CyPhyMasterInterpreter.Rules.ContextCheckerResult> sortedResults = contextCheckerResults.ToList();

                    // sort results Passed, Failed, then alphabetically based on message.
                    sortedResults.Sort((x, y) => { return x.Success == y.Success ? x.Message.CompareTo(y.Message) : y.Success.CompareTo(x.Success); });


                    // print out nicely in the GME console
                    MgaGateway.PerformInTransaction(() =>
                    {
                        MgaObject parent = null;
                        GME.MGA.Meta.objtype_enum type;
                        subject.GetParent(out parent, out type);

                        var successExpected = parent.Name.ToLowerInvariant() == "invalid" ? false : true;

                        sbAssumptions.AppendFormat("{0}{1}{2}{3}",
                            (successExpected == checkerSuccess).ToString().PadToCenter(11),
                            successExpected.ToString().PadToCenter(11),
                            subject.Meta.Name.PadToCenter(30),
                            subject.Name.ToSentenceCase());

                        sbAssumptions.AppendLine();

                        if (successExpected == checkerSuccess)
                        {
                            numSuccess++;
                            //GMEConsole.Info.WriteLine("OK");
                            if (currentobj != null)
                            {
                                foreach (var result in sortedResults)
                                {
                                    TextWriter tw = null;
                                    StringBuilder sb = new StringBuilder();
                                    if (result.Success)
                                    {
                                        sb.Append("[<b style=\"color:darkgreen\">Passed</b>]");
                                        tw = GMEConsole.Info;
                                    }
                                    else
                                    {
                                        sb.Append("[<b style=\"color:red\">Failed</b>]");
                                        tw = GMEConsole.Error;
                                    }

                                    sb.AppendFormat(" <i><a href=\"mga:{0}\">{1}</a></i> ", result.Subject.ID, result.Subject.Name);

                                    sb.Append(result.Message);

                                    tw.WriteLine(sb);
                                }
                            }
                        }
                        else
                        {
                            foreach (var result in sortedResults)
                            {
                                TextWriter tw = null;
                                StringBuilder sb = new StringBuilder();
                                if (result.Success)
                                {
                                    sb.Append("[<b style=\"color:darkgreen\">Passed</b>]");
                                    tw = GMEConsole.Info;
                                }
                                else
                                {
                                    sb.Append("[<b style=\"color:red\">Failed</b>]");
                                    tw = GMEConsole.Error;
                                }

                                sb.AppendFormat(" <i><a href=\"mga:{0}\">{1}</a></i> ", result.Subject.ID, result.Subject.Name);

                                sb.Append(result.Message);

                                tw.WriteLine(sb);
                            }

                            numFailures++;
                            GMEConsole.Error.WriteLine("========= FAILED ==========");
                            GMEConsole.Error.WriteLine("= {0}", subject.Name);
                            GMEConsole.Error.WriteLine("= {0}", subject.AbsPath);
                            GMEConsole.Error.WriteLine("===========================");
                        }


                    });

                    if (currentobj != null)
                    {
                        CyPhyMasterInterpreter.AnalysisModelProcessor analysisModelProcessor = null;

                        MgaGateway.PerformInTransaction(() =>
                        {
                            analysisModelProcessor = CyPhyMasterInterpreter.AnalysisModelProcessor.GetAnalysisModelProcessor(subject as MgaModel);
                        });

                        GMEConsole.Info.WriteLine("AnalysisProcessor type: {0}", analysisModelProcessor.GetType().Name);
                        GMEConsole.Info.WriteLine("Interpreters: {0}", string.Join(", ", analysisModelProcessor.Interpreters));
                        GMEConsole.Info.WriteLine("InterpretersToConfigure: {0}", string.Join(", ", analysisModelProcessor.InterpretersToConfiguration));

                        MgaFCO configuration = null;
                        configuration = masterInterpreter.GetConfigurations(subject as MgaModel).Cast<MgaFCO>().FirstOrDefault();

                        var results = masterInterpreter.RunInTransaction(subject as MgaModel, configuration, keepTempModels: true);

                        MgaGateway.PerformInTransaction(() =>
                        {
                            foreach (var result in results)
                            {
                                TextWriter tw = null;
                                StringBuilder sb = new StringBuilder();
                                if (result.Success)
                                {
                                    sb.Append("[<b style=\"color:darkgreen\">Passed</b>]");
                                    tw = GMEConsole.Info;
                                }
                                else
                                {
                                    sb.Append("[<b style=\"color:red\">Failed</b>]");
                                    tw = GMEConsole.Error;
                                }

                                sb.AppendFormat(" <i>{0}</i> {1} ", result.Context.Name, result.Configuration.Name);

                                sb.Append(result.Message);

                                tw.WriteLine(sb);
                            }
                        });
                    }

                }

                File.WriteAllText("master_interpreter_assumptions.txt", sbAssumptions.ToString());

                foreach (var subject in objectsToGetConfigurations)
                {
                    var masterInterpreter = new CyPhyMasterInterpreter.CyPhyMasterInterpreterAPI();

                    // we are not checking the models again, these test models must be valid enough to get configurations from them

                    var configurations = masterInterpreter.GetConfigurations(subject as MgaModel);

                    // print out nicely in the GME console
                    MgaGateway.PerformInTransaction(() =>
                    {
                        GMEConsole.Info.WriteLine("{0} has {1} configurations.", subject.Name, configurations.Count);
                        //GMEConsole.Info.WriteLine("- {0}", string.Join(", ", configurations.Cast<MgaFCO>().Select(x => x.Name)));
                    });

                    //CyPhyMasterInterpreter.MasterInterpreterResult[] masterInterpreterResults = null;

                    //using (var progressDialog = new CyPhyMasterInterpreter.ProgressDialog())
                    //{
                    //    masterInterpreter.MultipleConfigurationProgress += progressDialog.MultipleConfigurationProgressHandler;
                    //    masterInterpreter.SingleConfigurationProgress += progressDialog.SingleConfigurationProgressHandler;

                    //    progressDialog.ShowWithDisabledMainWindow();

                    //    masterInterpreterResults = masterInterpreter.RunInTransaction(subject as IMgaModel, configurations);
                    //}
                }

                GMEConsole.Info.WriteLine("ContextChecks: {0}", numContexts);
                GMEConsole.Info.WriteLine("Successful   : {0}", numSuccess);
                GMEConsole.Info.WriteLine("Failures     : {0}", numFailures);

                if (numContexts == numSuccess)
                {
                    GMEConsole.Info.WriteLine("ALL GREEN :-)");
                }
                else
                {
                    GMEConsole.Error.WriteLine("You need to work more on the code...");
                }

                GMEConsole.Info.WriteLine(
                    "Duration: {0}.",
                    sw.Elapsed.ToString("c"));

            }
            finally
            {
                System.Windows.Forms.Application.DoEvents();

                if (MgaGateway.territory != null)
                {
                    MgaGateway.territory.Destroy();
                }
                MgaGateway = null;
                project = null;
                currentobj = null;
                selectedobjs = null;
                GMEConsole = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
        private bool CallCyber(MgaProject mgaProject, MgaFCO mgaFCO, MgaFCOs mgaFCOs, int param)
        {
            var filter = mgaProject.CreateFilter();
            filter.Kind = typeof(CyPhy.CyberModel).Name;

            bool success = true;

            var cyberModelFcos = (mgaFCO as MgaModel).GetDescendantFCOs(filter);

            foreach (var cyberModelFco in cyberModelFcos)
            {
                success = success && this.CallCyberInterpreter(CyPhyClasses.CyberModel.Cast(cyberModelFco as MgaObject));
            }

            return success;
        }
        //[Fact]
        public void TestCodeSample()
        {
            string ProjectConnStr;
            MgaUtils.ImportXMEForTest(Path.GetFullPath(@"..\..\..\..\models\DynamicsTeam\MasterInterpreter\MasterInterpreter.xme"), out ProjectConnStr);

            MgaProject project = new MgaProject();
            bool ro_mode;
            project.Open(ProjectConnStr, out ro_mode);

            MgaHelper.CheckParadigmVersionUpgrade(project);

            try
            {
                List<IMgaFCO> objectsToCheck = null;

                project.BeginTransactionInNewTerr();
                try
                {
                    // discover objects

                    var allObjects = project
                        .RootFolder
                        .ChildFolders
                        .Cast<MgaFolder>()
                        .Where(x => x.Name.StartsWith("0"))
                        .SelectMany(x => x.GetDescendantFCOs(project.CreateFilter()).Cast<IMgaFCO>())
                        .Where(x => x.RootFCO == x);

                    // get all objects from folders starts with 0 within the root folder.
                    objectsToCheck = allObjects.Where(x => x.AbsPath.Contains("TestingContextChecker") && x.Name.Contains("ReadOnly") == false).ToList();

                    objectsToCheck.Sort((x, y) =>
                    {
                        return x.Meta.Name.CompareTo(y.Meta.Name) != 0 ?
                            x.Meta.Name.CompareTo(y.Meta.Name) :
                            x.AbsPath.CompareTo(y.AbsPath);
                    });
                }
                finally
                {
                    project.AbortTransaction();
                }

                Assert.True(objectsToCheck != null, "There are no object in the project that has to be checked.");

                int numContexts = objectsToCheck.Count;
                int numSuccess = 0;
                int numFailures = 0;

                bool success = true;

                foreach (var subject in objectsToCheck)
                {
                    // single test
                    using (var masterInterpreter = new CyPhyMasterInterpreter.CyPhyMasterInterpreterAPI(project))
                    {
                        CyPhyMasterInterpreter.Rules.ContextCheckerResult[] contextCheckerResults = null;

                        // check context
                        var checkerSuccess = masterInterpreter.TryCheckContext(subject as MgaModel, out contextCheckerResults);

                        List<CyPhyMasterInterpreter.Rules.ContextCheckerResult> sortedResults = contextCheckerResults.ToList();

                        // sort results Passed, Failed, then alphabetically based on message.
                        sortedResults.Sort((x, y) => { return x.Success == y.Success ? x.Message.CompareTo(y.Message) : y.Success.CompareTo(x.Success); });

                        project.BeginTransactionInNewTerr();
                        try
                        {
                            MgaObject parent = null;
                            GME.MGA.Meta.objtype_enum type;
                            subject.GetParent(out parent, out type);

                            var successExpected = parent.Name.ToLowerInvariant() == "invalid" ? false : true;

                            if (successExpected == checkerSuccess)
                            {
                                numSuccess++;
                                //GMEConsole.Info.WriteLine("OK");
                            }
                            else
                            {
                                success = false;

                                foreach (var result in sortedResults)
                                {
                                    TextWriter tw = null;
                                    StringBuilder sb = new StringBuilder();
                                    if (result.Success)
                                    {
                                        sb.Append("[Passed]");
                                        tw = Console.Out;
                                    }
                                    else
                                    {
                                        sb.Append("[Failed]");
                                        tw = Console.Error;
                                    }

                                    sb.AppendFormat(" {0} - {1} ", result.Subject.Name, result.Subject.AbsPath);

                                    sb.Append(result.Message);

                                    tw.WriteLine(sb);
                                }

                                numFailures++;
                                Console.Error.WriteLine("========= FAILED ==========");
                                Console.Error.WriteLine("= {0}", subject.Name);
                                Console.Error.WriteLine("= {0}", subject.AbsPath);
                                Console.Error.WriteLine("===========================");
                            }

                        }
                        finally
                        {
                            project.AbortTransaction();
                        }
                    }
                }

                if (success)
                {
                    Console.Out.WriteLine("[OK] Checked contexts: {0}, Success: {1}, Failed: {2}", numContexts, numSuccess, numFailures);
                }
                else
                {
                    Console.Error.WriteLine("[FAILED] Checked contexts: {0}, Success: {1}, Failed: {2}", numContexts, numSuccess, numFailures);
                }

                Assert.True(success, "At least one context was failed to check against the expected results.");

            }
            finally
            {
                project.Close(true);
            }



        }
        internal void findOldPortTypes(MgaProject project, bool printHyperlinks)
        {
            List<string> oldPortKinds = new List<string>() 
            {
                "MultibodyFramePowerPort",
                "MultibodyFrame", 
                "ModelicaAggregateInterface",
                "AggregatePort", 
                "HydraulicPowerPort",
                "FluidPort", 
                "HeatPort",
                "ThermalPowerPort",
                "ElectricalPowerPort",
                "ElectricalPin",
                "InputSignalPort",
                "OutputSignalPort",
                "RealInput",
                "RealOutput",
                "BooleanInput",
                "BooleanOutput",
                "IntegerInput",
                "IntegerOutput",
                "TranslationalPowerPort",
                "TranslationalFlange",
                "RotationalPowerPort",
                "RotationalFlange",
                "ModelicaMaterialSpec",
            };

            MgaFilter filter = project.CreateFilter();
            var oldPorts = project.AllFCOs(filter).Cast<MgaFCO>().Where(x => oldPortKinds.Contains(x.Meta.Name));

            if (printHyperlinks)
            {
                foreach (var port in oldPorts)
                {
                    GMEConsole.Info.WriteLine(
                        "Obsolete Port found: <a href=\"mga:{0}\">{1}</a>: {2}",
                        port.ID,
                        port.Name,
                        port.Meta.Name);
                }
            }

            GMEConsole.Info.WriteLine("Number of Obsolete ports found in project: {0}", oldPorts.Count());
        }
Beispiel #12
0
        public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
        {
            Boolean disposeLogger = false;

            if (Logger == null)
            {
                Logger        = new CyPhyGUIs.GMELogger(project, "CyPhyDesignExporter");
                disposeLogger = true;
            }

            // TODO: Add your interpreter code
            Logger.WriteInfo("Running Design Exporter...");

            #region Prompt for Output Path
            // Get an output path from the user.
            if (this.OutputDir == null)
            {
                using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog()
                {
                    Description = "Choose a path for the generated files.",
                    //ShowNewFolderButton = true,
                    SelectedPath = Environment.CurrentDirectory,
                })
                {
                    DialogResult dr = fbd.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        OutputDir = fbd.SelectedPath;
                    }
                    else
                    {
                        Logger.WriteWarning("Design Exporter cancelled");
                        return;
                    }
                }
            }
            #endregion

            Logger.WriteInfo("Beginning Export...");
            List <CyPhy.DesignEntity>  lde_allCAandDC = new List <CyPhy.DesignEntity>();
            List <CyPhy.TestBenchType> ltbt_allTB     = new List <CyPhy.TestBenchType>();

            if (currentobj != null &&
                currentobj.Meta.Name == "ComponentAssembly")
            {
                lde_allCAandDC.Add(CyPhyClasses.ComponentAssembly.Cast(currentobj));
            }
            else if (currentobj != null &&
                     currentobj.Meta.Name == "DesignContainer")
            {
                lde_allCAandDC.Add(CyPhyClasses.DesignContainer.Cast(currentobj));
            }
            else if (currentobj != null &&
                     IsTestBenchType(currentobj.MetaBase.Name))
            {
                ltbt_allTB.Add(CyPhyClasses.TestBenchType.Cast(currentobj));
            }
            else if (selectedobjs != null && selectedobjs.Count > 0)
            {
                foreach (MgaFCO mf in selectedobjs)
                {
                    if (mf.Meta.Name == "ComponentAssembly")
                    {
                        lde_allCAandDC.Add(CyPhyClasses.ComponentAssembly.Cast(mf));
                    }
                    else if (mf.Meta.Name == "DesignContainer")
                    {
                        lde_allCAandDC.Add(CyPhyClasses.DesignContainer.Cast(mf));
                    }
                    else if (IsTestBenchType(mf.MetaBase.Name))
                    {
                        ltbt_allTB.Add(CyPhyClasses.TestBenchType.Cast(mf));
                    }
                }
            }
            else
            {
                CyPhy.RootFolder rootFolder = ISIS.GME.Common.Utils.CreateObject <CyPhyClasses.RootFolder>(project.RootFolder as MgaObject);

                MgaFilter filter = project.CreateFilter();
                filter.Kind = "ComponentAssembly";
                foreach (var item in project.AllFCOs(filter).Cast <MgaFCO>())
                {
                    if (item.ParentFolder != null)
                    {
                        lde_allCAandDC.Add(CyPhyClasses.ComponentAssembly.Cast(item));
                    }
                }

                filter      = project.CreateFilter();
                filter.Kind = "DesignContainer";
                foreach (var item in project.AllFCOs(filter).Cast <MgaFCO>())
                {
                    if (item.ParentFolder != null)
                    {
                        lde_allCAandDC.Add(CyPhyClasses.DesignContainer.Cast(item));
                    }
                }

                filter      = project.CreateFilter();
                filter.Kind = "TestBenchType";
                foreach (var item in project.AllFCOs(filter).Cast <MgaFCO>())
                {
                    if (item.ParentFolder != null)
                    {
                        ltbt_allTB.Add(CyPhyClasses.TestBenchType.Cast(item));
                    }
                }
            }

            foreach (CyPhy.DesignEntity de in lde_allCAandDC)
            {
                System.Windows.Forms.Application.DoEvents();
                try
                {
                    if (de is CyPhy.ComponentAssembly)
                    {
                        ExportToPackage(de as CyPhy.ComponentAssembly, OutputDir);
                    }
                    else
                    {
                        ExportToFile(de, OutputDir);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteError("{0}: Exception encountered ({1})", de.Name, ex.Message);
                }
                Logger.WriteInfo("{0}: {1}", de.Name, OutputDir);
            }

            foreach (CyPhy.TestBenchType tbt in ltbt_allTB)
            {
                System.Windows.Forms.Application.DoEvents();
                try
                {
                    ExportToFile(tbt, OutputDir);
                }
                catch (Exception ex)
                {
                    Logger.WriteError("{0}: Exception encountered ({1})", tbt.Name, ex.Message);
                }
                Logger.WriteInfo("{0}: {1}", tbt.Name, OutputDir);
            }

            Logger.WriteInfo(String.Format("{0} model(s) exported", lde_allCAandDC.Count + ltbt_allTB.Count));
            Logger.WriteInfo("Design Exporter finished");

            if (disposeLogger)
            {
                DisposeLogger();
            }
        }
        public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
        {
            if (currentobj == null)
            {
                GMEConsole.Error.WriteLine("Please open a TestBench to run {0}.", ComponentName);
                return;
            }
            else if (currentobj.Meta.Name != "TestBench")
            {
                GMEConsole.Error.WriteLine("Please open a TestBench to run {0}.", ComponentName);
                return;
            }

            GMEConsole.Info.WriteLine("Running {0} on TestBench '{1}'", ComponentName, currentobj.Name);

            // get root folder
            IMgaFolder rootFolder = project.RootFolder;
            
            // create a filter for components
            MgaFilter filter = project.CreateFilter();
            filter.Kind = "Component";

            // get all components
            var components = project.AllFCOs(filter).OfType<IMgaModel>().Cast<IMgaModel>().ToList();

            // store components that may have an option (e.g. MM1, MM2)
            List<IMgaModel> componentsToShow = new List<IMgaModel>();

            // iterate through all components
            // select only those which has more than one modelica model in it
            foreach (var component in components)
            {
                var modelicaModels = component.ChildFCOs.Cast<IMgaFCO>().Where(x => x.Meta.Name == "ModelicaModel");
                if (modelicaModels.Count() > 1)
                {
                    componentsToShow.Add(component);
                }
            }

            using (FidelitySelectorForm fsf = new FidelitySelectorForm())
            {

                // show the form for the user
                foreach (var component in componentsToShow)
                {
                    if (fsf.componentItems.FirstOrDefault(
                        x => x.Classification == component.StrAttrByName["Classifications"]) == null)
                    {
                        fsf.componentItems.Add(new ComponentItem(component));
                    }
                }

                // get the current fidelity settings from the Testbench registry
                fsf.FidelitySettings = currentobj.RegistryValue["FidelitySettings"];

                fsf.PopulateDgv();
                fsf.ShowDialog();

                foreach (string msg in fsf.consoleMessages)
                {
                    GMEConsole.Info.WriteLine(msg);
                }

                // Check where the new fidelity settings should be applied:
                if (fsf.rbThisTestbench.Checked)
                {
                    // Write the updated fidelity settings back to the Testbench registry
                    currentobj.RegistryValue["FidelitySettings"] = fsf.FidelitySettings;
                }
                else if (fsf.rbThisFolder.Checked)
                {
                    // Get all testbenches in the same folder as currentobj
                    var thisTestingFolder = currentobj.ParentFolder;
                    var siblingTBs =
                        thisTestingFolder.ChildFCOs.Cast<IMgaFCO>().Where(x => x.Meta.Name == "TestBench").ToList();

                    GMEConsole.Info.WriteLine(
                        "Applying these FidelitySettings to all TestBenches in folder '{0}':", thisTestingFolder.Name);

                    // Go through each one and set the fidelity settings
                    foreach (MgaFCO testbench in siblingTBs)
                    {
                        testbench.RegistryValue["FidelitySettings"] = fsf.FidelitySettings;

                        GMEConsole.Info.WriteLine("=> {0}", testbench.Name); 
                    }
                }
                else if (fsf.rbThisProject.Checked)
                {
                    // Get all testbenches in the entire project
                    MgaFilter testbenchFilter = project.CreateFilter();
                    testbenchFilter.Kind = "TestBench";

                    // get all testbenches
                    var testbenches = project.AllFCOs(testbenchFilter).OfType<IMgaModel>().Cast<IMgaModel>().ToList();

                    GMEConsole.Info.WriteLine(
                        "Applying these FidelitySettings to all TestBenches in project '{0}':", project.Name);

                    // Go through each one and set the fidelity settings
                    foreach (MgaFCO testbench in testbenches)
                    {
                        testbench.RegistryValue["FidelitySettings"] = fsf.FidelitySettings;

                        GMEConsole.Info.WriteLine("=> {0}", testbench.Name); 
                    }
                }
            }


            GMEConsole.Info.WriteLine("{0} finished.", ComponentName);
        }
Beispiel #14
0
        public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
        {
            // Get RootFolder
            IMgaFolder rootFolder = project.RootFolder;

            #region Prompt for Output Path
            // Get an output path from the user.
            String s_outPath;
            using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog()
            {
                Description = "Choose a path for the generated files.",
                //ShowNewFolderButton = true,
                SelectedPath = Environment.CurrentDirectory,
            })
            {
                DialogResult dr = fbd.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    s_outPath = fbd.SelectedPath;
                }
                else
                {
                    GMEConsole.Warning.WriteLine("Design Exporter cancelled");
                    return;
                }
            }
            #endregion

            GMEConsole.Info.WriteLine("Beginning Export...");
            var testBanches = new List <CyPhy.TestBench>();

            if (currentobj != null &&
                currentobj.Meta.Name == "TestBench")
            {
                testBanches.Add(CyPhyClasses.TestBench.Cast(currentobj));
            }
            else if (selectedobjs.Count > 0)
            {
                foreach (MgaFCO mf in selectedobjs)
                {
                    if (mf.Meta.Name == "TestBench")
                    {
                        testBanches.Add(CyPhyClasses.TestBench.Cast(mf));
                    }
                }
            }
            else
            {
                CyPhy.RootFolder root = ISIS.GME.Common.Utils.CreateObject <CyPhyClasses.RootFolder>(project.RootFolder as MgaObject);

                MgaFilter filter = project.CreateFilter();
                filter.Kind = "TestBench";
                foreach (var item in project.AllFCOs(filter).Cast <MgaFCO>())
                {
                    if (item.ParentFolder != null)
                    {
                        testBanches.Add(CyPhyClasses.TestBench.Cast(item));
                    }
                }
            }

            foreach (var tb in testBanches)
            {
                System.Windows.Forms.Application.DoEvents();
                try
                {
                    ExportToFile(tb, s_outPath);
                }
                catch (Exception ex)
                {
                    GMEConsole.Error.WriteLine("{0}: Exception encountered ({1})", tb.Name, ex.Message);
                }
                GMEConsole.Info.WriteLine("{0}: {1}", tb.Name, s_outPath);
            }
        }
Beispiel #15
0
        public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
        {
            // TODO: show how to initialize DSML-generated classes

            myMig = new myMigrator(project);
            mig   = new Migrator(project);

            if (currentobj != null)
            {
                if (currentobj is MgaModel)
                {
                    GMEConsole.Info.WriteLine(
                        "Migrating {0}... (To migrate the whole project, close all models and try again)",
                        currentobj.Name);

                    //myMig.migrateModel(currentobj as MgaModel);
                    mig.findOldPortTypes(project, false);

                    try
                    {
                        mig.migrateModel(currentobj as MgaModel);
                    }
                    catch (Exception ex)
                    {
                        GMEConsole.Error.WriteLine("{0}", ex.Message);
                        GMEConsole.Info.WriteLine("{0}", ex.StackTrace);
                    }
                }
            }
            else
            {
                //mig.convertFluidParameters(project);

                GMEConsole.Info.WriteLine("Migrating the entire project...");
                myMig.migrateProject();

                mig.findOldPortTypes(project, false);
                mig.migrateCyPhy2ModelicaWorkflow(project);

                List <string> kinds = new List <string>()
                {
                    "TestBench",
                    "ComponentAssembly",
                    "DesignContainer",
                    "TestComponent",
                    "Component",
                    "Environment"
                };

                MgaFilter cyPhyModelFilter = project.CreateFilter();

                cyPhyModelFilter.ObjType = objtype_enum.OBJTYPE_MODEL.ToString();

                var objectsToMigrate = project
                                       .AllFCOs(cyPhyModelFilter)
                                       .OfType <MgaModel>()
                                       .Where(x => x.ParentModel == null &&
                                              kinds.Contains(x.Meta.Name));

                foreach (var objectToMigrate in objectsToMigrate)
                {
                    //GMEConsole.Info.WriteLine(
                    //    "== Migrating <a href=\"mga:{0}\">{1}</a>",
                    //    objectToMigrate.ID,
                    //    objectToMigrate.Name);
                    try
                    {
                        mig.migrateModel(objectToMigrate);
                    }
                    catch (Exception ex)
                    {
                        GMEConsole.Error.WriteLine("{0}", ex.Message);
                        GMEConsole.Info.WriteLine("{0}", ex.StackTrace);
                    }
                }
            }
        }
        public void InvokeEx(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, int param)
        {
            if (!enabled)
            {
                return;
            }

            try
            {
                GMEConsole = GMEConsole.CreateFromProject(project);
                MgaGateway = new MgaGateway(project);
                project.CreateTerritoryWithoutSink(out MgaGateway.territory);

                this.InteractiveMode = this.Convert(param) != ComponentStartMode.GME_SILENT_MODE;

                //bool runNewImplementationOnly = true;
                //runNewImplementationOnly = false;

                //if (runNewImplementationOnly)
                //{
                //    this.NewMasterInterpreterImplementationFull(currentobj);
                //    return;
                //}

                List <IMgaFCO> objectsToCheck             = new List <IMgaFCO>();
                List <IMgaFCO> objectsToGetConfigurations = new List <IMgaFCO>();

                MgaGateway.PerformInTransaction(() =>
                {
                    if (currentobj == null)
                    {
                        var allObjects = project
                                         .RootFolder
                                         .ChildFolders
                                         .Cast <MgaFolder>()
                                         .Where(x => x.Name.StartsWith("0"))
                                         .SelectMany(x => x.GetDescendantFCOs(project.CreateFilter()).Cast <IMgaFCO>())
                                         .Where(x => x.RootFCO == x);

                        // get all objects from folders starts with 0 within the root folder.
                        objectsToCheck.AddRange(allObjects.Where(x => x.AbsPath.Contains("TestingContextChecker")));

                        objectsToGetConfigurations.AddRange(allObjects.Where(x => x.AbsPath.Contains("TestingGetConfigurations")));
                    }
                    else
                    {
                        objectsToCheck.Add(currentobj);
                        //objectsToGetConfigurations.Add(currentobj);
                    }

                    objectsToCheck.Sort((x, y) =>
                    {
                        return(x.Meta.Name.CompareTo(y.Meta.Name) != 0 ?
                               x.Meta.Name.CompareTo(y.Meta.Name) :
                               x.AbsPath.CompareTo(y.AbsPath));
                    });
                });



                System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

                sw.Start();

                int numContexts = objectsToCheck.Count;
                int numSuccess  = 0;
                int numFailures = 0;

                StringBuilder sbAssumptions = new StringBuilder();

                sbAssumptions.Append("Implemented".PadToCenter(11));
                sbAssumptions.Append("Valid".PadToCenter(11));
                sbAssumptions.Append("Context".PadToCenter(30));
                sbAssumptions.Append("Assumption");
                sbAssumptions.AppendLine();

                foreach (var subject in objectsToCheck)
                {
                    var masterInterpreter = new CyPhyMasterInterpreter.CyPhyMasterInterpreterAPI();

                    IEnumerable <CyPhyMasterInterpreter.Rules.ContextCheckerResult> contextCheckerResults = null;

                    // check context
                    var checkerSuccess = masterInterpreter.TryCheckContext(subject as MgaModel, out contextCheckerResults);

                    List <CyPhyMasterInterpreter.Rules.ContextCheckerResult> sortedResults = contextCheckerResults.ToList();

                    // sort results Passed, Failed, then alphabetically based on message.
                    sortedResults.Sort((x, y) => { return(x.Success == y.Success ? x.Message.CompareTo(y.Message) : y.Success.CompareTo(x.Success)); });


                    // print out nicely in the GME console
                    MgaGateway.PerformInTransaction(() =>
                    {
                        MgaObject parent = null;
                        GME.MGA.Meta.objtype_enum type;
                        subject.GetParent(out parent, out type);

                        var successExpected = parent.Name.ToLowerInvariant() == "invalid" ? false : true;

                        sbAssumptions.AppendFormat("{0}{1}{2}{3}",
                                                   (successExpected == checkerSuccess).ToString().PadToCenter(11),
                                                   successExpected.ToString().PadToCenter(11),
                                                   subject.Meta.Name.PadToCenter(30),
                                                   subject.Name.ToSentenceCase());

                        sbAssumptions.AppendLine();

                        if (successExpected == checkerSuccess)
                        {
                            numSuccess++;
                            //GMEConsole.Info.WriteLine("OK");
                            if (currentobj != null)
                            {
                                foreach (var result in sortedResults)
                                {
                                    TextWriter tw    = null;
                                    StringBuilder sb = new StringBuilder();
                                    if (result.Success)
                                    {
                                        sb.Append("[<b style=\"color:darkgreen\">Passed</b>]");
                                        tw = GMEConsole.Info;
                                    }
                                    else
                                    {
                                        sb.Append("[<b style=\"color:red\">Failed</b>]");
                                        tw = GMEConsole.Error;
                                    }

                                    sb.AppendFormat(" <i><a href=\"mga:{0}\">{1}</a></i> ", result.Subject.ID, result.Subject.Name);

                                    sb.Append(result.Message);

                                    tw.WriteLine(sb);
                                }
                            }
                        }
                        else
                        {
                            foreach (var result in sortedResults)
                            {
                                TextWriter tw    = null;
                                StringBuilder sb = new StringBuilder();
                                if (result.Success)
                                {
                                    sb.Append("[<b style=\"color:darkgreen\">Passed</b>]");
                                    tw = GMEConsole.Info;
                                }
                                else
                                {
                                    sb.Append("[<b style=\"color:red\">Failed</b>]");
                                    tw = GMEConsole.Error;
                                }

                                sb.AppendFormat(" <i><a href=\"mga:{0}\">{1}</a></i> ", result.Subject.ID, result.Subject.Name);

                                sb.Append(result.Message);

                                tw.WriteLine(sb);
                            }

                            numFailures++;
                            GMEConsole.Error.WriteLine("========= FAILED ==========");
                            GMEConsole.Error.WriteLine("= {0}", subject.Name);
                            GMEConsole.Error.WriteLine("= {0}", subject.AbsPath);
                            GMEConsole.Error.WriteLine("===========================");
                        }
                    });

                    if (currentobj != null)
                    {
                        CyPhyMasterInterpreter.AnalysisModelProcessor analysisModelProcessor = null;

                        MgaGateway.PerformInTransaction(() =>
                        {
                            analysisModelProcessor = CyPhyMasterInterpreter.AnalysisModelProcessor.GetAnalysisModelProcessor(subject as MgaModel);
                        });

                        GMEConsole.Info.WriteLine("AnalysisProcessor type: {0}", analysisModelProcessor.GetType().Name);
                        GMEConsole.Info.WriteLine("Interpreters: {0}", string.Join(", ", analysisModelProcessor.Interpreters));
                        GMEConsole.Info.WriteLine("InterpretersToConfigure: {0}", string.Join(", ", analysisModelProcessor.InterpretersToConfiguration));

                        MgaFCO configuration = null;
                        configuration = masterInterpreter.GetConfigurations(subject as MgaModel).Cast <MgaFCO>().FirstOrDefault();

                        var results = masterInterpreter.RunInTransaction(subject as MgaModel, configuration, keepTempModels: true);

                        MgaGateway.PerformInTransaction(() =>
                        {
                            foreach (var result in results)
                            {
                                TextWriter tw    = null;
                                StringBuilder sb = new StringBuilder();
                                if (result.Success)
                                {
                                    sb.Append("[<b style=\"color:darkgreen\">Passed</b>]");
                                    tw = GMEConsole.Info;
                                }
                                else
                                {
                                    sb.Append("[<b style=\"color:red\">Failed</b>]");
                                    tw = GMEConsole.Error;
                                }

                                sb.AppendFormat(" <i>{0}</i> {1} ", result.Context.Name, result.Configuration.Name);

                                sb.Append(result.Message);

                                tw.WriteLine(sb);
                            }
                        });
                    }
                }

                File.WriteAllText("master_interpreter_assumptions.txt", sbAssumptions.ToString());

                foreach (var subject in objectsToGetConfigurations)
                {
                    var masterInterpreter = new CyPhyMasterInterpreter.CyPhyMasterInterpreterAPI();

                    // we are not checking the models again, these test models must be valid enough to get configurations from them

                    var configurations = masterInterpreter.GetConfigurations(subject as MgaModel);

                    // print out nicely in the GME console
                    MgaGateway.PerformInTransaction(() =>
                    {
                        GMEConsole.Info.WriteLine("{0} has {1} configurations.", subject.Name, configurations.Count);
                        //GMEConsole.Info.WriteLine("- {0}", string.Join(", ", configurations.Cast<MgaFCO>().Select(x => x.Name)));
                    });

                    //CyPhyMasterInterpreter.MasterInterpreterResult[] masterInterpreterResults = null;

                    //using (var progressDialog = new CyPhyMasterInterpreter.ProgressDialog())
                    //{
                    //    masterInterpreter.MultipleConfigurationProgress += progressDialog.MultipleConfigurationProgressHandler;
                    //    masterInterpreter.SingleConfigurationProgress += progressDialog.SingleConfigurationProgressHandler;

                    //    progressDialog.ShowWithDisabledMainWindow();

                    //    masterInterpreterResults = masterInterpreter.RunInTransaction(subject as IMgaModel, configurations);
                    //}
                }

                GMEConsole.Info.WriteLine("ContextChecks: {0}", numContexts);
                GMEConsole.Info.WriteLine("Successful   : {0}", numSuccess);
                GMEConsole.Info.WriteLine("Failures     : {0}", numFailures);

                if (numContexts == numSuccess)
                {
                    GMEConsole.Info.WriteLine("ALL GREEN :-)");
                }
                else
                {
                    GMEConsole.Error.WriteLine("You need to work more on the code...");
                }

                GMEConsole.Info.WriteLine(
                    "Duration: {0}.",
                    sw.Elapsed.ToString("c"));
            }
            finally
            {
                System.Windows.Forms.Application.DoEvents();

                if (MgaGateway.territory != null)
                {
                    MgaGateway.territory.Destroy();
                }
                MgaGateway   = null;
                project      = null;
                currentobj   = null;
                selectedobjs = null;
                GMEConsole   = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
        public T GetGMEObjectFromIdentification <T>(MgaProject project, string identification) where T : IMgaObject
        {
            T result = default(T);

            // is project in transaction already?
            bool projectWasNotInTransaction = (project.ProjectStatus & 8) == 0;

            try
            {
                if (projectWasNotInTransaction)
                {
                    // open a transaction if it is not in a transaction already.
                    project.BeginTransactionInNewTerr();
                }

                // regexp for GME ID - case insensitive
                string idPattern = @"(id-006[0-9a-f]{1}-[0-9a-f]{8})"; // hexadecimal char: [0-9a-f]

                System.Text.RegularExpressions.Regex regexId =
                    new System.Text.RegularExpressions.Regex(idPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                bool isId = regexId.IsMatch(identification);

                // regexp for GUID - case insensitive
                string guidPattern = @"(\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\})";

                System.Text.RegularExpressions.Regex regexGuid =
                    new System.Text.RegularExpressions.Regex(guidPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                bool isGuid = regexGuid.IsMatch(identification);

                if (isId)
                {
                    // assume it is an id
                    identification = identification.ToLowerInvariant();

                    result = (T)project.GetObjectByID(identification);
                }
                else if (isGuid)
                {
                    // FIXME: does not work for folders

                    // assume it is a GUID
                    identification = identification.ToLowerInvariant();

                    // this may take time, no better method on the GME API at this point.
                    foreach (MgaFCO fco in project.AllFCOs(project.CreateFilter()))
                    {
                        if (fco.GetGuidDisp() == identification)
                        {
                            result = (T)fco;
                            break;
                        }
                    }
                }
                else if (identification.StartsWith("/"))
                {
                    // assume it is an AbsPath
                    if (identification.StartsWith("/@") == false)
                    {
                        // inject @ signs for the user
                        // FIXME: what if the name has / for any objects?
                        identification = identification.Replace("/", "/@");
                    }

                    result = (T)project.ObjectByPath[identification];
                }
                else
                {
                    throw new FormatException(string.Format("Identification must be a GME ID 'id-006X-YYYYYYYY' or a GUID '{{guid}}' or an AbsPath '/@...' : given value:'{0}'", identification));
                }
            }
            finally
            {
                if (projectWasNotInTransaction)
                {
                    project.AbortTransaction();
                }
            }

            return(result);
        }
        public void getObjectsByFilter(MgaProject project)
        {
            //MgaFilter componentFilter = project.CreateFilter();
            //componentFilter.ObjType = "OBJTYPE_MODEL";
            //componentFilter.Kind = "Component";
            //componentArchetypes = project.AllFCOs(componentFilter).Cast<MgaFCO>().Where(x => x.ArcheType == null).ToList();

            //foreach (var c in componentArchetypes)
            //{
            //    string path = c.AbsPath;
            //    string[] splitPath = path.Split('/');
            //    string newPath = "";
            //    foreach (var s in splitPath)
            //    {
            //        newPath = newPath + s.Split('|').FirstOrDefault();
            //    }
            //    GMEConsole.Out.WriteLine("{0}", newPath);
            //}

            //MgaFilter assemblyFilter = project.CreateFilter();
            //assemblyFilter.ObjType = "OBJTYPE_MODEL";
            //assemblyFilter.Kind = "ComponentAssembly";
            //componentAssemblies = project.AllFCOs(assemblyFilter).Cast<MgaFCO>().ToList();

            //MgaFilter designContainerFilter = project.CreateFilter();
            //designContainerFilter.ObjType = "OBJTYPE_MODEL";
            //designContainerFilter.Kind = "DesignContainer";
            //designContainers = project.AllFCOs(designContainerFilter).Cast<MgaFCO>().ToList();

            //MgaFilter testCompFilter = project.CreateFilter();
            //testCompFilter.ObjType = "OBJTYPE_MODEL";
            //testCompFilter.Kind = "TestComponent";
            //testComponents = project.AllFCOs(testCompFilter).Cast<MgaFCO>().Where(x => x.ArcheType == null).ToList();

            //MgaFilter testbenchFilter = project.CreateFilter();
            //testbenchFilter.ObjType = "OBJTYPE_MODEL";
            //testbenchFilter.Kind = "TestBench";
            //testbenches = project.AllFCOs(testbenchFilter).Cast<MgaFCO>().ToList();

            MgaFilter portLibFilter = project.CreateFilter();
            portLibFilter.ObjType = objtype_enum.OBJTYPE_MODEL.ToString();
            portLibFilter.Kind = "ModelicaConnector";

            var newPortTypes = project.AllFCOs(portLibFilter).Cast<MgaFCO>().Where(x => x.ParentFolder != null);

            foreach (var pType in newPortTypes)
            {
                if (modelicaPortLib.ContainsKey(pType.Name))
                {
                    continue;
                }
                modelicaPortLib.Add(pType.Name, pType);
            }

            d_OldKindToNewPortArchetype_jk = new Dictionary<string, MgaFCO>() 
            {
                { "MultibodyFramePowerPort" , modelicaPortLib["MultibodyFrame"] },
                { "MultibodyFrame" , modelicaPortLib["MultibodyFrame"] },
                { "ModelicaAggregateInterface" , modelicaPortLib["FlangeWithBearing"] },
                { "AggregatePort" , modelicaPortLib["FlangeWithBearing"] },
                { "HydraulicPowerPort" , modelicaPortLib["FluidPort"] },
                { "FluidPort" , modelicaPortLib["FluidPort"] },
                { "HeatPort" , modelicaPortLib["HeatPort"] },
                { "ThermalPowerPort" , modelicaPortLib["HeatPort"] },
                { "ElectricalPowerPort" , modelicaPortLib["ElectricalPin"] },
                { "ElectricalPin" , modelicaPortLib["ElectricalPin"] },
                { "InputSignalPort" , modelicaPortLib["RealInput"] },
                { "OutputSignalPort" , modelicaPortLib["RealOutput"] },
                { "RealInput" , modelicaPortLib["RealInput"] },
                { "RealOutput" , modelicaPortLib["RealOutput"] },
                { "BooleanInput" , modelicaPortLib["BooleanInput"] },
                { "BooleanOutput" , modelicaPortLib["BooleanOutput"] },
                { "IntegerInput" , modelicaPortLib["IntegerInput"] },
                { "IntegerOutput" , modelicaPortLib["IntegerOutput"] },
                { "TranslationalPowerPort" , modelicaPortLib["TranslationalFlange"] },
                { "TranslationalFlange" , modelicaPortLib["TranslationalFlange"] },
                { "RotationalPowerPort" , modelicaPortLib["RotationalFlange"] },
                { "RotationalFlange" , modelicaPortLib["RotationalFlange"] },
                { "Modelica.Blocks.Interfaces.BooleanInput" , modelicaPortLib["BooleanInput"] },
                { "Modelica.Blocks.Interfaces.BooleanOutput" , modelicaPortLib["BooleanOutput"] },
                { "Modelica.Blocks.Interfaces.IntegerInput" , modelicaPortLib["IntegerInput"] },
                { "Modelica.Blocks.Interfaces.IntegerOutput" , modelicaPortLib["IntegerOutput"] },
                { "C2M2L_Ext.Electrical.Interfaces.Battery_Bus" , modelicaPortLib["BatteryBus"] },
                { "C2M2L_Ext.Interfaces.Context_Interfaces.Driver.Driver_Bus" , modelicaPortLib["DriverBus"] },
                { "Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing" , modelicaPortLib["FlangeWithBearing"] },
                { "C2M2L_Ext.Fluid.Hydraulics_Simple.Interfaces.Hydraulic_Port" , modelicaPortLib["HydraulicPower"] },
                { "C2M2L_Ext.C2M2L_Component_Building_Blocks.Drive_Line.Brakes_Clutch.Common_Controls.Brake_Control_Bus" , modelicaPortLib["BrakeControlBus"] },
                { "C2M2L_Ext.Electrical.Interfaces.Electric_Machine_Bus" , modelicaPortLib["ElectricMachineBus"] },
                { "C2M2L_Ext.C2M2L_Component_Building_Blocks.Prime_Movers.Common_Controls.Engine_Control_Bus" , modelicaPortLib["EngineControlBus"] },
                { "C2M2L_Ext.C2M2L_Component_Building_Blocks.Drive_Line.Range_Packs.Common_Controls.Range_Pack_Control_Bus" , modelicaPortLib["RangePackControlBus"] },
                { "C2M2L_Ext.C2M2L_Component_Building_Blocks.Drive_Line.Cross_Drive_Steering.Common_Controls.Steering_Control_Bus" , modelicaPortLib["SteeringControlBus"] },
                { "C2M2L_Ext.C2M2L_Component_Building_Blocks.Drive_Line.Torque_Converters.Common_Controls.Torque_Converter_Control_Bus" , modelicaPortLib["TorqueConverterControlBus"] },
                { "C2M2L_Ext.Interfaces.Context_Interfaces.Atmospheric_Environment.Atmospheric_Environment_Bus" , modelicaPortLib["AtmosphericEnvironmentBus"] },
            };
        }
        internal void migrateCyPhy2ModelicaWorkflow(MgaProject project)
        {
            MgaFilter workflowFilter = project.CreateFilter();

            workflowFilter.ObjType = objtype_enum.OBJTYPE_ATOM.ToString();
            workflowFilter.Kind = "Task";

            var workflowTasks = project.AllFCOs(workflowFilter).OfType<MgaAtom>();

            foreach (var task in workflowTasks)
            {
                if (task.IsLibObject == false &&
                    task.StrAttrByName["COMName"] == "MGA.Interpreter.CyPhy2Modelica")
                {
                    task.StrAttrByName["COMName"] = task.StrAttrByName["COMName"] + "_v2";
                }
            }

        }
        internal void DeleteAllOldTypes(MgaProject project)
        {
            foreach (var kvp in dfco_OldToNewMap)
            {
                try
                {
                    if (kvp.Key == null)
                    {
                        if (kvp.Value != null)
                        {
                            GMEConsole.Warning.WriteLine(
                                "Migrated? <a href=\"mga:{0}\">{1}</a>",
                                kvp.Value.ID,
                                kvp.Value.Name);
                        }
                        continue;
                    }
                    if (kvp.Key.IsLibObject == false &&
                        kvp.Key.ParentModel != null &&
                        kvp.Key.ParentModel.DerivedFrom == null)
                    {
                        kvp.Key.DestroyObject();
                    }
                    else
                    {
                        GMEConsole.Info.WriteLine(
                            "Skipped <a href=\"mga:{0}\">{1}</a>",
                            kvp.Key.ID,
                            kvp.Key.Name);
                    }
                }
                catch (Exception ex)
                {
                    GMEConsole.Error.WriteLine(
                        "Cannot delete object <a href=\"mga:{0}\">{1}</a>. Exception: {2} ({3})",
                        kvp.Key.ID,
                        kvp.Key.Name,
                        ex.Message,
                        ex.StackTrace);
                }

            }

            foreach (var kvp in mapModel_migrated2original)
            {
                try
                {
                    if (kvp.Value != null)
                    {
                        kvp.Value.DestroyObject();
                    }
                }
                catch (Exception ex)
                {
                    GMEConsole.Error.WriteLine(
                        "Failed to Delete <a href=\"mga:{1}\">{2}</a>: {0}",
                        ex.Message,
                        kvp.Value.ID,
                        kvp.Value.Name);
                }
            }

            MgaFilter materialSpecFilter = project.CreateFilter();
            materialSpecFilter.Kind = "ModelicaMaterialSpec";

            var materialSpecBlocks = project.AllFCOs(materialSpecFilter).Cast<MgaFCO>(); //.ToList()
            foreach (MgaFCO msb in materialSpecBlocks)
            {
                try
                {
                    msb.DestroyObject();
                }
                catch (Exception ex)
                {
                    GMEConsole.Error.WriteLine(
                        "Failed to Delete <a href=\"mga:{1}\">{2}</a>: {0}",
                        ex.Message,
                        msb.ID,
                        msb.Name);
                }
            }
        }
        //[Fact]
        public void TestCodeSample()
        {
            string ProjectConnStr;
            MgaUtils.ImportXMEForTest(Path.GetFullPath(@"..\..\..\..\models\DynamicsTeam\MasterInterpreter\MasterInterpreter.xme"), out ProjectConnStr);

            MgaProject project = new MgaProject();
            bool ro_mode;
            project.Open(ProjectConnStr, out ro_mode);

            MgaHelper.CheckParadigmVersionUpgrade(project);

            try
            {
                List<IMgaFCO> objectsToGetConfigurations = null;

                project.BeginTransactionInNewTerr();
                try
                {
                    // discover objects

                    var allObjects = project
                        .RootFolder
                        .ChildFolders
                        .Cast<MgaFolder>()
                        .Where(x => x.Name.StartsWith("0"))
                        .SelectMany(x => x.GetDescendantFCOs(project.CreateFilter()).Cast<IMgaFCO>())
                        .Where(x => x.RootFCO == x);

                    // get all objects from folders starts with 0 within the root folder.
                    objectsToGetConfigurations = allObjects.Where(x => x.AbsPath.Contains("TestingGetConfigurations")).ToList();

                    objectsToGetConfigurations.Sort((x, y) =>
                    {
                        return x.Meta.Name.CompareTo(y.Meta.Name) != 0 ?
                            x.Meta.Name.CompareTo(y.Meta.Name) :
                            x.AbsPath.CompareTo(y.AbsPath);
                    });
                }
                finally
                {
                    project.AbortTransaction();
                }

                Assert.True(objectsToGetConfigurations != null, "There are no object in the project that has to be checked.");

                int numContexts = objectsToGetConfigurations.Count;
                int numSuccess = 0;
                int numFailures = 0;

                bool success = true;

                foreach (var subject in objectsToGetConfigurations)
                {
                    // single test
                    using (var masterInterpreter = new CyPhyMasterInterpreter.CyPhyMasterInterpreterAPI(project))
                    {

                        IMgaFCOs configurations = null;

                        Assert.ThrowsDelegate d = () =>
                        {
                            configurations = masterInterpreter.GetConfigurations(subject as MgaModel);
                        };

                        Assert.DoesNotThrow(d);
                        //Assert.True(configurations != null, "GetConfiguration returned with null.");

                        if (configurations == null)
                        {
                            numFailures++;
                        }
                        else
                        {
                            numSuccess++;
                        }

                        // print out nicely in the GME console
                        project.BeginTransactionInNewTerr();
                        try
                        {
                            Console.Out.WriteLine("{0} [{1}] has {2} configurations.", subject.Name, subject.Meta.Name, configurations.Count);
                            foreach (IMgaFCO configuration in configurations)
                            {
                                Console.Out.WriteLine(" > {0} - {1}", configuration.Name, configuration.ID);
                            }

                        }
                        finally
                        {
                            project.AbortTransaction();
                        }
                    }
                }

                if (success)
                {
                    Console.Out.WriteLine("[OK] Got configurations for: {0} test benches. Success: {1}, Failed {2}", numContexts, numSuccess, numFailures);
                }
                else
                {
                    Console.Error.WriteLine("[FAILED] Tried to get configurations for: {0} test benches. Success: {1}, Failed {2}", numContexts, numSuccess, numFailures);
                }

                Assert.True(success, "At least one context was failed to check against the expected results.");

            }
            finally
            {
                project.Close(true);
            }



        }
        //[Fact]
        public void TestCodeSample()
        {
            string ProjectConnStr;
            MgaUtils.ImportXMEForTest(Path.GetFullPath(@"..\..\..\..\models\DynamicsTeam\MasterInterpreter\MasterInterpreter.xme"), out ProjectConnStr);

            MgaProject project = new MgaProject();
            bool ro_mode;
            project.Open(ProjectConnStr, out ro_mode);

            MgaHelper.CheckParadigmVersionUpgrade(project);

            try
            {
                List<IMgaFCO> objectsToCheck = null;

                project.BeginTransactionInNewTerr();
                try
                {
                    // discover objects

                    var allObjects = project
                        .RootFolder
                        .ChildFolders
                        .Cast<MgaFolder>()
                        .Where(x => x.Name.StartsWith("0"))
                        .SelectMany(x => x.GetDescendantFCOs(project.CreateFilter()).Cast<IMgaFCO>())
                        .Where(x => x.RootFCO == x);

                    // get all objects from folders starts with 0 within the root folder.
                    objectsToCheck = allObjects.Where(x => x.AbsPath.Contains("ProcessorTypesForContexts")).ToList();

                    objectsToCheck.Sort((x, y) =>
                    {
                        return x.Meta.Name.CompareTo(y.Meta.Name) != 0 ?
                            x.Meta.Name.CompareTo(y.Meta.Name) :
                            x.AbsPath.CompareTo(y.AbsPath);
                    });
                }
                finally
                {
                    project.AbortTransaction();
                }

                Assert.True(objectsToCheck != null, "There are no object in the project that has to be checked.");

                int numContexts = objectsToCheck.Count;
                int numSuccess = 0;
                int numFailures = 0;

                bool success = true;

                foreach (var subject in objectsToCheck)
                {
                    // single test
                    CyPhyMasterInterpreter.AnalysisModelProcessor analysisModelProcessor = null;

                    project.BeginTransactionInNewTerr();
                    try
                    {
                        Assert.ThrowsDelegate d = () =>
                        {
                            analysisModelProcessor = CyPhyMasterInterpreter.AnalysisModelProcessor.GetAnalysisModelProcessor(subject as MgaModel);
                        };

                        MgaObject parent = null;
                        GME.MGA.Meta.objtype_enum type;
                        subject.GetParent(out parent, out type);

                        var contextSupportExpected = parent.Name.ToLowerInvariant() == "invalid" ? false : true;
                        if (contextSupportExpected)
                        {
                            Assert.DoesNotThrow(d);
                            Assert.True(analysisModelProcessor != null, string.Format("Analysis model processor was not able to create the model processor for {0} {1}.", subject.Name, subject.Meta.Name));

                            if (subject.Name.Contains(analysisModelProcessor.GetType().Name))
                            {
                                numSuccess++;
                                Console.Out.WriteLine("[Passed] {0} was created for test bench {1} [{2}]", analysisModelProcessor.GetType().Name, subject.Name, subject.Meta.Name);
                            }
                            else
                            {
                                success = false;
                                numFailures++;
                                Console.Out.WriteLine("[Failed] {0} was created for test bench {1} [{2}]", analysisModelProcessor.GetType().Name, subject.Name, subject.Meta.Name);
                            }
                        }
                        else
                        {
                            Assert.Throws<CyPhyMasterInterpreter.AnalysisModelContextNotSupportedException>(d);
                            numSuccess++;
                            Console.Out.WriteLine("[Passed] Context not supported {0} [{1}]", subject.Name, subject.Meta.Name);
                        }
                    }
                    finally
                    {
                        project.AbortTransaction();
                    }
                }

                if (success)
                {
                    Console.Out.WriteLine("[OK] Analysis model processor creation was checked for: {0}, Success: {1}, Failed: {2}", numContexts, numSuccess, numFailures);
                }
                else
                {
                    Console.Error.WriteLine("[FAILED] Analysis model processor creation was checked for: {0}, Success: {1}, Failed: {2}", numContexts, numSuccess, numFailures);
                }

                Assert.True(success, "At least one analysis model processor was not instantiated as expected.");

            }
            finally
            {
                project.Close(true);
            }



        }
Beispiel #23
0
        //[Fact]
        public void TestCodeSample()
        {
            string ProjectConnStr;

            MgaUtils.ImportXMEForTest(Path.GetFullPath(@"..\..\..\..\models\DynamicsTeam\MasterInterpreter\MasterInterpreter.xme"), out ProjectConnStr);

            MgaProject project = new MgaProject();
            bool       ro_mode;

            project.Open(ProjectConnStr, out ro_mode);

            MgaHelper.CheckParadigmVersionUpgrade(project);

            try
            {
                List <IMgaFCO> objectsToCheck = null;

                project.BeginTransactionInNewTerr();
                try
                {
                    // discover objects

                    var allObjects = project
                                     .RootFolder
                                     .ChildFolders
                                     .Cast <MgaFolder>()
                                     .Where(x => x.Name.StartsWith("0"))
                                     .SelectMany(x => x.GetDescendantFCOs(project.CreateFilter()).Cast <IMgaFCO>())
                                     .Where(x => x.RootFCO == x);

                    // get all objects from folders starts with 0 within the root folder.
                    objectsToCheck = allObjects.Where(x => x.AbsPath.Contains("ProcessorTypesForContexts")).ToList();

                    objectsToCheck.Sort((x, y) =>
                    {
                        return(x.Meta.Name.CompareTo(y.Meta.Name) != 0 ?
                               x.Meta.Name.CompareTo(y.Meta.Name) :
                               x.AbsPath.CompareTo(y.AbsPath));
                    });
                }
                finally
                {
                    project.AbortTransaction();
                }

                Assert.True(objectsToCheck != null, "There are no object in the project that has to be checked.");

                int numContexts = objectsToCheck.Count;
                int numSuccess  = 0;
                int numFailures = 0;

                bool success = true;

                foreach (var subject in objectsToCheck)
                {
                    // single test
                    CyPhyMasterInterpreter.AnalysisModelProcessor analysisModelProcessor = null;

                    project.BeginTransactionInNewTerr();
                    try
                    {
                        Assert.ThrowsDelegate d = () =>
                        {
                            analysisModelProcessor = CyPhyMasterInterpreter.AnalysisModelProcessor.GetAnalysisModelProcessor(subject as MgaModel);
                        };

                        MgaObject parent = null;
                        GME.MGA.Meta.objtype_enum type;
                        subject.GetParent(out parent, out type);

                        var contextSupportExpected = parent.Name.ToLowerInvariant() == "invalid" ? false : true;
                        if (contextSupportExpected)
                        {
                            Assert.DoesNotThrow(d);
                            Assert.True(analysisModelProcessor != null, string.Format("Analysis model processor was not able to create the model processor for {0} {1}.", subject.Name, subject.Meta.Name));

                            if (subject.Name.Contains(analysisModelProcessor.GetType().Name))
                            {
                                numSuccess++;
                                Console.Out.WriteLine("[Passed] {0} was created for test bench {1} [{2}]", analysisModelProcessor.GetType().Name, subject.Name, subject.Meta.Name);
                            }
                            else
                            {
                                success = false;
                                numFailures++;
                                Console.Out.WriteLine("[Failed] {0} was created for test bench {1} [{2}]", analysisModelProcessor.GetType().Name, subject.Name, subject.Meta.Name);
                            }
                        }
                        else
                        {
                            Assert.Throws <CyPhyMasterInterpreter.AnalysisModelContextNotSupportedException>(d);
                            numSuccess++;
                            Console.Out.WriteLine("[Passed] Context not supported {0} [{1}]", subject.Name, subject.Meta.Name);
                        }
                    }
                    finally
                    {
                        project.AbortTransaction();
                    }
                }

                if (success)
                {
                    Console.Out.WriteLine("[OK] Analysis model processor creation was checked for: {0}, Success: {1}, Failed: {2}", numContexts, numSuccess, numFailures);
                }
                else
                {
                    Console.Error.WriteLine("[FAILED] Analysis model processor creation was checked for: {0}, Success: {1}, Failed: {2}", numContexts, numSuccess, numFailures);
                }

                Assert.True(success, "At least one analysis model processor was not instantiated as expected.");
            }
            finally
            {
                project.Close(true);
            }
        }
Beispiel #24
0
        //[Fact]
        public void TestCodeSample()
        {
            string ProjectConnStr;

            MgaUtils.ImportXMEForTest(Path.GetFullPath(@"..\..\..\..\models\DynamicsTeam\MasterInterpreter\MasterInterpreter.xme"), out ProjectConnStr);

            MgaProject project = new MgaProject();
            bool       ro_mode;

            project.Open(ProjectConnStr, out ro_mode);

            MgaHelper.CheckParadigmVersionUpgrade(project);

            try
            {
                List <IMgaFCO> objectsToGetConfigurations = null;

                project.BeginTransactionInNewTerr();
                try
                {
                    // discover objects

                    var allObjects = project
                                     .RootFolder
                                     .ChildFolders
                                     .Cast <MgaFolder>()
                                     .Where(x => x.Name.StartsWith("0"))
                                     .SelectMany(x => x.GetDescendantFCOs(project.CreateFilter()).Cast <IMgaFCO>())
                                     .Where(x => x.RootFCO == x);

                    // get all objects from folders starts with 0 within the root folder.
                    objectsToGetConfigurations = allObjects.Where(x => x.AbsPath.Contains("TestingGetConfigurations")).ToList();

                    objectsToGetConfigurations.Sort((x, y) =>
                    {
                        return(x.Meta.Name.CompareTo(y.Meta.Name) != 0 ?
                               x.Meta.Name.CompareTo(y.Meta.Name) :
                               x.AbsPath.CompareTo(y.AbsPath));
                    });
                }
                finally
                {
                    project.AbortTransaction();
                }

                Assert.True(objectsToGetConfigurations != null, "There are no object in the project that has to be checked.");

                int numContexts = objectsToGetConfigurations.Count;
                int numSuccess  = 0;
                int numFailures = 0;

                bool success = true;

                foreach (var subject in objectsToGetConfigurations)
                {
                    // single test
                    using (var masterInterpreter = new CyPhyMasterInterpreter.CyPhyMasterInterpreterAPI(project))
                    {
                        IMgaFCOs configurations = null;

                        Assert.ThrowsDelegate d = () =>
                        {
                            configurations = masterInterpreter.GetConfigurations(subject as MgaModel);
                        };

                        Assert.DoesNotThrow(d);
                        //Assert.True(configurations != null, "GetConfiguration returned with null.");

                        if (configurations == null)
                        {
                            numFailures++;
                        }
                        else
                        {
                            numSuccess++;
                        }

                        // print out nicely in the GME console
                        project.BeginTransactionInNewTerr();
                        try
                        {
                            Console.Out.WriteLine("{0} [{1}] has {2} configurations.", subject.Name, subject.Meta.Name, configurations.Count);
                            foreach (IMgaFCO configuration in configurations)
                            {
                                Console.Out.WriteLine(" > {0} - {1}", configuration.Name, configuration.ID);
                            }
                        }
                        finally
                        {
                            project.AbortTransaction();
                        }
                    }
                }

                if (success)
                {
                    Console.Out.WriteLine("[OK] Got configurations for: {0} test benches. Success: {1}, Failed {2}", numContexts, numSuccess, numFailures);
                }
                else
                {
                    Console.Error.WriteLine("[FAILED] Tried to get configurations for: {0} test benches. Success: {1}, Failed {2}", numContexts, numSuccess, numFailures);
                }

                Assert.True(success, "At least one context was failed to check against the expected results.");
            }
            finally
            {
                project.Close(true);
            }
        }
        public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
        {
			// Get RootFolder
			IMgaFolder rootFolder = project.RootFolder;

            #region Prompt for Output Path
            // Get an output path from the user.
            String s_outPath;
            using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog()
            {
                Description = "Choose a path for the generated files.",
                //ShowNewFolderButton = true,
                SelectedPath = Environment.CurrentDirectory,
            })
            {

                DialogResult dr = fbd.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    s_outPath = fbd.SelectedPath;
                }
                else
                {
                    GMEConsole.Warning.WriteLine("Design Exporter cancelled");
                    return;
                }
            }
            #endregion

            GMEConsole.Info.WriteLine("Beginning Export...");
            var testBanches = new List<CyPhy.TestBench>();

            if (currentobj != null &&
                currentobj.Meta.Name == "TestBench")
            {
                testBanches.Add(CyPhyClasses.TestBench.Cast(currentobj));
            }
            else if (selectedobjs.Count > 0)
            {
                foreach (MgaFCO mf in selectedobjs)
                {
                    if (mf.Meta.Name == "TestBench")
                    {
                        testBanches.Add(CyPhyClasses.TestBench.Cast(mf));
                    }
                }
            }
            else
            {
                CyPhy.RootFolder root = ISIS.GME.Common.Utils.CreateObject<CyPhyClasses.RootFolder>(project.RootFolder as MgaObject);

                MgaFilter filter = project.CreateFilter();
                filter.Kind = "TestBench";
                foreach (var item in project.AllFCOs(filter).Cast<MgaFCO>())
                {
                    if (item.ParentFolder != null)
                    {
                        testBanches.Add(CyPhyClasses.TestBench.Cast(item));
                    }
                }
            }

            foreach (var tb in testBanches)
            {
                System.Windows.Forms.Application.DoEvents();
                try
                {
                    ExportToFile(tb, s_outPath);
                }
                catch (Exception ex)
                {
                    GMEConsole.Error.WriteLine("{0}: Exception encountered ({1})", tb.Name, ex.Message);
                }
                GMEConsole.Info.WriteLine("{0}: {1}", tb.Name, s_outPath);
            }

        }
        public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
        {
            Boolean disposeLogger = false;
            if (Logger == null)
            {
                Logger = new CyPhyGUIs.GMELogger(project, "CyPhyDesignExporter");
                disposeLogger = true;
            }

            // TODO: Add your interpreter code
            Logger.WriteInfo("Running Design Exporter...");

            #region Prompt for Output Path
            // Get an output path from the user.
            if (this.OutputDir == null)
            {
                using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog()
                {
                    Description = "Choose a path for the generated files.",
                    //ShowNewFolderButton = true,
                    SelectedPath = Environment.CurrentDirectory,
                })
                {

                    DialogResult dr = fbd.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        OutputDir = fbd.SelectedPath;
                    }
                    else
                    {
                        Logger.WriteWarning("Design Exporter cancelled");
                        return;
                    }
                }
            }
            #endregion

            Logger.WriteInfo("Beginning Export...");
            List<CyPhy.DesignEntity> lde_allCAandDC = new List<CyPhy.DesignEntity>();
            List<CyPhy.TestBenchType> ltbt_allTB = new List<CyPhy.TestBenchType>();
            
            if (currentobj != null && 
                currentobj.Meta.Name == "ComponentAssembly")
            {
                lde_allCAandDC.Add(CyPhyClasses.ComponentAssembly.Cast(currentobj));
            }
            else if (currentobj != null &&
                     currentobj.Meta.Name == "DesignContainer")
            {
                lde_allCAandDC.Add(CyPhyClasses.DesignContainer.Cast(currentobj));
            }
            else if (currentobj != null &&
                IsTestBenchType(currentobj.MetaBase.Name))
            {
                ltbt_allTB.Add(CyPhyClasses.TestBenchType.Cast(currentobj));
            }
            else if (selectedobjs != null && selectedobjs.Count > 0)
            {
                foreach (MgaFCO mf in selectedobjs)
                {
                    if (mf.Meta.Name == "ComponentAssembly")
                    {
                        lde_allCAandDC.Add(CyPhyClasses.ComponentAssembly.Cast(mf));
                    }
                    else if (mf.Meta.Name == "DesignContainer")
                    {
                        lde_allCAandDC.Add(CyPhyClasses.DesignContainer.Cast(mf));
                    }
                    else if (IsTestBenchType(mf.MetaBase.Name))
                    {
                        ltbt_allTB.Add(CyPhyClasses.TestBenchType.Cast(mf));
                    }
                }
            }
            else
            {
                CyPhy.RootFolder rootFolder = ISIS.GME.Common.Utils.CreateObject<CyPhyClasses.RootFolder>(project.RootFolder as MgaObject);

                MgaFilter filter = project.CreateFilter();
                filter.Kind = "ComponentAssembly";
                foreach (var item in project.AllFCOs(filter).Cast<MgaFCO>())
                {
                    if (item.ParentFolder != null)
                    {
                        lde_allCAandDC.Add(CyPhyClasses.ComponentAssembly.Cast(item));
                    }
                }

                filter = project.CreateFilter();
                filter.Kind = "DesignContainer";
                foreach (var item in project.AllFCOs(filter).Cast<MgaFCO>())
                {
                    if (item.ParentFolder != null)
                    {
                        lde_allCAandDC.Add(CyPhyClasses.DesignContainer.Cast(item));
                    }
                }

                filter = project.CreateFilter();
                filter.Kind = "TestBenchType";
                foreach (var item in project.AllFCOs(filter).Cast<MgaFCO>())
                {
                    if (item.ParentFolder != null)
                    {
                        ltbt_allTB.Add(CyPhyClasses.TestBenchType.Cast(item));
                    }
                }
            }

            foreach (CyPhy.DesignEntity de in lde_allCAandDC)
            {
                System.Windows.Forms.Application.DoEvents();
                try
                {
                    if (de is CyPhy.ComponentAssembly)
                    {
                        ExportToPackage(de as CyPhy.ComponentAssembly, OutputDir);
                    }
                    else
                    {
                        ExportToFile(de, OutputDir);
                    }
                } 
                catch (Exception ex) 
                {
                    Logger.WriteError("{0}: Exception encountered ({1})",de.Name,ex.Message);
                }
                Logger.WriteInfo("{0}: {1}", de.Name, OutputDir);
            }

            foreach (CyPhy.TestBenchType tbt in ltbt_allTB)
            {
                System.Windows.Forms.Application.DoEvents();
                try
                {
                    ExportToFile(tbt, OutputDir);
                }
                catch (Exception ex)
                {
                    Logger.WriteError("{0}: Exception encountered ({1})", tbt.Name, ex.Message);
                }
                Logger.WriteInfo("{0}: {1}", tbt.Name, OutputDir);
            }

            Logger.WriteInfo(String.Format("{0} model(s) exported", lde_allCAandDC.Count + ltbt_allTB.Count));
            Logger.WriteInfo("Design Exporter finished");

            if (disposeLogger)
            {
                DisposeLogger();
            }
        }
Beispiel #27
0
        //[Fact]
        public void TestCodeSample()
        {
            string ProjectConnStr;

            MgaUtils.ImportXMEForTest(Path.GetFullPath(@"..\..\..\..\models\DynamicsTeam\MasterInterpreter\MasterInterpreter.xme"), out ProjectConnStr);

            MgaProject project = new MgaProject();
            bool       ro_mode;

            project.Open(ProjectConnStr, out ro_mode);

            MgaHelper.CheckParadigmVersionUpgrade(project);

            try
            {
                List <IMgaFCO> objectsToCheck = null;

                project.BeginTransactionInNewTerr();
                try
                {
                    // discover objects

                    var allObjects = project
                                     .RootFolder
                                     .ChildFolders
                                     .Cast <MgaFolder>()
                                     .Where(x => x.Name.StartsWith("0"))
                                     .SelectMany(x => x.GetDescendantFCOs(project.CreateFilter()).Cast <IMgaFCO>())
                                     .Where(x => x.RootFCO == x);

                    // get all objects from folders starts with 0 within the root folder.
                    objectsToCheck = allObjects.Where(x => x.AbsPath.Contains("TestingContextChecker") && x.Name.Contains("ReadOnly") == false).ToList();

                    objectsToCheck.Sort((x, y) =>
                    {
                        return(x.Meta.Name.CompareTo(y.Meta.Name) != 0 ?
                               x.Meta.Name.CompareTo(y.Meta.Name) :
                               x.AbsPath.CompareTo(y.AbsPath));
                    });
                }
                finally
                {
                    project.AbortTransaction();
                }

                Assert.True(objectsToCheck != null, "There are no object in the project that has to be checked.");

                int numContexts = objectsToCheck.Count;
                int numSuccess  = 0;
                int numFailures = 0;

                bool success = true;

                foreach (var subject in objectsToCheck)
                {
                    // single test
                    using (var masterInterpreter = new CyPhyMasterInterpreter.CyPhyMasterInterpreterAPI(project))
                    {
                        CyPhyMasterInterpreter.Rules.ContextCheckerResult[] contextCheckerResults = null;

                        // check context
                        var checkerSuccess = masterInterpreter.TryCheckContext(subject as MgaModel, out contextCheckerResults);

                        List <CyPhyMasterInterpreter.Rules.ContextCheckerResult> sortedResults = contextCheckerResults.ToList();

                        // sort results Passed, Failed, then alphabetically based on message.
                        sortedResults.Sort((x, y) => { return(x.Success == y.Success ? x.Message.CompareTo(y.Message) : y.Success.CompareTo(x.Success)); });

                        project.BeginTransactionInNewTerr();
                        try
                        {
                            MgaObject parent = null;
                            GME.MGA.Meta.objtype_enum type;
                            subject.GetParent(out parent, out type);

                            var successExpected = parent.Name.ToLowerInvariant() == "invalid" ? false : true;

                            if (successExpected == checkerSuccess)
                            {
                                numSuccess++;
                                //GMEConsole.Info.WriteLine("OK");
                            }
                            else
                            {
                                success = false;

                                foreach (var result in sortedResults)
                                {
                                    TextWriter    tw = null;
                                    StringBuilder sb = new StringBuilder();
                                    if (result.Success)
                                    {
                                        sb.Append("[Passed]");
                                        tw = Console.Out;
                                    }
                                    else
                                    {
                                        sb.Append("[Failed]");
                                        tw = Console.Error;
                                    }

                                    sb.AppendFormat(" {0} - {1} ", result.Subject.Name, result.Subject.AbsPath);

                                    sb.Append(result.Message);

                                    tw.WriteLine(sb);
                                }

                                numFailures++;
                                Console.Error.WriteLine("========= FAILED ==========");
                                Console.Error.WriteLine("= {0}", subject.Name);
                                Console.Error.WriteLine("= {0}", subject.AbsPath);
                                Console.Error.WriteLine("===========================");
                            }
                        }
                        finally
                        {
                            project.AbortTransaction();
                        }
                    }
                }

                if (success)
                {
                    Console.Out.WriteLine("[OK] Checked contexts: {0}, Success: {1}, Failed: {2}", numContexts, numSuccess, numFailures);
                }
                else
                {
                    Console.Error.WriteLine("[FAILED] Checked contexts: {0}, Success: {1}, Failed: {2}", numContexts, numSuccess, numFailures);
                }

                Assert.True(success, "At least one context was failed to check against the expected results.");
            }
            finally
            {
                project.Close(true);
            }
        }
Beispiel #28
0
        public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
        {
            // TODO: show how to initialize DSML-generated classes

            myMig = new myMigrator(project);
            mig = new Migrator(project);

            if (currentobj != null)
            {
                if (currentobj is MgaModel)
                {
                    GMEConsole.Info.WriteLine(
                        "Migrating {0}... (To migrate the whole project, close all models and try again)",
                        currentobj.Name);

                    //myMig.migrateModel(currentobj as MgaModel);
                    mig.findOldPortTypes(project, false);

                    try
                    {
                        mig.migrateModel(currentobj as MgaModel);
                    }
                    catch (Exception ex)
                    {
                        GMEConsole.Error.WriteLine("{0}", ex.Message);
                        GMEConsole.Info.WriteLine("{0}", ex.StackTrace);
                    }
                }
            }
            else
            {
                //mig.convertFluidParameters(project);

                GMEConsole.Info.WriteLine("Migrating the entire project...");
                myMig.migrateProject();

                mig.findOldPortTypes(project, false);
                mig.migrateCyPhy2ModelicaWorkflow(project);

                List<string> kinds = new List<string>()
                    {
                        "TestBench",
                        "ComponentAssembly",
                        "DesignContainer",
                        "TestComponent",
                        "Component",
                        "Environment"
                    };

                MgaFilter cyPhyModelFilter = project.CreateFilter();

                cyPhyModelFilter.ObjType = objtype_enum.OBJTYPE_MODEL.ToString();

                var objectsToMigrate = project
                    .AllFCOs(cyPhyModelFilter)
                    .OfType<MgaModel>()
                    .Where(x => x.ParentModel == null &&
                        kinds.Contains(x.Meta.Name));

                foreach (var objectToMigrate in objectsToMigrate)
                {
                    //GMEConsole.Info.WriteLine(
                    //    "== Migrating <a href=\"mga:{0}\">{1}</a>",
                    //    objectToMigrate.ID,
                    //    objectToMigrate.Name);
                    try
                    {
                        mig.migrateModel(objectToMigrate);
                    }
                    catch (Exception ex)
                    {
                        GMEConsole.Error.WriteLine("{0}", ex.Message);
                        GMEConsole.Info.WriteLine("{0}", ex.StackTrace);
                    }

                }
            }
        }
        public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
        {
            if (currentobj == null)
            {
                GMEConsole.Error.WriteLine("Please open a TestBench to run {0}.", ComponentName);
                return;
            }
            else if (currentobj.Meta.Name != "TestBench")
            {
                GMEConsole.Error.WriteLine("Please open a TestBench to run {0}.", ComponentName);
                return;
            }

            GMEConsole.Info.WriteLine("Running {0} on TestBench '{1}'", ComponentName, currentobj.Name);

            // get root folder
            IMgaFolder rootFolder = project.RootFolder;

            // create a filter for components
            MgaFilter filter = project.CreateFilter();

            filter.Kind = "Component";

            // get all components
            var components = project.AllFCOs(filter).OfType <IMgaModel>().Cast <IMgaModel>().ToList();

            // store components that may have an option (e.g. MM1, MM2)
            List <IMgaModel> componentsToShow = new List <IMgaModel>();

            // iterate through all components
            // select only those which has more than one modelica model in it
            foreach (var component in components)
            {
                var modelicaModels = component.ChildFCOs.Cast <IMgaFCO>().Where(x => x.Meta.Name == "ModelicaModel");
                if (modelicaModels.Count() > 1)
                {
                    componentsToShow.Add(component);
                }
            }

            using (FidelitySelectorForm fsf = new FidelitySelectorForm())
            {
                // show the form for the user
                foreach (var component in componentsToShow)
                {
                    if (fsf.componentItems.FirstOrDefault(
                            x => x.Classification == component.StrAttrByName["Classifications"]) == null)
                    {
                        fsf.componentItems.Add(new ComponentItem(component));
                    }
                }

                // get the current fidelity settings from the Testbench registry
                fsf.FidelitySettings = currentobj.RegistryValue["FidelitySettings"];

                fsf.PopulateDgv();
                fsf.ShowDialog();

                foreach (string msg in fsf.consoleMessages)
                {
                    GMEConsole.Info.WriteLine(msg);
                }

                // Check where the new fidelity settings should be applied:
                if (fsf.rbThisTestbench.Checked)
                {
                    // Write the updated fidelity settings back to the Testbench registry
                    currentobj.RegistryValue["FidelitySettings"] = fsf.FidelitySettings;
                }
                else if (fsf.rbThisFolder.Checked)
                {
                    // Get all testbenches in the same folder as currentobj
                    var thisTestingFolder = currentobj.ParentFolder;
                    var siblingTBs        =
                        thisTestingFolder.ChildFCOs.Cast <IMgaFCO>().Where(x => x.Meta.Name == "TestBench").ToList();

                    GMEConsole.Info.WriteLine(
                        "Applying these FidelitySettings to all TestBenches in folder '{0}':", thisTestingFolder.Name);

                    // Go through each one and set the fidelity settings
                    foreach (MgaFCO testbench in siblingTBs)
                    {
                        testbench.RegistryValue["FidelitySettings"] = fsf.FidelitySettings;

                        GMEConsole.Info.WriteLine("=> {0}", testbench.Name);
                    }
                }
                else if (fsf.rbThisProject.Checked)
                {
                    // Get all testbenches in the entire project
                    MgaFilter testbenchFilter = project.CreateFilter();
                    testbenchFilter.Kind = "TestBench";

                    // get all testbenches
                    var testbenches = project.AllFCOs(testbenchFilter).OfType <IMgaModel>().Cast <IMgaModel>().ToList();

                    GMEConsole.Info.WriteLine(
                        "Applying these FidelitySettings to all TestBenches in project '{0}':", project.Name);

                    // Go through each one and set the fidelity settings
                    foreach (MgaFCO testbench in testbenches)
                    {
                        testbench.RegistryValue["FidelitySettings"] = fsf.FidelitySettings;

                        GMEConsole.Info.WriteLine("=> {0}", testbench.Name);
                    }
                }
            }


            GMEConsole.Info.WriteLine("{0} finished.", ComponentName);
        }
Beispiel #30
0
        void TestSubTreeMergeModel()
        {
            string mgaFileCopy = mgaFile + "copy.mga";

            File.Copy(mgaFile, mgaFile + "copy.mga", true);
            MgaProject project = new MgaProject();

            project.OpenEx("MGA=" + this.mgaFile, "CyPhyML", null);
            try
            {
                project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_NON_NESTED);
                try
                {
                    string mergeMeModelPath       = "/@ComponentAssemblies/@MergeMe";
                    MgaFCO mergeMe                = (MgaFCO)project.ObjectByPath[mergeMeModelPath];
                    int    startingDescendantFCOs = ((MgaModel)mergeMe).GetDescendantFCOs(mergeMe.Project.CreateFilter()).Count;

                    var fcos = ((MgaModel)mergeMe).GetDescendantFCOs(project.CreateFilter()).Cast <MgaFCO>().Select(
                        x => x.AbsPath).ToList();

                    foreach (MgaObject obj in mergeMe.ChildObjects)
                    {
                        if (obj.MetaBase.Name != "Connector" && obj.MetaBase.Name != "Axis" && /* keep these, since they have refport connections*/
                            obj.Status == (int)objectstatus_enum.OBJECT_EXISTS /* connections may be deleted when their endpoints are */)
                        {
                            obj.DestroyObject();
                        }
                    }

                    var subTreeMerge = new SubTreeMerge.SubTreeMerge();
                    subTreeMerge.merge(mergeMe, mgaFileCopy);
                    Assert.Equal(SubTreeMerge.SubTreeMerge.Errors.NoError, subTreeMerge.exitStatus);
                    MgaFCO newMergeMe = (MgaFCO)project.ObjectByPath[mergeMeModelPath];

                    Assert.Equal(newMergeMe.ID, ((MgaReference)project.ObjectByPath["/@ComponentAssemblies/@AsmWithRef/@MergeMe"]).Referred.ID);
                    Assert.Equal(newMergeMe.ID, ((MgaReference)project.ObjectByPath["/@Testing/@TestBench/@MergeMe"]).Referred.ID);
                    Assert.Equal(2, ((MgaReference)project.ObjectByPath["/@ComponentAssemblies/@AsmWithRef/@MergeMe"]).UsedByConns.Count);
                    Assert.Equal(2, ((MgaReference)project.ObjectByPath["/@Testing/@TestBench/@MergeMe"]).UsedByConns.Count);
                    //Debugging:
                    //var fcos2 = ((MgaModel)newMergeMe).GetDescendantFCOs(project.CreateFilter()).Cast<MgaFCO>().Select(x => x.AbsPath)
                    //    .Where(x => fcos.Contains(x) == false);
                    //HashSet<string> originalObjects = new HashSet<string>();
                    //foreach (string abspath in fcos)
                    //    originalObjects.Add(abspath);
                    //foreach (string abspath in ((MgaModel)newMergeMe).GetDescendantFCOs(project.CreateFilter()).Cast<IMgaFCO>().Select(x => x.AbsPath))
                    //    originalObjects.Remove(abspath);
                    // Console.Out.WriteLine(string.Join("\n", originalObjects));
                    Assert.Equal(startingDescendantFCOs, ((MgaModel)newMergeMe).GetDescendantFCOs(project.CreateFilter()).Count);
                }
                finally
                {
                    project.CommitTransaction();
                }
            }
            finally
            {
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    project.Save(project.ProjectConnStr + "_testoutput.mga", true);
                }
                project.Close(true);
            }
        }
Beispiel #31
0
 protected MgaFCO GetTestAssembly(MgaProject project)
 {
     var filter = project.CreateFilter();
     filter.Kind = "ComponentAssembly";
     return project.AllFCOs(filter).Cast<MgaFCO>().Where(fco => fco.GetGuidDisp() == new Guid(testAssemblyId).ToString("B")).First();
 }
Beispiel #32
0
        public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
        {
            if (currentobj == null)
            {
                GMEConsole.Error.WriteLine("Please open a TestBench to run {0}.", ComponentName);
                return;
            }
            else if (currentobj.Meta.Name != "TestBench")
            {
                GMEConsole.Error.WriteLine("Please open a TestBench to run {0}.", ComponentName);
                return;
            }

            GMEConsole.Info.WriteLine("Running {0} on TestBench '{1}'", ComponentName, currentobj.Name);

            // get root folder
            IMgaFolder rootFolder = project.RootFolder;

            this.currentobj = ISIS.GME.Dsml.CyPhyML.Classes.TestBench.Cast(currentobj);
            this.sut        = this.currentobj.Children.TopLevelSystemUnderTestCollection.First();

            MgaReference workflowRef = ((MgaModel)currentobj).ChildFCOs.Cast <MgaFCO>().Where(fco => fco.Meta.Name == "WorkflowRef").FirstOrDefault() as MgaReference;
            MgaFCO       spiceTask   = null;

            if (workflowRef != null && workflowRef.Referred != null)
            {
                foreach (var task in ((MgaModel)workflowRef.Referred).ChildFCOs.Cast <MgaFCO>().Where(fco => fco.Meta.Name == "Task"))
                {
                    if (task.GetStrAttrByNameDisp("COMName").Equals("MGA.Interpreter.CyPhy2Schematic", StringComparison.InvariantCultureIgnoreCase))
                    {
                        spiceTask = task;
                    }
                }
            }
            if (spiceTask != null)
            {
                DoSpiceFidelitySelection(currentobj);
                return;
            }

            // create a filter for components
            MgaFilter filter = project.CreateFilter();

            filter.Kind = "Component";

            // get all components
            var components = project.AllFCOs(filter).OfType <IMgaModel>().Cast <IMgaModel>().ToList();

            // store components that may have an option (e.g. MM1, MM2)
            List <IMgaModel> componentsToShow = new List <IMgaModel>();

            // iterate through all components
            // select only those which has more than one modelica model in it
            foreach (var component in components)
            {
                var modelicaModels = component.ChildFCOs.Cast <IMgaFCO>().Where(x => x.Meta.Name == "ModelicaModel");
                if (modelicaModels.Count() > 1)
                {
                    componentsToShow.Add(component);
                }
            }

            using (FidelitySelectorForm fsf = new FidelitySelectorForm())
            {
                // show the form for the user
                foreach (var component in componentsToShow)
                {
                    if (fsf.componentItems.FirstOrDefault(
                            x => x.Classification == component.StrAttrByName["Classifications"]) == null)
                    {
                        fsf.componentItems.Add(new ComponentItem(component));
                    }
                }

                // get the current fidelity settings from the Testbench registry
                fsf.FidelitySettings = currentobj.RegistryValue["FidelitySettings"];

                fsf.PopulateDgv();
                fsf.ShowDialog();

                foreach (string msg in fsf.consoleMessages)
                {
                    GMEConsole.Info.WriteLine(msg);
                }

                // Check where the new fidelity settings should be applied:
                if (fsf.rbThisTestbench.Checked)
                {
                    // Write the updated fidelity settings back to the Testbench registry
                    currentobj.RegistryValue["FidelitySettings"] = fsf.FidelitySettings;
                }
                else if (fsf.rbThisFolder.Checked)
                {
                    // Get all testbenches in the same folder as currentobj
                    var thisTestingFolder = currentobj.ParentFolder;
                    var siblingTBs        =
                        thisTestingFolder.ChildFCOs.Cast <IMgaFCO>().Where(x => x.Meta.Name == "TestBench").ToList();

                    GMEConsole.Info.WriteLine(
                        "Applying these FidelitySettings to all TestBenches in folder '{0}':", thisTestingFolder.Name);

                    // Go through each one and set the fidelity settings
                    foreach (MgaFCO testbench in siblingTBs)
                    {
                        testbench.RegistryValue["FidelitySettings"] = fsf.FidelitySettings;

                        GMEConsole.Info.WriteLine("=> {0}", testbench.Name);
                    }
                }
                else if (fsf.rbThisProject.Checked)
                {
                    // Get all testbenches in the entire project
                    MgaFilter testbenchFilter = project.CreateFilter();
                    testbenchFilter.Kind = "TestBench";

                    // get all testbenches
                    var testbenches = project.AllFCOs(testbenchFilter).OfType <IMgaModel>().Cast <IMgaModel>().ToList();

                    GMEConsole.Info.WriteLine(
                        "Applying these FidelitySettings to all TestBenches in project '{0}':", project.Name);

                    // Go through each one and set the fidelity settings
                    foreach (MgaFCO testbench in testbenches)
                    {
                        testbench.RegistryValue["FidelitySettings"] = fsf.FidelitySettings;

                        GMEConsole.Info.WriteLine("=> {0}", testbench.Name);
                    }
                }
            }


            GMEConsole.Info.WriteLine("{0} finished.", ComponentName);
        }