Пример #1
0
        private IMgaTraceability CallElaborator(
            MgaProject project,
            MgaFCO currentobj,
            MgaFCOs selectedobjs,
            int param,
            bool expand = true)
        {
            bool result = false;

            try
            {
                // GMEConsole.Info.WriteLine("Elaborating model...");
                var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                elaborator.Initialize(project);
                int verbosity = 128;
                //elaborator.UnrollConnectors = false;
                result = elaborator.RunInTransaction(project, currentobj, selectedobjs, verbosity);

                if (result == true)
                {
                    return(elaborator.Traceability);
                }
                // GMEConsole.Info.WriteLine("Elaboration is done.");
            }
            catch (Exception ex)
            {
                GMEConsole.Error.WriteLine("Exception occurred in Elaborator : {0}", ex.ToString());
            }
            throw new ApplicationException("Elaborator failed");
        }
Пример #2
0
 private void ElaborateModel(MgaProject project,
                             MgaFCO currentobj,
                             MgaFCOs selectedobjs,
                             int param)
 {
     try
     {
         var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
         elaborator.Logger = new GMELogger(project);
         //elaborator.Logger.AddWriter(Logger.Instance);
         var result = elaborator.RunInTransaction(project, currentobj, selectedobjs, param);
         if (result == false)
         {
             throw new ApplicationException("see elaborator log");
         }
         if (this.result.Traceability == null)
         {
             this.result.Traceability = new META.MgaTraceability();
         }
         if (elaborator.Traceability != null)
         {
             elaborator.Traceability.CopyTo(this.result.Traceability);
         }
     }
     catch (Exception e)
     {
         //Logger.Instance.AddLogMessage("Elaborator exception occurred: " + e.Message, Severity.Error);
         throw new Exception(e.Message);
     }
 }
Пример #3
0
        public static bool RunElaborator(string projectPath, string absPath)
        {
            bool result = false;

            Assert.True(File.Exists(projectPath), "Project file does not exist.");
            string ProjectConnStr = "MGA=" + Path.GetFullPath(projectPath);

            MgaProject project = new MgaProject();

            project.OpenEx(ProjectConnStr, "CyPhyML", null);
            try
            {
                var terr    = project.BeginTransactionInNewTerr();
                var testObj = project.ObjectByPath[absPath] as MgaFCO;
                if (testObj == null)
                {
                    throw new ApplicationException(absPath + " not found in " + project.ProjectConnStr);
                }
                project.AbortTransaction();

                MgaFCOs fcos = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs"));

                var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                result = elaborator.RunInTransaction(project, testObj, fcos, 128);
            }
            finally
            {
                project.Close(true);
            }

            return(result);
        }
Пример #4
0
        private bool CallElaborator(
            MgaProject project,
            MgaFCO currentobj,
            MgaFCOs selectedobjs,
            int param,
            bool expand = true)
        {
            bool result = false;

            try
            {
                this.Logger.WriteDebug("Elaborating model...");
                var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                elaborator.Initialize(project);
                int verbosity = 128;
                result = elaborator.RunInTransaction(project, currentobj, selectedobjs, verbosity);
                this.Logger.WriteDebug("Elaboration is done.");
            }
            catch (Exception ex)
            {
                this.Logger.WriteError("Exception occurred in Elaborator : {0}", ex.ToString());
                result = false;
            }

            return(result);
        }
Пример #5
0
        public static bool RunElaborator(string projectPath, string absPath)
        {
            bool result = false;
            Assert.True(File.Exists(projectPath), "Project file does not exist.");
            string ProjectConnStr = "MGA=" + Path.GetFullPath(projectPath);

            MgaProject project = new MgaProject();
            project.OpenEx(ProjectConnStr, "CyPhyML", null);
            try
            {
                var terr = project.BeginTransactionInNewTerr();
                var testObj = project.ObjectByPath[absPath] as MgaFCO;
                if (testObj == null)
                {
                    throw new ApplicationException(absPath + " not found in " + project.ProjectConnStr);
                }
                project.AbortTransaction();

                MgaFCOs fcos = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs"));

                var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                result = elaborator.RunInTransaction(project, testObj, fcos, 128);
            }
            finally
            {
                project.Close(true);
            }

            return result;
        }
Пример #6
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);
        }
Пример #7
0
        public void GenericParameters()
        {
            fixture.proj.PerformInTransaction(delegate
            {
                var asm = fixture.proj.ObjectByPath["/@ComponentAssemblies/@GenericParameters"];

                CyPhyElaborateCS.CyPhyElaborateCSInterpreter elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                elaborator.Initialize(asm.Project);
                int verbosity = 128;
                elaborator.RunInTransaction(asm.Project, (MgaFCO)asm, null, verbosity);

                var output = (IMgaFCO)asm.ObjectByPath["@ComponentWithGeneric/@GenericDomainModel/@GenericDomainModelParameter1"];
                Assert.Equal("1 2 3", output.StrAttrByName["Value"]);
                output = (IMgaFCO)asm.ObjectByPath["@ComponentWithGeneric/@GenericDomainModel/@GenericDomainModelParameter2"];
                Assert.Equal("123", output.StrAttrByName["Value"]);
            });
        }
Пример #8
0
        private bool Elaborate(
            MgaProject project,
            MgaFCO currentobj,
            MgaFCOs selectedobjs,
            int param)
        {
            try
            {
                bool Expanded = this.componentParameters[OptionNameIFab] as String == "true";
                if (!Expanded)
                {
                    try
                    {
                        var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                        elaborator.Logger = new GMELogger(project);
                        elaborator.Logger.AddWriter(Logger.Instance);
                        var result = elaborator.RunInTransaction(project, currentobj, selectedobjs, param);
                        if (result == false)
                        {
                            throw new ApplicationException("see elaborator log");
                        }
                        if (this.result.Traceability == null)
                        {
                            this.result.Traceability = new META.MgaTraceability();
                        }
                        if (elaborator.Traceability != null)
                        {
                            elaborator.Traceability.CopyTo(this.result.Traceability);
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Instance.AddLogMessage("Elaborator exception occurred: " + e.Message, Severity.Error);
                        throw new Exception(e.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.AddLogMessage(ex.ToString(), Severity.Error);
                return(false);
            }

            return(true);
        }
Пример #9
0
        private bool CallElaborator(
            MgaProject project,
            MgaFCO currentobj,
            MgaFCOs selectedobjs,
            int param,
            bool expand = true)
        {
            bool result = false;

            try
            {
                this.Logger.WriteDebug("Elaborating model...");
                var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter()
                {
                    Logger = Logger
                };
                elaborator.Initialize(project);
                int verbosity = 128;
                elaborator.UnrollConnectors = true;
                result = elaborator.RunInTransaction(project, currentobj, selectedobjs, verbosity, mainParameters.OutputDirectory);

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

                if (elaborator.Traceability != null)
                {
                    elaborator.Traceability.CopyTo(this.result.Traceability);
                    elaborator.Traceability.CopyTo(Logger.Traceability);
                }
                this.Logger.WriteDebug("Elaboration is done.");
            }
            catch (Exception ex)
            {
                this.Logger.WriteError("Exception occurred in Elaborator : {0}", ex.ToString());
                result = false;
            }

            return(result);
        }
Пример #10
0
        private bool CallElaborator(
            MgaProject project,
            MgaFCO currentobj,
            MgaFCOs selectedobjs,
            int param,
            bool expand = true)
        {
            bool result = false;

            try
            {
                var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                elaborator.Initialize(project);

                Logger.WriteInfo("Elaborating model...");
                System.Windows.Forms.Application.DoEvents();

                int verbosity = 128;
                result = elaborator.RunInTransaction(project, currentobj, selectedobjs, verbosity);

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

                if (elaborator.Traceability != null)
                {
                    elaborator.Traceability.CopyTo(this.result.Traceability);
                }
                //this.Logger.WriteDebug("Elaboration is done.");
            }
            catch (Exception ex)
            {
                Logger.WriteError(ex.Message);
                return(false);
            }

            return(true);
        }
Пример #11
0
        private bool CallElaborator(
            MgaProject project,
            MgaFCO currentobj,
            MgaFCOs selectedobjs,
            int param,
            bool expand = true)
        {
            bool result = false;

            try
            {
                GMEConsole.Info.WriteLine("Calling elaborator...");
                var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                elaborator.Initialize(project);
                int verbosity = 128;

                elaborator.UnrollConnectors = true;
                result = elaborator.RunInTransaction(project, currentobj, selectedobjs, verbosity);

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

                if (elaborator.Traceability != null)
                {
                    elaborator.Traceability.CopyTo(this.result.Traceability);
                }
                GMEConsole.Info.WriteLine("Elaboration is done.");
            }
            catch (Exception ex)
            {
                GMEConsole.Error.WriteLine("Exception occurred in Elaborator : {0}", ex.ToString());
                result = false;
            }

            return(result);
        }
Пример #12
0
 private void ElaborateModel(MgaProject project,
                             MgaFCO currentobj,
                             MgaFCOs selectedobjs,
                             int param)
 {
     try
     {
         var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
         elaborator.Logger = new GMELogger(project);
         //elaborator.Logger.AddWriter(Logger.Instance);
         var result = elaborator.RunInTransaction(project, currentobj, selectedobjs, param);
         if (result == false)
         {
             throw new ApplicationException("see elaborator log");
         }
         if (this.result.Traceability == null)
         {
             this.result.Traceability = new META.MgaTraceability();
         }
         if (elaborator.Traceability != null)
         {
             elaborator.Traceability.CopyTo(this.result.Traceability);
         }
     }
     catch (Exception e)
     {
         //Logger.Instance.AddLogMessage("Elaborator exception occurred: " + e.Message, Severity.Error);
         throw new Exception(e.Message);
     }
 }
        private bool Elaborate(
            MgaProject project,
            MgaFCO currentobj,
            MgaFCOs selectedobjs,
            int param)
        {
            try
            {
                bool Expanded = this.componentParameters[OptionNameIFab] as String == "true";
                if (!Expanded)
                {
                    try
                    {
                        var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                        elaborator.Logger = new GMELogger(project);
                        elaborator.Logger.AddWriter(Logger.Instance);
                        var result = elaborator.RunInTransaction(project, currentobj, selectedobjs, param);
                        if (result == false)
                        {
                            throw new ApplicationException("see elaborator log");
                        }
                        if (this.result.Traceability == null)
                        {
                            this.result.Traceability = new META.MgaTraceability();
                        }
                        if (elaborator.Traceability != null)
                        {
                            elaborator.Traceability.CopyTo(this.result.Traceability);
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Instance.AddLogMessage("Elaborator exception occurred: " + e.Message, Severity.Error);
                        throw new Exception(e.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.AddLogMessage(ex.ToString(), Severity.Error);
                return false;
            }

            return true;
        }
Пример #14
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;
        }
        private bool CallElaborator(
            MgaProject project,
            MgaFCO currentobj,
            MgaFCOs selectedobjs,
            int param,
            bool expand = true)
        {
            bool result = false;
            try
            {
                this.Logger.WriteDebug("Elaborating model...");
                var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                elaborator.Initialize(project);
                int verbosity = 128;
                result = elaborator.RunInTransaction(project, currentobj, selectedobjs, verbosity);

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

                if (elaborator.Traceability != null)
                {
                    elaborator.Traceability.CopyTo(this.result.Traceability);
                }
                this.Logger.WriteDebug("Elaboration is done.");
            }
            catch (Exception ex)
            {
                this.Logger.WriteError("Exception occurred in Elaborator : {0}", ex.ToString());
                result = false;
            }

            return result;
        }
Пример #16
0
        private bool CallElaborator(
            MgaProject project,
            MgaFCO currentobj,
            MgaFCOs selectedobjs,
            int param,
            bool expand = true)
        {
            bool result = false;
            try
            {
                var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                elaborator.Initialize(project);

                Logger.WriteInfo("Elaborating model...");
                System.Windows.Forms.Application.DoEvents();

                int verbosity = 128;
                result = elaborator.RunInTransaction(project, currentobj, selectedobjs, verbosity);

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

                if (elaborator.Traceability != null)
                {
                    elaborator.Traceability.CopyTo(this.result.Traceability);
                }
                //this.Logger.WriteDebug("Elaboration is done.");
            }
            catch (Exception ex)
            {
                Logger.WriteError(ex.Message);
                return false;
            }

            return true;
        }
        private bool CallElaborator(
            MgaProject project,
            MgaFCO currentobj,
            MgaFCOs selectedobjs,
            int param,
            bool expand = true)
        {
            bool result = false;
            try
            {
                if (Logger != null)
                    Logger.WriteInfo("Elaborating model...");
                var elaborator = new CyPhyElaborateCS.CyPhyElaborateCSInterpreter();
                elaborator.Initialize(project);
                int verbosity = 128;
                elaborator.UnrollConnectors = false;
                result = elaborator.RunInTransaction(project, currentobj, selectedobjs, verbosity);

                if (Logger != null)
                    Logger.WriteInfo("Elaboration is done.");
            }
            catch (Exception ex)
            {
                if (Logger != null)
                    Logger.WriteError("Exception occurred in Elaborator : {0}", ex.ToString());
                result = false;
            }

            return result;
        }