コード例 #1
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.mainParameters = (InterpreterMainParameters)parameters;

            try
            {
                MgaGateway = new MgaGateway(mainParameters.Project);

                var result = new InterpreterResult() { Success = true, RunCommand = "" };

                MgaGateway.PerformInTransaction(delegate
                {
                    MainInTransaction((InterpreterMainParameters)parameters);


                    // TODO: this part needs to be refactored!
                    var workflowRef = this.mainParameters
                        .CurrentFCO
                        .ChildObjects
                        .OfType<MgaReference>()
                        .FirstOrDefault(x => x.Meta.Name == "WorkflowRef");
                    
                    if (workflowRef != null)
                    {
                        string Parameters = workflowRef
                            .Referred
                            .ChildObjects
                            .OfType<MgaAtom>()
                            .FirstOrDefault(fco => fco.Meta.Name == typeof(CyPhy.Task).Name
                                && String.Equals(CyPhyClasses.Task.Cast(fco).Attributes.COMName, this.ComponentProgID, StringComparison.InvariantCultureIgnoreCase))
                            .StrAttrByName["Parameters"];

                        Dictionary<string, string> workflowParameters = new Dictionary<string, string>();

                        try
                        {
                            workflowParameters = (Dictionary<string, string>)Newtonsoft.Json.JsonConvert.DeserializeObject(Parameters, typeof(Dictionary<string, string>));
                            if (workflowParameters == null)
                            {
                                workflowParameters = new Dictionary<string, string>();
                            }
                        }
                        catch (Newtonsoft.Json.JsonReaderException)
                        {
                        }

                        META.AnalysisTool.ApplyToolSelection(this.ComponentProgID, workflowParameters, result, this.mainParameters);
                    }
                });

                return result;
            }
            finally
            {
                MgaGateway = null;                
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
コード例 #2
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            var result = new InterpreterResult();

            result.RunCommand = "runCarSim.bat";
            try
            {
                MgaGateway.PerformInTransaction(delegate
                {
                    if (parameters.CurrentFCO.MetaBase.Name == "CarTestBench")
                    {
                        try
                        {
                            var elaborator    = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                            elaborator.Logger = new GMELogger(parameters.Project);
                            //elaborator.Logger.AddWriter(Logger.Instance);
                            var elaboratorresult = elaborator.RunInTransaction(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam);
                            if (elaboratorresult == false)
                            {
                                throw new ApplicationException("see elaborator log");
                            }
                        }
                        catch (Exception e)
                        {
                            //Logger.Instance.AddLogMessage("Elaborator exception occurred: " + e.Message, Severity.Error);
                            throw new Exception(e.Message);
                        }
                        var testBench = CyPhyClasses.CarTestBench.Cast(parameters.CurrentFCO);

                        TestBenchProcessor processor = new TestBenchProcessor()
                        {
                            GMEConsole = GMEConsole, OutputDir = parameters.OutputDirectory, ProjectDir = parameters.ProjectDirectory
                        };
                        processor.Process(testBench);
                    }
                    else
                    {
                        GMEConsole.Error.WriteLine("Not a Car Test Bench.");
                        return;
                    }
                },
                                                transactiontype_enum.TRANSACTION_NON_NESTED, abort: true);
                result.Success = true;
            }
            catch (Exception ex)
            {
                GMEConsole.Error.WriteLine("Exception was raised: {0}", ex.ToString());
                result.Success = false;
            }
            finally
            {
//                parameters.Project.AbortTransaction();
                MgaGateway = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }

            return(result);
        }
コード例 #3
0
ファイル: CyPhyComplexity.cs プロジェクト: landunin/meta-core
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            OutputDirectory = parameters.OutputDirectory;
            CallElaboratorAndMain(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam);

            result.Success = true;
            return(result);
        }
コード例 #4
0
        /// <summary>
        /// No GUI and interactive elements are allowed within this function.
        /// </summary>
        /// <param name="parameters">Main parameters for this run and GUI configuration.</param>
        /// <returns>Result of the run, which contains a success flag.</returns>
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            if (Logger == null)
            {
                Logger = new GMELogger(parameters.Project, ComponentName);
            }

            this.runtime.Clear();
            this.mainParameters = parameters;
            var configSuccess = this.mainParameters != null;

            this.UpdateSuccess("Configuration", configSuccess);
            this.result.Labels = "RF";

            try
            {
                MgaGateway.PerformInTransaction(delegate
                {
                    this.WorkInMainTransaction();
                },
                                                transactiontype_enum.TRANSACTION_NON_NESTED,
                                                abort: true
                                                );

                this.PrintRuntimeStatistics();
                if (this.result.Success)
                {
                    Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                    Logger.WriteInfo("RF simulation has been created. [SUCCESS: {0}, Labels: {1}]", this.result.Success, this.result.Labels);
                }
                else
                {
                    Logger.WriteError("RF simulation cannot be created! See error messages above.");
                }
            }
            catch (Exception ex)
            {
                Logger.WriteError("Exception: {0}<br> {1}", ex.Message, ex.StackTrace);
            }
            finally
            {
                MgaGateway = null;
                if (Logger != null)
                {
                    Logger.Dispose();
                    Logger = null;
                }
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }

            META.Logger.RemoveFileListener(this.ComponentName);

            return(this.result);
        }
コード例 #5
0
ファイル: CyPhyElaborateCS.cs プロジェクト: daoos/meta-core
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            var result = new InterpreterResult();

            this.parameters   = parameters;
            result.Success    = this.RunInTransaction(parameters.CurrentFCO.Project, parameters.CurrentFCO, parameters.SelectedFCOs, 128, parameters.OutputDirectory);
            result.RunCommand = "cmd.exe /c \"\"";

            return(result);
        }
コード例 #6
0
        private void MainThrows(IInterpreterMainParameters parameters)
        {
            // TODO: remove this line, since this is the old implementation
            //this.OpenWebPageWithChromeOrDefaultBrowser("http://fame-deploy.parc.com:2040/");

            this.mainParameters = parameters as InterpreterMainParameters;

            this.result.Labels     = "";
            this.result.RunCommand = "";
            var config = META.ComComponent.DeserializeConfiguration(
                this.mainParameters.ProjectDirectory,
                typeof(CyPhyReliabilityAnalysisSettings),
                this.ComponentProgID) as CyPhyReliabilityAnalysisSettings;

            if (config != null)
            {
                this.mainParameters.config = config;
            }
            else
            {
                this.mainParameters.config = new CyPhyReliabilityAnalysisSettings();
            }

            if (Directory.Exists(this.mainParameters.OutputDirectory) == false)
            {
                Directory.CreateDirectory(this.mainParameters.OutputDirectory);
            }

            using (StreamWriter writer1 = new StreamWriter(Path.Combine(this.mainParameters.OutputDirectory, "bracket_config.json")))
            {
                writer1.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(
                                      new BracketConfig(this.mainParameters.config as CyPhyReliabilityAnalysisSettings),
                                      Newtonsoft.Json.Formatting.Indented));
            }

            // TODO: call all dependent interpreter

            MgaGateway.PerformInTransaction(() =>
            {
                this.WorkInMainTransaction();
            }, transactiontype_enum.TRANSACTION_NON_NESTED);

            //this.PrintRuntimeStatistics();
            if (this.result.Success)
            {
                this.Logger.WriteInfo("CyPhyReliabilityAnalysis 1.0 finished successfully.");
                this.Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                this.Logger.WriteDebug("[SUCCESS: {0}, Labels: {1}]", this.result.Success, this.result.Labels);
            }
            else
            {
                this.Logger.WriteError("CyPhyReliabilityAnalysis 1.0 failed! See error messages above.");
            }
        }
コード例 #7
0
 /// <summary>
 /// No GUI and interactive elements are allowed within this function.
 /// </summary>
 /// <param name="parameters">Main parameters for this run and GUI configuration.</param>
 /// <returns>Result of the run, which contains a success flag.</returns>
 public IInterpreterResult Main(IInterpreterMainParameters parameters)
 {
     try
     {
         return(_Main(parameters));
     }
     finally
     {
         DisposeLogger();
     }
 }
コード例 #8
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.OutputDirectory      = parameters.OutputDirectory;
            this.ProjectRootDirectory = parameters.ProjectDirectory;

            result.RunCommand = "PrepareIFab.bat";
            result.Labels     = "Creo&&CADCreoParametricCreateAssembly.exev1.4&&" + JobManager.Job.DefaultLabels;

            PrepareIFabConfig config = (PrepareIFabConfig)parameters.config;

            cadSettings.AuxiliaryDirectory       = config.AuxiliaryDirectory;
            cadSettings.StepFormats              = config.StepFormats;
            cadSettings.OtherDataFormat.STLAscii = true;
            InvokeEx(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam);

            MgaGateway.PerformInTransaction(() =>
            {
                // TODO: this part needs to be refactored!
                string Parameters = parameters
                                    .CurrentFCO
                                    .ChildObjects
                                    .OfType <MgaReference>()
                                    .FirstOrDefault(x => x.Meta.Name == "WorkflowRef")
                                    .Referred
                                    .ChildObjects
                                    .OfType <MgaAtom>()
                                    .FirstOrDefault(fco => fco.Meta.Name == typeof(CyPhy.Task).Name &&
                                                    String.Equals(CyPhyClasses.Task.Cast(fco).Attributes.COMName, this.ComponentProgID, StringComparison.InvariantCultureIgnoreCase))
                                    .StrAttrByName["Parameters"];

                Dictionary <string, string> workflowParameters = new Dictionary <string, string>();

                try
                {
                    workflowParameters = (Dictionary <string, string>)Newtonsoft.Json.JsonConvert.DeserializeObject(Parameters, typeof(Dictionary <string, string>));
                    if (workflowParameters == null)
                    {
                        workflowParameters = new Dictionary <string, string>();
                    }
                }
                catch (Newtonsoft.Json.JsonReaderException)
                {
                }

                META.AnalysisTool.ApplyToolSelection(this.ComponentProgID, workflowParameters, this.result, parameters);
            }, abort: true);

            result.Success = true;
            return(result);
        }
コード例 #9
0
        public CodeGenerator(IInterpreterMainParameters parameters, Mode mode, MgaTraceability traceability, Dictionary <string, CyPhy2SchematicInterpreter.IDs> mgaIdToDomainIDs, ISet <IMgaObject> selectedSpiceModels)
        {
            this.mainParameters   = parameters;
            this.Traceability     = traceability;
            this.mgaIdToDomainIDs = mgaIdToDomainIDs;
            this.verbose          = ((CyPhy2Schematic.CyPhy2Schematic_Settings)parameters.config).Verbose;
            partNames             = new Dictionary <string, int>();
            partComponentMap      = new Dictionary <Eagle.part, Component>();
            componentPartMap      = new Dictionary <Component, Eagle.part>();
            polyNetMap            = new Dictionary <Port, Eagle.net>();
            preRouted             = new Dictionary <ComponentAssembly, Layout.LayoutParser>();

            this.mode = mode;
            this.selectedSpiceModels = selectedSpiceModels;
        }
コード例 #10
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            bool disposeLogger = false;

            try
            {
                if (this.Logger == null)
                {
                    this.Logger   = new CyPhyGUIs.GMELogger(parameters.Project, this.ComponentName);
                    disposeLogger = true;
                }
                this.Logger.WriteInfo("Running CyPhyReliabilityAnalysis");
                System.Windows.Forms.Application.DoEvents();

                var asyncResult = this.Logger.LoggingVersionInfo.BeginInvoke(parameters.Project, null, null);
                var header      = this.Logger.LoggingVersionInfo.EndInvoke(asyncResult);
                this.Logger.WriteDebug(header);

                this.MainThrows(parameters);
            }
            catch (Exception ex)
            {
                this.Logger.WriteError("Exception was thrown : {0}", ex.ToString());
                this.result.Success = false;
            }
            finally
            {
                if (disposeLogger && this.Logger != null)
                {
                    this.Logger.Dispose();
                    this.Logger = null;
                }
            }

            return(this.result);
        }
コード例 #11
0
ファイル: CyPhyPET.cs プロジェクト: neemask/meta-core
        /// <summary>
        /// Actual implementation of Main, does not catch general exceptions.
        /// </summary>
        /// <param name="parameters">Main parameters for this run and GUI configuration.</param>
        /// <returns>Result of the run, which contains a success flag.</returns>
        public IInterpreterResult MainThrows(IInterpreterMainParameters parameters)
        {
            this.runtime.Clear();

            this.mainParameters = (InterpreterMainParameters)parameters;
            var configSuccess = this.mainParameters != null;
            if (configSuccess && this.mainParameters.config == null)
            {
                var config = META.ComComponent.DeserializeConfiguration(this.mainParameters.ProjectDirectory, typeof(CyPhyPETSettings), this.ComponentProgID) as
                    CyPhyPETSettings;
                if (config != null)
                {
                    this.mainParameters.config = config;
                }
                else
                {
                    this.mainParameters.config = new CyPhyPETSettings();
                }

                configSuccess = this.mainParameters.config != null;
            }

            bool disposeLogger = false;
            if (this.Logger == null)
            {
                this.Logger = new CyPhyGUIs.GMELogger(this.mainParameters.Project, this.ComponentName);
                disposeLogger = true;
            }
            this.Logger.MakeVersionInfoHeader();
            if (this.mainParameters.VerboseConsole)
            {
                this.Logger.GMEConsoleLoggingLevel = SmartLogger.MessageType_enum.Debug;
            }
            else
            {
                this.Logger.GMEConsoleLoggingLevel = SmartLogger.MessageType_enum.Info;
            }

            //this.result.Traceability.CopyTo(this.Logger.Traceability);

            this.UpdateSuccess("Configuration", configSuccess);

            this.result.Labels = "";
            this.result.RunCommand = "run_PCC.cmd";

            //this.result.LogFileDirectory = Path.Combine(this.mainParameters.ProjectDirectory, "log");
            //this.LogFileFilename = this.ComponentName + "." + System.Diagnostics.Process.GetCurrentProcess().Id + ".log";
            //META.Logger.AddFileListener(this.LogFilePath, this.ComponentName, parameters.Project);

            try
            {
                MgaGateway.PerformInTransaction(delegate
                {
                    this.WorkInMainTransaction();
                },
                transactiontype_enum.TRANSACTION_NON_NESTED, abort: true);

                this.PrintRuntimeStatistics();
                if (this.result.Success)
                {
                    this.Logger.WriteInfo("CyPhyPET finished successfully.");
                    this.Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                    this.Logger.WriteDebug("[SUCCESS: {0}, Labels: {1}]", this.result.Success, this.result.Labels);
                }
                else
                {
                    this.Logger.WriteError("PET Interpreter failed! See error messages above.");
                }
            }
            finally
            {
                if (disposeLogger && this.Logger != null)
                {
                    this.Logger.Dispose();
                    this.Logger = null;
                }
                if (MgaGateway != null &&
                    MgaGateway.territory != null)
                {
                    MgaGateway.territory.Destroy();
                }
                MgaGateway = null;
                //GMEConsole = null; 
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }

            //META.Logger.RemoveFileListener(this.ComponentName);

            return this.result;
        }
コード例 #12
0
ファイル: CyPhyPET.cs プロジェクト: neemask/meta-core
        /// <summary>
        /// No GUI and interactive elements are allowed within this function.
        /// </summary>
        /// <param name="parameters">Main parameters for this run and GUI configuration.</param>
        /// <returns>Result of the run, which contains a success flag.</returns>
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            bool disposeLogger = false;
            try
            {
                if (this.Logger == null)
                {
                    this.Logger = new CyPhyGUIs.GMELogger(parameters.Project, this.ComponentName);
                    disposeLogger = true;
                }
                this.Logger.WriteInfo("Running CyPhyPET");
                System.Windows.Forms.Application.DoEvents();

                var asyncResult = this.Logger.LoggingVersionInfo.BeginInvoke(parameters.Project, null, null);
                var header = this.Logger.LoggingVersionInfo.EndInvoke(asyncResult);
                this.Logger.WriteDebug(header);

                MainThrows(parameters);
            }
            catch (Exception ex)
            {
                this.Logger.WriteError("Exception was thrown : {0}", ex.ToString());
                this.result.Success = false;
            }
            finally
            {
                if (disposeLogger && this.Logger != null)
                {
                    this.Logger.Dispose();
                    this.Logger = null;
                }
            }

            return this.result;
        }
コード例 #13
0
ファイル: CyPhyComplexity.cs プロジェクト: neemask/meta-core
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            OutputDirectory = parameters.OutputDirectory;
            CallElaboratorAndMain(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam);

            result.Success = true;
            return result;
        }
コード例 #14
0
        /// <summary>
        /// No GUI and interactive elements are allowed within this function.
        /// </summary>
        /// <param name="parameters">Main parameters for this run and GUI configuration.</param>
        /// <returns>Result of the run, which contains a success flag.</returns>
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            if (Logger == null)
                Logger = new GMELogger(parameters.Project, ComponentName);

            this.runtime.Clear();
            this.mainParameters = parameters;
            var configSuccess = this.mainParameters != null;
            this.UpdateSuccess("Configuration", configSuccess);
            this.result.Labels = "RF";

            try
            {
                MgaGateway.PerformInTransaction(delegate
                    {
                        this.WorkInMainTransaction();
                    },
                    transactiontype_enum.TRANSACTION_NON_NESTED,
                    abort: true
                );

                this.PrintRuntimeStatistics();
                if (this.result.Success)
                {
                    Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                    Logger.WriteInfo("RF simulation has been created. [SUCCESS: {0}, Labels: {1}]", this.result.Success, this.result.Labels);
                }
                else
                {
                    Logger.WriteError("RF simulation cannot be created! See error messages above.");
                }
            }
            catch (Exception ex)
            {
                Logger.WriteError("Exception: {0}<br> {1}", ex.Message, ex.StackTrace);
            }
            finally
            {
                if (MgaGateway != null &&
                    MgaGateway.territory != null)
                {
                    MgaGateway.territory.Destroy();
                }
                MgaGateway = null;
                if (Logger != null)
                {
                    Logger.Dispose();
                    Logger = null;
                }
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }

            META.Logger.RemoveFileListener(this.ComponentName);

            return this.result;
        }
コード例 #15
0
        /// <summary>
        /// Actual implementation of Main, does not catch general exceptions.
        /// </summary>
        /// <param name="parameters">Main parameters for this run and GUI configuration.</param>
        /// <returns>Result of the run, which contains a success flag.</returns>
        public IInterpreterResult MainThrows(IInterpreterMainParameters parameters)
        {
            this.runtime.Clear();
            this.mainParameters  = (InterpreterMainParameters) parameters;
            this.Factory = new CyPhyTypeFactory(parameters.Project.RootMeta);
            var configSuccess = this.mainParameters != null;
            if (configSuccess && this.mainParameters.config == null)
            {
                var config = META.ComComponent.DeserializeConfiguration(this.mainParameters.ProjectDirectory, typeof(CyPhy2Modelica_v2Settings), this.ComponentProgID) as
                    CyPhy2Modelica_v2Settings;
                if (config != null)
                {
                    this.mainParameters.config = config;
                }
                else
                {
                    this.mainParameters.config = new CyPhy2Modelica_v2Settings();
                }

                configSuccess = this.mainParameters.config != null;
            }

            if (this.result.Traceability == null)
            {
                this.result.Traceability = new META.MgaTraceability();
            }

            // getting traceability from caller, like master interpreter
            if (this.mainParameters.Traceability != null)
            {
                this.mainParameters.Traceability.CopyTo(this.result.Traceability);
            }

            // If called from InvokeEx logger is already created
            bool disposeLogger = false;
            if (this.Logger == null)
            {
                this.Logger = new CyPhyGUIs.GMELogger(this.mainParameters.Project, this.ComponentName);
                disposeLogger = true;
            }

           // this.Logger.MakeVersionInfoHeaderAsync();

            if (this.mainParameters.VerboseConsole)
            {
                this.Logger.GMEConsoleLoggingLevel = SmartLogger.MessageType_enum.Debug;
                this.Logger.WriteDebug("Components not used in this design will still be generated in the Modelica Package.");
                this.GenerateUnusedComponents = true;
            }
            else
            {
                this.Logger.GMEConsoleLoggingLevel = SmartLogger.MessageType_enum.Info;
                this.Logger.WriteDebug("Components not used in this design will not be generated in the Modelica Package. Use verbose console to enable this option.");
                this.GenerateUnusedComponents = false;
            }

            this.result.Traceability.CopyTo(this.Logger.Traceability);


            this.UpdateSuccess("Configuration", configSuccess);

            this.result.Labels = "OpenModelica && py_modelica12.08";
            this.result.RunCommand = "om_simulate.py";
            //var elaboratorSuccess = this.CallElaboratorOLD(this.mainParameters.Project,
            //    this.mainParameters.CurrentFCO, this.mainParameters.SelectedFCOs, this.mainParameters.StartModeParam);
            try
            {
                MgaGateway.PerformInTransaction(delegate
                {
                    this.WorkInMainTransaction();
                },
                transactiontype_enum.TRANSACTION_NON_NESTED, abort: true);

                this.PrintRuntimeStatistics();
                if (this.result.Success)
                {
                    this.Logger.WriteInfo("CyPhy2Modelica 2.0 finished successfully.");
                    this.Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                    this.Logger.WriteDebug("[SUCCESS: {0}, Labels: {1}]", this.result.Success, this.result.Labels);
                }
                else
                {
                    this.Logger.WriteError("CyPhy2Modelica 2.0 failed! See error messages above.");
                }
            }
            finally
            {
                if (disposeLogger && this.Logger != null)
                {
                    this.Logger.Dispose();
                    this.Logger = null;
                }
                if (MgaGateway != null && MgaGateway.territory != null)
                {
                    MgaGateway.territory.Destroy();
                }
                MgaGateway = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }

            return this.result;
        }
コード例 #16
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.OutputDirectory = parameters.OutputDirectory;
            this.ProjectRootDirectory = parameters.ProjectDirectory;
            if (this.result.Traceability == null)
            {
                this.result.Traceability = new META.MgaTraceability();
            }

            result.RunCommand = "CyPhyCADAnalysis.bat";
            result.Labels = "Creo&&CADCreoParametricCreateAssembly.exev1.4";

            Dictionary<string, string> workflowParameters = new Dictionary<string, string>();
            MgaGateway.PerformInTransaction(() =>
            {
                string Parameters = parameters
                    .CurrentFCO
                    .ChildObjects
                    .OfType<MgaReference>()
                    .FirstOrDefault(x => x.Meta.Name == "WorkflowRef")
                    .Referred
                    .ChildObjects
                    .OfType<MgaAtom>()
                    .FirstOrDefault()
                    .StrAttrByName["Parameters"];

                try
                {
                    workflowParameters = (Dictionary<string, string>)Newtonsoft.Json.JsonConvert.DeserializeObject(Parameters, typeof(Dictionary<string, string>));
                    if (workflowParameters == null)
                    {
                        workflowParameters = new Dictionary<string, string>();
                    }
                }
                catch (Newtonsoft.Json.JsonReaderException)
                {
                }
                META.AnalysisTool.ApplyToolSelection(this.ComponentProgID, workflowParameters, this.result, parameters, modifyLabels: false);
                this.result.Labels += " && CyPhyCADAnalysis" + JobManager.Job.LabelVersion; // META-2405
            }, abort: true);

            List<string> Inventor_Tests = new List<string>() {"closures", "field_of_view", "field_of_fire", "ergonomics", "ingress_egress", "transportability"};
            List<string> Leaf_Metrics = new List<string>() { "conceptual_mfg", "detailed_mfg", "completeness", "corrosion" };
            bool b = Inventor_Tests.Any(workflowParameters.Values.Contains);
            bool c = Leaf_Metrics.Any(workflowParameters.Values.Contains);

            CADAnalysisConfig config = (CADAnalysisConfig)parameters.config;
            cadSettings.AuxiliaryDirectory = config.AuxiliaryDirectory;
            cadSettings.StepFormats = config.StepFormats;
            if (b)
                cadSettings.OtherDataFormat.Inventor = true;
            if (c)
                cadSettings.SpecialInstructions.LeafAssembliesMetric = true;
            InvokeEx(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam);

            result.Success = true;
            return result;
        }
コード例 #17
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.runtime.Clear();

            this.mainParameters = (InterpreterMainParameters)parameters;
            this.result.Success = true;
            var configSuccess = this.mainParameters != null;

            this.paramInvoked    = this.mainParameters.StartModeParam;
            this.ProjectFilename = this.mainParameters.Project.ProjectConnStr.Substring("MGA=".Length);
            this.OutputBaseDir   = this.mainParameters.OutputDirectory;

            sotConfig.OriginalProjectFileName = this.ProjectFilename;
            bool disposeLogger = false;

            if (this.Logger == null)
            {
                this.Logger = new CyPhyGUIs.GMELogger(this.mainParameters.Project, this.ComponentName);
                this.Logger.WriteInfo("Running CyPhySoT");
                System.Windows.Forms.Application.DoEvents();
                disposeLogger = true;
            }
            if (this.mainParameters.VerboseConsole)
            {
                this.Logger.GMEConsoleLoggingLevel = SmartLogger.MessageType_enum.Debug;
            }
            else
            {
                this.Logger.GMEConsoleLoggingLevel = SmartLogger.MessageType_enum.Info;
            }

            CyPhy.TestBenchSuite tbs = CyPhyClasses.TestBenchSuite.Cast(parameters.CurrentFCO);

//            MgaGateway.PerformInTransaction(delegate
//            {
//                foreach (var testBenchRef in tbs.Children.TestBenchRefCollection)
//                {
//                    if (testBenchRef.Referred == null)
//                    {
//                        continue;
//                    }

//                    var testBench = testBenchRef.Referred.TestBenchType;
//                    if (testBench != null &&
//                        testBench.Impl.MetaBase.Name != (typeof(CyPhy.TestBench)).Name)
//                    {
//                        this.Logger.WriteError(string.Format(@"Test benches must currently
//                        be of type TestBench in a CyPhySoT. Please see {0}.",
//                            testBenchRef.ToHyperLink()));

//                        this.result.Success = false;

//                        object automation;
//                        if (this.componentParameters != null &&
//                            this.componentParameters.TryGetValue("automation", out automation))
//                        {
//                            if ((string)automation == "true")
//                            {
//                                throw new NotSupportedException(@"Error: only test benches of
//                                type TestBench are currently supported in a CyPhySoT!");
//                            }
//                        }
//                    }
//                }
//            });

            if (this.result.Success == false)
            {
                return(this.result);
            }

            var asyncResult = this.Logger.LoggingVersionInfo.BeginInvoke(parameters.Project, null, null);
            var header      = this.Logger.LoggingVersionInfo.EndInvoke(asyncResult);

            this.Logger.WriteDebug(header);

            this.UpdateSuccess("Configuration", configSuccess);

            this.result.Labels = "";
            //this.result.LogFileDirectory = Path.Combine(this.mainParameters.ProjectDirectory, "log");
            //this.LogFileFilename = this.ComponentName + "." + System.Diagnostics.Process.GetCurrentProcess().Id + ".log";
            //META.Logger.AddFileListener(this.LogFilePath, this.ComponentName, parameters.Project);

            try
            {
                MgaGateway.PerformInTransaction(delegate
                {
                    this.WorkInMainTransaction();
                },
                                                abort: true);

                this.WorkOutsideOfMainTransaction();

                this.PrintRuntimeStatistics();
                if (this.result.Success)
                {
                    this.Logger.WriteInfo("CyPhySoT finished successfully.");
                    this.Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                    this.Logger.WriteDebug("[SUCCESS: {0}]", this.result.Success);
                }
                else
                {
                    this.Logger.WriteError("CyPhySoT failed! See error messages above.");
                }
            }
            finally
            {
                if (this.Logger != null && disposeLogger)
                {
                    this.Logger.Dispose();
                    this.Logger = null;
                }
                MgaGateway = null;
                //GMEConsole = null;

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }

            //META.Logger.RemoveFileListener(this.ComponentName);

            return(this.result);
        }
コード例 #18
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            var result = new InterpreterResult();
            this.parameters = parameters;
            result.Success = this.RunInTransaction(parameters.CurrentFCO.Project, parameters.CurrentFCO, parameters.SelectedFCOs, 128, parameters.OutputDirectory);
            result.RunCommand = "cmd.exe /c \"\"";

            return result;
        }
コード例 #19
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.mainParameters = (InterpreterMainParameters)parameters;

            try
            {
                MgaGateway = new MgaGateway(mainParameters.Project);

                var result = new InterpreterResult()
                {
                    Success = true, RunCommand = "cmd.exe /c \"\""
                };

                MgaGateway.PerformInTransaction(delegate
                {
                    MainInTransaction((InterpreterMainParameters)parameters);


                    // TODO: this part needs to be refactored!
                    var workflowRef = this.mainParameters
                                      .CurrentFCO
                                      .ChildObjects
                                      .OfType <MgaReference>()
                                      .FirstOrDefault(x => x.Meta.Name == "WorkflowRef");

                    if (workflowRef != null)
                    {
                        string Parameters = workflowRef
                                            .Referred
                                            .ChildObjects
                                            .OfType <MgaAtom>()
                                            .FirstOrDefault(fco => fco.Meta.Name == typeof(CyPhy.Task).Name &&
                                                            String.Equals(CyPhyClasses.Task.Cast(fco).Attributes.COMName, this.ComponentProgID, StringComparison.InvariantCultureIgnoreCase))
                                            .StrAttrByName["Parameters"];

                        Dictionary <string, string> workflowParameters = new Dictionary <string, string>();

                        try
                        {
                            workflowParameters = (Dictionary <string, string>)Newtonsoft.Json.JsonConvert.DeserializeObject(Parameters, typeof(Dictionary <string, string>));
                            if (workflowParameters == null)
                            {
                                workflowParameters = new Dictionary <string, string>();
                            }
                        }
                        catch (Newtonsoft.Json.JsonReaderException)
                        {
                        }

                        META.AnalysisTool.ApplyToolSelection(this.ComponentProgID, workflowParameters, result, this.mainParameters);
                    }
                });

                return(result);
            }
            finally
            {
                MgaGateway = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
コード例 #20
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.OutputDirectory      = parameters.OutputDirectory;
            this.ProjectRootDirectory = parameters.ProjectDirectory;
            if (this.result.Traceability == null)
            {
                this.result.Traceability = new META.MgaTraceability();
            }

            result.RunCommand = "CyPhyCADAnalysis.bat";
            result.Labels     = "Creo&&CADCreoParametricCreateAssembly.exev1.4";

            Dictionary <string, string> workflowParameters = new Dictionary <string, string>();

            MgaGateway.PerformInTransaction(() =>
            {
                string Parameters = parameters
                                    .CurrentFCO
                                    .ChildObjects
                                    .OfType <MgaReference>()
                                    .FirstOrDefault(x => x.Meta.Name == "WorkflowRef")
                                    .Referred
                                    .ChildObjects
                                    .OfType <MgaAtom>()
                                    .FirstOrDefault()
                                    .StrAttrByName["Parameters"];

                try
                {
                    workflowParameters = (Dictionary <string, string>)Newtonsoft.Json.JsonConvert.DeserializeObject(Parameters, typeof(Dictionary <string, string>));
                    if (workflowParameters == null)
                    {
                        workflowParameters = new Dictionary <string, string>();
                    }
                }
                catch (Newtonsoft.Json.JsonReaderException)
                {
                }
                META.AnalysisTool.ApplyToolSelection(this.ComponentProgID, workflowParameters, this.result, parameters, modifyLabels: false);
                this.result.Labels += " && CyPhyCADAnalysis" + JobManager.Job.LabelVersion; // META-2405
            }, abort: true);

            List <string> Inventor_Tests = new List <string>()
            {
                "closures", "field_of_view", "field_of_fire", "ergonomics", "ingress_egress", "transportability"
            };
            List <string> Leaf_Metrics = new List <string>()
            {
                "conceptual_mfg", "detailed_mfg", "completeness", "corrosion"
            };
            bool b = Inventor_Tests.Any(workflowParameters.Values.Contains);
            bool c = Leaf_Metrics.Any(workflowParameters.Values.Contains);

            CADAnalysisConfig config = (CADAnalysisConfig)parameters.config;

            cadSettings.AuxiliaryDirectory = config.AuxiliaryDirectory;
            cadSettings.StepFormats        = config.StepFormats;
            if (b)
            {
                cadSettings.OtherDataFormat.Inventor = true;
            }
            if (c)
            {
                cadSettings.SpecialInstructions.LeafAssembliesMetric = true;
            }
            InvokeEx(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam);

            result.Success = true;
            return(result);
        }
コード例 #21
0
        /// <summary>
        /// No GUI and interactive elements are allowed within this function.
        /// </summary>
        /// <param name="parameters">Main parameters for this run and GUI configuration.</param>
        /// <returns>Result of the run, which contains a success flag.</returns>
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.mainParameters = parameters;

            this.result = new InterpreterResult()
            {
                Success = true
            };


            bool disposeLogger = false;
            try
            {
                if (this.Logger == null)
                {
                    this.Logger = new CyPhyGUIs.GMELogger(parameters.Project, this.ComponentName);
                    disposeLogger = true;
                }
                
                string pathDesign = "";
                string camFilePath = "";
                MgaGateway.PerformInTransaction(delegate
                {
                    var testbench = CyPhyClasses.TestBench.Cast(parameters.CurrentFCO)
                                    as CyPhy.TestBench;
                    var firstThing = testbench.Children.TopLevelSystemUnderTestCollection.First();
                    var design = firstThing.Referred.ComponentAssembly;
                    pathDesign = design.GetDirectoryPath(ComponentLibraryManager.PathConvention.ABSOLUTE);
                    // MOT-444: find a test bench parameter with a value of the CAM file's path.
                    foreach (var param in testbench.Children.ParameterCollection)
                    {
                        if (param.Name.ToUpper().Contains("CAM "))
                        {
                            if (param.Attributes.Value.ToUpper().Contains(".CAM"))
                            {
                                camFilePath = param.Attributes.Value;
                            }
                        }
                    }
                },
                transactiontype_enum.TRANSACTION_NON_NESTED,
                abort: true);

                // The input files to the CAM and Eagle ULP scripts should already be in the pathDesign folder.
                // We need to move them into the project results/<random> folder, which is under parameters.OutputDirectory.
                // See also MOT-444.
                string[] filesToMove = new string[] { "BomTable.csv", "schema.brd", "schema.sch", "reference_designator_mapping_table.html" };
                foreach (string fileName in filesToMove)
                {
                    string srcPath = Path.Combine(pathDesign, fileName);
                    string dstPath = Path.Combine(parameters.OutputDirectory, fileName);

                    if (File.Exists(dstPath))
                    {
                        File.Delete(dstPath);
                    }

                    if (File.Exists(srcPath))
                    {
                        Logger.WriteInfo("About to copy \"{0}\" to \"{1}\".", srcPath, dstPath);
                        File.Copy(srcPath, dstPath);
                    }
                    else
                    {
                        Logger.WriteWarning("The file {0} does not exist.", srcPath);
                    }
                }
                // Set the current directory to the project directory, so that
                // the CAM file's path can be relative to it.
                try
                {
                    // Get the current directory. 
                    string path = this.mainParameters.ProjectDirectory;
                    System.IO.Directory.SetCurrentDirectory(path);
                    Logger.WriteInfo("The current directory is {0}", path);
                }
                catch (Exception e)
                {
                    Console.WriteLine("GetCurrentDirectory() failed: {0}", e.ToString());
                }

                // Copy the CAM file to a well-known name in the output directory.
                {
                    string srcPath = camFilePath;
                    string dstPath = Path.Combine(parameters.OutputDirectory, "pcb_mfg.cam");

                    if (File.Exists(dstPath))
                    {
                        File.Delete(dstPath);
                    }

                    if (File.Exists(srcPath))
                    {
                        Logger.WriteInfo("About to copy \"{0}\" to \"{1}\".", srcPath, dstPath);
                        File.Copy(srcPath, dstPath);
                    }
                    else
                    {
                        Logger.WriteWarning("The file {0} does not exist.", srcPath);
                    }
                }


                if (this.result.Success)
                {
                    this.result.RunCommand = "dir";     // Dummy first command of job manager for master interpreter.
                    Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                    Logger.WriteInfo("CyPhy2PCBMfg has finished. [SUCCESS: {0}, Labels: {1}]", this.result.Success, this.result.Labels);
                }
                else
                {
                    Logger.WriteError("CyPhy2PCBMfg failed! See error messages above.");
                }
            }
            catch (Exception ex)
            {
                this.Logger.WriteError("Exception was thrown : {0}", ex.ToString());
                this.result.Success = false;
            }
            finally
            {
                if (disposeLogger && this.Logger != null)
                {
                    this.DisposeLogger();
                }
            }

            return this.result;
        }
コード例 #22
0
        private IInterpreterResult _Main(IInterpreterMainParameters parameters)
        {
            this.mainParameters = parameters;

            //this.runtime = new Queue<Tuple<string, TimeSpan>>();
            //this.runtime.Clear();
            this.result = new InterpreterResult()
            {
                Success = true
            };

            try
            {
                BOMVisitor visitor = new BOMVisitor()
                {
                    Logger       = Logger,
                    Traceability = this.result.Traceability
                };

                String        nameFCO              = null;
                int           designQuantity       = 1;
                List <String> listSupplierAffinity = null;
                MgaGateway.PerformInTransaction(delegate
                {
                    // Call Elaborator
                    var elaboratorSuccess = this.CallElaborator(this.mainParameters.Project,
                                                                this.mainParameters.CurrentFCO,
                                                                this.mainParameters.SelectedFCOs,
                                                                this.mainParameters.StartModeParam);
                    this.UpdateSuccess("Elaborator", elaboratorSuccess);

                    // Parse design
                    var tb = CyPhyClasses.TestBench.Cast(parameters.CurrentFCO);
                    visitor.visit(tb);

                    nameFCO = this.mainParameters.CurrentFCO.Name;

                    var propDesignQuantity = tb.Children
                                             .PropertyCollection
                                             .FirstOrDefault(p => p.Name == "design_quantity");
                    if (propDesignQuantity != null)
                    {
                        int val;
                        if (int.TryParse(propDesignQuantity.Attributes.Value, out val))
                        {
                            designQuantity = val;
                        }
                        else
                        {
                            Logger.WriteWarning("The property <a href=\"mga:{0}\">{1}</a> has a non-integer value of \"{2}\". Setting to default of 1.",
                                                propDesignQuantity.ID,
                                                propDesignQuantity.Name,
                                                propDesignQuantity.Attributes.Value);
                        }
                    }
                    else
                    {
                        Logger.WriteWarning("No property named \"design_quantity\" found. Assuming quantity of 1.");
                    }

                    var metricPartCostPerDesign = tb.Children
                                                  .MetricCollection
                                                  .FirstOrDefault(m => m.Name == "part_cost_per_design");
                    if (metricPartCostPerDesign == null)
                    {
                        var manifest = AVM.DDP.MetaTBManifest.OpenForUpdate(this.mainParameters.OutputDirectory);
                        var metric   = new AVM.DDP.MetaTBManifest.Metric()
                        {
                            Name          = "part_cost_per_design",
                            DisplayedName = "Part Cost Per Design",
                            Unit          = "USD",
                            GMEID         = null
                        };
                        if (manifest.Metrics == null)
                        {
                            manifest.Metrics = new List <AVM.DDP.MetaTBManifest.Metric>();
                        }
                        manifest.Metrics.Add(metric);

                        manifest.Serialize(this.mainParameters.OutputDirectory);
                    }

                    var propSupplierAffinity = tb.Children
                                               .PropertyCollection
                                               .FirstOrDefault(p => p.Name == "supplier_affinity");
                    if (propSupplierAffinity != null &&
                        !String.IsNullOrWhiteSpace(propSupplierAffinity.Attributes.Value))
                    {
                        listSupplierAffinity = propSupplierAffinity.Attributes
                                               .Value
                                               .Split(',')
                                               .Select(s => s.Trim())
                                               .ToList();
                    }
                },
                                                transactiontype_enum.TRANSACTION_NON_NESTED,
                                                abort: true);

                // Serialize BOM to file
                var bom         = visitor.bom;
                var filenameBom = nameFCO + "_bom.json";
                var pathBom     = Path.Combine(this.mainParameters.OutputDirectory,
                                               filenameBom);
                using (StreamWriter outfile = new StreamWriter(pathBom))
                {
                    outfile.Write(bom.Serialize());
                }

                // Create CostEstimationRequest
                var request = new MfgBom.CostEstimation.CostEstimationRequest()
                {
                    bom               = bom,
                    design_quantity   = designQuantity,
                    supplier_affinity = listSupplierAffinity
                };
                var filenameRequest = nameFCO + "_cost_estimate_request.json";
                var pathRequest     = Path.Combine(this.mainParameters.OutputDirectory,
                                                   filenameRequest);
                using (StreamWriter outfile = new StreamWriter(pathRequest))
                {
                    outfile.Write(request.Serialize());
                }

                var tbManifest = AVM.DDP.MetaTBManifest.OpenForUpdate(this.mainParameters.OutputDirectory);
                tbManifest.AddArtifact(filenameBom, "CyPhy2MfgBom::BOM");
                tbManifest.AddArtifact(filenameRequest, "CyPhy2MfgBom::CostEstimationRequest");
                tbManifest.Serialize(this.mainParameters.OutputDirectory);

                using (var batRunBomCostAnalysis = new StreamWriter(Path.Combine(this.mainParameters.OutputDirectory,
                                                                                 "runBomCostAnalysis.bat")))
                {
                    batRunBomCostAnalysis.Write(CyPhy2MfgBom.Properties.Resources.runBomCostAnalysis);
                }
                this.result.RunCommand = "runBomCostAnalysis.bat";


                if (this.result.Success)
                {
                    Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                    Logger.WriteInfo("CyPhy2MfgBom has finished. [SUCCESS: {0}, Labels: {1}]", this.result.Success, this.result.Labels);
                }
                else
                {
                    Logger.WriteError("CyPhy2MfgBom failed! See error messages above.");
                }
            }
            catch (Exception ex)
            {
                Logger.WriteError("Exception: {0}<br> {1}", ex.Message, ex.StackTrace);
            }
            return(this.result);
        }
コード例 #23
0
        /// <summary>
        /// No GUI and interactive elements are allowed within this function.
        /// </summary>
        /// <param name="parameters">Main parameters for this run and GUI configuration.</param>
        /// <returns>Result of the run, which contains a success flag.</returns>
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.mainParameters = parameters;

            //this.runtime = new Queue<Tuple<string, TimeSpan>>();
            //this.runtime.Clear();
            this.result = new InterpreterResult()
            {
                Success = true
            };

            try
            {
                BOMVisitor visitor = new BOMVisitor()
                {
                    Logger = Logger,
                    Traceability = this.result.Traceability
                };

                String nameFCO = null;
                int designQuantity = 1;
                List<String> listSupplierAffinity = null;
                MgaGateway.PerformInTransaction(delegate
                {
                    // Call Elaborator
                    var elaboratorSuccess = this.CallElaborator(this.mainParameters.Project,
                                                                this.mainParameters.CurrentFCO,
                                                                this.mainParameters.SelectedFCOs,
                                                                this.mainParameters.StartModeParam);
                    this.UpdateSuccess("Elaborator", elaboratorSuccess);

                    // Parse design
                    var tb = CyPhyClasses.TestBench.Cast(parameters.CurrentFCO);
                    visitor.visit(tb);

                    nameFCO = this.mainParameters.CurrentFCO.Name;

                    var propDesignQuantity = tb.Children
                                               .PropertyCollection
                                               .FirstOrDefault(p => p.Name == "design_quantity");
                    if (propDesignQuantity != null)
                    {
                        int val;
                        if (int.TryParse(propDesignQuantity.Attributes.Value, out val))
                        {
                            designQuantity = val;
                        }
                        else
                        {
                            Logger.WriteWarning("The property <a href=\"mga:{0}\">{1}</a> has a non-integer value of \"{2}\". Setting to default of 1.",
                                                propDesignQuantity.ID,
                                                propDesignQuantity.Name,
                                                propDesignQuantity.Attributes.Value);
                        }
                    }
                    else
                    {
                        Logger.WriteWarning("No property named \"design_quantity\" found. Assuming quantity of 1.");
                    }

                    var metricPartCostPerDesign = tb.Children
                                                    .MetricCollection
                                                    .FirstOrDefault(m => m.Name == "part_cost_per_design");
                    if (metricPartCostPerDesign == null)
                    {
                        var manifest = AVM.DDP.MetaTBManifest.OpenForUpdate(this.mainParameters.OutputDirectory);
                        var metric = new AVM.DDP.MetaTBManifest.Metric()
                        {
                            Name = "part_cost_per_design",
                            DisplayedName = "Part Cost Per Design",
                            Unit = "USD",
                            GMEID = null
                        };
                        if (manifest.Metrics == null)
                        {
                            manifest.Metrics = new List<AVM.DDP.MetaTBManifest.Metric>();
                        }
                        manifest.Metrics.Add(metric);

                        manifest.Serialize(this.mainParameters.OutputDirectory);
                    }

                    var propSupplierAffinity = tb.Children
                                                 .PropertyCollection
                                                 .FirstOrDefault(p => p.Name == "supplier_affinity");
                    if (propSupplierAffinity != null &&
                        !String.IsNullOrWhiteSpace(propSupplierAffinity.Attributes.Value))
                    {
                        listSupplierAffinity = propSupplierAffinity.Attributes
                                                                   .Value
                                                                   .Split(',')
                                                                   .Select(s => s.Trim())
                                                                   .ToList();
                    }
                },
                transactiontype_enum.TRANSACTION_NON_NESTED,
                abort: true);

                // Serialize BOM to file
                var bom = visitor.bom;
                var filenameBom = nameFCO + "_bom.json";
                var pathBom = Path.Combine(this.mainParameters.OutputDirectory, 
                                           filenameBom);
                using (StreamWriter outfile = new StreamWriter(pathBom))
                {
                    outfile.Write(bom.Serialize());
                }

                // Create CostEstimationRequest
                var request = new MfgBom.CostEstimation.CostEstimationRequest()
                {
                    bom = bom,
                    design_quantity = designQuantity,
                    supplier_affinity = listSupplierAffinity
                };
                var filenameRequest = nameFCO + "_cost_estimate_request.json";
                var pathRequest = Path.Combine(this.mainParameters.OutputDirectory,
                                               filenameRequest);
                using (StreamWriter outfile = new StreamWriter(pathRequest))
                {
                    outfile.Write(request.Serialize());
                }

                var tbManifest = AVM.DDP.MetaTBManifest.OpenForUpdate(this.mainParameters.OutputDirectory);
                tbManifest.AddArtifact(filenameBom, "CyPhy2MfgBom::BOM");
                tbManifest.AddArtifact(filenameRequest, "CyPhy2MfgBom::CostEstimationRequest");
                tbManifest.Serialize(this.mainParameters.OutputDirectory);
                
                using (var batRunBomCostAnalysis = new StreamWriter(Path.Combine(this.mainParameters.OutputDirectory, 
                                                                                 "runBomCostAnalysis.bat")))
                {
                    batRunBomCostAnalysis.Write(CyPhy2MfgBom.Properties.Resources.runBomCostAnalysis);
                }
                this.result.RunCommand = "runBomCostAnalysis.bat";
                

                if (this.result.Success)
                {
                    Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                    Logger.WriteInfo("CyPhy2MfgBom has finished. [SUCCESS: {0}, Labels: {1}]", this.result.Success, this.result.Labels);
                }
                else
                {
                    Logger.WriteError("CyPhy2MfgBom failed! See error messages above.");
                }
            }
            catch (Exception ex)
            {
                Logger.WriteError("Exception: {0}<br> {1}", ex.Message, ex.StackTrace);
            }
            return this.result;
        }
コード例 #24
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.mainParameters = (InterpreterMainParameters)parameters;

            try
            {
                MgaGateway = new MgaGateway(mainParameters.Project);
                parameters.Project.CreateTerritoryWithoutSink(out MgaGateway.territory);

                MgaGateway.PerformInTransaction(delegate
                {
                    MainInTransaction((InterpreterMainParameters)parameters);
                });
                return new InterpreterResult() { Success = true, RunCommand = "" };
            }
            finally
            {
                if (MgaGateway.territory != null)
                {
                    MgaGateway.territory.Destroy();
                }
                MgaGateway = null;                
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
コード例 #25
0
ファイル: CyPhyCar.cs プロジェクト: metamorph-inc/meta-core
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            var result = new InterpreterResult();
            result.RunCommand = "runCarSim.bat";
            try
            {

                MgaGateway.PerformInTransaction(delegate
                {
                    if (parameters.CurrentFCO.MetaBase.Name == "CarTestBench")
                    {
                        try
                        {
                            var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                            elaborator.Logger = new GMELogger(parameters.Project);
                            //elaborator.Logger.AddWriter(Logger.Instance);
                            var elaboratorresult = elaborator.RunInTransaction(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam);
                            if (elaboratorresult == false)
                            {
                                throw new ApplicationException("see elaborator log");
                            }

                        }
                        catch (Exception e)
                        {
                            //Logger.Instance.AddLogMessage("Elaborator exception occurred: " + e.Message, Severity.Error);
                            throw new Exception(e.Message);
                        }
                        var testBench = CyPhyClasses.CarTestBench.Cast(parameters.CurrentFCO);

                        TestBenchProcessor processor = new TestBenchProcessor() { GMEConsole = GMEConsole, OutputDir = parameters.OutputDirectory, ProjectDir = parameters.ProjectDirectory };
                        processor.Process(testBench);
                    }
                    else
                    {
                        GMEConsole.Error.WriteLine("Not a Car Test Bench.");
                        return;
                    }
                },
                transactiontype_enum.TRANSACTION_NON_NESTED, abort: true);
                result.Success = true;
            }
            catch (Exception ex)
            {
                GMEConsole.Error.WriteLine("Exception was raised: {0}", ex.ToString());
                result.Success = false;
            }
            finally
            {
//                parameters.Project.AbortTransaction();
                MgaGateway = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }

            return result;
        }
コード例 #26
0
        /// <summary>
        /// No GUI and interactive elements are allowed within this function.
        /// </summary>
        /// <param name="parameters">Main parameters for this run and GUI configuration.</param>
        /// <returns>Result of the run, which contains a success flag.</returns>
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.runtime.Clear();

            this.mainParameters = parameters;

            var configSuccess = this.mainParameters != null;

            this.UpdateSuccess("Configuration", configSuccess);

            this.result.Labels           = "Simulink";
            this.result.LogFileDirectory = Path.Combine(this.mainParameters.ProjectDirectory, "log");
            this.LogFileFilename         = this.ComponentName + "." + System.Diagnostics.Process.GetCurrentProcess().Id + ".log";

            try
            {
                META.Logger.AddFileListener(this.LogFilePath, this.ComponentName, this.mainParameters.Project);
            }
            catch (Exception ex) // logger construction may fail, which should be an ignorable exception
            {
                GMEConsole.Warning.WriteLine("Error in Logger construction: {0}", ex.Message);
            }

            try
            {
                MgaGateway.PerformInTransaction(delegate
                {
                    this.WorkInMainTransaction();
                },
                                                transactiontype_enum.TRANSACTION_NON_NESTED,
                                                abort: true
                                                );

                this.PrintRuntimeStatistics();
                if (this.result.Success)
                {
                    GMEConsole.Info.WriteLine("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                    GMEConsole.Info.WriteLine("Simulink Generator has finished. [SUCCESS: {0}, Labels: {1}]", this.result.Success, this.result.Labels);
                }
                else
                {
                    GMEConsole.Error.WriteLine("Simulink Generator failed! See error messages above.");
                }
            }
            catch (Exception ex)
            {
                GMEConsole.Error.WriteLine("Exception: {0}<br> {1}", ex.Message, ex.StackTrace);
            }
            finally
            {
                MgaGateway = null;
                GMEConsole = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }

            META.Logger.RemoveFileListener(this.ComponentName);

            //var SystemCSettings = this.mainParameters.config as CyPhy2Simulink_Settings;

            return(this.result);
        }
コード例 #27
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            result.RunCommand = "runCADJob.bat";
            result.Labels = "Creo&&CADCreoParametricCreateAssembly.exev1.4&&" + JobManager.Job.DefaultLabels;
            var ProjectIsNotInTransaction = (parameters.Project.ProjectStatus & 8) == 0;
            if (ProjectIsNotInTransaction)
            {
                parameters.Project.BeginTransactionInNewTerr();
            }
            Dictionary<string, string> workflowParameters = new Dictionary<string, string>();
            var workflowRef = parameters
                .CurrentFCO
                .ChildObjects
                .OfType<MgaReference>()
                .FirstOrDefault(x => x.Meta.Name == "WorkflowRef");
            if (workflowRef != null)
            {
                string Parameters = workflowRef.Referred
                    .ChildObjects
                    .OfType<MgaAtom>()
                    .FirstOrDefault(x => x.Meta.Name == "Task")
                    .StrAttrByName["Parameters"];
                try
                {
                    workflowParameters = (Dictionary<string, string>)Newtonsoft.Json.JsonConvert.DeserializeObject(Parameters, typeof(Dictionary<string, string>));
                    if (workflowParameters == null)
                    {
                        workflowParameters = new Dictionary<string, string>();
                    }
                }
                catch (Newtonsoft.Json.JsonReaderException)
                {
                }
            }
            META.AnalysisTool.ApplyToolSelection(this.ComponentProgID, workflowParameters, this.result, parameters, modifyLabels: false);
            if (ProjectIsNotInTransaction)
            {
                parameters.Project.AbortTransaction();
            }

            this.CopySTL = workflowParameters.ContainsValue("FreedLinkageAssembler");



            var resultzip = CyPhy2CAD_CSharp.Properties.Resources.ResultZip;            
            result.ZippyServerSideHook = Encoding.UTF8.GetString(resultzip);
            result.LogFileDirectory = Path.Combine(parameters.OutputDirectory, "log");

            this.mainParameters = (InterpreterMainParameters)parameters;
            if (this.mainParameters.config == null)
            {
                var config = META.ComComponent.DeserializeConfiguration(this.mainParameters.ProjectDirectory, typeof(CyPhy2CADSettings), this.ComponentProgID) as CyPhy2CADSettings;
                if (config != null)
                {
                    this.mainParameters.config = config;
                    settings = config;
                }
                else
                {
                    this.mainParameters.config = new CyPhy2CADSettings();
                }

            }
            if (this.result.Traceability == null)
            {
                this.result.Traceability = new META.MgaTraceability();
            }

            // getting traceability from caller, like master interpreter
            if (this.mainParameters.Traceability != null)
            {
                this.mainParameters.Traceability.CopyTo(this.result.Traceability);
            }

            //CyPhy2CAD_CSharp.CyPhy2CADSettings configSettings = (CyPhy2CAD_CSharp.CyPhy2CADSettings)parameters.config;
            //settings = configSettings;

            settings = (CyPhy2CAD_CSharp.CyPhy2CADSettings)this.mainParameters.config;
            settings.OutputDirectory = parameters.OutputDirectory;
            Automation = true;
            Logger.Instance.AddLogMessage("Main:Aux Directory is: " + settings.AuxiliaryDirectory, Severity.Info);
            Logger.Instance.AddLogMessage("Output Directory is: " + settings.OutputDirectory, Severity.Info);
            MgaGateway.voidDelegate action = delegate
            {
                if (Elaborate(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam))
                {
                    result.Success = Main(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, Convert(parameters.StartModeParam));
                }
                else
                {
                    result.Success = false;
                    Logger.Instance.DumpLog(GMEConsole, LogDir);
                }
            };

            if ((parameters.Project.ProjectStatus & 8) == 0)
            {
                MgaGateway.PerformInTransaction(
                    d: action, 
                    mode: transactiontype_enum.TRANSACTION_NON_NESTED, 
                    abort: true);
            }
            else
            {
                action.Invoke();
            }

            return result;
        }
コード例 #28
0
        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;
        }
コード例 #29
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.OutputDirectory = parameters.OutputDirectory;
            this.ProjectRootDirectory = parameters.ProjectDirectory;

            result.RunCommand = "PrepareIFab.bat";
            result.Labels = "Creo&&CADCreoParametricCreateAssembly.exev1.4&&" + JobManager.Job.DefaultLabels;

            PrepareIFabConfig config = (PrepareIFabConfig)parameters.config;
            cadSettings.AuxiliaryDirectory = config.AuxiliaryDirectory;
            cadSettings.StepFormats = config.StepFormats;
            cadSettings.OtherDataFormat.STLAscii = true;
            InvokeEx(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam);

            MgaGateway.PerformInTransaction(() =>
            {

                // TODO: this part needs to be refactored!
                string Parameters = parameters
                    .CurrentFCO
                    .ChildObjects
                    .OfType<MgaReference>()
                    .FirstOrDefault(x => x.Meta.Name == "WorkflowRef")
                    .Referred
                    .ChildObjects
                    .OfType<MgaAtom>()
                    .FirstOrDefault(fco => fco.Meta.Name == typeof(CyPhy.Task).Name
                        && String.Equals(CyPhyClasses.Task.Cast(fco).Attributes.COMName, this.ComponentProgID, StringComparison.InvariantCultureIgnoreCase))
                    .StrAttrByName["Parameters"];

                Dictionary<string, string> workflowParameters = new Dictionary<string, string>();

                try
                {
                    workflowParameters = (Dictionary<string, string>)Newtonsoft.Json.JsonConvert.DeserializeObject(Parameters, typeof(Dictionary<string, string>));
                    if (workflowParameters == null)
                    {
                        workflowParameters = new Dictionary<string, string>();
                    }
                }
                catch (Newtonsoft.Json.JsonReaderException)
                {
                }

                META.AnalysisTool.ApplyToolSelection(this.ComponentProgID, workflowParameters, this.result, parameters);
            }, abort: true);

            result.Success = true;
            return result;
        }
コード例 #30
0
        private void MainThrows(IInterpreterMainParameters parameters)
        {
            // TODO: remove this line, since this is the old implementation
            //this.OpenWebPageWithChromeOrDefaultBrowser("http://fame-deploy.parc.com:2040/");

            this.mainParameters = parameters as InterpreterMainParameters;

            this.result.Labels = "";
            this.result.RunCommand = "";
            var config = META.ComComponent.DeserializeConfiguration(
                this.mainParameters.ProjectDirectory,
                typeof(CyPhyReliabilityAnalysisSettings),
                this.ComponentProgID) as CyPhyReliabilityAnalysisSettings;

            if (config != null)
            {
                this.mainParameters.config = config;
            }
            else
            {
                this.mainParameters.config = new CyPhyReliabilityAnalysisSettings();
            }

            if (Directory.Exists(this.mainParameters.OutputDirectory) == false)
            {
                Directory.CreateDirectory(this.mainParameters.OutputDirectory);
            }

            using (StreamWriter writer1 = new StreamWriter(Path.Combine(this.mainParameters.OutputDirectory, "bracket_config.json")))
            {
                writer1.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(
                    new BracketConfig(this.mainParameters.config as CyPhyReliabilityAnalysisSettings),
                    Newtonsoft.Json.Formatting.Indented));
            }

            // TODO: call all dependent interpreter

            MgaGateway.PerformInTransaction(() =>
            {
                this.WorkInMainTransaction();
            }, transactiontype_enum.TRANSACTION_NON_NESTED);

            //this.PrintRuntimeStatistics();
            if (this.result.Success)
            {
                this.Logger.WriteInfo("CyPhyReliabilityAnalysis 1.0 finished successfully.");
                this.Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                this.Logger.WriteDebug("[SUCCESS: {0}, Labels: {1}]", this.result.Success, this.result.Labels);
            }
            else
            {
                this.Logger.WriteError("CyPhyReliabilityAnalysis 1.0 failed! See error messages above.");
            }
        }
コード例 #31
0
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            result.RunCommand = "runCADJob.bat";
            result.Labels     = "Creo&&CADCreoParametricCreateAssembly.exev1.4&&" + JobManager.Job.DefaultLabels;
            var ProjectIsNotInTransaction = (parameters.Project.ProjectStatus & 8) == 0;

            if (ProjectIsNotInTransaction)
            {
                parameters.Project.BeginTransactionInNewTerr();
            }
            Dictionary <string, string> workflowParameters = new Dictionary <string, string>();
            var workflowRef = parameters
                              .CurrentFCO
                              .ChildObjects
                              .OfType <MgaReference>()
                              .FirstOrDefault(x => x.Meta.Name == "WorkflowRef");

            if (workflowRef != null)
            {
                string Parameters = workflowRef.Referred
                                    .ChildObjects
                                    .OfType <MgaAtom>()
                                    .FirstOrDefault(x => x.Meta.Name == "Task")
                                    .StrAttrByName["Parameters"];
                try
                {
                    workflowParameters = (Dictionary <string, string>)Newtonsoft.Json.JsonConvert.DeserializeObject(Parameters, typeof(Dictionary <string, string>));
                    if (workflowParameters == null)
                    {
                        workflowParameters = new Dictionary <string, string>();
                    }
                }
                catch (Newtonsoft.Json.JsonReaderException)
                {
                }
            }
            META.AnalysisTool.ApplyToolSelection(this.ComponentProgID, workflowParameters, this.result, parameters, modifyLabels: false);
            if (ProjectIsNotInTransaction)
            {
                parameters.Project.AbortTransaction();
            }

            this.CopySTL = workflowParameters.ContainsValue("FreedLinkageAssembler");



            var resultzip = CyPhy2CAD_CSharp.Properties.Resources.ResultZip;

            result.ZippyServerSideHook = Encoding.UTF8.GetString(resultzip);
            result.LogFileDirectory    = Path.Combine(parameters.OutputDirectory, "log");

            this.mainParameters = (InterpreterMainParameters)parameters;
            if (this.mainParameters.config == null)
            {
                var config = META.ComComponent.DeserializeConfiguration(this.mainParameters.ProjectDirectory, typeof(CyPhy2CADSettings), this.ComponentProgID) as CyPhy2CADSettings;
                if (config != null)
                {
                    this.mainParameters.config = config;
                    settings = config;
                }
                else
                {
                    this.mainParameters.config = new CyPhy2CADSettings();
                }
            }
            if (this.result.Traceability == null)
            {
                this.result.Traceability = new META.MgaTraceability();
            }

            // getting traceability from caller, like master interpreter
            if (this.mainParameters.Traceability != null)
            {
                this.mainParameters.Traceability.CopyTo(this.result.Traceability);
            }

            //CyPhy2CAD_CSharp.CyPhy2CADSettings configSettings = (CyPhy2CAD_CSharp.CyPhy2CADSettings)parameters.config;
            //settings = configSettings;

            settings = (CyPhy2CAD_CSharp.CyPhy2CADSettings) this.mainParameters.config;
            settings.OutputDirectory = parameters.OutputDirectory;
            Automation = true;
            Logger.Instance.AddLogMessage("Main:Aux Directory is: " + settings.AuxiliaryDirectory, Severity.Info);
            Logger.Instance.AddLogMessage("Output Directory is: " + settings.OutputDirectory, Severity.Info);
            MgaGateway.voidDelegate action = delegate
            {
                if (Elaborate(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, parameters.StartModeParam))
                {
                    result.Success = Main(parameters.Project, parameters.CurrentFCO, parameters.SelectedFCOs, Convert(parameters.StartModeParam));
                }
                else
                {
                    result.Success = false;
                    Logger.Instance.DumpLog(GMEConsole, LogDir);
                }
            };

            if ((parameters.Project.ProjectStatus & 8) == 0)
            {
                MgaGateway.PerformInTransaction(
                    d: action,
                    mode: transactiontype_enum.TRANSACTION_NON_NESTED,
                    abort: true);
            }
            else
            {
                action.Invoke();
            }

            return(result);
        }
コード例 #32
0
        /// <summary>
        /// No GUI and interactive elements are allowed within this function.
        /// </summary>
        /// <param name="parameters">Main parameters for this run and GUI configuration.</param>
        /// <returns>Result of the run, which contains a success flag.</returns>
        public IInterpreterResult Main(IInterpreterMainParameters parameters)
        {
            this.mainParameters = parameters;

            this.result = new InterpreterResult()
            {
                Success = true
            };


            bool disposeLogger = false;

            try
            {
                if (this.Logger == null)
                {
                    this.Logger   = new CyPhyGUIs.GMELogger(parameters.Project, this.ComponentName);
                    disposeLogger = true;
                }

                string pathDesign  = "";
                string camFilePath = "";
                MgaGateway.PerformInTransaction(delegate
                {
                    var testbench = CyPhyClasses.TestBench.Cast(parameters.CurrentFCO)
                                    as CyPhy.TestBench;
                    var firstThing = testbench.Children.TopLevelSystemUnderTestCollection.First();
                    var design     = firstThing.Referred.ComponentAssembly;
                    pathDesign     = design.GetDirectoryPath(ComponentLibraryManager.PathConvention.ABSOLUTE);
                    // MOT-444: find a test bench parameter with a value of the CAM file's path.
                    foreach (var param in testbench.Children.ParameterCollection)
                    {
                        if (param.Name.ToUpper().Contains("CAM "))
                        {
                            if (param.Attributes.Value.ToUpper().Contains(".CAM"))
                            {
                                camFilePath = param.Attributes.Value;
                            }
                        }
                    }
                },
                                                transactiontype_enum.TRANSACTION_NON_NESTED,
                                                abort: true);

                // The input files to the CAM and Eagle ULP scripts should already be in the pathDesign folder.
                // We need to move them into the project results/<random> folder, which is under parameters.OutputDirectory.
                // See also MOT-444.
                string[] filesToMove = new string[] { "BomTable.csv", "schema.brd", "schema.sch", "reference_designator_mapping_table.html" };
                foreach (string fileName in filesToMove)
                {
                    string srcPath = Path.Combine(pathDesign, fileName);
                    string dstPath = Path.Combine(parameters.OutputDirectory, fileName);

                    if (File.Exists(dstPath))
                    {
                        File.Delete(dstPath);
                    }

                    if (File.Exists(srcPath))
                    {
                        Logger.WriteInfo("About to copy \"{0}\" to \"{1}\".", srcPath, dstPath);
                        File.Copy(srcPath, dstPath);
                    }
                    else
                    {
                        Logger.WriteWarning("The file {0} does not exist.", srcPath);
                    }
                }
                // Set the current directory to the project directory, so that
                // the CAM file's path can be relative to it.
                try
                {
                    // Get the current directory.
                    string path = this.mainParameters.ProjectDirectory;
                    System.IO.Directory.SetCurrentDirectory(path);
                    Logger.WriteInfo("The current directory is {0}", path);
                }
                catch (Exception e)
                {
                    Console.WriteLine("GetCurrentDirectory() failed: {0}", e.ToString());
                }

                // Copy the CAM file to a well-known name in the output directory.
                {
                    string srcPath = camFilePath;
                    string dstPath = Path.Combine(parameters.OutputDirectory, "pcb_mfg.cam");

                    if (File.Exists(dstPath))
                    {
                        File.Delete(dstPath);
                    }

                    if (File.Exists(srcPath))
                    {
                        Logger.WriteInfo("About to copy \"{0}\" to \"{1}\".", srcPath, dstPath);
                        File.Copy(srcPath, dstPath);
                    }
                    else
                    {
                        Logger.WriteWarning("The file {0} does not exist.", srcPath);
                    }
                }


                if (this.result.Success)
                {
                    this.result.RunCommand = "cmd /c dir";     // Dummy first command of job manager for master interpreter.
                    Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory);
                    Logger.WriteInfo("CyPhy2PCBMfg has finished. [SUCCESS: {0}, Labels: {1}]", this.result.Success, this.result.Labels);
                }
                else
                {
                    Logger.WriteError("CyPhy2PCBMfg failed! See error messages above.");
                }
            }
            catch (Exception ex)
            {
                this.Logger.WriteError("Exception was thrown : {0}", ex.ToString());
                this.result.Success = false;
            }
            finally
            {
                if (disposeLogger && this.Logger != null)
                {
                    this.DisposeLogger();
                }
            }

            return(this.result);
        }