Пример #1
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);
                }
            }
        }
Пример #2
0
        public virtual void TraverseTestBench(CyPhy.TestBenchType testBench)
        {
            AnalysisID = testBench.ID;

            MakeRep    = GetParameterValue(testBench, "MAKE_REP");
            DefaultRep = GetParameterValue(testBench, "DEFAULT_REP");
            BuyRep     = GetParameterValue(testBench, "BUY_REP");

            string exportParameterName;
            string exportFormat;

            exportParameterName = "EXPORT_STEP_AP203_SINGLE_FILE";
            exportFormat        = "AP203_Single_File";
            if (GetParameterValue(testBench, exportParameterName) != null)
            {
                if (!STEP_DataExchangeFormats.Contains(exportFormat, StringComparer.CurrentCultureIgnoreCase))
                {
                    STEP_DataExchangeFormats.Add(exportFormat);
                }
            }

            exportParameterName = "EXPORT_STEP_AP203_E2_SINGLE_FILE";
            exportFormat        = "AP203_E2_Single_File";
            if (GetParameterValue(testBench, exportParameterName) != null)
            {
                if (!STEP_DataExchangeFormats.Contains(exportFormat, StringComparer.CurrentCultureIgnoreCase))
                {
                    STEP_DataExchangeFormats.Add(exportFormat);
                }
            }

            exportParameterName = "EXPORT_STEP_AP203_E2_SEPARATE_PART_FILES";
            exportFormat        = "AP203_E2_Separate_Part_Files";
            if (GetParameterValue(testBench, exportParameterName) != null)
            {
                if (!STEP_DataExchangeFormats.Contains(exportFormat, StringComparer.CurrentCultureIgnoreCase))
                {
                    STEP_DataExchangeFormats.Add(exportFormat);
                }
            }

            exportParameterName = "EXPORT_STEP_AP214_SINGLE_FILE";
            exportFormat        = "AP214_Single_File";
            if (GetParameterValue(testBench, exportParameterName) != null)
            {
                if (!STEP_DataExchangeFormats.Contains(exportFormat, StringComparer.CurrentCultureIgnoreCase))
                {
                    STEP_DataExchangeFormats.Add(exportFormat);
                }
            }

            exportParameterName = "EXPORT_STEP_AP214_SEPARATE_PART_FILES";
            exportFormat        = "AP214_Separate_Part_Files";
            if (GetParameterValue(testBench, exportParameterName) != null)
            {
                if (!STEP_DataExchangeFormats.Contains(exportFormat, StringComparer.CurrentCultureIgnoreCase))
                {
                    STEP_DataExchangeFormats.Add(exportFormat);
                }
            }

            exportParameterName = "EXPORT_STEREOLITHOGRAPHY_ASCII";
            exportFormat        = "Stereolithography_ASCII";
            if (GetParameterValue(testBench, exportParameterName) != null)
            {
                if (!NonSTEP_DataExchangeFormats.Contains(exportFormat, StringComparer.CurrentCultureIgnoreCase))
                {
                    NonSTEP_DataExchangeFormats.Add(exportFormat);
                }
            }

            exportParameterName = "EXPORT_STEREOLITHOGRAPHY_BINARY";
            exportFormat        = "Stereolithography_Binary";
            if (GetParameterValue(testBench, exportParameterName) != null)
            {
                if (!NonSTEP_DataExchangeFormats.Contains(exportFormat, StringComparer.CurrentCultureIgnoreCase))
                {
                    NonSTEP_DataExchangeFormats.Add(exportFormat);
                }
            }

            exportParameterName = "EXPORT_INVENTOR";
            exportFormat        = "Inventor";
            if (GetParameterValue(testBench, exportParameterName) != null)
            {
                if (!NonSTEP_DataExchangeFormats.Contains(exportFormat, StringComparer.CurrentCultureIgnoreCase))
                {
                    NonSTEP_DataExchangeFormats.Add(exportFormat);
                }
            }

            exportParameterName = "EXPORT_PARASOLID";
            exportFormat        = "Parasolid";
            if (GetParameterValue(testBench, exportParameterName) != null)
            {
                if (!NonSTEP_DataExchangeFormats.Contains(exportFormat, StringComparer.CurrentCultureIgnoreCase))
                {
                    NonSTEP_DataExchangeFormats.Add(exportFormat);
                }
            }

            exportParameterName = "EXPORT_DXF_2013";
            exportFormat        = "DXF_2013";
            if (GetParameterValue(testBench, exportParameterName) != null)
            {
                if (!NonSTEP_DataExchangeFormats.Contains(exportFormat, StringComparer.CurrentCultureIgnoreCase))
                {
                    NonSTEP_DataExchangeFormats.Add(exportFormat);
                }
            }


            foreach (var param in testBench.Children.ParameterCollection.Where(p => p.Name == "PROCESSINGINSTRUCTION"))
            {
                string[] paramarr = param.Attributes.Value.Split(',');
                ProcessingInstructions.Add(new KeyValuePair <string, string>(paramarr[0], paramarr.Length > 1 ? paramarr[1] : ""));
            }

            ExportComponentPoints = testBench.Children.ParameterCollection
                                    .Where(p => p.Name == "Export_All_Component_Points")
                                    .Any();



            // R.O. 1/26/2015, InterferenceCheck deprecated. Now interference check is specified by adding a InterferenceCount to
            // a CADComputationComponent
            //var interference = testBench.Children.ParameterCollection.Where(p => p.Name == "INTERFERENCE_CHECK");
            //if (interference.Any())
            //{
            //   if (interference.First().Attributes.Value == "1")
            //  {
            //       InterferenceCheck = true;
            //   }
            //}

            // [email protected]: Collect additional CAD executable parameters from the assembly
            if (testBench.Children.TopLevelSystemUnderTestCollection.Any())
            {
                if (testBench.Children.TopLevelSystemUnderTestCollection.First().AllReferred is CyPhy.ComponentAssembly)
                {
                    var assembly = testBench.Children.TopLevelSystemUnderTestCollection.First().AllReferred as CyPhy.ComponentAssembly;
                    var param    = assembly.Children.ParameterCollection.Where(p => p.Name.ToUpper() == "CADEXEPARAMS");
                    if (param.Any())
                    {
                        this.CADOptions = param.First().Attributes.Value;
                    }
                }
            }
            else if (testBench.Children.ComponentAssemblyCollection.Any())
            {
                var assembly = testBench.Children.ComponentAssemblyCollection.First();
                var param    = assembly.Children.ParameterCollection.Where(p => p.Name.ToUpper() == "CADEXEPARAMS");
                if (param.Any())
                {
                    this.CADOptions = param.First().Attributes.Value;
                }
            }
        }
Пример #3
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;
            }
        }