当前位置: 首页>>代码示例>>C#>>正文


C# MgaProject.AllFCOs方法代码示例

本文整理汇总了C#中MgaProject.AllFCOs方法的典型用法代码示例。如果您正苦于以下问题:C# MgaProject.AllFCOs方法的具体用法?C# MgaProject.AllFCOs怎么用?C# MgaProject.AllFCOs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MgaProject的用法示例。


在下文中一共展示了MgaProject.AllFCOs方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: convertFluidParameters

        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);
                }
            }
        }
开发者ID:neemask,项目名称:meta-core,代码行数:43,代码来源:Migrator.cs

示例2: GetTestAssembly

 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();
 }
开发者ID:neemask,项目名称:meta-core,代码行数:6,代码来源:MetaLinkTestBase.cs

示例3: Main

        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
//.........这里部分代码省略.........
开发者ID:metamorph-inc,项目名称:meta-core,代码行数:101,代码来源:CyPhyComponentFidelitySelector.cs

示例4: Main

        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);
            }

        }
开发者ID:metamorph-inc,项目名称:meta-core,代码行数:77,代码来源:CyPhyTestBenchExporter.cs

示例5: Main

        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);
                    }

                }
            }
        }
开发者ID:neemask,项目名称:meta-core,代码行数:78,代码来源:ModelMigrator.cs

示例6: Main

        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();
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:101,代码来源:CyPhyDesignExporter.cs

示例7: getObjectsByFilter

        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"] },
            };
        }
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:95,代码来源:Migrator.cs

示例8: migrateCyPhy2ModelicaWorkflow

        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";
                }
            }

        }
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:19,代码来源:Migrator.cs

示例9: DeleteAllOldTypes

        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);
                }
            }
        }
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:82,代码来源:Migrator.cs

示例10: findOldPortTypes

        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());
        }
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:46,代码来源:Migrator.cs


注:本文中的MgaProject.AllFCOs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。