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());
        }
Exemple #2
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);
        }
Exemple #3
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)));
        }
Exemple #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)));
        }
Exemple #5
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"));
        }
Exemple #6
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);
                }
            }
        }
Exemple #7
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)
        {
            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);
        }
        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);
        }
        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);
                }
            }
        }
        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());
        }
Exemple #15
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)
        {
			// 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 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);
        }
Exemple #18
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);
            }
        }
Exemple #19
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);
                    }
                }
            }
        }
Exemple #20
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();
 }
Exemple #21
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);
        }