Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase)
        {
            // META-3195 - CFD needs Inventor format now instead of STL ASCII
            STLDataExchangeFormats.Add("Inventor");

            CyPhy.CFDTestBench testBench = testBenchBase as CyPhy.CFDTestBench;
            if (testBench == null)
                testBench = CyPhyClasses.CFDTestBench.Cast(testBenchBase.Impl);

            base.TraverseTestBench(testBenchBase); //AnalysisID = testBench.ID;

            foreach (var conn in testBench.Children.CFDComputation2MetricCollection)
            {
                TBComputation tbcomputation = new TBComputation();
                tbcomputation.MetricID = conn.DstEnds.Metric.ID;
                tbcomputation.ComputationType = TBComputation.Type.COEFFICIENTOFDRAG;
                tbcomputation.RequestedValueType = "SCALAR";
                Computations.Add(tbcomputation);
            }

            int calmSolverCnt = testBench.Children.CalmWaterSolverSettingsCollection.Count();
            int waveSolverCnt = testBench.Children.WaveResistanceSolverSettingsCollection.Count();
            int correlationSolverCnt = testBench.Children.CorrelationSettingsCollection.Count();
            int hydrostaticsSolverCnt = testBench.Children.HydrostaticsSolverSettingsCollection.Count();

            if ((calmSolverCnt + waveSolverCnt + correlationSolverCnt + hydrostaticsSolverCnt) < 1)
            {
                Logger.Instance.AddLogMessage("No CFD solver settings in the test bench", Severity.Error);
                return;
            }

            if (hydrostaticsSolverCnt > 1 || (calmSolverCnt + waveSolverCnt + correlationSolverCnt) > 1)
            {
                Logger.Instance.AddLogMessage(
                    "Multiple CFD solver settings in the test bench", 
                    Severity.Error);
                Logger.Instance.AddLogMessage( 
                    "A test bench can only contain one hydrostatics and one calm, wave or correlation solver setting.", 
                    Severity.Info);
                return;
            }

            #region ValidAttributes

            double MinVelocity = 0;
            double MaxVelocity = 343;
            double AbsZero = -273.15;
            double MaxTemp = 100;
            double MinAngle = 0;
            double MaxAngle = 360;

            #endregion

            if (hydrostaticsSolverCnt == 1)
            {
                CyPhy.HydrostaticsSolverSettings solverSettings = testBench.Children.HydrostaticsSolverSettingsCollection.First();

                if (solverSettings.Attributes.FluidTemperature < AbsZero ||
                    solverSettings.Attributes.FluidTemperature > MaxTemp)
                {
                    string message = string.Format(
                        "'{0}': 'FluidTemperature' attribute must be [{1} - {2}]",
                        solverSettings.Name,
                        AbsZero,
                        MaxTemp);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                if (solverSettings.Attributes.PitchAngleStart < MinAngle ||
                    solverSettings.Attributes.PitchAngleStart > MaxAngle ||
                    solverSettings.Attributes.PitchAngleEnd < MinAngle ||
                    solverSettings.Attributes.PitchAngleEnd > MaxAngle ||
                    solverSettings.Attributes.RollAngleStart < MinAngle ||
                    solverSettings.Attributes.RollAngleStart > MaxAngle ||
                    solverSettings.Attributes.RollAngleEnd < MinAngle ||
                    solverSettings.Attributes.RollAngleEnd > MaxAngle ||
                    solverSettings.Attributes.PitchAngleStepSize < MinAngle ||
                    solverSettings.Attributes.PitchAngleStepSize > MaxAngle ||
                    solverSettings.Attributes.RollAngleStepSize < MinAngle ||
                    solverSettings.Attributes.RollAngleStepSize > MaxAngle)
                {
                    string message = string.Format(
                        "'{0}': 'Angle' attributes must be [{1}-{2}]",
                        solverSettings.Name,
                        MinAngle,
                        MaxAngle);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                cfdConfigs.Add(new CFDConfig.HydrostaticsSolverSettings(solverSettings, testBench));
            }

            if (calmSolverCnt == 1)
            {
                CyPhy.CalmWaterSolverSettings solverSettings = testBench.Children.CalmWaterSolverSettingsCollection.First();

                if (solverSettings.Attributes.VehicleVelocity > MaxVelocity ||
                    solverSettings.Attributes.VehicleVelocity < MinVelocity)
                {
                    string message = string.Format(
                        "'{0}': 'Velocity' attribute must be [{1}-{2}]",
                        solverSettings.Name,
                        MinVelocity,
                        MaxVelocity);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                if (solverSettings.Attributes.FluidTemperature < AbsZero ||
                    solverSettings.Attributes.FluidTemperature > MaxTemp)
                {
                    string message = string.Format(
                        "'{0}': 'FluidTemperature' attribute must be [{1} - {2}]",
                        solverSettings.Name,
                        AbsZero,
                        MaxTemp);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                cfdConfigs.Add(new CFDConfig.CalmWaterSolverSettings(solverSettings, testBench));
                return;
            }

            if (waveSolverCnt == 1)
            {
                CyPhy.WaveResistanceSolverSettings solverSettings = testBench.Children.WaveResistanceSolverSettingsCollection.First();

                if (solverSettings.Attributes.VehicleVelocity > MaxVelocity ||
                    solverSettings.Attributes.VehicleVelocity < MinVelocity)
                {
                    string message = string.Format(
                        "'{0}': 'Velocity' attribute must be [{1}-{2}]",
                        solverSettings.Name,
                        MinVelocity,
                        MaxVelocity);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                if (solverSettings.Attributes.FluidTemperature < AbsZero ||
                    solverSettings.Attributes.FluidTemperature > MaxTemp)
                {
                    string message = string.Format(
                        "'{0}': 'FluidTemperature' attribute must be [{1} - {2}]",
                        solverSettings.Name,
                        AbsZero,
                        MaxTemp);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                if (solverSettings.Attributes.WaveFrequency < 0)
                {
                    string message = string.Format(
                        "'{0}': 'WaveFrequency' attribute must be greater than 0",
                        solverSettings.Name);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                if (solverSettings.Attributes.WaveDirection < MinAngle ||
                    solverSettings.Attributes.WaveDirection > MaxAngle)
                {
                    string message = string.Format(
                        "'{0}': 'Angle' attributes must be [{1}-{2}]",
                        solverSettings.Name,
                        MinAngle,
                        MaxAngle);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                cfdConfigs.Add(new CFDConfig.WaveResistanceSolverSettings(solverSettings, testBench));
                return;
            }

            if (correlationSolverCnt == 1)
            {
                CyPhy.CorrelationSettings solverSettings = testBench.Children.CorrelationSettingsCollection.First();

                if (solverSettings.Attributes.VehicleVelocity > MaxVelocity ||
                    solverSettings.Attributes.VehicleVelocity < 0)
                {
                    string message = string.Format(
                        "'{0}': 'Velocity' attribute must be [{1}-{2}]",
                        solverSettings.Name,
                        MinVelocity,
                        MaxVelocity);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                cfdConfigs.Add(new CFDConfig.CorrelationSolverSettings(solverSettings, testBench));
                return;
            }

            // Post Processing Blocks
            foreach (var postprocess in testBench.Children.PostProcessingCollection)
            {
                PostProcessScripts.Add(postprocess.Attributes.ScriptPath);
            }

        }
Ejemplo n.º 3
0
        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);
                }
            }
        }
Ejemplo n.º 4
0
        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);
                }

            }
        }
Ejemplo n.º 5
0
        public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase)
        {           
            string stepFormat = "AP203_E2_Single_File";
            if (!DataExchangeFormats.Contains(stepFormat))
                DataExchangeFormats.Add(stepFormat);

            CyPhy.CADTestBench testBench = testBenchBase as CyPhy.CADTestBench;
            if (testBench == null)
                testBench = CyPhyClasses.CADTestBench.Cast(testBenchBase.Impl);

            this.CyphyTestBenchRef = testBench;
            base.TraverseTestBench(testBenchBase);

            AdjSurfTreatment = CyphyTestBenchRef.Attributes.AdjoiningTreatment;

            // Solver Settings
            ElementType = "MIDPOINT_PARABOLIC_FIXED";
            ShellType = "N/A";
            SolverType = testBench.Attributes.SolverType.ToString(); 
            MeshType = "SOLID";
            MaxAdaptiveIterations = testBench.Attributes.MaxAdaptiveIterations;

            FEAAnalysisType = "STRUCTURAL";
            if (testBench.Children.ThermalLoadCollection.Any() || testBench.Children.ThermalEnvironmentCollection.Any())
            {
                FEAAnalysisType = "THERMAL";
            }


            // Metrics
            foreach (var item in testBench.Children.TIP2StructuralMetricCollection)
            {
                if (item.SrcEnds.TestInjectionPoint != null)
                {
                    CyPhy.TestInjectionPoint tip = item.SrcEnds.TestInjectionPoint;
                    CyPhy.StructuralFEAComputation feaComp = item.DstEnds.StructuralFEAComputation;

                    if (tip.AllReferred == null)
                        continue;

                    List<CyPhy.Component> testComponents = new List<CyPhy.Component>();
                    if (tip.AllReferred is CyPhy.ComponentAssembly)
                    {
                        CollectLeafComponents(testComponents, tip.AllReferred as CyPhy.ComponentAssembly);
                    }
                    else if (tip.AllReferred is CyPhy.Component)
                    {
                        // Interested in components with CAD Model only
                        if ((tip.AllReferred as CyPhy.Component).Children.CADModelCollection.Any())
                            testComponents.Add(tip.AllReferred as CyPhy.Component);
                    }

                    foreach (CyPhy.Component comp in testComponents)
                    {
                        string compId = comp.Attributes.InstanceGUID;

                        foreach (var cyphycompport in feaComp.Children.StructuralAnalysisComputationTypeCollection)
                        {
                            TBComputation tbcomputation = new TBComputation();
                            if (cyphycompport is CyPhy.BearingStress)
                            {
                                tbcomputation.ComputationType = TBComputation.Type.BEARINGSTRESS;
                            } else if (cyphycompport is CyPhy.MisesStress)
                            {
                                tbcomputation.ComputationType = TBComputation.Type.VONMISESSTRESS;
                            } else if (cyphycompport is CyPhy.ShearStress)
                            {
                                tbcomputation.ComputationType = TBComputation.Type.SHEARSTRESS;
                            } else if (cyphycompport is CyPhy.MaximumDisplacement)
                            {
                                tbcomputation.ComputationType = TBComputation.Type.DISPLACEMENT;
                            } else if (cyphycompport is CyPhy.FactorOfSafety)
                            {
                                tbcomputation.ComputationType = TBComputation.Type.FACTOROFSAFETY;
                            }
                            tbcomputation.FeatureDatumName = "";
                            tbcomputation.RequestedValueType = "Scalar";
                            tbcomputation.Details = "InfiniteCycle";
                            tbcomputation.ComponentID = compId;

                            foreach (var cyphyconn in cyphycompport.DstConnections.FEAComputation2MetricCollection)
                            {
                                tbcomputation.MetricID = cyphyconn.DstEnds.Metric.ID;
                            }

                            if (!String.IsNullOrEmpty(tbcomputation.MetricID))
                                this.Computations.Add(tbcomputation);
                        }
                    }
                }
            }

            // Thermal Metrics
            foreach (var item in testBench.Children.TIP2ThermalMetricCollection)
            {
                if (item.SrcEnds.TestInjectionPoint != null)
                {
                    CyPhy.TestInjectionPoint tip = item.SrcEnds.TestInjectionPoint;
                    CyPhy.ThermalFEAComputation feaComp = item.DstEnds.ThermalFEAComputation;

                    if (tip.AllReferred == null)
                        continue;

                    List<CyPhy.Component> testComponents = new List<CyPhy.Component>();
                    if (tip.AllReferred is CyPhy.ComponentAssembly)
                    {
                        CollectLeafComponents(testComponents, tip.AllReferred as CyPhy.ComponentAssembly);
                    }
                    else if (tip.AllReferred is CyPhy.Component)
                    {
                        // Interested in components with CAD Model only
                        if ((tip.AllReferred as CyPhy.Component).Children.CADModelCollection.Any())
                            testComponents.Add(tip.AllReferred as CyPhy.Component);
                    }

                    foreach (CyPhy.Component comp in testComponents)
                    {
                        string compId = comp.Attributes.InstanceGUID;

                        foreach (var cyphycompport in feaComp.Children.ThermalAnalysisMetricsCollection)
                        {
                            TBComputation tbcomputation = new TBComputation();
                            if (cyphycompport is CyPhy.MinimumTemperature)
                            {
                                tbcomputation.ComputationType = TBComputation.Type.MINIMUMTEMPERATURE;
                            } else if (cyphycompport is CyPhy.MaximumTemperature)
                            {
                                tbcomputation.ComputationType = TBComputation.Type.MAXIMUMTEMPERATURE;
                            }
                            tbcomputation.FeatureDatumName = "";
                            tbcomputation.RequestedValueType = "Scalar";
                            tbcomputation.Details = "InfiniteCycle";
                            tbcomputation.ComponentID = compId;

                            foreach (var cyphyconn in cyphycompport.DstConnections.FEAComputation2MetricCollection)
                            {
                                tbcomputation.MetricID = cyphyconn.DstEnds.Metric.ID;
                            }

                            if (!String.IsNullOrEmpty(tbcomputation.MetricID))
                                this.Computations.Add(tbcomputation);
                        }
                    }
                }
            }

            bool convectionPresent = false;
            bool ambientTempPresent = false;

            // thermal elements
            foreach(var item in testBench.Children.ThermalFEAElementsCollection)
            {
                foreach (var conn in item.DstConnections.ThermalElement2TIPCollection)
                {
                    CyPhy.TestInjectionPoint tip = conn.DstEnds.TestInjectionPoint;

                    if (tip.AllReferred == null)
                        continue;

                    List<CyPhy.Component> testComponents = new List<CyPhy.Component>();
                    if (tip.AllReferred is CyPhy.ComponentAssembly)
                    {
                        CollectLeafComponents(testComponents, tip.AllReferred as CyPhy.ComponentAssembly);
                    }
                    else if (tip.AllReferred is CyPhy.Component)
                    {
                        // Interested in components with CAD Model only
                        if ((tip.AllReferred as CyPhy.Component).Children.CADModelCollection.Any())
                            testComponents.Add(tip.AllReferred as CyPhy.Component);
                    }

                    foreach (var component in testComponents)
                    {
                        FEAThermalElement[] element = FEAThermalElement.Extract(item, component.Attributes.InstanceGUID, null);
                        if (element.Where(e => e.Type == "Convection").Any())
                        {
                            convectionPresent = true;
                        }
                        ThermalElements.AddRange(element);
                    }
                }

                foreach (var conn in item.DstConnections.ThermalElements2GeometryCollection)
                {
                    CyPhy.GeometryBase geometryBase = conn.DstEnds.GeometryTypes;
                    string tipContextPath = Path.GetDirectoryName(geometryBase.Path);
                    CADGeometry geometryRep = FillOutGeometryRep(geometryBase.Impl as MgaFCO,
                                                                 tipContextPath);
                    FEAThermalElement[] element = FEAThermalElement.Extract(item, null, geometryRep);
                    ThermalElements.AddRange(element);
                }
            }

            if (testBench.Children.ThermalEnvironmentCollection.Any())
            {
                if (testBench.Children.ThermalEnvironmentCollection.Count() > 1)
                {
                    Logger.Instance.AddLogMessage("Multiple ThermalEnvironments are present in the testbench. There should be only one.", Severity.Error);
                }
                else
                {
                    if (!testBench.Children.ThermalEnvironmentCollection.First().Children.ParameterCollection.Any())
                    {
                        Logger.Instance.AddLogMessage("ThermalEnvironment is present but there are no parameters specified in it.", Severity.Warning);
                    }
                    else
                    {
                        foreach (var param in testBench.Children.ThermalEnvironmentCollection.First().Children.ParameterCollection)
                        {
                            var elem = new FEAThermalElement(param) { Unit = "K", ComponentID = cadDataContainer.assemblies.First().Key };
                            ThermalElements.Add(elem);
                            ambientTempPresent = true;
                        }
                    }
                }
            }

            if (convectionPresent && !ambientTempPresent)
            {
                Logger.Instance.AddLogMessage("Convection is present but no Ambient Temperature has been specified. Please specify Ambient Temperature.", Severity.Error);
            }

            // Constraints
            foreach (var cyphyconstraint in testBench.Children.AnalysisConstraintCollection)
            {
                if (cyphyconstraint.Kind == "PinConstraint")
                {
                    CyPhy.PinConstraint pinConstraint = CyPhyClasses.PinConstraint.Cast(cyphyconstraint.Impl);

                    // Geometry - must be a cylinder
                    foreach (var geometry in pinConstraint.DstConnections.Pin2CylinderCollection)
                    {
                        FEAPinConstraint feapinRep = new FEAPinConstraint();
                        feapinRep.AxialDisplacement = pinConstraint.Attributes.AxialDisplacement.ToString();
                        feapinRep.AxialRotation = pinConstraint.Attributes.AxialRotation.ToString();

                        CyPhy.CylinderGeometryType cylinderType = geometry.DstEnds.CylinderGeometryType;
                        if (cylinderType != null)
                        {
                            string tipContextPath = Path.GetDirectoryName(cylinderType.Path);
                            AddGeometry2Constraint(feapinRep,
                                                   cylinderType.Impl as MgaFCO,
                                                   tipContextPath, true);
                        }
                    }

                }
                else if (cyphyconstraint.Kind == "BallConstraint")
                {
                    CyPhy.BallConstraint ballConstraint = CyPhyClasses.BallConstraint.Cast(cyphyconstraint.Impl);

                    foreach (var item in ballConstraint.DstConnections.Ball2SphereCollection)
                    {
                        FEABallConstraint feaballRep = new FEABallConstraint();
                        CyPhy.SphereGeometryType sphereType = item.DstEnds.SphereGeometryType;
                        if (sphereType != null)
                        {
                            string tipContextPath = Path.GetDirectoryName(sphereType.Path);
                            AddGeometry2Constraint(feaballRep,
                                                   sphereType.Impl as MgaFCO,
                                                   tipContextPath, true);
                        }
                    }
                }
                else if (cyphyconstraint.Kind == "DisplacementConstraint")
                {
                    CyPhy.DisplacementConstraint displacementConstraint = CyPhyClasses.DisplacementConstraint.Cast(cyphyconstraint.Impl);                    

                    string tx = "FREE", ty = "FREE", tz = "FREE", tunit = "mm", rx = "FREE", ry = "FREE", rz = "FREE", runit = "deg";

                    CyPhy.Rotation rotation = displacementConstraint.Children.RotationCollection.FirstOrDefault();
                    if (rotation != null)
                    {
                        bool hasScalar = (rotation.Attributes.XDirection == CyPhyClasses.Rotation.AttributesClass.XDirection_enum.SCALAR) ||
                                         (rotation.Attributes.YDirection == CyPhyClasses.Rotation.AttributesClass.YDirection_enum.SCALAR) ||
                                         (rotation.Attributes.ZDirection == CyPhyClasses.Rotation.AttributesClass.ZDirection_enum.SCALAR) ;
                        rx = (rotation.Attributes.XDirection == CyPhyClasses.Rotation.AttributesClass.XDirection_enum.SCALAR) ? 
                              rotation.Attributes.XDirectionValue.ToString() : rotation.Attributes.XDirection.ToString();
                        ry = (rotation.Attributes.YDirection == CyPhyClasses.Rotation.AttributesClass.YDirection_enum.SCALAR) ?
                              rotation.Attributes.YDirectionValue.ToString() : rotation.Attributes.YDirection.ToString();
                        rz = (rotation.Attributes.ZDirection == CyPhyClasses.Rotation.AttributesClass.ZDirection_enum.SCALAR) ?
                              rotation.Attributes.ZDirectionValue.ToString() : rotation.Attributes.ZDirection.ToString();

                        if (!hasScalar)
                        {
                            runit = "N/A";
                        }
                        else
                        {
                            if (rotation.Referred.unit != null)
                                runit = rotation.Referred.unit.Name;
                        }
                    }

                    CyPhy.Translation translation = displacementConstraint.Children.TranslationCollection.FirstOrDefault();
                    if (translation != null)
                    {
                        bool hasScalar = (translation.Attributes.XDirection == CyPhyClasses.Translation.AttributesClass.XDirection_enum.SCALAR) ||
                                         (translation.Attributes.YDirection == CyPhyClasses.Translation.AttributesClass.YDirection_enum.SCALAR) ||
                                         (translation.Attributes.ZDirection == CyPhyClasses.Translation.AttributesClass.ZDirection_enum.SCALAR);
                        tx = (translation.Attributes.XDirection == CyPhyClasses.Translation.AttributesClass.XDirection_enum.SCALAR) ?
                              translation.Attributes.XDirectionValue.ToString() : translation.Attributes.XDirection.ToString();
                        ty = (translation.Attributes.YDirection == CyPhyClasses.Translation.AttributesClass.YDirection_enum.SCALAR) ?
                              translation.Attributes.YDirectionValue.ToString() : translation.Attributes.YDirection.ToString();
                        tz = (translation.Attributes.ZDirection == CyPhyClasses.Translation.AttributesClass.ZDirection_enum.SCALAR) ?
                              translation.Attributes.ZDirectionValue.ToString() : translation.Attributes.ZDirection.ToString();

                        if (!hasScalar)
                        {
                            tunit = "N/A";
                        }
                        else
                        {
                            if (translation.Referred.unit != null)
                                tunit = translation.Referred.unit.Name;
                        }
                        
                    }


                    foreach (var item in displacementConstraint.DstConnections.Displacement2GeometryCollection)
                    {
                        FEADisplacementConstraint feadispRep = new FEADisplacementConstraint();
                        feadispRep.Rotation_X = rx;
                        feadispRep.Rotation_Y = ry;
                        feadispRep.Rotation_Z = rz;
                        feadispRep.RotationUnits = runit;
                        feadispRep.Translation_X = tx;
                        feadispRep.Translation_Y = ty;
                        feadispRep.Translation_Z = tz;
                        feadispRep.TranslationUnits = tunit;

                        Logger.Instance.AddLogMessage(String.Format("DisplacementConstraint Units - Rotation Component = {0}, Translation Component = {1}", runit, tunit), Severity.Info);

                        CyPhy.GeometryBase geometry = item.DstEnds.GeometryBase;
                        if (geometry != null)
                        {
                            string tipContextPath = Path.GetDirectoryName(geometry.Path);
                            AddGeometry2Constraint(feadispRep,
                                                   geometry.Impl as MgaFCO,
                                                   tipContextPath, true);
                        }
                    }
                }
                
            }

            // Loads
            foreach (var cyphyload in testBench.Children.AnalysisLoadCollection)
            {
                if (cyphyload is CyPhy.ForceLoadParam)
                {
                    CyPhy.ForceLoadParam forceLoad = CyPhyClasses.ForceLoadParam.Cast(cyphyload.Impl);

                    double fx = 0.0, fy = 0.0, fz = 0.0, mx = 0.0, my = 0.0, mz = 0.0;
                    string funit = "N", munit = "N-mm";

                    CyPhy.Parameter p1 = GetForceLoadParam(forceLoad, "ForceX", out fx);
                    GetForceLoadParam(forceLoad, "ForceY", out fy);
                    GetForceLoadParam(forceLoad, "ForceZ", out fz);
                    CyPhy.Parameter p2 = GetForceLoadParam(forceLoad, "MomentX", out mx);
                    GetForceLoadParam(forceLoad, "MomentY", out my);
                    GetForceLoadParam(forceLoad, "MomentZ", out mz);

                    GetParamUnitName(p1, ref funit);
                    GetParamUnitName(p2, ref munit);


                    foreach (var item in forceLoad.DstConnections.ForceLoadParam2GeometryCollection)

                    {
                        FEAForceLoad feaforceRep = new FEAForceLoad();
                        feaforceRep.Force_X = fx;
                        feaforceRep.Force_Y = fy;
                        feaforceRep.Force_Z = fz;
                        feaforceRep.ForceUnit = funit;
                        feaforceRep.Moment_X = mx;
                        feaforceRep.Moment_Y = my;
                        feaforceRep.Moment_Z = mz;
                        feaforceRep.MomentUnit = munit;

                        Logger.Instance.AddLogMessage(String.Format("ForceLoad Units - Force Component = {0}, Moment Component = {1}", funit, munit), Severity.Info);

                        CyPhy.GeometryBase geometry = item.DstEnds.GeometryBase;
                        if (geometry != null)
                        {
                            string tipContextPath = Path.GetDirectoryName(geometry.Path);
                            AddGeometry2Load(feaforceRep,
                                             geometry.Impl as MgaFCO,
                                             tipContextPath, true);
                        }
                    }
                }
                else
                if (cyphyload is CyPhy.ForceLoad)
                {
                    Logger.Instance.AddLogMessage("ForceLoad is used in FEA testbench. This construct is obsolete, please use ForceLoadParam instead.", Severity.Warning);
                    CyPhy.ForceLoad forceLoad = CyPhyClasses.ForceLoad.Cast(cyphyload.Impl);
                    
                    double fx = 0.0, fy = 0.0, fz = 0.0, mx = 0.0, my = 0.0, mz = 0.0;
		            string funit = "N", munit = "N-mm";

                    CyPhy.Force force = forceLoad.Children.ForceCollection.FirstOrDefault();
                    if (force != null)
                    {
                        fx = force.Attributes.XDirectionValue;
                        fy = force.Attributes.YDirectionValue;
                        fz = force.Attributes.ZDirectionValue;
                        if (force.Referred.unit != null)
                            funit = force.Referred.unit.Name;
                    }

                    CyPhy.Moment moment = forceLoad.Children.MomentCollection.FirstOrDefault();
                    if (moment != null)
                    {
                        mx = moment.Attributes.XDirectionValue;
                        my = moment.Attributes.YDirectionValue;
                        mz = moment.Attributes.ZDirectionValue;
                        if (moment.Referred.unit != null)
                            munit = moment.Referred.unit.Name;
                    }


                    foreach (var item in forceLoad.DstConnections.Force2GeometryCollection)
                    {
                        FEAForceLoad feaforceRep = new FEAForceLoad();
                        feaforceRep.Force_X = fx;
                        feaforceRep.Force_Y = fy;
                        feaforceRep.Force_Z = fz;
                        feaforceRep.ForceUnit = funit;
                        feaforceRep.Moment_X = mx;
                        feaforceRep.Moment_Y = my;
                        feaforceRep.Moment_Z = mz;
                        feaforceRep.MomentUnit = munit;

                        Logger.Instance.AddLogMessage(String.Format("ForceLoad Units - Force Component = {0}, Moment Component = {1}", funit, munit), Severity.Info);

                        CyPhy.GeometryBase geometry = item.DstEnds.GeometryBase;
                        if (geometry != null)
                        {
                            string tipContextPath = Path.GetDirectoryName(geometry.Path);
                            AddGeometry2Load(feaforceRep,
                                             geometry.Impl as MgaFCO,
                                             tipContextPath, true);
                        }
                    }

                }
                else if (cyphyload is CyPhy.AccelerationLoadParam)
                {
                    CyPhy.AccelerationLoadParam acceleration = CyPhyClasses.AccelerationLoadParam.Cast(cyphyload.Impl);
                    FEAccelerationLoad feaaccelRep = new FEAccelerationLoad();
                    double x = 0;
                    double y = 0;
                    double z = 0;
                    CyPhy.Parameter p1 = GetAccelerationLoadParam(acceleration, "X", out x);
                    GetAccelerationLoadParam(acceleration, "Y", out y);
                    GetAccelerationLoadParam(acceleration, "Z", out z);
                    feaaccelRep.X = x;
                    feaaccelRep.Y = y;
                    feaaccelRep.Z = z;

                    string unit = "mm/s^2";
                    GetParamUnitName(p1, ref unit);
                    feaaccelRep.Units = unit;

                    Logger.Instance.AddLogMessage(String.Format("AccelerationLoad Units = {0}", feaaccelRep.Units), Severity.Info);

                    this.Loads.Add(feaaccelRep);

                }
                else if (cyphyload is CyPhy.AccelerationLoad)
                {
                    Logger.Instance.AddLogMessage("AccelerationLoad is used in FEA testbench. This construct is obsolete, please use AccelerationLoadParam instead.", Severity.Warning);
                    CyPhy.AccelerationLoad acceleration = CyPhyClasses.AccelerationLoad.Cast(cyphyload.Impl);
                    FEAccelerationLoad feaaccelRep = new FEAccelerationLoad();
                    feaaccelRep.X = acceleration.Attributes.XDirectionValue;
                    feaaccelRep.Y = acceleration.Attributes.YDirectionValue;
                    feaaccelRep.Z = acceleration.Attributes.ZDirectionValue;
                    if (acceleration.Referred.unit != null)
                        feaaccelRep.Units = acceleration.Referred.unit.Name;
                    else
                        feaaccelRep.Units = "mm/s^2";

                    Logger.Instance.AddLogMessage(String.Format("AccelerationLoad Units = {0}", feaaccelRep.Units), Severity.Info);

                    this.Loads.Add(feaaccelRep);
                }
                else if (cyphyload is CyPhy.PressureLoadParam)
                {
                    CyPhy.PressureLoadParam pressure = CyPhyClasses.PressureLoadParam.Cast(cyphyload.Impl);

                    foreach (var item in pressure.DstConnections.PressureParam2GeometryCollection)
                    {
                        FEAPressureLoad feapressRep = new FEAPressureLoad();
                        double p = 0;
                        CyPhy.Parameter p1 = GetPressureLoadParam(pressure, "PressureLoad", out p);
                        feapressRep.Value = p;
                        string unit = "MPa";
                        GetParamUnitName(p1, ref unit);
                        feapressRep.Units = unit;

                        Logger.Instance.AddLogMessage(String.Format("PressureLoad Units = {0}", feapressRep.Units), Severity.Info);

                        CyPhy.GeometryBase geometry = item.DstEnds.GeometryBase;
                        if (geometry != null)
                        {
                            string tipContextPath = Path.GetDirectoryName(geometry.Path);
                            AddGeometry2Load(feapressRep,
                                             geometry.Impl as MgaFCO,
                                             tipContextPath, true);
                        }
                    }
                }
                else if (cyphyload is CyPhy.PressureLoad)
                {
                    Logger.Instance.AddLogMessage("PressureLoad is used in FEA testbench. This construct is obsolete, please use PressureLoadParam instead.", Severity.Warning);

                    CyPhy.PressureLoad pressure = CyPhyClasses.PressureLoad.Cast(cyphyload.Impl);

                    foreach (var item in pressure.DstConnections.Pressure2GeometryCollection)
                    {
                        FEAPressureLoad feapressRep = new FEAPressureLoad();
                        feapressRep.Value = pressure.Attributes.Value;
                        if (pressure.Referred.unit != null)
                            feapressRep.Units = pressure.Referred.unit.Name;
                        else
                            feapressRep.Units = "MPa";

                        Logger.Instance.AddLogMessage(String.Format("PressureLoad Units = {0}", feapressRep.Units), Severity.Info);

                        CyPhy.GeometryBase geometry = item.DstEnds.GeometryBase;
                        if (geometry != null)
                        {
                            string tipContextPath = Path.GetDirectoryName(geometry.Path);
                            AddGeometry2Load(feapressRep,
                                             geometry.Impl as MgaFCO,
                                             tipContextPath, true);
                        }
                    }
                }
            }
            // Post Processing Blocks
            foreach (var postprocess in testBench.Children.PostProcessingCollection)
            {
                PostProcessScripts.Add(postprocess.Attributes.ScriptPath);
            }


        }
Ejemplo n.º 6
0
        private void AddGeometry2Load(FEALoadBase loadRep,
                                      MgaFCO geometryFCO,
                                      string tipContextPath, bool addcomputations)
        {
            GeometryTraversal traverser = new GeometryTraversal();
            traverser.TraverseGeometry(geometryFCO);
            
            CADGeometry geomRep = FillOutGeometryRep(geometryFCO,
                                                     tipContextPath);

            if (addcomputations)
            {
                foreach (var point in geomRep.GeometryFeatures)
                {
                    TBComputation tbcomputation = new TBComputation();
                    tbcomputation.ComputationType = TBComputation.Type.POINTCOORDINATES;
                    tbcomputation.MetricID = point.ComponentID + ":" + point.DatumName;
                    tbcomputation.RequestedValueType = "Vector";
                    tbcomputation.FeatureDatumName = point.DatumName;
                    tbcomputation.ComponentID = point.ComponentID;

                    StaticComputations.Add(tbcomputation);
                }
            }

            if (geomRep != null)
            {                     
                loadRep.AddGeometry(geomRep);
                this.Loads.Add(loadRep);
            }

        }
Ejemplo n.º 7
0
        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;
            }
        }
Ejemplo n.º 8
0
        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 (!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;
            }
        }
Ejemplo n.º 9
0
        public override void TraverseTestBench(CyPhy.TestBenchType testBenchBase)
        {
            // META-3195 - CFD needs Inventor format now instead of STL - Stereolithography_ASCII
            NonSTEP_DataExchangeFormats.Add("Inventor");

            CyPhy.CFDTestBench testBench = testBenchBase as CyPhy.CFDTestBench;
            if (testBench == null)
            {
                testBench = CyPhyClasses.CFDTestBench.Cast(testBenchBase.Impl);
            }

            base.TraverseTestBench(testBenchBase); //AnalysisID = testBench.ID;

            foreach (var conn in testBench.Children.CFDComputation2MetricCollection)
            {
                TBComputation tbcomputation = new TBComputation();
                tbcomputation.MetricID           = conn.DstEnds.Metric.ID;
                tbcomputation.ComputationType    = TBComputation.Type.COEFFICIENTOFDRAG;
                tbcomputation.RequestedValueType = "SCALAR";
                Computations.Add(tbcomputation);
            }

            int calmSolverCnt         = testBench.Children.CalmWaterSolverSettingsCollection.Count();
            int waveSolverCnt         = testBench.Children.WaveResistanceSolverSettingsCollection.Count();
            int correlationSolverCnt  = testBench.Children.CorrelationSettingsCollection.Count();
            int hydrostaticsSolverCnt = testBench.Children.HydrostaticsSolverSettingsCollection.Count();

            if ((calmSolverCnt + waveSolverCnt + correlationSolverCnt + hydrostaticsSolverCnt) < 1)
            {
                Logger.Instance.AddLogMessage("No CFD solver settings in the test bench", Severity.Error);
                return;
            }

            if (hydrostaticsSolverCnt > 1 || (calmSolverCnt + waveSolverCnt + correlationSolverCnt) > 1)
            {
                Logger.Instance.AddLogMessage(
                    "Multiple CFD solver settings in the test bench",
                    Severity.Error);
                Logger.Instance.AddLogMessage(
                    "A test bench can only contain one hydrostatics and one calm, wave or correlation solver setting.",
                    Severity.Info);
                return;
            }

            #region ValidAttributes

            double MinVelocity = 0;
            double MaxVelocity = 343;
            double AbsZero     = -273.15;
            double MaxTemp     = 100;
            double MinAngle    = 0;
            double MaxAngle    = 360;

            #endregion

            if (hydrostaticsSolverCnt == 1)
            {
                CyPhy.HydrostaticsSolverSettings solverSettings = testBench.Children.HydrostaticsSolverSettingsCollection.First();

                if (solverSettings.Attributes.FluidTemperature < AbsZero ||
                    solverSettings.Attributes.FluidTemperature > MaxTemp)
                {
                    string message = string.Format(
                        "'{0}': 'FluidTemperature' attribute must be [{1} - {2}]",
                        solverSettings.Name,
                        AbsZero,
                        MaxTemp);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                if (solverSettings.Attributes.PitchAngleStart < MinAngle ||
                    solverSettings.Attributes.PitchAngleStart > MaxAngle ||
                    solverSettings.Attributes.PitchAngleEnd < MinAngle ||
                    solverSettings.Attributes.PitchAngleEnd > MaxAngle ||
                    solverSettings.Attributes.RollAngleStart < MinAngle ||
                    solverSettings.Attributes.RollAngleStart > MaxAngle ||
                    solverSettings.Attributes.RollAngleEnd < MinAngle ||
                    solverSettings.Attributes.RollAngleEnd > MaxAngle ||
                    solverSettings.Attributes.PitchAngleStepSize < MinAngle ||
                    solverSettings.Attributes.PitchAngleStepSize > MaxAngle ||
                    solverSettings.Attributes.RollAngleStepSize < MinAngle ||
                    solverSettings.Attributes.RollAngleStepSize > MaxAngle)
                {
                    string message = string.Format(
                        "'{0}': 'Angle' attributes must be [{1}-{2}]",
                        solverSettings.Name,
                        MinAngle,
                        MaxAngle);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                cfdConfigs.Add(new CFDConfig.HydrostaticsSolverSettings(solverSettings, testBench));
            }

            if (calmSolverCnt == 1)
            {
                CyPhy.CalmWaterSolverSettings solverSettings = testBench.Children.CalmWaterSolverSettingsCollection.First();

                if (solverSettings.Attributes.VehicleVelocity > MaxVelocity ||
                    solverSettings.Attributes.VehicleVelocity < MinVelocity)
                {
                    string message = string.Format(
                        "'{0}': 'Velocity' attribute must be [{1}-{2}]",
                        solverSettings.Name,
                        MinVelocity,
                        MaxVelocity);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                if (solverSettings.Attributes.FluidTemperature < AbsZero ||
                    solverSettings.Attributes.FluidTemperature > MaxTemp)
                {
                    string message = string.Format(
                        "'{0}': 'FluidTemperature' attribute must be [{1} - {2}]",
                        solverSettings.Name,
                        AbsZero,
                        MaxTemp);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                cfdConfigs.Add(new CFDConfig.CalmWaterSolverSettings(solverSettings, testBench));
                return;
            }

            if (waveSolverCnt == 1)
            {
                CyPhy.WaveResistanceSolverSettings solverSettings = testBench.Children.WaveResistanceSolverSettingsCollection.First();

                if (solverSettings.Attributes.VehicleVelocity > MaxVelocity ||
                    solverSettings.Attributes.VehicleVelocity < MinVelocity)
                {
                    string message = string.Format(
                        "'{0}': 'Velocity' attribute must be [{1}-{2}]",
                        solverSettings.Name,
                        MinVelocity,
                        MaxVelocity);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                if (solverSettings.Attributes.FluidTemperature < AbsZero ||
                    solverSettings.Attributes.FluidTemperature > MaxTemp)
                {
                    string message = string.Format(
                        "'{0}': 'FluidTemperature' attribute must be [{1} - {2}]",
                        solverSettings.Name,
                        AbsZero,
                        MaxTemp);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                if (solverSettings.Attributes.WaveFrequency < 0)
                {
                    string message = string.Format(
                        "'{0}': 'WaveFrequency' attribute must be greater than 0",
                        solverSettings.Name);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                if (solverSettings.Attributes.WaveDirection < MinAngle ||
                    solverSettings.Attributes.WaveDirection > MaxAngle)
                {
                    string message = string.Format(
                        "'{0}': 'Angle' attributes must be [{1}-{2}]",
                        solverSettings.Name,
                        MinAngle,
                        MaxAngle);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                cfdConfigs.Add(new CFDConfig.WaveResistanceSolverSettings(solverSettings, testBench));
                return;
            }

            if (correlationSolverCnt == 1)
            {
                CyPhy.CorrelationSettings solverSettings = testBench.Children.CorrelationSettingsCollection.First();

                if (solverSettings.Attributes.VehicleVelocity > MaxVelocity ||
                    solverSettings.Attributes.VehicleVelocity < 0)
                {
                    string message = string.Format(
                        "'{0}': 'Velocity' attribute must be [{1}-{2}]",
                        solverSettings.Name,
                        MinVelocity,
                        MaxVelocity);

                    Logger.Instance.AddLogMessage(
                        message,
                        Severity.Error);
                }

                cfdConfigs.Add(new CFDConfig.CorrelationSolverSettings(solverSettings, testBench));
                return;
            }

            // Post Processing Blocks
            foreach (var postprocess in testBench.Children.PostProcessingCollection)
            {
                PostProcessScripts.Add(postprocess.Attributes.ScriptPath);
            }
        }
Ejemplo n.º 10
0
        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);
            }
        }
Ejemplo n.º 11
0
        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);
            }
        }