示例#1
0
        // This tests that the interpreters would not fail on null object
        public void CAD_CurrentObjectNull()
        {
            var XmePath = Path.GetFullPath(@"..\..\..\..\models\CADTeam\MSD_CAD.xme");

            UnpackXmes(XmePath);
            var mgaFile = XmePath.Replace(".xme", ".mga");

            string ProjectConnStr = "MGA=" + mgaFile;

            MgaProject project = new MgaProject();

            project.OpenEx(ProjectConnStr, "CyPhyML", null);
            try
            {
                var PrepIFABInt    = new CyPhyPrepareIFab.CyPhyPrepareIFabInterpreter();
                var CADAnalysisInt = new CyPhyCADAnalysis.CyPhyCADAnalysisInterpreter();
                var CyPhy2CAD      = new CyPhy2CAD_CSharp.CyPhy2CAD_CSharpInterpreter();

                PrepIFABInt.Initialize(project);
                CADAnalysisInt.Initialize(project);
                CyPhy2CAD.Initialize(project);

                Assert.DoesNotThrow(() => PrepIFABInt.InvokeEx(project, null, null, 16));
                Assert.DoesNotThrow(() => CyPhy2CAD.InvokeEx(project, null, null, 16));
                Assert.DoesNotThrow(() => CADAnalysisInt.InvokeEx(project, null, null, 16));
            }
            finally
            {
                project.Close(true);
            }
        }
示例#2
0
        public static bool Run(string originalProjectDir, MgaProject project, MgaFCO testObj, bool copycomponents)
        {
            bool status = true;

            try
            {
                var outputdirname = GetProjectDir(project);
                if (copycomponents)
                {
                    CopyDirectory(Path.Combine(originalProjectDir, "components"), Path.Combine(outputdirname, "components"));
                }

                var interpreter = new CyPhy2CAD_CSharp.CyPhy2CAD_CSharpInterpreter();
                interpreter.Initialize(project);

                var mainParameters = new CyPhyGUIs.InterpreterMainParameters();
                var cadSettings    = new CyPhy2CAD_CSharp.CyPhy2CADSettings();
                cadSettings.OutputDirectory     = outputdirname;
                cadSettings.AuxiliaryDirectory  = "";
                mainParameters.config           = cadSettings;
                mainParameters.Project          = project;
                mainParameters.CurrentFCO       = testObj;
                mainParameters.SelectedFCOs     = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs"));
                mainParameters.StartModeParam   = 128;
                mainParameters.ConsoleMessages  = false;
                mainParameters.ProjectDirectory = Path.GetDirectoryName(GetProjectDir(project));
                mainParameters.OutputDirectory  = outputdirname;

                interpreter.Main(mainParameters);
            }
            catch (Exception)
            {
                status = false;
            }
            finally
            {
                project.Close();
            }

            return(status);
        }
示例#3
0
        public static bool Run(string outputdirname, MgaProject project, MgaFCO testObj, bool copycomponents)
        {
            bool status = true;
            try
            {

                if (copycomponents)
                {
                    CopyDirectory(Path.Combine(GetProjectDir(project),"components"), Path.Combine(outputdirname, "components"));
                }

                var interpreter = new CyPhy2CAD_CSharp.CyPhy2CAD_CSharpInterpreter();
                interpreter.Initialize(project);

                var mainParameters = new CyPhyGUIs.InterpreterMainParameters();
                var cadSettings = new CyPhy2CAD_CSharp.CyPhy2CADSettings();
                cadSettings.OutputDirectory = outputdirname;
                cadSettings.AuxiliaryDirectory = "";
                mainParameters.config = cadSettings;
                mainParameters.Project = project;
                mainParameters.CurrentFCO = testObj;
                mainParameters.SelectedFCOs = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs"));
                mainParameters.StartModeParam = 128;
                mainParameters.ConsoleMessages = false;
                mainParameters.ProjectDirectory = Path.GetDirectoryName(GetProjectDir(project));
                mainParameters.OutputDirectory = outputdirname;

                interpreter.Main(mainParameters);
            }
            catch (Exception)
            {
                status = false;
            }
            finally
            {
                project.Close();
            }

            return status;

        }
示例#4
0
        // This tests that the interpreters would not fail on null object
        public void CAD_CurrentObjectNull()
        {
            var XmePath = Path.GetFullPath(@"..\..\..\..\models\CADTeam\MSD_CAD.xme");
            UnpackXmes(XmePath);
            var mgaFile = XmePath.Replace(".xme", ".mga");

            string ProjectConnStr = "MGA=" + mgaFile;
            
            MgaProject project = new MgaProject();
            project.OpenEx(ProjectConnStr, "CyPhyML", null);
            try
            {
                var PrepIFABInt = new CyPhyPrepareIFab.CyPhyPrepareIFabInterpreter();
                var CADAnalysisInt = new CyPhyCADAnalysis.CyPhyCADAnalysisInterpreter();
                var CyPhy2CAD = new CyPhy2CAD_CSharp.CyPhy2CAD_CSharpInterpreter();

                PrepIFABInt.Initialize(project);
                CADAnalysisInt.Initialize(project);
                CyPhy2CAD.Initialize(project);

                Assert.DoesNotThrow(() => PrepIFABInt.InvokeEx(project, null, null, 16));
                Assert.DoesNotThrow(() => CyPhy2CAD.InvokeEx(project, null, null, 16));
                Assert.DoesNotThrow(() => CADAnalysisInt.InvokeEx(project, null, null, 16));
            }
            finally
            {
                project.Close(true);
            }
        }
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            if (parameters.config == null)
            {
                throw new ArgumentNullException("Parameter 'parameters' cannot be null.");
            }
            if (false == (parameters.config is CyPhy2CADPCB_Settings))
            {
                throw new ArgumentException("Parameter 'parameters' is not of type CyPhy2CADPCB_Settings.");
            }

            this.mainParameters = parameters;
            
            try
            {
                // Call into CyPhy2CAD.
                // - Pass same context variables.
                // - Call the Main function so that no GUI is needed.
                // - Catch the "runcommand" that they pass out.

                CyPhy2CAD_CSharp.CyPhy2CAD_CSharpInterpreter cyphy2cad = new CyPhy2CAD_CSharp.CyPhy2CAD_CSharpInterpreter()
                {
                    InteractiveMode = true,   // JS: will be false in the future
                };
                cyphy2cad.Initialize(parameters.Project);

                String auxDir = Path.Combine(parameters.ProjectDirectory,
                                             "CAD");

                var cyphy2cad_parameters = new InterpreterMainParameters()
                {
                    config = new CyPhy2CAD_CSharp.CyPhy2CADSettings()
                    {
                        OutputDirectory = parameters.OutputDirectory,
                        AuxiliaryDirectory = auxDir
                    },
                    CurrentFCO = parameters.CurrentFCO,
                    OutputDirectory = parameters.OutputDirectory,
                    Project = parameters.Project,
                    ProjectDirectory = parameters.ProjectDirectory,
                    SelectedFCOs = parameters.SelectedFCOs                    
                };

                this.Logger.WriteInfo("CyPhy2CADPCB cadauxdir [{0}]", auxDir);

                this.Logger.WriteDebug("Running CyPhy2CAD.Main(...)");
                var cyphy2cad_result = cyphy2cad.Main(cyphy2cad_parameters);
                this.Logger.WriteDebug("Completed CyPhy2CAD.Main(...)");

                this.Logger.WriteInfo("CyPhy2CADPCB Layout.json path: [{0}]", (this.mainParameters.config as CyPhy2CADPCB_Settings).GetLayoutPath);
                GenerateScriptFiles(parameters.OutputDirectory);
                GenerateRunBatFile(parameters.OutputDirectory);

                this.result.RunCommand = "runAddComponentToPcbConstraints.bat";  //cyPhy2CAD_RunCommand
                this.result.Success = true;

                this.Logger.WriteInfo("CyPhy2CADPCB finished successfully.");
            }
            catch (Exception ex)
            {
                this.result.Success = false;
                this.Logger.WriteError("CyPhy2CADPCB has failed! ", ex.ToString());
            }
            finally
            {
                this.Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", parameters.OutputDirectory);
            }
            return this.result;
        }