public MainForm(CyPhy2CADSettings settings, bool automated = false, bool prepareifab = false) { InitializeComponent(); ConfigOptions = settings; // Enable/Disable controls // [1] automated --> outputdir textbox readonly, outputdir button disabled // [2] prepareifab --> step formats readonly if (automated) { textBox_OutputDir.ReadOnly = true; button_OutputDir.Enabled = false; } else { textBox_OutputDir.Text = ConfigOptions==null?"":ConfigOptions.OutputDirectory; } textBox_AuxiliaryDir.Text = ConfigOptions.AuxiliaryDirectory; // PrepareIFab: 1 step formats selected // Other: config file if (prepareifab) { SetCheckListBoxItem("AP203_E2_Separate_Part_Files"); clb_Step.Enabled = false; } else if (automated) { if (ConfigOptions.StepFormats.Count == 0) { SetCheckListBoxItem("AP203_E2_Single_File"); SetCheckListBoxItem("AP203_E2_Separate_Part_Files"); } else { foreach (var checkListBoxItem in settings.StepFormats) { SetCheckListBoxItem(checkListBoxItem); } } } else { for (int i = 0; i < ConfigOptions.StepFormats.Count; i++) SetCheckListBoxItem(ConfigOptions.StepFormats[i]); } }
private void FetchSettings() { string projectDirectory = ""; if (mainParameters != null) { projectDirectory = mainParameters.ProjectDirectory; } var config = META.ComComponent.DeserializeConfiguration(projectDirectory, typeof(CyPhy2CADSettings), this.ComponentProgID) as CyPhy2CADSettings; settings = config; if (settings == null) { settings = new CyPhy2CADSettings(); } }
public MainForm(CyPhy2CADSettings settings, bool automated = false, bool prepareifab = false) { InitializeComponent(); ConfigOptions = settings; // Enable/Disable controls // [1] automated --> outputdir textbox readonly, outputdir button disabled // [2] prepareifab --> step formats readonly if (automated) { textBox_OutputDir.ReadOnly = true; button_OutputDir.Enabled = false; } else { textBox_OutputDir.Text = ConfigOptions == null ? "" : ConfigOptions.OutputDirectory; } textBox_AuxiliaryDir.Text = ConfigOptions.AuxiliaryDirectory; // PrepareIFab: 1 step formats selected // Other: config file if (prepareifab) { SetCheckListBoxItem("AP203_E2_Separate_Part_Files"); clb_Step.Enabled = false; } else { for (int i = 0; i < ConfigOptions.StepFormats.Count; i++) { SetCheckListBoxItem(ConfigOptions.StepFormats[i]); } if (ConfigOptions.wasDeserialized == false) { SetCheckListBoxItem("AP203_E2_Single_File"); SetCheckListBoxItem("AP203_E2_Separate_Part_Files"); } } }
public IInterpreterResult Main(IInterpreterMainParameters parameters) { result.RunCommand = "runCADJob.bat"; result.Labels = "Creo&&CADCreoParametricCreateAssembly.exev1.4&&" + JobManager.Job.DefaultLabels; var ProjectIsNotInTransaction = (parameters.Project.ProjectStatus & 8) == 0; if (ProjectIsNotInTransaction) { parameters.Project.BeginTransactionInNewTerr(); } Dictionary <string, string> workflowParameters = new Dictionary <string, string>(); var workflowRef = parameters .CurrentFCO .ChildObjects .OfType <MgaReference>() .FirstOrDefault(x => x.Meta.Name == "WorkflowRef"); if (workflowRef != null) { string Parameters = workflowRef.Referred .ChildObjects .OfType <MgaAtom>() .FirstOrDefault(x => x.Meta.Name == "Task") .StrAttrByName["Parameters"]; try { workflowParameters = (Dictionary <string, string>)Newtonsoft.Json.JsonConvert.DeserializeObject(Parameters, typeof(Dictionary <string, string>)); if (workflowParameters == null) { workflowParameters = new Dictionary <string, string>(); } } catch (Newtonsoft.Json.JsonReaderException) { } } META.AnalysisTool.ApplyToolSelection(this.ComponentProgID, workflowParameters, this.result, parameters, modifyLabels: false); if (ProjectIsNotInTransaction) { parameters.Project.AbortTransaction(); } this.CopySTL = workflowParameters.ContainsValue("FreedLinkageAssembler"); var resultzip = CyPhy2CAD_CSharp.Properties.Resources.ResultZip; result.ZippyServerSideHook = Encoding.UTF8.GetString(resultzip); result.LogFileDirectory = Path.Combine(parameters.OutputDirectory, "log"); this.mainParameters = (InterpreterMainParameters)parameters; if (this.mainParameters.config == null) { var config = META.ComComponent.DeserializeConfiguration(this.mainParameters.ProjectDirectory, typeof(CyPhy2CADSettings), this.ComponentProgID) as CyPhy2CADSettings; if (config != null) { this.mainParameters.config = config; settings = config; } else { this.mainParameters.config = new CyPhy2CADSettings(); } } if (this.result.Traceability == null) { this.result.Traceability = new META.MgaTraceability(); } // getting traceability from caller, like master interpreter if (this.mainParameters.Traceability != null) { this.mainParameters.Traceability.CopyTo(this.result.Traceability); } //CyPhy2CAD_CSharp.CyPhy2CADSettings configSettings = (CyPhy2CAD_CSharp.CyPhy2CADSettings)parameters.config; //settings = configSettings; settings = (CyPhy2CAD_CSharp.CyPhy2CADSettings) this.mainParameters.config; settings.OutputDirectory = parameters.OutputDirectory; Automation = true; Logger.Instance.AddLogMessage("Main:Aux Directory is: " + settings.AuxiliaryDirectory, Severity.Info); Logger.Instance.AddLogMessage("Output Directory is: " + settings.OutputDirectory, Severity.Info); MgaGateway.voidDelegate action = delegate { if (Elaborate(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam)) { result.Success = Main(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, Convert(parameters.StartModeParam)); } else { result.Success = false; Logger.Instance.DumpLog(GMEConsole, LogDir); } }; if ((parameters.Project.ProjectStatus & 8) == 0) { MgaGateway.PerformInTransaction( d: action, mode: transactiontype_enum.TRANSACTION_NON_NESTED, abort: true); } else { action.Invoke(); } return(result); }
public IInterpreterResult Main(IInterpreterMainParameters parameters) { result.RunCommand = "runCADJob.bat"; result.Labels = "Creo&&CADCreoParametricCreateAssembly.exev1.4&&" + JobManager.Job.DefaultLabels; var ProjectIsNotInTransaction = (parameters.Project.ProjectStatus & 8) == 0; if (ProjectIsNotInTransaction) { parameters.Project.BeginTransactionInNewTerr(); } Dictionary<string, string> workflowParameters = new Dictionary<string, string>(); var workflowRef = parameters .CurrentFCO .ChildObjects .OfType<MgaReference>() .FirstOrDefault(x => x.Meta.Name == "WorkflowRef"); if (workflowRef != null) { string Parameters = workflowRef.Referred .ChildObjects .OfType<MgaAtom>() .FirstOrDefault(x => x.Meta.Name == "Task") .StrAttrByName["Parameters"]; try { workflowParameters = (Dictionary<string, string>)Newtonsoft.Json.JsonConvert.DeserializeObject(Parameters, typeof(Dictionary<string, string>)); if (workflowParameters == null) { workflowParameters = new Dictionary<string, string>(); } } catch (Newtonsoft.Json.JsonReaderException) { } } META.AnalysisTool.ApplyToolSelection(this.ComponentProgID, workflowParameters, this.result, parameters, modifyLabels: false); if (ProjectIsNotInTransaction) { parameters.Project.AbortTransaction(); } this.CopySTL = workflowParameters.ContainsValue("FreedLinkageAssembler"); var resultzip = CyPhy2CAD_CSharp.Properties.Resources.ResultZip; result.ZippyServerSideHook = Encoding.UTF8.GetString(resultzip); result.LogFileDirectory = Path.Combine(parameters.OutputDirectory, "log"); this.mainParameters = (InterpreterMainParameters)parameters; if (this.mainParameters.config == null) { var config = META.ComComponent.DeserializeConfiguration(this.mainParameters.ProjectDirectory, typeof(CyPhy2CADSettings), this.ComponentProgID) as CyPhy2CADSettings; if (config != null) { this.mainParameters.config = config; settings = config; } else { this.mainParameters.config = new CyPhy2CADSettings(); } } if (this.result.Traceability == null) { this.result.Traceability = new META.MgaTraceability(); } // getting traceability from caller, like master interpreter if (this.mainParameters.Traceability != null) { this.mainParameters.Traceability.CopyTo(this.result.Traceability); } //CyPhy2CAD_CSharp.CyPhy2CADSettings configSettings = (CyPhy2CAD_CSharp.CyPhy2CADSettings)parameters.config; //settings = configSettings; settings = (CyPhy2CAD_CSharp.CyPhy2CADSettings)this.mainParameters.config; settings.OutputDirectory = parameters.OutputDirectory; Automation = true; Logger.Instance.AddLogMessage("Main:Aux Directory is: " + settings.AuxiliaryDirectory, Severity.Info); Logger.Instance.AddLogMessage("Output Directory is: " + settings.OutputDirectory, Severity.Info); MgaGateway.voidDelegate action = delegate { if (Elaborate(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam)) { result.Success = Main(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, Convert(parameters.StartModeParam)); } else { result.Success = false; Logger.Instance.DumpLog(GMEConsole, LogDir); } }; if ((parameters.Project.ProjectStatus & 8) == 0) { MgaGateway.PerformInTransaction( d: action, mode: transactiontype_enum.TRANSACTION_NON_NESTED, abort: true); } else { action.Invoke(); } return result; }
private void FetchSettings() { string projectDirectory = ""; if (mainParameters != null) projectDirectory = mainParameters.ProjectDirectory; var config = META.ComComponent.DeserializeConfiguration(projectDirectory, typeof(CyPhy2CADSettings), this.ComponentProgID) as CyPhy2CADSettings; settings = config; if (settings == null) { settings = new CyPhy2CADSettings(); } }
public static TestBenchModel.TestBenchBase CreateTestBenchModel(string type, CyPhy2CADSettings cadSetting, string outputdir, string projectdir, bool Automation) { TestBenchModel.TestBenchBase testBenchModel = null; if (type == "TestBench") { testBenchModel = new TestBenchModel.TestBench(cadSetting, outputdir, projectdir, Automation); return testBenchModel; } if (type == "BallisticTestBench") { testBenchModel = new TestBenchModel.BallisticTestBench(cadSetting, outputdir, projectdir, Automation); return testBenchModel; } if (type == "CFDTestBench") { testBenchModel = new TestBenchModel.CFDTestBenchData(cadSetting, outputdir, projectdir, Automation); return testBenchModel; } if (type == "BlastTestBench") { testBenchModel = new TestBenchModel.BlastTestBench(cadSetting, outputdir, projectdir, Automation); return testBenchModel; } if (type == "CADTestBench") { testBenchModel = new TestBenchModel.FEATestBench(cadSetting, outputdir, projectdir, Automation); return testBenchModel; } if (type == "KinematicTestBench") { testBenchModel = new TestBenchModel.KinematicTestBench(cadSetting, outputdir, projectdir, Automation); return testBenchModel; } return testBenchModel; }
public static TestBenchModel.TestBenchBase CreateTestBenchModel(string type, CyPhy2CADSettings cadSetting, string outputdir, string projectdir, bool Automation) { TestBenchModel.TestBenchBase testBenchModel = null; if (type == "TestBench") { testBenchModel = new TestBenchModel.TestBench(cadSetting, outputdir, projectdir, Automation); return(testBenchModel); } if (type == "BallisticTestBench") { testBenchModel = new TestBenchModel.BallisticTestBench(cadSetting, outputdir, projectdir, Automation); return(testBenchModel); } if (type == "CFDTestBench") { testBenchModel = new TestBenchModel.CFDTestBenchData(cadSetting, outputdir, projectdir, Automation); return(testBenchModel); } if (type == "BlastTestBench") { testBenchModel = new TestBenchModel.BlastTestBench(cadSetting, outputdir, projectdir, Automation); return(testBenchModel); } if (type == "CADTestBench") { testBenchModel = new TestBenchModel.FEATestBench(cadSetting, outputdir, projectdir, Automation); return(testBenchModel); } if (type == "KinematicTestBench") { testBenchModel = new TestBenchModel.KinematicTestBench(cadSetting, outputdir, projectdir, Automation); return(testBenchModel); } return(testBenchModel); }
private void ProcessCAD(MgaFCO currentobj) { string outputdir = this.mainParameters.OutputDirectory; if (!Directory.Exists(outputdir)) { Directory.CreateDirectory(outputdir); } string debuglogdir = Path.Combine(outputdir, "log"); if (!Directory.Exists(debuglogdir)) { Directory.CreateDirectory(debuglogdir); } string projectdir = this.mainParameters.ProjectDirectory; CyPhy2CADSettings cadSetting = (CyPhy2CADSettings)this.mainParameters.config; string cadauxdir = cadSetting.AuxiliaryDirectory; CyPhy.ComponentAssembly curassembly; string curObjMetaBase = currentobj.MetaBase.Name; if (curObjMetaBase == "TestBench" || curObjMetaBase == "BallisticTestBench" || curObjMetaBase == "CFDTestBench" || curObjMetaBase == "BlastTestBench" || curObjMetaBase == "KinematicTestBench") { CyPhy.TestBenchType tb = CyPhyClasses.TestBenchType.Cast(currentobj); if (result != null && curObjMetaBase == "BlastTestBench") { result.Labels = JobManager.Job.DefaultLabels + "&&SwRI_Blast"; } if (result != null && curObjMetaBase == "KinematicTestBench") { result.Labels = JobManager.Job.DefaultLabels + "&&Adams"; } var catlsut = tb.Children.ComponentAssemblyCollection.FirstOrDefault(); // should be an instance b/c elaborate was called earlier if (catlsut == null) { result.Success = false; throw new Exception("There is no elaborated system under test component assembly in the model!"); } curassembly = catlsut; if (curassembly == null) { result.Success = false; throw new Exception("No Valid Component Assembly."); } // META-1971: ADM + ACM file export for blast + ballistics if (curObjMetaBase == "BallisticTestBench" || curObjMetaBase == "BlastTestBench") { // ADM: Export DDP 2.x version (XML) { var design = CyPhy2DesignInterchange.CyPhy2DesignInterchange.Convert(catlsut, this.result.Traceability); string TestBenchName = tb.Name; string admDir = Path.Combine(cadSetting.OutputDirectory, "DesignADM"); if (!Directory.Exists(admDir)) { Directory.CreateDirectory(admDir); } OpenMETA.Interchange.AvmXmlSerializer.SaveToFile(Path.Combine(admDir, TestBenchName + ".adm"), design); } } // end META-1971 // META-2987 GenerateCADParameterMapping(tb, outputdir, new List <object>()); CADFlatDataCreator datacreator = new CADFlatDataCreator(debuglogdir, this.mainParameters.ProjectDirectory, CadFormat); datacreator.Traceability = this.result.Traceability; datacreator.CreateFlatData(curassembly); DataRep.CADContainer cadcontainer = datacreator.CreateCADDataContainer(curassembly.Attributes.ConfigurationUniqueID, UtilityHelpers.CleanString2(curassembly.Name)); using (StreamWriter writer = new StreamWriter(Path.Combine(outputdir, "log", "CyPhy2CAD_Graphviz_Representation.gv"))) { writer.WriteLine(cadcontainer.ToGraphviz(true)); } if (!cadcontainer.IsAnalyzable() && curObjMetaBase != "TestBench") { result.Success = false; //Logger.Instance.AddLogMessage("Test Bench can not proceed because the test bench contains islands and/or orphans! Please see graphviz file in /log directory for details.", Severity.Error); throw new META.InterpreterException("Test Bench can not proceed because the test bench contains islands and/or orphans, see graphviz file in /log/CyPhy2CAD_Graphviz_Representation.gv for details. Please remove islands/orphans and try again."); } TestBenchModel.TestBenchBase testBenchRep = TestBenchModelFactory.CreateTestBenchModel(curObjMetaBase, cadSetting, outputdir, projectdir, Automation); testBenchRep.cadDataContainer = cadcontainer; testBenchRep.CopySTL = this.CopySTL; if (curObjMetaBase != "ComponentAssembly") { testBenchRep.TraverseTestBench(tb); } testBenchRep.CollectDirectories(); result.Success = testBenchRep.GenerateOutputFiles(); } else if (curObjMetaBase == "CADTestBench") { CyPhy.CADTestBench tb = CyPhyClasses.CADTestBench.Cast(currentobj); // META-1701: label for Abaqus if (result != null) { Dictionary <CyPhyClasses.CADTestBench.AttributesClass.SolverType_enum, string> labelMap = new Dictionary <CyPhyClasses.CADTestBench.AttributesClass.SolverType_enum, string>() { { CyPhyClasses.CADTestBench.AttributesClass.SolverType_enum.ABAQUS_Deck_Based, "Abaqus" }, { CyPhyClasses.CADTestBench.AttributesClass.SolverType_enum.ABAQUS_Model_Based, "Abaqus" }, { CyPhyClasses.CADTestBench.AttributesClass.SolverType_enum.NASTRAN, "Nastran" }, }; string label = "Abaqus"; labelMap.TryGetValue(tb.Attributes.SolverType, out label); result.Labels += "&&" + label; } var toplevelSUT = tb.Children.ComponentAssemblyCollection.FirstOrDefault(); // should be an instance b/c elaborate was called earlier if (toplevelSUT == null) { result.Success = false; throw new Exception("There is no elaborated system under test component assembly in the model!"); } CADFlatDataCreator datacreator = new CADFlatDataCreator(debuglogdir, this.mainParameters.ProjectDirectory, CadFormat); datacreator.Traceability = this.result.Traceability; datacreator.CreateFlatData(tb, toplevelSUT.Path); DataRep.CADContainer cadcontainer = datacreator.CreateCADDataContainer(tb.Guid.ToString(), UtilityHelpers.CleanString2(tb.Name)); using (StreamWriter writer = new StreamWriter(Path.Combine(outputdir, "log", "CyPhy2CAD_Graphviz_Representation.gv"))) { writer.WriteLine(cadcontainer.ToGraphviz(true)); } result.Success = false; if (!cadcontainer.IsAnalyzable()) { //Logger.Instance.AddLogMessage("FEA Test Bench can not proceed because the test bench contains islands and/or orphans! Please see graphviz file in /log directory for details.", Severity.Error); throw new META.InterpreterException("FEA Test Bench can not proceed because the test bench contains islands and/or orphans, see graphviz file in /log/CyPhy2CAD_Graphviz_Representation.gv for details. Please remove islands/orphans and try again."); } TestBenchModel.TestBenchBase testBenchRep = TestBenchModelFactory.CreateTestBenchModel(curObjMetaBase, cadSetting, outputdir, projectdir, Automation); testBenchRep.cadDataContainer = cadcontainer; testBenchRep.CopySTL = this.CopySTL; testBenchRep.TraverseTestBench(tb); testBenchRep.CollectDirectories(); result.Success = testBenchRep.GenerateOutputFiles(); List <object> mappings = new List <object>(); if (testBenchRep is TestBenchModel.FEATestBench) { var feaRep = (TestBenchModel.FEATestBench)testBenchRep; mappings = feaRep.TestBenchParameterMappings; } // META-2987 GenerateCADParameterMapping(tb, outputdir, mappings); } else if (curObjMetaBase == "ComponentAssembly") { curassembly = CyPhyClasses.ComponentAssembly.Cast(currentobj); CADFlatDataCreator datacreator = new CADFlatDataCreator(debuglogdir, this.mainParameters.ProjectDirectory, CadFormat); datacreator.Traceability = this.result.Traceability; datacreator.CreateFlatData(curassembly); DataRep.CADContainer cadcontainer = datacreator.CreateCADDataContainer(curassembly.Guid.ToString(), UtilityHelpers.CleanString2(curassembly.Name)); TestBenchModel.TestBenchBase testbenchbase = new TestBenchModel.TestBenchBase(cadSetting, outputdir, projectdir); testbenchbase.cadDataContainer = cadcontainer; testbenchbase.CopySTL = this.CopySTL; testbenchbase.CollectDirectories(); } else { result.Success = false; throw new NotImplementedException(String.Format("Running Cyphy2CAD on {0} is not implemented.", curObjMetaBase)); } }