private string GetFeatureName(CyPhy.Port port) { string datumName = ""; PointMetricTraversal traverser = new PointMetricTraversal(port); if (traverser.portsFound.Count() == 1) { CyPhy.Port foundPort = traverser.portsFound.First(); if (foundPort.Kind == "Surface") { datumName = (foundPort as CyPhy.Surface).Attributes.DatumName; } else if (foundPort.Kind == "Point") { datumName = (foundPort as CyPhy.Point).Attributes.DatumName; } else if (foundPort.Kind == "Axis") { datumName = (foundPort as CyPhy.Axis).Attributes.DatumName; } } return(datumName); }
private static bool CreateFeatureFromPoint(CyPhy.Port port, List <KeyValuePair <string, string> > featureList) { PointMetricTraversal traverser = new PointMetricTraversal(port); if (traverser.portsFound.Count() == 1) { CyPhy.Port foundPort = traverser.portsFound.First(); string datumName = ""; if (foundPort.Kind == "Surface") { datumName = (foundPort as CyPhy.Surface).Attributes.DatumName; } else if (foundPort.Kind == "Point") { datumName = (foundPort as CyPhy.Point).Attributes.DatumName; } else if (foundPort.Kind == "Axis") { datumName = (foundPort as CyPhy.Axis).Attributes.DatumName; } KeyValuePair <string, string> pair = new KeyValuePair <string, string>(datumName, CyPhyClasses.Component.Cast(foundPort.ParentContainer.ParentContainer.Impl).Attributes.InstanceGUID); featureList.Add(pair); return(true); } else { return(false); } }
public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase) { CyPhy.TestBench testBench = testBenchBase as CyPhy.TestBench; if (testBench == null) testBench = CyPhyClasses.TestBench.Cast(testBenchBase.Impl); base.TraverseTestBench(testBenchBase); //AnalysisID = testBench.ID; // R.O. added 11/15/2016, because the MSD_CAD.xme/TestBench_Valid was failing because the schema for CADAssmbly.xml requires // that ComponentID be set for Metrics/Metric attributes. For Mass, CenterOfGravity, BoundingBox, and Interference, // the metric applies to the entire assembly; therefore, we will use the top-level assembly as the ComponentID. var catlsut = testBench.Children.ComponentAssemblyCollection.FirstOrDefault(); // should be an instance b/c elaborate was called earlier if (catlsut == null) { // This check occurs earlier in ProcessCAD(), but will repeat here in case someone changes the code to not // test this earlier. throw new Exception("There is no elaborated system under test component assembly in the model!"); } // "|1" is set in other places in the code for the top-level assembly. Search on "|" to see those places. // If someone changes to another system ( different suffix than "|1") and does not change the following // line, then the CreateAssembly program will throw an exception. This will be caught by the build tests // (e.g. MSD_CAD.xme/TestBench_Valid). string topLevelAssemblyComponentInstanceID_temp = catlsut.Attributes.ConfigurationUniqueID + "|" + "1"; // CADComputations Metrics foreach (var conn in testBench.Children.CADComputation2MetricCollection) { CyPhy.CADComputationType cadcomputation = conn.SrcEnds.CADComputationType; TBComputation tbcomputation = new TBComputation(); tbcomputation.MetricID = conn.DstEnds.Metric.ID; if (cadcomputation is CyPhy.CenterOfGravity) { tbcomputation.ComponentID = topLevelAssemblyComponentInstanceID_temp; tbcomputation.RequestedValueType = (cadcomputation as CyPhy.CenterOfGravity).Attributes.CADComputationRequestedValue.ToString(); tbcomputation.ComputationType = TBComputation.Type.CENTEROFGRAVITY; } else if (cadcomputation is CyPhy.BoundingBox) { tbcomputation.ComponentID = topLevelAssemblyComponentInstanceID_temp; tbcomputation.RequestedValueType = (cadcomputation as CyPhy.BoundingBox).Attributes.CADComputationRequestedValue.ToString(); tbcomputation.ComputationType = TBComputation.Type.BOUNDINGBOX; } else if (cadcomputation is CyPhy.InterferenceCount) { tbcomputation.ComponentID = topLevelAssemblyComponentInstanceID_temp; tbcomputation.RequestedValueType = "Scalar"; tbcomputation.ComputationType = TBComputation.Type.INTERFERENCECOUNT; } else if (cadcomputation is CyPhy.Mass) { tbcomputation.ComponentID = topLevelAssemblyComponentInstanceID_temp; tbcomputation.RequestedValueType = "Scalar"; tbcomputation.ComputationType = TBComputation.Type.MASS; } this.StaticAnalysisMetrics.Add(tbcomputation); } // PointCoordinate Metrics foreach (var metric in testBench.Children.MetricCollection) { List<CyPhy.Point> points_list = new List<CyPhy.Point>(); foreach (var pt in metric.SrcConnections.PointCoordinates2MetricCollection) { points_list.Add(pt.SrcEnds.Point); } foreach (var pt in metric.DstConnections.PointCoordinates2MetricCollection) { points_list.Add(pt.DstEnds.Point); } if (points_list.Any()) { if (points_list.Count() > 1) Logger.Instance.AddLogMessage("Metric should not be connected to multiple Point datums in a test bench.", Severity.Error); CyPhy.Point point = points_list.First(); PointMetricTraversal traverser = new PointMetricTraversal(point); if (traverser.portsFound.Count() == 1) { TBComputation tbcomputation = new TBComputation(); tbcomputation.ComputationType = TBComputation.Type.POINTCOORDINATES; tbcomputation.MetricID = metric.ID; tbcomputation.RequestedValueType = "Vector"; tbcomputation.Details = (traverser.portsFound.First() as CyPhy.Point).Attributes.DatumName; tbcomputation.ComponentID = CyPhyClasses.Component.Cast(traverser.portsFound.First().ParentContainer.ParentContainer.Impl).Attributes.InstanceGUID; tbcomputation.MetricName = metric.Name; StaticAnalysisMetrics.Add(tbcomputation); } } } // Post Processing Blocks foreach (var postprocess in testBench.Children.PostProcessingCollection) { PostProcessScripts.Add(postprocess.Attributes.ScriptPath); } }
public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase) { CyPhy.KinematicTestBench testBench = testBenchBase as CyPhy.KinematicTestBench; if (testBench == null) testBench = CyPhyClasses.KinematicTestBench.Cast(testBenchBase.Impl); base.TraverseTestBench(testBenchBase); //STLDataExchangeFormats.Add("Parasolid"); Name = testBench.Name; SimulationStep = testBench.Attributes.SimulationResolution; SimulationTime = testBench.Attributes.Duration; if (testBench.Children.GravityLoadCollection.Any()) { CyPhy.GravityLoad load = testBench.Children.GravityLoadCollection.First(); double x = 0; double y = 0; double z = 0; GetGravityLoadParam(load, "X", out x); GetGravityLoadParam(load, "Y", out y); GetGravityLoadParam(load, "Z", out z); Gravity = new KinematicGravity(x, y, z, load.Attributes.Active); } var terrain = testBench.Children.ComponentRefCollection.Where(c => ((MgaFCO)c.Impl).MetaRole.Name == "Terrain"); if (terrain.Any()) { CyPhy.Component terraincomp = terrain.First().AllReferred as CyPhy.Component; if (terraincomp == null) { Logger.Instance.AddLogMessage("Terrain component reference must refer to a cyphy component.", Severity.Error); return; } if (!terraincomp.Children.CADModelCollection.Any()) { Logger.Instance.AddLogMessage("Terrain component must contain a CAD model.", Severity.Error); return; } TerrainFileName = terraincomp.Children.ResourceCollection.First().Attributes.Path; try { File.Copy(Path.Combine(terraincomp.GetDirectoryPath(), TerrainFileName), Path.Combine(OutputDirectory, Path.GetFileName(TerrainFileName))); } catch (Exception e) { Logger.Instance.AddLogMessage("Unable to copy terrain file: " + e.Message, Severity.Warning); } TerrainFileName = Path.GetFileNameWithoutExtension(TerrainFileName); } else { if (testBench.Children.AnchorCollection.Any()) { CyPhy.Anchor anchor = testBench.Children.AnchorCollection.First(); var pointList = anchor .DstConnections .SetAnchorCollection .Select(x => x.DstEnds.Point) .Concat(anchor .SrcConnections .SetAnchorCollection .Select(x => x.SrcEnds.Point)); if (!pointList.Any()) { Logger.Instance.AddLogMessage("Anchor is not connected to a point. Anchor should be connected to a datum point on one of the components.", Severity.Error); return; } var point = pointList.First(); PointMetricTraversal traverser = new PointMetricTraversal(point); foreach (var pointFound in traverser.portsFound) { string name = (pointFound as CyPhy.Point).Attributes.DatumName; string componentID = CyPhyClasses.Component.Cast((pointFound as CyPhy.Point).ParentContainer.ParentContainer.Impl).Attributes.InstanceGUID; Computations.Add(new TBComputationType() { ComponentID = componentID, FeatureDatumName = name, MetricID = "Anchor", ComputationType = "PointCoordinates", RequestedValueType = "Vector" }); GroundCyphyID = componentID; } } else { Logger.Instance.AddLogMessage("Anchor not found. There should be exactly one anchor in the testbench, to specify which body is fixed to the ground in the kinematic simnulation.", Severity.Error); return; } } foreach (var motion in testBench.Children.MotionLoadCollection) { var connectorList = motion .SrcConnections .ApplyMotionToJointCollection .Select(x => x.SrcEnds.Connector) .Concat(motion .DstConnections .ApplyMotionToJointCollection .Select(x => x.DstEnds.Connector) ); var toplevelSUT = testBench.Children.ComponentAssemblyCollection.FirstOrDefault(); foreach (var connector in connectorList) { OriginatingConnectorTraversal traverser = new OriginatingConnectorTraversal(connector); if (traverser.result != null) { CyPhy.KinematicJoint joint = GetJoint(traverser.result); if (joint != null) { Multibody.ModelLoadsMotion mbdMotion = new Multibody.ModelLoadsMotion(); mbdMotion.Active = (motion.Attributes.Active) ? Multibody.ModelLoadsMotionActive.on : Multibody.ModelLoadsMotionActive.off; mbdMotion.FreedomType = (Multibody.ModelLoadsMotionFreedomType)((int)motion.Attributes.JointFreedomType); mbdMotion.Function = motion.Attributes.CustomFunction; mbdMotion.JointID = cadDataContainer.GetJointIDFromGMEID(joint.ID); mbdMotion.MotionID = motion.Name; mbdMotion.TimeDerivative = (Multibody.ModelLoadsMotionTimeDerivative)((int)motion.Attributes.TimeDerivative); mbdMotion.Type = "JointMotion"; MotionList.Add(mbdMotion); } else { Logger.Instance.AddLogMessage("Kinematic motion is connected to a connector without joint information: " + connector.ToHyperLink(), Severity.Error); } } } } if (testBench.Children.AdamsScriptCollection.Any()) { Scripts = new List<Multibody.ModelScript>(); foreach (var script in testBench.Children.AdamsScriptCollection) { Scripts.Add(new Multibody.ModelScript() { Path = script.Attributes.Path }); } } ProcessContacts(testBench); }
public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase) { string stepFormat = "AP203_E2_Single_File"; if (!DataExchangeFormats.Contains(stepFormat)) DataExchangeFormats.Add(stepFormat); CyPhy.BallisticTestBench testBench = testBenchBase as CyPhy.BallisticTestBench; if (testBench == null) testBench = CyPhyClasses.BallisticTestBench.Cast(testBenchBase.Impl); base.TraverseTestBench(testBenchBase); //AnalysisID = testBench.ID; foreach (var item in testBench.Children.BallisticComputation2MetricCollection) { TBComputation tbcomputation = new TBComputation(); if (item.SrcEnds.TotalIntersections != null) { tbcomputation.ComputationType = TBComputation.Type.TOTALINTERSECTIONS; } else if (item.SrcEnds.TotalKills != null) { tbcomputation.ComputationType = TBComputation.Type.TOTALKILLS; } else if (item.SrcEnds.TotalPerforations != null) { tbcomputation.ComputationType = TBComputation.Type.TOTALPERFORATIONS; } else if (item.SrcEnds.TotalShots != null) { tbcomputation.ComputationType = TBComputation.Type.TOTALSHOTS; } else { Logger.Instance.AddLogMessage("Unknown Ballistic calculation: " + item.SrcEnd.Impl.Name, Severity.Error); } tbcomputation.MetricID = item.DstEnds.Metric.ID; tbcomputation.MetricName = item.Name; tbcomputation.RequestedValueType = ""; Computations.Add(tbcomputation); } int predefinedCnt = testBench.Children.PredefinedBallisticSuiteCollection.Count(); int customCnt = testBench.Children.ShotlineModelCollection.Count(); if (predefinedCnt > 0) { if (predefinedCnt > 1) { Logger.Instance.AddLogMessage("Ballistic testbench can only have at most 1 predefined shotline suite.", Severity.Error); return; } if (customCnt > 0) { Logger.Instance.AddLogMessage("Ballistic testbench can not have both predefined and custom shotline suites.", 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; } } // analysis Survivability.BallisticConfig.Analysis ballisticAnalysis = new Survivability.BallisticConfig.Analysis(); ballisticAnalysis.ID = AnalysisID; if (predefinedCnt > 0) { ballisticAnalysis.suiteName = testBench.Children.PredefinedBallisticSuiteCollection.First().Attributes.Name; } else { ballisticAnalysis.suiteName = testBench.Name; } if (ballisticAnalysis.suiteName.Length == 0) { Logger.Instance.AddLogMessage("Ballistic analysis suite has no name specified.", Severity.Warning); } ballisticAnalysis.tier = (int)testBench.Attributes.Tier+1; // starts at 0 ballisticConfig.analysis = ballisticAnalysis; // ballistic threat foreach (var item in testBench.Children.BallisticThreatCollection) { VerifyBallisticThreat(item); Survivability.BallisticConfig.BallisticThreat threat = new Survivability.BallisticConfig.BallisticThreat(); threat.diameter_meters = item.Attributes.Diameter; threat.length_meters = item.Attributes.Length; threat.materialRef = item.Attributes.Material; threat.speed_metersPerSec = item.Attributes.Speed; if (item.Kind == "ProjectileBallisticThreat") { threat.type = Survivability.BallisticConfig.BallisticThreat.BallisticThreatTypeEnum.Ballistic; } else if (item.Kind == "ShapedChargeJetBallisticThreat") { threat.type = Survivability.BallisticConfig.BallisticThreat.BallisticThreatTypeEnum.ShapedChargeJet; threat.standoff_meters = (item as CyPhy.ShapedChargeJetBallisticThreat).Attributes.Standoff; int chargeq = (int)(item as CyPhy.ShapedChargeJetBallisticThreat).Attributes.ChargeQuality; threat.chargeQuality = (Survivability.BallisticConfig.BallisticThreat.ChargeQualityEnum)(chargeq); } threat.name = item.ID; ballisticConfig.ballisticThreats.Add(threat); } // critical components foreach (var item in testBench.Children.CriticalComponentCollection) { int type = (int)item.Attributes.Type; CyPhy.TIPRefBase refbase = item.Referred.TIPRefBase; if (refbase != null) { if (refbase.Kind != "Component") { Logger.Instance.AddLogMessage(String.Format("Critical component must refer to a component: {0}", refbase.Name), Severity.Error); } else { Survivability.BallisticConfig.CriticalComponent criticalcomponent = new Survivability.BallisticConfig.CriticalComponent(); criticalcomponent.componentID = (refbase as CyPhy.Component).Attributes.InstanceGUID; criticalcomponent.type = (Survivability.BallisticConfig.CriticalComponent.CriticalityTypeEnum)(type); ballisticConfig.criticalComponents.Add(criticalcomponent); } } } // file location // see GenerateCADXmlOutput(); // custom shotline foreach (var item in testBench.Children.ShotlineModelCollection) { if (VerifyShotLineModel(item)) continue; string componentid = ""; string datumname = ""; CyPhy.ShotlineTarget target = item.DstConnections.ShotlineTargetCollection.First(); CyPhy.Point ap = target.DstEnds.Point; PointMetricTraversal traverser = new PointMetricTraversal(ap); if (!traverser.portsFound.Any()) { Logger.Instance.AddLogMessage("Shotline Model is connected to an AnalysisPoint which does not end in a PointGeometry [" + item.Path + "]", Severity.Error); continue; } datumname = (traverser.portsFound.First() as CyPhy.Point).Attributes.DatumName; CyPhy.Component targetComponent = CyPhyClasses.Component.Cast(traverser.portsFound.First().ParentContainer.ParentContainer.Impl); componentid = targetComponent.Attributes.InstanceGUID; foreach (var conn in item.SrcConnections.Threat2ShotlineSuiteCollection) { CyPhy.BallisticThreat threat = conn.SrcEnds.BallisticThreat; CustomShotline customshotline = new CustomShotline(); customshotline.Azimuth = item.Children.AzimuthAngleCollection.First().Attributes.Value; customshotline.Elevation = item.Children.ElevationAngleCollection.First().Attributes.Value; customshotline.BallisticThreatRef = threat.ID; customshotline.ComponentID = componentid; customshotline.DatumPoint = datumname; customshotline.ShotlineName = item.Attributes.Name; customShotlineList.Add(customshotline); } } }
private string GetFeatureName(CyPhy.Port port) { string datumName = ""; PointMetricTraversal traverser = new PointMetricTraversal(port); if (traverser.portsFound.Count() == 1) { CyPhy.Port foundPort = traverser.portsFound.First(); if (foundPort.Kind == "Surface") { datumName = (foundPort as CyPhy.Surface).Attributes.DatumName; } else if (foundPort.Kind == "Point") { datumName = (foundPort as CyPhy.Point).Attributes.DatumName; } else if (foundPort.Kind == "Axis") { datumName = (foundPort as CyPhy.Axis).Attributes.DatumName; } } return datumName; }
public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase) { string stepFormat = "AP203_E2_Single_File"; if (!STEP_DataExchangeFormats.Contains(stepFormat, StringComparer.OrdinalIgnoreCase)) { STEP_DataExchangeFormats.Add(stepFormat); } CyPhy.BallisticTestBench testBench = testBenchBase as CyPhy.BallisticTestBench; if (testBench == null) { testBench = CyPhyClasses.BallisticTestBench.Cast(testBenchBase.Impl); } base.TraverseTestBench(testBenchBase); //AnalysisID = testBench.ID; foreach (var item in testBench.Children.BallisticComputation2MetricCollection) { TBComputation tbcomputation = new TBComputation(); if (item.SrcEnds.TotalIntersections != null) { tbcomputation.ComputationType = TBComputation.Type.TOTALINTERSECTIONS; } else if (item.SrcEnds.TotalKills != null) { tbcomputation.ComputationType = TBComputation.Type.TOTALKILLS; } else if (item.SrcEnds.TotalPerforations != null) { tbcomputation.ComputationType = TBComputation.Type.TOTALPERFORATIONS; } else if (item.SrcEnds.TotalShots != null) { tbcomputation.ComputationType = TBComputation.Type.TOTALSHOTS; } else { Logger.Instance.AddLogMessage("Unknown Ballistic calculation: " + item.SrcEnd.Impl.Name, Severity.Error); } tbcomputation.MetricID = item.DstEnds.Metric.ID; tbcomputation.MetricName = item.Name; tbcomputation.RequestedValueType = ""; Computations.Add(tbcomputation); } int predefinedCnt = testBench.Children.PredefinedBallisticSuiteCollection.Count(); int customCnt = testBench.Children.ShotlineModelCollection.Count(); if (predefinedCnt > 0) { if (predefinedCnt > 1) { Logger.Instance.AddLogMessage("Ballistic testbench can only have at most 1 predefined shotline suite.", Severity.Error); return; } if (customCnt > 0) { Logger.Instance.AddLogMessage("Ballistic testbench can not have both predefined and custom shotline suites.", 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; } } // analysis Survivability.BallisticConfig.Analysis ballisticAnalysis = new Survivability.BallisticConfig.Analysis(); ballisticAnalysis.ID = AnalysisID; if (predefinedCnt > 0) { ballisticAnalysis.suiteName = testBench.Children.PredefinedBallisticSuiteCollection.First().Attributes.Name; } else { ballisticAnalysis.suiteName = testBench.Name; } if (ballisticAnalysis.suiteName.Length == 0) { Logger.Instance.AddLogMessage("Ballistic analysis suite has no name specified.", Severity.Warning); } ballisticAnalysis.tier = (int)testBench.Attributes.Tier + 1; // starts at 0 ballisticConfig.analysis = ballisticAnalysis; // ballistic threat foreach (var item in testBench.Children.BallisticThreatCollection) { VerifyBallisticThreat(item); Survivability.BallisticConfig.BallisticThreat threat = new Survivability.BallisticConfig.BallisticThreat(); threat.diameter_meters = item.Attributes.Diameter; threat.length_meters = item.Attributes.Length; threat.materialRef = item.Attributes.Material; threat.speed_metersPerSec = item.Attributes.Speed; if (item.Kind == "ProjectileBallisticThreat") { threat.type = Survivability.BallisticConfig.BallisticThreat.BallisticThreatTypeEnum.Ballistic; } else if (item.Kind == "ShapedChargeJetBallisticThreat") { threat.type = Survivability.BallisticConfig.BallisticThreat.BallisticThreatTypeEnum.ShapedChargeJet; threat.standoff_meters = (item as CyPhy.ShapedChargeJetBallisticThreat).Attributes.Standoff; int chargeq = (int)(item as CyPhy.ShapedChargeJetBallisticThreat).Attributes.ChargeQuality; threat.chargeQuality = (Survivability.BallisticConfig.BallisticThreat.ChargeQualityEnum)(chargeq); } threat.name = item.ID; ballisticConfig.ballisticThreats.Add(threat); } // critical components foreach (var item in testBench.Children.CriticalComponentCollection) { int type = (int)item.Attributes.Type; CyPhy.TIPRefBase refbase = item.Referred.TIPRefBase; if (refbase != null) { if (refbase.Kind != "Component") { Logger.Instance.AddLogMessage(String.Format("Critical component must refer to a component: {0}", refbase.Name), Severity.Error); } else { Survivability.BallisticConfig.CriticalComponent criticalcomponent = new Survivability.BallisticConfig.CriticalComponent(); criticalcomponent.componentID = (refbase as CyPhy.Component).Attributes.InstanceGUID; criticalcomponent.type = (Survivability.BallisticConfig.CriticalComponent.CriticalityTypeEnum)(type); ballisticConfig.criticalComponents.Add(criticalcomponent); } } } // file location // see GenerateCADXmlOutput(); // custom shotline foreach (var item in testBench.Children.ShotlineModelCollection) { if (VerifyShotLineModel(item)) { continue; } string componentid = ""; string datumname = ""; CyPhy.ShotlineTarget target = item.DstConnections.ShotlineTargetCollection.First(); CyPhy.Point ap = target.DstEnds.Point; PointMetricTraversal traverser = new PointMetricTraversal(ap); if (!traverser.portsFound.Any()) { Logger.Instance.AddLogMessage("Shotline Model is connected to an AnalysisPoint which does not end in a PointGeometry [" + item.Path + "]", Severity.Error); continue; } datumname = (traverser.portsFound.First() as CyPhy.Point).Attributes.DatumName; CyPhy.Component targetComponent = CyPhyClasses.Component.Cast(traverser.portsFound.First().ParentContainer.ParentContainer.Impl); componentid = targetComponent.Attributes.InstanceGUID; foreach (var conn in item.SrcConnections.Threat2ShotlineSuiteCollection) { CyPhy.BallisticThreat threat = conn.SrcEnds.BallisticThreat; CustomShotline customshotline = new CustomShotline(); customshotline.Azimuth = item.Children.AzimuthAngleCollection.First().Attributes.Value; customshotline.Elevation = item.Children.ElevationAngleCollection.First().Attributes.Value; customshotline.BallisticThreatRef = threat.ID; customshotline.ComponentID = componentid; customshotline.DatumPoint = datumname; customshotline.ShotlineName = item.Attributes.Name; customShotlineList.Add(customshotline); } } }
private static bool CreateFeatureFromPoint(CyPhy.Port port, List<KeyValuePair<string, string>> featureList) { PointMetricTraversal traverser = new PointMetricTraversal(port); if (traverser.portsFound.Count() == 1) { CyPhy.Port foundPort = traverser.portsFound.First(); string datumName = ""; if (foundPort.Kind == "Surface") { datumName = (foundPort as CyPhy.Surface).Attributes.DatumName; } else if (foundPort.Kind == "Point") { datumName = (foundPort as CyPhy.Point).Attributes.DatumName; } else if (foundPort.Kind == "Axis") { datumName = (foundPort as CyPhy.Axis).Attributes.DatumName; } KeyValuePair<string, string> pair = new KeyValuePair<string, string>(datumName, CyPhyClasses.Component.Cast(foundPort.ParentContainer.ParentContainer.Impl).Attributes.InstanceGUID); featureList.Add(pair); return true; } else return false; }
public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase) { CyPhy.KinematicTestBench testBench = testBenchBase as CyPhy.KinematicTestBench; if (testBench == null) { testBench = CyPhyClasses.KinematicTestBench.Cast(testBenchBase.Impl); } base.TraverseTestBench(testBenchBase); //NonSTEP_DataExchangeFormats.Add("Parasolid"); Name = testBench.Name; SimulationStep = testBench.Attributes.SimulationResolution; SimulationTime = testBench.Attributes.Duration; if (testBench.Children.GravityLoadCollection.Any()) { CyPhy.GravityLoad load = testBench.Children.GravityLoadCollection.First(); double x = 0; double y = 0; double z = 0; GetGravityLoadParam(load, "X", out x); GetGravityLoadParam(load, "Y", out y); GetGravityLoadParam(load, "Z", out z); Gravity = new KinematicGravity(x, y, z, load.Attributes.Active); } var terrain = testBench.Children.ComponentRefCollection.Where(c => ((MgaFCO)c.Impl).MetaRole.Name == "Terrain"); if (terrain.Any()) { CyPhy.Component terraincomp = terrain.First().AllReferred as CyPhy.Component; if (terraincomp == null) { Logger.Instance.AddLogMessage("Terrain component reference must refer to a cyphy component.", Severity.Error); return; } if (!terraincomp.Children.CADModelCollection.Any()) { Logger.Instance.AddLogMessage("Terrain component must contain a CAD model.", Severity.Error); return; } TerrainFileName = terraincomp.Children.ResourceCollection.First().Attributes.Path; try { File.Copy(Path.Combine(terraincomp.GetDirectoryPath(), TerrainFileName), Path.Combine(OutputDirectory, Path.GetFileName(TerrainFileName))); } catch (Exception e) { Logger.Instance.AddLogMessage("Unable to copy terrain file: " + e.Message, Severity.Warning); } TerrainFileName = Path.GetFileNameWithoutExtension(TerrainFileName); } else { if (testBench.Children.AnchorCollection.Any()) { CyPhy.Anchor anchor = testBench.Children.AnchorCollection.First(); var pointList = anchor .DstConnections .SetAnchorCollection .Select(x => x.DstEnds.Point) .Concat(anchor .SrcConnections .SetAnchorCollection .Select(x => x.SrcEnds.Point)); if (!pointList.Any()) { Logger.Instance.AddLogMessage("Anchor is not connected to a point. Anchor should be connected to a datum point on one of the components.", Severity.Error); return; } var point = pointList.First(); PointMetricTraversal traverser = new PointMetricTraversal(point); foreach (var pointFound in traverser.portsFound) { string name = (pointFound as CyPhy.Point).Attributes.DatumName; string componentID = CyPhyClasses.Component.Cast((pointFound as CyPhy.Point).ParentContainer.ParentContainer.Impl).Attributes.InstanceGUID; StaticAnalysisMetrics.Add(new TBComputation() { ComponentID = componentID, Details = name, MetricID = "Anchor", ComputationType = TBComputation.Type.POINTCOORDINATES, RequestedValueType = "Vector" }); //Computations.Add(new TBComputation() { ComponentID = componentID, FeatureDatumName = name, MetricID = "Anchor", ComputationType = TBComputation.Type.POINTCOORDINATES, RequestedValueType = "Vector" }); GroundCyphyID = componentID; } } else { Logger.Instance.AddLogMessage("Anchor not found. There should be exactly one anchor in the testbench, to specify which body is fixed to the ground in the kinematic simnulation.", Severity.Error); return; } } foreach (var motion in testBench.Children.MotionLoadCollection) { var connectorList = motion .SrcConnections .ApplyMotionToJointCollection .Select(x => x.SrcEnds.Connector) .Concat(motion .DstConnections .ApplyMotionToJointCollection .Select(x => x.DstEnds.Connector) ); var toplevelSUT = testBench.Children.ComponentAssemblyCollection.FirstOrDefault(); foreach (var connector in connectorList) { OriginatingConnectorTraversal traverser = new OriginatingConnectorTraversal(connector); if (traverser.result != null) { CyPhy.KinematicJoint joint = GetJoint(traverser.result); if (joint != null) { Multibody.ModelLoadsMotion mbdMotion = new Multibody.ModelLoadsMotion(); mbdMotion.Active = (motion.Attributes.Active) ? Multibody.ModelLoadsMotionActive.on : Multibody.ModelLoadsMotionActive.off; mbdMotion.FreedomType = (Multibody.ModelLoadsMotionFreedomType)((int)motion.Attributes.JointFreedomType); mbdMotion.Function = motion.Attributes.CustomFunction; mbdMotion.JointID = cadDataContainer.GetJointIDFromGMEID(joint.ID); mbdMotion.MotionID = motion.Name; mbdMotion.TimeDerivative = (Multibody.ModelLoadsMotionTimeDerivative)((int)motion.Attributes.TimeDerivative); mbdMotion.Type = "JointMotion"; MotionList.Add(mbdMotion); } else { Logger.Instance.AddLogMessage("Kinematic motion is connected to a connector without joint information: " + connector.ToHyperLink(), Severity.Error); } } } } if (testBench.Children.AdamsScriptCollection.Any()) { Scripts = new List <Multibody.ModelScript>(); foreach (var script in testBench.Children.AdamsScriptCollection) { Scripts.Add(new Multibody.ModelScript() { Path = script.Attributes.Path }); } } ProcessContacts(testBench); }
public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase) { CyPhy.TestBench testBench = testBenchBase as CyPhy.TestBench; if (testBench == null) { testBench = CyPhyClasses.TestBench.Cast(testBenchBase.Impl); } base.TraverseTestBench(testBenchBase); //AnalysisID = testBench.ID; // R.O. added 11/15/2016, because the MSD_CAD.xme/TestBench_Valid was failing because the schema for CADAssmbly.xml requires // that ComponentID be set for Metrics/Metric attributes. For Mass, CenterOfGravity, BoundingBox, and Interference, // the metric applies to the entire assembly; therefore, we will use the top-level assembly as the ComponentID. var catlsut = testBench.Children.ComponentAssemblyCollection.FirstOrDefault(); // should be an instance b/c elaborate was called earlier if (catlsut == null) { // This check occurs earlier in ProcessCAD(), but will repeat here in case someone changes the code to not // test this earlier. throw new Exception("There is no elaborated system under test component assembly in the model!"); } // "|1" is set in other places in the code for the top-level assembly. Search on "|" to see those places. // If someone changes to another system ( different suffix than "|1") and does not change the following // line, then the CreateAssembly program will throw an exception. This will be caught by the build tests // (e.g. MSD_CAD.xme/TestBench_Valid). string topLevelAssemblyComponentInstanceID_temp = catlsut.Attributes.ConfigurationUniqueID + "|" + "1"; // CADComputations Metrics foreach (var conn in testBench.Children.CADComputation2MetricCollection) { CyPhy.CADComputationType cadcomputation = conn.SrcEnds.CADComputationType; TBComputation tbcomputation = new TBComputation(); tbcomputation.MetricID = conn.DstEnds.Metric.ID; if (cadcomputation is CyPhy.CenterOfGravity) { tbcomputation.ComponentID = topLevelAssemblyComponentInstanceID_temp; tbcomputation.RequestedValueType = (cadcomputation as CyPhy.CenterOfGravity).Attributes.CADComputationRequestedValue.ToString(); tbcomputation.ComputationType = TBComputation.Type.CENTEROFGRAVITY; } else if (cadcomputation is CyPhy.BoundingBox) { tbcomputation.ComponentID = topLevelAssemblyComponentInstanceID_temp; tbcomputation.RequestedValueType = (cadcomputation as CyPhy.BoundingBox).Attributes.CADComputationRequestedValue.ToString(); tbcomputation.ComputationType = TBComputation.Type.BOUNDINGBOX; } else if (cadcomputation is CyPhy.InterferenceCount) { tbcomputation.ComponentID = topLevelAssemblyComponentInstanceID_temp; tbcomputation.RequestedValueType = "Scalar"; tbcomputation.ComputationType = TBComputation.Type.INTERFERENCECOUNT; } else if (cadcomputation is CyPhy.Mass) { tbcomputation.ComponentID = topLevelAssemblyComponentInstanceID_temp; tbcomputation.RequestedValueType = "Scalar"; tbcomputation.ComputationType = TBComputation.Type.MASS; } this.StaticAnalysisMetrics.Add(tbcomputation); } // PointCoordinate Metrics foreach (var metric in testBench.Children.MetricCollection) { List <CyPhy.Point> points_list = new List <CyPhy.Point>(); foreach (var pt in metric.SrcConnections.PointCoordinates2MetricCollection) { points_list.Add(pt.SrcEnds.Point); } foreach (var pt in metric.DstConnections.PointCoordinates2MetricCollection) { points_list.Add(pt.DstEnds.Point); } if (points_list.Any()) { if (points_list.Count() > 1) { Logger.Instance.AddLogMessage("Metric should not be connected to multiple Point datums in a test bench.", Severity.Error); } CyPhy.Point point = points_list.First(); PointMetricTraversal traverser = new PointMetricTraversal(point); if (traverser.portsFound.Count() == 1) { TBComputation tbcomputation = new TBComputation(); tbcomputation.ComputationType = TBComputation.Type.POINTCOORDINATES; tbcomputation.MetricID = metric.ID; tbcomputation.RequestedValueType = "Vector"; tbcomputation.Details = (traverser.portsFound.First() as CyPhy.Point).Attributes.DatumName; tbcomputation.ComponentID = CyPhyClasses.Component.Cast(traverser.portsFound.First().ParentContainer.ParentContainer.Impl).Attributes.InstanceGUID; tbcomputation.MetricName = metric.Name; StaticAnalysisMetrics.Add(tbcomputation); } } } // Post Processing Blocks foreach (var postprocess in testBench.Children.PostProcessingCollection) { PostProcessScripts.Add(postprocess.Attributes.ScriptPath); } }
public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase) { CyPhy.TestBench testBench = testBenchBase as CyPhy.TestBench; if (testBench == null) testBench = CyPhyClasses.TestBench.Cast(testBenchBase.Impl); base.TraverseTestBench(testBenchBase); //AnalysisID = testBench.ID; // CADComputations Metrics foreach (var conn in testBench.Children.CADComputation2MetricCollection) { CyPhy.CADComputationType cadcomputation = conn.SrcEnds.CADComputationType; TBComputation tbcomputation = new TBComputation(); tbcomputation.MetricID = conn.DstEnds.Metric.ID; if (cadcomputation is CyPhy.CenterOfGravity) { tbcomputation.RequestedValueType = (cadcomputation as CyPhy.CenterOfGravity).Attributes.CADComputationRequestedValue.ToString(); tbcomputation.ComputationType = TBComputation.Type.CENTEROFGRAVITY; } else if (cadcomputation is CyPhy.BoundingBox) { tbcomputation.RequestedValueType = (cadcomputation as CyPhy.BoundingBox).Attributes.CADComputationRequestedValue.ToString(); tbcomputation.ComputationType = TBComputation.Type.BOUNDINGBOX; } else if (cadcomputation is CyPhy.InterferenceCount) { tbcomputation.RequestedValueType = "Scalar"; tbcomputation.ComputationType = TBComputation.Type.INTERFERENCECOUNT; } else if (cadcomputation is CyPhy.Mass) { tbcomputation.RequestedValueType = "Scalar"; tbcomputation.ComputationType = TBComputation.Type.MASS; } Computations.Add(tbcomputation); } // PointCoordinate Metrics foreach (var metric in testBench.Children.MetricCollection) { List<CyPhy.Point> points_list = new List<CyPhy.Point>(); foreach (var pt in metric.SrcConnections.PointCoordinates2MetricCollection) { points_list.Add(pt.SrcEnds.Point); } foreach (var pt in metric.DstConnections.PointCoordinates2MetricCollection) { points_list.Add(pt.DstEnds.Point); } if (points_list.Any()) { if (points_list.Count() > 1) Logger.Instance.AddLogMessage("Metric should not be connected to multiple Point datums in a test bench.", Severity.Error); CyPhy.Point point = points_list.First(); PointMetricTraversal traverser = new PointMetricTraversal(point); if (traverser.portsFound.Count() == 1) { TBComputation tbcomputation = new TBComputation(); tbcomputation.ComputationType = TBComputation.Type.POINTCOORDINATES; tbcomputation.MetricID = metric.ID; tbcomputation.RequestedValueType = "Vector"; tbcomputation.FeatureDatumName = (traverser.portsFound.First() as CyPhy.Point).Attributes.DatumName; tbcomputation.ComponentID = CyPhyClasses.Component.Cast(traverser.portsFound.First().ParentContainer.ParentContainer.Impl).Attributes.InstanceGUID; tbcomputation.MetricName = metric.Name; Computations.Add(tbcomputation); } } } // Post Processing Blocks foreach (var postprocess in testBench.Children.PostProcessingCollection) { PostProcessScripts.Add(postprocess.Attributes.ScriptPath); } }