示例#1
0
        // META-2987
        private void GenerateCADParameterMapping(CyPhy.TestBenchType testBench, string outputDir, List <object> cadParamList)
        {
            foreach (var parameter in testBench.Children.ParameterCollection)
            {
                List <CyPhy.CADParameter>    vftFound   = new List <CyPhy.CADParameter>();
                List <CyPhy.ValueFlowTarget> vftVisited = new List <CyPhy.ValueFlowTarget>();

                FindValueFlowTargets(parameter,
                                     vftFound,
                                     vftVisited);

                foreach (var cadParam in vftFound)
                {
                    CyPhy2CAD_CSharp.TestBenchModel.TBCadParameterMapping cadParameterMapping = new TestBenchModel.TBCadParameterMapping(cadParam, parameter.Name);
                    if (!String.IsNullOrEmpty(cadParameterMapping.ComponentInstanceGUID))
                    {
                        cadParamList.Add(cadParameterMapping);
                    }
                }
            }

            if (cadParamList.Any())
            {
                string mappingFileContent = Newtonsoft.Json.JsonConvert.SerializeObject(cadParamList);
                File.WriteAllText(Path.Combine(outputDir, "CADParamTestBenchMapping.json"), mappingFileContent, new UTF8Encoding(false));
            }

            // generate testbench_manifest.json if it does not exist

            if (true /*!File.Exists(Path.Combine(outputDir, "testbench_manifest.json"))*/)
            {
                AVM.DDP.MetaTBManifest tbManifest = new AVM.DDP.MetaTBManifest();
                tbManifest.MakeManifest(testBench,
                                        outputDir);
                tbManifest.Serialize(outputDir);
            }
        }
        // META-2987
        private void GenerateCADParameterMapping(CyPhy.TestBenchType testBench,
                                                 string outputDir)
        {
            List<CyPhy2CAD_CSharp.TestBenchModel.TBCadParameterMapping> cadParamList = new List<TestBenchModel.TBCadParameterMapping>();
            if (testBench.Children.ParameterCollection.Any())
            {
                foreach (var parameter in testBench.Children.ParameterCollection)
                {
                    List<CyPhy.CADParameter> vftFound = new List<CyPhy.CADParameter>();
                    List<CyPhy.ValueFlowTarget> vftVisited = new List<CyPhy.ValueFlowTarget>();
 
                    FindValueFlowTargets(parameter, 
                                         vftFound,
                                         vftVisited);

                    foreach (var cadParam in vftFound)
                    {
                        CyPhy2CAD_CSharp.TestBenchModel.TBCadParameterMapping cadParameterMapping = new TestBenchModel.TBCadParameterMapping(cadParam, parameter.Name);
                        if (!String.IsNullOrEmpty(cadParameterMapping.ComponentInstanceGUID))
                            cadParamList.Add(cadParameterMapping);
                    }
                }
            }

            if (cadParamList.Any())
            {
                string mappingFileContent = Newtonsoft.Json.JsonConvert.SerializeObject(cadParamList);
                using (StreamWriter writer = new StreamWriter(Path.Combine(outputDir, "CADParamTestBenchMapping.json")))
                {
                    writer.WriteLine(mappingFileContent);
                }
            }            

            // generate testbench_manifest.json if it does not exist
            
            if (true/*!File.Exists(Path.Combine(outputDir, "testbench_manifest.json"))*/)
            {
                AVM.DDP.MetaTBManifest tbManifest = new AVM.DDP.MetaTBManifest();
                tbManifest.MakeManifest(testBench,
                                        outputDir);
                tbManifest.Serialize(outputDir);
            }
            
        }