Beispiel #1
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;
                }
            }
        }
Beispiel #2
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);
            }
        }