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