示例#1
0
        /// <summary>
        /// Exports the design space into design interchange format AVM Design Model and indexes the file
        /// in the project manifest.
        /// </summary>
        /// <param name="projectManifest">Given project manifest object.</param>
        /// <returns>True if exporting and indexing are successful, otherwise false.</returns>
        public bool SaveDesignSpace(AVM.DDP.MetaAvmProject projectManifest)
        {
            if (projectManifest == null)
            {
                throw new ArgumentNullException("projectManifest");
            }

            this.ThrowIfNotExpanded();

            if (this.OriginalSystemUnderTest == null)
            {
                return(true);
            }
            else if (this.OriginalSystemUnderTest.AllReferred is CyPhy.DesignContainer)
            {
                bool success = false;
                try
                {
                    success = projectManifest.SaveDesign(this.OriginalSystemUnderTest.Referred.DesignEntity);
                }
                catch (Exception ex)
                {
                    throw new AnalysisModelProcessorException("Saving design space model failed.", ex);
                }

                return(success);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        public override void SaveTestBenchManifest(AVM.DDP.MetaAvmProject project, string configurationName, DateTime analysisStartTime)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            this.ThrowIfNotExpanded();

            this.EnsureOutputDirectory();

            try
            {
                project.SaveTestBenchManifest(
                    this.Configuration.Name,
                    configurationName,
                    this.expandedTestBenchType,
                    this.OutputDirectory,
                    this.testBenchType,
                    analysisStartTime);
            }
            catch (Exception ex)
            {
                throw new AnalysisModelProcessorException("Saving test bench manifest failed.", ex);
            }
        }
示例#3
0
        public static void CreateCADManifest(string projectJsonPath)
        {
            // [1] Parse project json file
            // [2] Go through Component list
            // [3] Parse each ComponentData.component.json
           
            if (!File.Exists(projectJsonPath))
                return;

            string projectRoot = Path.GetDirectoryName(projectJsonPath);
            AVM.DDP.MetaAvmProject avmProj = new AVM.DDP.MetaAvmProject();

            if (File.Exists(projectJsonPath))
            {
                string sjson = "{}";
                using (StreamReader reader = new StreamReader(projectJsonPath))
                {
                    sjson = reader.ReadToEnd();
                    avmProj = JsonConvert.DeserializeObject<AVM.DDP.MetaAvmProject>(sjson);
                }
            }

            List<string> cadFileDirs = FindComponentCreoFiles(avmProj.Project.Components, projectRoot);
            if (cadFileDirs.Any())
            {
                using (StreamWriter writer = new StreamWriter(Path.Combine(projectRoot, "cadmanifest.txt")))
                {
                    foreach (string dir in cadFileDirs)
                    {
                        writer.WriteLine(dir);
                    }
                }
            }
        }
示例#4
0
 public override bool SaveDesign(AVM.DDP.MetaAvmProject projectManifest)
 {
     if (this.Configuration == null)
     {
         // standalone PET doesn't have design model
         return(true);
     }
     return(base.SaveDesign(projectManifest));
 }
        public override void SaveTestBenchManifest(AVM.DDP.MetaAvmProject project, string configurationName, DateTime analysisStartTime)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            // TODO: implement this method!
        }
示例#6
0
        public override void SaveTestBenchManifest(AVM.DDP.MetaAvmProject project, string configurationName, DateTime analysisStartTime)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            this.ThrowIfNotExpanded();

            this.EnsureOutputDirectory();

            project.SaveTestBenchManifest(
                this.Configuration != null ? this.Configuration.Name : this.parametricExploration.Name,
                configurationName,
                this.parametricExploration.Name,
                expandedParametricExploration,
                this.OutputDirectory,
                analysisStartTime);
        }
示例#7
0
        public void ProjectManifestPopulationTest()
        {
            var testPath = Path.Combine(Common._importModelDirectory, "ProjectManifestPopulation");
            var xmePath  = Path.Combine(testPath, "InputModel.xme");

            var pathGeneratedManifest = Path.Combine(testPath, "manifest.project.json");

            // Delete manifest, if it exists
            if (File.Exists(pathGeneratedManifest))
            {
                File.Delete(pathGeneratedManifest);
            }

            var mgaFilename = Path.ChangeExtension(xmePath, "mga");

            GME.MGA.MgaUtils.ImportXME(xmePath, mgaFilename);

            var mgaProject = Common.GetProject(mgaFilename);

            Assert.True(mgaProject != null, "Could not load MGA project.");

            AVM.DDP.MetaAvmProject proj = null;
            bool resultIsNull           = false;
            var  mgaGateway             = new MgaGateway(mgaProject);

            mgaGateway.PerformInTransaction(delegate {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                var result = importer.ImportFile(mgaProject, testPath, Path.Combine(testPath, "InputModel.component.acm"));
                if (result == null)
                {
                    resultIsNull = true;
                }

                // Load manifest while we're in a transaction
                proj = AVM.DDP.MetaAvmProject.Create(mgaProject);
            });
            Assert.False(resultIsNull, "Exception occurred during import.");
            Assert.False(File.Exists(pathGeneratedManifest), "Manifest erroneously generated");
        }
示例#8
0
        /// <summary>
        /// Exports the design into design interchange format AVM Design Model and indexes the file
        /// in the project manifest.
        /// </summary>
        /// <param name="projectManifest">Given project manifest object.</param>
        /// <returns>True if exporting and indexing are successful, otherwise false.</returns>
        public virtual bool SaveDesign(AVM.DDP.MetaAvmProject projectManifest)
        {
            if (projectManifest == null)
            {
                throw new ArgumentNullException("projectManifest");
            }

            this.ThrowIfNotExpanded();

            bool success = false;

            try
            {
                success = projectManifest.SaveDesign(this.Configuration);
            }
            catch (Exception ex)
            {
                throw new AnalysisModelProcessorException("Saving design model failed.", ex);
            }

            return(success);
        }
示例#9
0
        public override bool SaveTestBench(AVM.DDP.MetaAvmProject project)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            this.ThrowIfNotExpanded();

            this.EnsureOutputDirectory();

            var success = true;

            // NOTE: saving the original design space test benches
            foreach (var testbenchRef in this.parametricExploration.Children.TestBenchRefCollection)
            {
                var thisSuccess = project.SaveTestBench(testbenchRef.Referred.TestBenchType);
                success = success && thisSuccess;
            }

            return(success);
        }
示例#10
0
        public override bool SaveTestBench(AVM.DDP.MetaAvmProject project)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            this.ThrowIfNotExpanded();

            this.EnsureOutputDirectory();

            bool success = false;

            try
            {
                success = project.SaveTestBench(this.testBenchType);
            }
            catch (System.IO.IOException ex)
            {
                // ignore sharing violation:
                // if another process is writing the same testbench file, it will have the same contents
                int       HResult          = System.Runtime.InteropServices.Marshal.GetHRForException(ex);
                const int SharingViolation = 32;
                if ((HResult & 0xFFFF) == SharingViolation)
                {
                }
                else
                {
                    throw new AnalysisModelProcessorException("Saving test bench failed.", ex);
                }
            }
            catch (Exception ex)
            {
                throw new AnalysisModelProcessorException("Saving test bench failed.", ex);
            }

            return(success);
        }
示例#11
0
        public static void CreateCADManifest(string projectJsonPath)
        {
            // [1] Parse project json file
            // [2] Go through Component list
            // [3] Parse each ComponentData.component.json

            if (!File.Exists(projectJsonPath))
            {
                return;
            }

            string projectRoot = Path.GetDirectoryName(projectJsonPath);

            AVM.DDP.MetaAvmProject avmProj = new AVM.DDP.MetaAvmProject();

            if (File.Exists(projectJsonPath))
            {
                string sjson = "{}";
                using (StreamReader reader = new StreamReader(projectJsonPath))
                {
                    sjson   = reader.ReadToEnd();
                    avmProj = JsonConvert.DeserializeObject <AVM.DDP.MetaAvmProject>(sjson);
                }
            }

            List <string> cadFileDirs = FindComponentCreoFiles(avmProj.Project.Components, projectRoot);

            if (cadFileDirs.Any())
            {
                using (StreamWriter writer = new StreamWriter(Path.Combine(projectRoot, "cadmanifest.txt")))
                {
                    foreach (string dir in cadFileDirs)
                    {
                        writer.WriteLine(dir);
                    }
                }
            }
        }
示例#12
0
        public void InvokeEx(MgaProject project,
                            MgaFCO currentobj,
                            MgaFCOs selectedobjs,
                            int param)
        {
            if (!enabled)
            {
                return;
            }

            try
            {
                //ComponentIndex ci = new ComponentIndex();
                GMEConsole = GMEConsole.CreateFromProject(project);
                MgaGateway = new MgaGateway(project);
                this.Logger = new CyPhyGUIs.GMELogger(project, this.ComponentName);

                if (currentobj == null)
                {
                    this.Logger.WriteError("Invalid context. This interpreter can only be run if open in the correct context (E.g., test bench).");
                    return;
                }

                GMEConsole.Out.WriteLine(DateTime.Now.ToString() + " running CyPhyCADAnalysis Interpreter");

                //InitLogger();

                // [1] create avmproj
                string projectName = "";
                MgaGateway.PerformInTransaction(delegate
                {
                    projectName = project.Name;
                },
                transactiontype_enum.TRANSACTION_NON_NESTED);

                // META-3080: use passed in project directory, especially in SOTs where .mga file is in a different directory than manifest.project.json
                if (String.IsNullOrEmpty(this.ProjectRootDirectory))
                    this.ProjectRootDirectory = Path.GetDirectoryName(project.ProjectConnStr.Substring("MGA=".Length));
                string avmProjFileName = Path.Combine(this.ProjectRootDirectory, "manifest.project.json");
                //string avmProjFileName = Path.Combine(Path.GetDirectoryName(project.ProjectConnStr.Substring("MGA=".Length)), "manifest.project.json");
                //this.ProjectRootDirectory = Path.GetDirectoryName(avmProjFileName);
                AVM.DDP.MetaAvmProject avmProj = new AVM.DDP.MetaAvmProject();

                if (File.Exists(avmProjFileName))
                {
                    string sjson = "{}";
                    using (StreamReader reader = new StreamReader(avmProjFileName))
                    {
                        sjson = reader.ReadToEnd();
                        avmProj = JsonConvert.DeserializeObject<AVM.DDP.MetaAvmProject>(sjson);
                        this.AVMComponentList = avmProj.Project.Components;
                    }
                }
                // end create avmproj


                // [1] CyPhy2CAD                                 
                // [2] Export DDP, Manufacture XML, Manufacture Manifest
                // [3] Generate AppendArtifact.py - script to append artifacts to testbench_manifest.json files
                // [4] Generate DesignModel1BOM.py - script to generate .bom.json from ddp file
                // [5] Generate main run bat file

                //CallCAD(project, currentobj, selectedobjs, param);                              // CyPhy2CAD                  
                MgaGateway.PerformInTransaction(delegate
                {
                    string kindName = string.Empty;
                    if (currentobj != null)
                    {
                        kindName = currentobj.MetaBase.Name;
                    }

                    if (string.IsNullOrEmpty(kindName) == false && kindName != typeof(CyPhyClasses.TestBench).Name)
                    {
                        Logger.WriteFailed("CyPhyCADAnalysis must be called from a TestBench.");
                        return;
                    }


                    ElaborateModel(project, currentobj, selectedobjs, param);                       // elaborate model        
                    CallCAD(project, currentobj, selectedobjs, param);                              // CyPhy2CAD
                    CallComponentExporter(project, currentobj, selectedobjs, param);                // JS: 7-15-13

                    ManufacturingGeneration(currentobj);                                            // DDP, Manufacture XML, Manufacture Manifest
                },
                transactiontype_enum.TRANSACTION_NON_NESTED);


                GenerateAppendArtifactScript();                                                     // AppendArtifact.py                                               
                GenerateBOMGenScript();                                                             // DesignModel1BOM.py                                                 
                //GenerateAnalysisFilesScript(wkflow_param);

                GenerateRunBatFile();                                                               // main run bat file                                            

                GMEConsole.Out.WriteLine("CyPhyCADAnalysis Interpreter Finished!");
            }

            catch (Exception ex)
            {
                Logger.WriteError("{0} has finished with critical errors. Please see above.", this.ComponentName);
                Logger.WriteError("Error Message: {0}", ex.Message);
            }
            finally
            {
                if (Logger!=null) Logger.Dispose();
                MgaGateway = null;
                project = null;
                currentobj = null;
                selectedobjs = null;
                GMEConsole = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            Trace.Flush();
            Trace.Close();
        }
示例#13
0
 /// <summary>
 /// Saves the test bench descriptor file to the test bench directory and indexes the newly generated file
 /// in the project manifest.
 /// </summary>
 /// <param name="projectManifest">Manifest object of the project.</param>
 /// <returns>True if the manifest was saved and indexed successfully, otherwise false.</returns>
 public abstract bool SaveTestBench(AVM.DDP.MetaAvmProject projectManifest);
示例#14
0
 /// <summary>
 /// Saves the test bench manifest file to interpreter's output directory and indexes the newly generated file
 /// in the project manifest.
 /// </summary>
 /// <param name="projectManifest">Manifest object of the project.</param>
 public abstract void SaveTestBenchManifest(AVM.DDP.MetaAvmProject projectManifest, string configurationName, DateTime analysisStartTime);
示例#15
0
        public void InvokeEx(MgaProject project,
                             MgaFCO currentobj,
                             MgaFCOs selectedobjs,
                             int param)
        {
            if (!enabled)
            {
                return;
            }

            try
            {
                //ComponentIndex ci = new ComponentIndex();
                GMEConsole  = GMEConsole.CreateFromProject(project);
                MgaGateway  = new MgaGateway(project);
                this.Logger = new CyPhyGUIs.GMELogger(project, this.ComponentName);

                if (currentobj == null)
                {
                    this.Logger.WriteError("Invalid context. This interpreter can only be run if open in the correct context (E.g., test bench).");
                    return;
                }

                GMEConsole.Out.WriteLine(DateTime.Now.ToString() + " running CyPhyCADAnalysis Interpreter");

                //InitLogger();

                // [1] create avmproj
                string projectName = "";
                MgaGateway.PerformInTransaction(delegate
                {
                    projectName = project.Name;
                },
                                                transactiontype_enum.TRANSACTION_NON_NESTED);

                // META-3080: use passed in project directory, especially in SOTs where .mga file is in a different directory than manifest.project.json
                if (String.IsNullOrEmpty(this.ProjectRootDirectory))
                {
                    this.ProjectRootDirectory = Path.GetDirectoryName(project.ProjectConnStr.Substring("MGA=".Length));
                }
                string avmProjFileName = Path.Combine(this.ProjectRootDirectory, "manifest.project.json");
                //string avmProjFileName = Path.Combine(Path.GetDirectoryName(project.ProjectConnStr.Substring("MGA=".Length)), "manifest.project.json");
                //this.ProjectRootDirectory = Path.GetDirectoryName(avmProjFileName);
                AVM.DDP.MetaAvmProject avmProj = new AVM.DDP.MetaAvmProject();

                if (File.Exists(avmProjFileName))
                {
                    string sjson = "{}";
                    using (StreamReader reader = new StreamReader(avmProjFileName))
                    {
                        sjson   = reader.ReadToEnd();
                        avmProj = JsonConvert.DeserializeObject <AVM.DDP.MetaAvmProject>(sjson);
                        this.AVMComponentList = avmProj.Project.Components;
                    }
                }
                // end create avmproj


                // [1] CyPhy2CAD
                // [2] Export DDP, Manufacture XML, Manufacture Manifest
                // [3] Generate AppendArtifact.py - script to append artifacts to testbench_manifest.json files
                // [4] Generate DesignModel1BOM.py - script to generate .bom.json from ddp file
                // [5] Generate main run bat file

                //CallCAD(project, currentobj, selectedobjs, param);                              // CyPhy2CAD
                MgaGateway.PerformInTransaction(delegate
                {
                    string kindName = string.Empty;
                    if (currentobj != null)
                    {
                        kindName = currentobj.MetaBase.Name;
                    }

                    if (string.IsNullOrEmpty(kindName) == false && kindName != typeof(CyPhyClasses.TestBench).Name)
                    {
                        Logger.WriteFailed("CyPhyCADAnalysis must be called from a TestBench.");
                        return;
                    }


                    ElaborateModel(project, currentobj, selectedobjs, param);                       // elaborate model
                    CallCAD(project, currentobj, selectedobjs, param);                              // CyPhy2CAD
                    CallComponentExporter(project, currentobj, selectedobjs, param);                // JS: 7-15-13

                    ManufacturingGeneration(currentobj);                                            // DDP, Manufacture XML, Manufacture Manifest
                },
                                                transactiontype_enum.TRANSACTION_NON_NESTED);


                GenerateAppendArtifactScript();                                                     // AppendArtifact.py
                GenerateBOMGenScript();                                                             // DesignModel1BOM.py
                //GenerateAnalysisFilesScript(wkflow_param);

                GenerateRunBatFile();                                                               // main run bat file

                GMEConsole.Out.WriteLine("CyPhyCADAnalysis Interpreter Finished!");
            }

            catch (Exception ex)
            {
                Logger.WriteError("{0} has finished with critical errors. Please see above.", this.ComponentName);
                Logger.WriteError("Error Message: {0}", ex.Message);
            }
            finally
            {
                if (Logger != null)
                {
                    Logger.Dispose();
                }
                MgaGateway   = null;
                project      = null;
                currentobj   = null;
                selectedobjs = null;
                GMEConsole   = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            Trace.Flush();
            Trace.Close();
        }