Example #1
0
        /// <summary>
        /// Intializes a new instance of the <see cref="CodeGenerator"/> class.
        /// </summary>
        /// <param name="parameters">Passed through the Main function in CyPhyGUIs API.</param>
        /// <param name="logger">Instance of logger to log to.</param>
        /// <param name="traceability">Traceability map from CyPhyElborate (and if called by it, the MasterInterpreter too).</param>
        public CodeGenerator(CyPhyGUIs.IInterpreterMainParameters parameters, CyPhyGUIs.GMELogger logger, CyPhyCOMInterfaces.IMgaTraceability traceability)
        {
            this.Logger = logger;
            this.MainParameters = parameters;
            this.modelicaSettings = this.MainParameters.config as CyPhy2Modelica_v2Settings;
            this.traceability = traceability;
            this.LimitDefintion = new LimitDefinition();
            this.reservedPackageNames = new List<string>() { "Modelica", MainPackage };
            this.instanceURIMap = new Dictionary<string, ComponentInfo>();
            this.modelURIMap = new Dictionary<string, ComponentInfo>();
            this.extendsURIMap = new Dictionary<string, ComponentInfo>();
            this.pccInputs = new List<PCCInputDistribution>();
            this.ModelicaURIMap = new ComponentMap()
            {
                InstanceMapping = this.instanceURIMap,
                ModelMapping = this.modelURIMap,
                ExtendsMapping = this.extendsURIMap
            };
            var externalPackages = (this.MainParameters.config as CyPhy2Modelica_v2Settings).IncludeDirectoryPath;
            foreach (var packagePath in externalPackages)
            {
                this.reservedPackageNames.Add(ModelicaLibrary.GetLibraryFromPath(packagePath).Name);
            }

            this.requirementMetrics = new List<RequirementMetric>();
        }
Example #2
0
        // used to get attached package names; these strings are invalid for certain uses in a CyPhy project
        private static void getExternalPackageNames(MgaFCO context)
        {
            if (externalPackageNames == null)
            {
                externalPackageNames = new List<string>();
                // get previous GUI config
                var cyPhy2Modelica_v2 = new META.ComComponent("MGA.Interpreter.CyPhy2Modelica_v2");
                var projectDir = GetProjectDir(context);
                var config = META.ComComponent.DeserializeConfiguration(projectDir, typeof(CyPhy2Modelica_v2Settings), cyPhy2Modelica_v2.ProgId);
                if (config == null)
                {
                    config = new CyPhy2Modelica_v2Settings();
                }
                
                var paths = (config as CyPhy2Modelica_v2Settings).IncludeDirectoryPath;
                foreach (var path in paths)
                {
                    externalPackageNames.Add(ModelicaLibrary.GetLibraryFromPath(path).Name);
                }

                externalPackageNames.Add("Modelica");
                externalPackageNames.Add(Modelica.CodeGenerator.MainPackage);
                // Cyber business
                externalPackageNames.Add(CyPhyClasses.CyberModel.AttributesClass.ModelType_enum.ESMoL.ToString());
                externalPackageNames.Add(CyPhyClasses.CyberModel.AttributesClass.ModelType_enum.SignalFlow.ToString());
                externalPackageNames.Add(CyPhyClasses.CyberModel.AttributesClass.ModelType_enum.Simulink.ToString());
            }
        }