Esempio n. 1
0
            public SimulinkConnector(CyPhyGUIs.SmartLogger logger)
            {
                _logger         = logger;
                _matlabInstance = null;

                int REGDB_E_CLASSNOTREG = unchecked ((int)0x80040154);

                try
                {
                    var matlabType = Type.GetTypeFromProgID("Matlab.Application");
                    if (matlabType == null)
                    {
                        throw new COMException("No type Matlab.Application", REGDB_E_CLASSNOTREG);
                    }
                    _matlabInstance = Activator.CreateInstance(matlabType);
                }
                catch (COMException e)
                {
                    if (e.ErrorCode == REGDB_E_CLASSNOTREG)
                    {
                        throw new ApplicationException("Matlab is not installed or registered");
                    }
                    else
                    {
                        throw;
                    }
                }
            }
Esempio n. 2
0
        /// <summary>
        /// Gets a new instance of an elaborator based on a given context.
        /// </summary>
        /// <param name="subject">Given context</param>
        /// <param name="logger">Logger which can be used to log messages.</param>
        /// <returns>A new instance of a context aware elaborator.</returns>
        /// <exception cref="ArgumentNullException">If subject or logger null.</exception>
        /// <exception cref="NotSupportedException">If subject does not have an associated elaborator class.</exception>
        public static Elaborator GetElaborator(MgaModel subject, CyPhyGUIs.SmartLogger logger, bool UnrollConnectors)
        {
            if (subject == null)
            {
                throw new ArgumentNullException("subject");
            }

            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            var        factory    = new CyPhyTypeFactory(subject.Project.RootMeta);
            Elaborator elaborator = null;

            if (subject.MetaBase.MetaRef == factory.TestBenchMeta ||
                subject.MetaBase.MetaRef == factory.CADTestBenchMeta ||
                subject.MetaBase.MetaRef == factory.BlastTestBenchMeta ||
                subject.MetaBase.MetaRef == factory.BallisticTestBenchMeta ||
                subject.MetaBase.MetaRef == factory.CFDTestBenchMeta ||
                subject.MetaBase.MetaRef == factory.KinematicTestBenchMeta ||
                subject.MetaBase.MetaRef == factory.CarTestBenchMeta)
            {
                elaborator = new TestBenchTypeElaborator(subject, UnrollConnectors);
            }
            else if (subject.MetaBase.MetaRef == factory.ComponentAssemblyMeta)
            {
                elaborator = new ComponentAssemblyElaborator(subject, UnrollConnectors);
            }
            else if (subject.MetaBase.MetaRef == factory.DesignContainerMeta)
            {
                elaborator = new DesignContainerElaborator(subject, UnrollConnectors);
            }
            else
            {
                throw new NotSupportedException(string.Format("Not supported context: {0} [{1}]", subject.Name, subject.MetaBase.Name));
            }

            if (subject.IsLibObject)
            {
                throw new NotSupportedException(string.Format("{0} cannot be a library object.", subject.MetaBase.Name));
            }

            elaborator.Logger  = logger;
            elaborator.Factory = factory;
            // TODO: how can we determine this?
            elaborator.IsElaborated = false;

            return(elaborator);
        }
Esempio n. 3
0
 public Checker(CyPhyGUIs.IInterpreterMainParameters parameters, CyPhyGUIs.SmartLogger logger, IMgaTraceability traceability)
 {
     this.Logger         = logger;
     this.mainParameters = parameters;
     this.Traceability   = traceability;
 }
Esempio n. 4
0
        public static Tuple <CyPhyGUIs.InterpreterMainParameters, CyPhyGUIs.IInterpreterResult> RunReturnFull(string outputdirname, string projectPath, string absPath,
                                                                                                              CyPhyGUIs.SmartLogger logger = null, Action <MgaProject> preProcess = null)
        {
            var mainParameters = new CyPhyGUIs.InterpreterMainParameters();

            CyPhyGUIs.IInterpreterResult results = null;
            Assert.True(File.Exists(projectPath), "Project file does not exist.");
            string ProjectConnStr = "MGA=" + projectPath;

            //Type CyPhyPETInterpreter = Type.GetTypeFromProgID("MGA.Interpreter.CyPhyPET");
            //Type MainParametersType = Type.GetTypeFromProgID("ISIS.CyPhyML.InterpreterConfiguration");

            MgaProject project = new MgaProject();

            project.OpenEx(ProjectConnStr, "CyPhyML", null);
            try
            {
                if (preProcess != null)
                {
                    preProcess(project);
                }
                var terr    = project.BeginTransactionInNewTerr();
                var testObj = project.ObjectByPath[absPath] as MgaFCO;
                Assert.True(testObj != null, String.Format("Could not find FCO by path '{0}'", absPath));
                mainParameters.OriginalCurrentFCOName = testObj.Name;
                project.AbortTransaction();

                string OutputDir = Path.Combine(Path.GetDirectoryName(projectPath), outputdirname);
                OutputDir = Path.GetFullPath(OutputDir);
                if (Directory.Exists(OutputDir))
                {
                    CyPhyGUIs.CyPhyDirectory.EnsureEmptyDirectory(OutputDir);
                }
                Directory.CreateDirectory(OutputDir);

                //dynamic interpreter = Activator.CreateInstance(CyPhyPETInterpreter);
                var interpreter = new CyPhyPET.CyPhyPETInterpreter();
                interpreter.Initialize(project);

                //dynamic mainParameters = Activator.CreateInstance(MainParametersType);
                mainParameters.Project          = project;
                mainParameters.CurrentFCO       = testObj;
                mainParameters.SelectedFCOs     = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs"));
                mainParameters.StartModeParam   = 128;
                mainParameters.ConsoleMessages  = false;
                mainParameters.ProjectDirectory = Path.GetDirectoryName(projectPath);
                mainParameters.OutputDirectory  = OutputDir;

                //dynamic results = interpreter.Main(mainParameters);
                interpreter.Logger = logger;
                results            = interpreter.MainThrows(mainParameters);

                Assert.True(File.Exists(ProjectConnStr.Substring("MGA=".Length)));

                if (results.Success == false)
                {
                    Test.DeleteDirectory(OutputDir);
                }
            }
            finally
            {
                project.Close(true);
            }

            return(new Tuple <CyPhyGUIs.InterpreterMainParameters, CyPhyGUIs.IInterpreterResult>(mainParameters, results));
        }
Esempio n. 5
0
 /// <summary>
 /// Gets a new instance of an elaborator based on a given context.
 /// </summary>
 /// <typeparam name="T">Specific type of elaborator</typeparam>
 /// <param name="subject">Given context</param>
 /// <param name="logger">Logger which can be used to log messages.</param>
 /// <returns>A new instance of a context aware elaborator.</returns>
 /// <exception cref="ArgumentNullException">If subject or logger null.</exception>
 /// <exception cref="NotSupportedException">If subject does not have an associated elaborator class.</exception>
 /// <exception cref="InvalidCastException">If the created elaborator cannot be casted to the requested type.</exception>
 public static T GetElaborator <T>(MgaModel subject, CyPhyGUIs.SmartLogger logger, bool UnrollConnectors)
     where T : Elaborator
 {
     return((T)GetElaborator(subject, logger, UnrollConnectors));
 }