Exemplo n.º 1
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);
        }
Exemplo n.º 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;
        }