public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase) { CyPhy.BlastTestBench testBench = testBenchBase as CyPhy.BlastTestBench; if (testBench == null) testBench = CyPhyClasses.BlastTestBench.Cast(testBenchBase.Impl); base.TraverseTestBench(testBenchBase); foreach (var item in testBench.Children.BlastComputation2MetricCollection) { CyPhy.BlastComputationType cadcomputation = item.SrcEnds.BlastComputationType; TBComputationType tbcomputation = new TBComputationType(); tbcomputation.MetricID = item.DstEnds.Metric.ID; tbcomputation.ComputationType = cadcomputation.Kind; tbcomputation.RequestedValueType = ""; Computations.Add(tbcomputation); } int predefinedCnt = testBench.Children.PredefinedBlastSuiteCollection.Count(); int customCnt = testBench.Children.BlastModelCollection.Count(); if (predefinedCnt > 0) { if (predefinedCnt > 1) { Logger.Instance.AddLogMessage("Blast testbench can only have at most 1 predefined blast suite.", Severity.Error); return; } if (customCnt > 0) { Logger.Instance.AddLogMessage("Blast testbench can not have both predefined and custom blast suite.", Severity.Error); return; } } // reference plane if (testBench.Children.ReferencePlaneCollection.Any()) { if (testBench.Children.ReferencePlaneCollection.First().Attributes.ReferencePlaneType == 0) { referencePlaneType = Survivability.ReferencePlaneTypeEnum.Ground; } else { referencePlaneType = Survivability.ReferencePlaneTypeEnum.Waterline; } } Survivability.BlastConfig.Analysis blastAnalysis = new Survivability.BlastConfig.Analysis(); blastAnalysis.ID = AnalysisID; //blastAnalysis.ID = testBench.ID; blastAnalysis.numDisplayTimeSteps = testBench.Attributes.DisplayTimeSteps; blastAnalysis.duration_seconds = testBench.Attributes.Duration; if (predefinedCnt > 0) { blastAnalysis.suiteName = testBench.Children.PredefinedBlastSuiteCollection.First().Attributes.BlastSuiteName; } if (customCnt > 0) { blastAnalysis.suiteName = testBench.Children.BlastModelCollection.First().Attributes.BlastSuiteName; } blastAnalysis.tier = (int)testBench.Attributes.BlastTier + 1; // starts at 0 blastConfig.analysis = blastAnalysis; string stepFormat; if (blastAnalysis.tier > 1) { stepFormat = "AP203_E2_Separate_Part_Files"; } else { stepFormat = "AP203_E2_Single_File"; } if (!DataExchangeFormats.Contains(stepFormat)) DataExchangeFormats.Add(stepFormat); // blast threat if (customCnt > 0) { CyPhy.BlastModel blastSuite = testBench.Children.BlastModelCollection.First(); if (!blastSuite.Children.BlastThreatCollection.Any()) { Logger.Instance.AddLogMessage("Custom blast testbench must contain a blast threat within a blast suite.", Severity.Error); return; } if (!blastSuite.Children.ChargeLocationCollection.Any()) { Logger.Instance.AddLogMessage("Custom blast testbench must contain a charge location within a blast suite.", Severity.Error); return; } CyPhy.BlastThreat threat = blastSuite.Children.BlastThreatCollection.First(); Survivability.BlastConfig.BlastThreat configThreat = new Survivability.BlastConfig.BlastThreat(); configThreat.burialDepth_meters = threat.Attributes.ThreatBurialDepth; configThreat.chargeSize_kgOfTNT = threat.Attributes.TNTChargeSize; int tTypeint = (int)threat.Attributes.ThreatType; configThreat.type = (Survivability.BlastConfig.BlastThreatTypeEnum)tTypeint; Survivability.BlastConfig.Shape shape = new Survivability.BlastConfig.Shape(); shape.height_meters = threat.Attributes.ThreatShapeHeight; shape.radius_meters = threat.Attributes.ThreatShapeRadius; int sTypeint = (int)threat.Attributes.ThreatShapeType; shape.type = (Survivability.BlastConfig.Shape.ShapeTypeEnum)sTypeint; configThreat.shape = shape; CyPhy.ChargeLocation loc = blastSuite.Children.ChargeLocationCollection.First(); Survivability.BlastConfig.ChargeLocation configChargeLoc = new Survivability.BlastConfig.ChargeLocation(); configChargeLoc.x_meters = loc.Attributes.X; configChargeLoc.y_meters = loc.Attributes.Y; configChargeLoc.z_meters = loc.Attributes.Z; configThreat.chargeLocation = configChargeLoc; blastConfig.blastThreat = configThreat; } }
public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase) { CyPhy.BlastTestBench testBench = testBenchBase as CyPhy.BlastTestBench; if (testBench == null) { testBench = CyPhyClasses.BlastTestBench.Cast(testBenchBase.Impl); } base.TraverseTestBench(testBenchBase); foreach (var item in testBench.Children.BlastComputation2MetricCollection) { CyPhy.BlastComputationType cadcomputation = item.SrcEnds.BlastComputationType; TBComputation tbcomputation = new TBComputation(); tbcomputation.MetricID = item.DstEnds.Metric.ID; if (cadcomputation is CyPhy.MaxHorizonalVelocity) { tbcomputation.ComputationType = TBComputation.Type.MAXHORIZONALVELOCITY; } else if (cadcomputation is CyPhy.MaxVerticalJump) { tbcomputation.ComputationType = TBComputation.Type.MAXVERTICALJUMP; } else if (cadcomputation is CyPhy.MaxVerticalVelocity) { tbcomputation.ComputationType = TBComputation.Type.MAXVERTICALVELOCITY; } tbcomputation.RequestedValueType = ""; Computations.Add(tbcomputation); } int predefinedCnt = testBench.Children.PredefinedBlastSuiteCollection.Count(); int customCnt = testBench.Children.BlastModelCollection.Count(); if (predefinedCnt > 0) { if (predefinedCnt > 1) { Logger.Instance.AddLogMessage("Blast testbench can only have at most 1 predefined blast suite.", Severity.Error); return; } if (customCnt > 0) { Logger.Instance.AddLogMessage("Blast testbench can not have both predefined and custom blast suite.", Severity.Error); return; } } // reference plane if (testBench.Children.ReferencePlaneCollection.Any()) { if (testBench.Children.ReferencePlaneCollection.First().Attributes.ReferencePlaneType == 0) { referencePlaneType = Survivability.ReferencePlaneTypeEnum.Ground; } else { referencePlaneType = Survivability.ReferencePlaneTypeEnum.Waterline; } } Survivability.BlastConfig.Analysis blastAnalysis = new Survivability.BlastConfig.Analysis(); blastAnalysis.ID = AnalysisID; //blastAnalysis.ID = testBench.ID; blastAnalysis.numDisplayTimeSteps = testBench.Attributes.DisplayTimeSteps; blastAnalysis.duration_seconds = testBench.Attributes.Duration; if (predefinedCnt > 0) { blastAnalysis.suiteName = testBench.Children.PredefinedBlastSuiteCollection.First().Attributes.BlastSuiteName; } if (customCnt > 0) { blastAnalysis.suiteName = testBench.Children.BlastModelCollection.First().Attributes.BlastSuiteName; } blastAnalysis.tier = (int)testBench.Attributes.BlastTier + 1; // starts at 0 blastConfig.analysis = blastAnalysis; string stepFormat; if (blastAnalysis.tier > 1) { stepFormat = "AP203_E2_Separate_Part_Files"; } else { stepFormat = "AP203_E2_Single_File"; } if (!STEP_DataExchangeFormats.Contains(stepFormat, StringComparer.CurrentCultureIgnoreCase)) { STEP_DataExchangeFormats.Add(stepFormat); } // blast threat if (customCnt > 0) { CyPhy.BlastModel blastSuite = testBench.Children.BlastModelCollection.First(); if (!blastSuite.Children.BlastThreatCollection.Any()) { Logger.Instance.AddLogMessage("Custom blast testbench must contain a blast threat within a blast suite.", Severity.Error); return; } if (!blastSuite.Children.ChargeLocationCollection.Any()) { Logger.Instance.AddLogMessage("Custom blast testbench must contain a charge location within a blast suite.", Severity.Error); return; } CyPhy.BlastThreat threat = blastSuite.Children.BlastThreatCollection.First(); Survivability.BlastConfig.BlastThreat configThreat = new Survivability.BlastConfig.BlastThreat(); configThreat.burialDepth_meters = threat.Attributes.ThreatBurialDepth; configThreat.chargeSize_kgOfTNT = threat.Attributes.TNTChargeSize; int tTypeint = (int)threat.Attributes.ThreatType; configThreat.type = (Survivability.BlastConfig.BlastThreatTypeEnum)tTypeint; Survivability.BlastConfig.Shape shape = new Survivability.BlastConfig.Shape(); shape.height_meters = threat.Attributes.ThreatShapeHeight; shape.radius_meters = threat.Attributes.ThreatShapeRadius; int sTypeint = (int)threat.Attributes.ThreatShapeType; shape.type = (Survivability.BlastConfig.Shape.ShapeTypeEnum)sTypeint; configThreat.shape = shape; CyPhy.ChargeLocation loc = blastSuite.Children.ChargeLocationCollection.First(); Survivability.BlastConfig.ChargeLocation configChargeLoc = new Survivability.BlastConfig.ChargeLocation(); configChargeLoc.x_meters = loc.Attributes.X; configChargeLoc.y_meters = loc.Attributes.Y; configChargeLoc.z_meters = loc.Attributes.Z; configThreat.chargeLocation = configChargeLoc; blastConfig.blastThreat = configThreat; } }