Пример #1
0
        public static HashSet <CyPhyML.Component> getCyPhyMLComponentSet(IMgaObject iMgaObject)
        {
            if (iMgaObject == null)
            {
                return(new HashSet <CyPhyML.Component>());
            }

            string metaName = iMgaObject.MetaBase.Name;

            HashSet <CyPhyML.Component> cyPhyMLComponentSet = null;

            if (metaName == "Component")
            {
                cyPhyMLComponentSet = new HashSet <CyPhyML.Component>();
                cyPhyMLComponentSet.Add(CyPhyMLClasses.Component.Cast(iMgaObject));
            }
            else if (metaName == "ComponentRef")
            {
                CyPhyML.ComponentRef cyPhyMLComponentRef = CyPhyMLClasses.ComponentRef.Cast(iMgaObject);
                cyPhyMLComponentSet = new HashSet <CyPhyML.Component>();
                cyPhyMLComponentSet.Add(cyPhyMLComponentRef.Referred as CyPhyML.Component);
            }
            else if (metaName == "ComponentAssembly")
            {
                cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(CyPhyMLClasses.ComponentAssembly.Cast(iMgaObject));
            }
            else if (metaName == "ComponentAssemblyRef")
            {
                CyPhyML.ComponentAssemblyRef cyPhyMLComponentAssemblyRef = CyPhyMLClasses.ComponentAssemblyRef.Cast(iMgaObject);
                cyPhyMLComponentSet = new HashSet <CyPhyML.Component>();
                cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(cyPhyMLComponentAssemblyRef.Referred as CyPhyML.ComponentAssembly);
            }
            else if (metaName == "TestBench")
            {
                cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(CyPhyMLClasses.TestBench.Cast(iMgaObject));
            }
            else if (metaName == "RootFolder")
            {
                cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(CyPhyMLClasses.RootFolder.GetRootFolder(iMgaObject.Project));
            }
            else
            {
                cyPhyMLComponentSet = new HashSet <CyPhyML.Component>();
            }

            return(cyPhyMLComponentSet);
        }
Пример #2
0
        /// <summary>
        /// Expands the given context.
        /// </summary>
        /// <param name="configuration">CWC object to expand to.</param>
        public void Expand(CyPhy.CWC configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            this.DesignConfiguration = configuration;

            if (configuration.DstConnections.Config2CACollection.Any())
            {
                this.Expand(configuration
                            .DstConnections
                            .Config2CACollection
                            .FirstOrDefault()
                            .DstEnds
                            .ComponentAssemblyRef
                            .Referred
                            .ComponentAssembly);
            }
            else
            {
                var exportedConfigurations = this.RunCAExporter(new List <MgaFCO>()
                {
                    configuration.Impl as MgaFCO
                });
                if (exportedConfigurations.Any() == false)
                {
                    throw new AnalysisModelExpandFailedException(string.Format("Failed to export configuration {0}.", configuration.Name));
                }

                // TODO: if CaRefsToProcess is empty then CAExporter failed.
                CyPhy.ComponentAssemblyRef componentAssemblyRef = CyPhyClasses.ComponentAssemblyRef.Cast(exportedConfigurations.FirstOrDefault());
                if (componentAssemblyRef.AllReferred == null)
                {
                    throw new AnalysisModelExpandFailedException(string.Format("Exported configuration {0} yielded null reference to component assembly.", configuration.Name));
                }

                temporaryObjects.Push(componentAssemblyRef.Referred.ComponentAssembly.Impl);
                this.Expand(componentAssemblyRef.Referred.ComponentAssembly);
            }
        }